micropython/tools/mpremote
Damien George 226c0341ca tools/mpremote: Remove support for pyb.USB_VCP in/out specialisation.
The sys.stdin.buffer and sys.stdout.buffer streams work just as well (and
are just as fast) as pyb.USB_VCP on stm32 devices, so there's no need to
have the USB_VCP specialisation code, which just adds complexity.

Also, on stm32 devices with both USB and UART (or other serial interface),
if something other than the USB_VCP port is used for the serial connection
then mpremote mount will not work because it will default to reading and
writing on USB_VCP instead of the other connected serial stream.

As part of this simplification, support for a second port as input is
removed (this feature was never exposed to the user).

Signed-off-by: Damien George <damien@micropython.org>
2021-08-19 18:56:11 +10:00
..
mpremote tools/mpremote: Remove support for pyb.USB_VCP in/out specialisation. 2021-08-19 18:56:11 +10:00
LICENSE tools/mpremote: Add new CLI utility to interact with remote device. 2021-05-29 17:17:22 +10:00
mpremote.py tools/mpremote: Add new CLI utility to interact with remote device. 2021-05-29 17:17:22 +10:00
pyproject.toml tools/mpremote: Add new CLI utility to interact with remote device. 2021-05-29 17:17:22 +10:00
README.md tools/mpremote: Add new CLI utility to interact with remote device. 2021-05-29 17:17:22 +10:00
setup.cfg tools/mpremote: Use signal to capture and handle ctrl-C on Windows. 2021-06-15 13:52:31 +10:00

mpremote -- MicroPython remote control

This CLI tool provides an integrated set of utilities to remotely interact with and automate a MicroPython device over a serial connection.

The simplest way to use this tool is:

mpremote

This will automatically connect to the device and provide an interactive REPL.

The full list of supported commands are:

mpremote connect <device>        -- connect to given device
                                    device may be: list, auto, id:x, port:x
                                    or any valid device name/path
mpremote disconnect              -- disconnect current device
mpremote mount <local-dir>       -- mount local directory on device
mpremote eval <string>           -- evaluate and print the string
mpremote exec <string>           -- execute the string
mpremote run <file>              -- run the given local script
mpremote fs <command> <args...>  -- execute filesystem commands on the device
                                    command may be: cat, ls, cp, rm, mkdir, rmdir
                                    use ":" as a prefix to specify a file on the device
mpremote repl                    -- enter REPL
                                    options:
                                        --capture <file>
                                        --inject-code <string>
                                        --inject-file <file>

Multiple commands can be specified and they will be run sequentially. Connection and disconnection will be done automatically at the start and end of the execution of the tool, if such commands are not explicitly given. Automatic connection will search for the first available serial device. If no action is specified then the REPL will be entered.

Shortcuts can be defined using the macro system. Built-in shortcuts are:

  • a0, a1, a2, a3: connect to /dev/ttyACM?
  • u0, u1, u2, u3: connect to /dev/ttyUSB?
  • c0, c1, c2, c3: connect to COM?
  • cat, ls, cp, rm, mkdir, rmdir, df: filesystem commands
  • reset: reset the device
  • bootloader: make the device enter its bootloader

Any user configuration, including user-defined shortcuts, can be placed in .config/mpremote/config.py. For example:

# Custom macro commands
commands = {
    "c33": "connect id:334D335C3138",
    "bl": "bootloader",
    "double x=4": "eval x*2",
}

Examples:

mpremote
mpremote a1
mpremote connect /dev/ttyUSB0 repl
mpremote ls
mpremote a1 ls
mpremote exec "import micropython; micropython.mem_info()"
mpremote eval 1/2 eval 3/4
mpremote mount .
mpremote mount . exec "import local_script"
mpremote ls
mpremote cat boot.py
mpremote cp :main.py .
mpremote cp main.py :
mpremote cp -r dir/ :