- Connect to devices over serial or network (WebREPL)
- List all serial devices:
mctl devices
- Enter the REPL:
mctl repl
- Manipulate files and directories:
mctl ls
,mctl rm
,mctl put
,mctl get
,mctl mkdir
- Synchronize a folder onto the device:
mctl sync
(only uploads changed files) - Edit a file and upload if changed:
mctl edit <filename>
- Reset the device:
mctl reset
- Run Python scripts:
mctl run <script_or_file>
- Reuse a
mctl repl
connection to runmctl
commands in another terminal at the same time - Mount the device into the local filesystem:
mctl mount
(experimental!) - More: see
mctl help
Code: cli/index.ts
mctl
is included in the micropython-ctl
npm package. You can also install it via the mctl
npm package:
npm install -g mctl
$ mctl help
Usage: index [options] [command]
Options:
-t, --tty <device> Connect over serial interface (eg. /dev/tty.SLAB_USBtoUART)
-h, --host <host> Connect over network to hostname or IP of device
-p, --password <password> Password for network device
-s, --silent Hide unnecessary output
--help display help for command
Commands:
devices List serial devices
repl Open a REPL terminal
run <fileOrCommand> Execute a Python file or command
info [options] Get information about the board (versions, unique id, space, memory)
ls [options] [directory] List files on a device
cat <filename> Print content of a file on the device
get <file_or_dirname> [out_file_or_dirname] Download a file or directory from the device. Download everything with 'get /'
put [options] <file_or_dirname> [dest_file_or_dirname] Upload a file or directory onto the device
sync [directory] Sync a local directory onto the device root (upload new/changes files, delete missing)
edit <filename> Edit a file, and if changed upload afterwards
mkdir <name> Create a directory
rm [options] <path> Delete a file or directory
mv <oldPath> <newPath> Rename a file or directory
sha256 <filename> Get the SHA256 hash of a file
reset [options] Reset the MicroPython device
mount [targetPath] Mount a MicroPython device (over serial or network)
run-tests Run micropython-ctl tests on a device
version Print the version of mctl
help [command] display help for command
Device connection logic:
--host
or--tty
optionMCTL_TTY
env var: serial connectionMCTL_HOST
env var: network connectionAMPY_PORT
env var: serial connectionWEBREPL_HOST
env var: network connection
For network connection passwords, the env vars MCTL_PASSWORD
and WEBREPL_PASSWORD
can be used.
# List serial devices
mctl devices
# By default connect to first serial device
mctl info
# Connect over specific serial device
mctl -t /dev/USB0 info
# Connect over network
mctl -h DEVICE_IP -p WEBREPL_PASSWORD info
# Get information about the board
mctl info
# Enter the REPL
mctl repl
# List files
mctl ls # list all files in /
mctl ls foo/ # list all files in /foo/
mctl ls -r # recursively list all files and directories
mctl ls -r --json # output as json
mctl ls -r --include-hash --json # output as json, include sha256 hash of each file
# Print contents of boot.py
mctl cat boot.py
# Download all files and directories recursively, into the current directory
mctl get /
# Download all files and directories recursively, into /tmp/
mctl get / /tmp/
# Upload a file
mctl put boot.py
# Upload all Python scripts
mctl put "*.py"
# Upload everything recursively
mctl put .
# Synchronize current local directory onto the device (upload only