Skip to main content

Command-line tool for interfacing with CircuitPython devices.

Project description

circuitpython-tool

PyPI version

Links:

Installation:

pip install circuitpython-tool

Overview

circuitpython-tool is a command-line utility for conveniently using CircuitPython devices from the terminal. Especially useful when multiple devices are connected to the same computer.

Benefits:

  • No need to manually mount CIRCUITPY drives, or even keep track of where its mounted. You can refer to the device by name instead.
  • No need to figure out the name of the serial terminal (e.g. /dev/ttyACM1). You can refer to the device by name instead.
  • No need to find the correct CircuitPython version, reset your device while holding BOOTSEL, or drag-and-drop the .uf2 file into RPI-RP2. You can enter the UF2 bootloader with one command, and automatically download and install CircuitPython with another command.

This tool is designed for a workflow where instead of editing files directly on the CircuitPython device, you edit files on your computer and sync the code over to the device.

Usage

circuitpython-tool --help

Terminology

  • Query: vendor:model:serial string that specifies one or more connected CircuitPython devices. Each component string is searched for in the respective attribute. Empty strings are allowed in each component of the query. Example queries:

    • :: matches ANY device.
    • Adafruit:: matches any device whose vendor contains the string "Adafruit"
    • :Feather: matches any device whose model contains the string "Feather"
    • Adafruit:Feather: matches any device whose vendor contains the string "Adafruit" AND whose model contains the string "Feather"
  • Device: A CircuitPython device connected over USB. The device shows up as a removeable drive labeled CIRCUITPY. When the term "device" is referred to in a command-line argument, the device is specified as a query strong as above. An error is thrown if the given query matches multiple connected devices.

  • UF2 Device: A device connected over USB that is in its UF2 bootloader. For RP2040-based devices, the device shows up as a removable drive labeled RPI-RP2. This is the default state for brand-new RP2040 devices. This is also the state entered when a device is reset with the BOOTSEL butten held down. This state can also be entered via the uf2 enter command.

Example Commands

List devices

List connected CircuitPython devices and their properties:

circuitpython-tool devices

Connect to serial terminal

Open serial terminal to connected Raspberry Pi Pico (without needing to find the correct /dev/ttyACM path!):

circuitpython-tool connect :Pico:

Upload code

Upload code to connected Raspberry Pi Pico everytime the contents of ~/mycode changes (without needing to manually mount the device!):

circuitpython-tool upload --dir ~/mycode :Pico:

Or to only upload code once and exit:

circuitpython-tool watch --dir ~/mycode :Pico: --mode=single-shot

Mount device

Mount Raspberry Pi Pico (if needed) and print the path to the mountpoint:

circuitpython-tool mount :Pico:

Install CircuitPython

Automatically download and install the correct version of CircuitPython onto a connected Raspberry Pi Pico.

If the device isn't already in the UF2 bootloader:

circuitpython-tool uf2 enter :Pico:

Then download and install CircuitPython:

circuitpython-tool install --board raspberry_pi_pico

Wipe out flash memory

Wipe out flash memory to bring the device to a factory default state:

circuitpython-tool uf2 nuke

Shell completion

The tool supports shell completion of all parameters, including device queries and board names!

Setup completion for your shell:

eval "$(circuitpython-tool completion)"

Device queries:

python3 -m circuitpython_tool.tools.shell_completer 'upload :Pico'

Adafruit board names:

python3 -m circuitpython_tool.tools.shell_completer 'uf2 install --board rasp'

CircuitPython locales:

python3 -m circuitpython_tool.tools.shell_completer 'uf2 install --locale en'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuitpython_tool-0.10.0.tar.gz (66.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circuitpython_tool-0.10.0-py3-none-any.whl (62.3 kB view details)

Uploaded Python 3

File details

Details for the file circuitpython_tool-0.10.0.tar.gz.

File metadata

  • Download URL: circuitpython_tool-0.10.0.tar.gz
  • Upload date:
  • Size: 66.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for circuitpython_tool-0.10.0.tar.gz
Algorithm Hash digest
SHA256 1bb0dfd894a947b6d3db70110e0e9ec25e85bfe777ab92713eec0c005e9a948d
MD5 0be4b1497c889a0b410fa9d1ecf5f1fe
BLAKE2b-256 d61a4205c4105858f85b2a553f5016a8f987f32e48082fb4c5aae446e9f219e0

See more details on using hashes here.

File details

Details for the file circuitpython_tool-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for circuitpython_tool-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4151108b50e352cb51d28bdee7eafe210f73755f1d556544005ff0054e4c072b
MD5 43704298264667a207ec4a9eb526db4f
BLAKE2b-256 9daa11a292ecb9993bafbef00697700343654ee2113549e818d0f17ed549926b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page