PythonExtra/tools/mpremote
Jim Mussared 69e34b6b6b all: Switch to new preview build versioning scheme.
See https://github.com/micropython/micropython/issues/12127 for details.

Previously at the point when a release is made, we update mpconfig.h
and set a git tag. i.e. the version increments at the release.

Now the version increments immediately after the release. The workflow is:
1. Final commit in the cycle updates mpconfig.h to set (X, Y, 0, 0) (i.e.
   clear the pre-release state).
2. This commit is tagged "vX.Y.0".
3. First commit for the new cycle updates mpconfig.h to set (X, Y+1, 0, 1)
   (i.e. increment the minor version, set the pre-release state).
4. This commit is tagged "vX.Y+1.0-preview".

The idea is that a nightly build is actually a "preview" of the _next_
release. i.e. any documentation describing the current release may not
actually match the nightly build. So we use "preview" as our semver
pre-release identifier.

Changes in this commit:
 - Add MICROPY_VERSION_PRERELEASE to mpconfig.h to allow indicating that
   this is not a release version.
 - Remove unused MICROPY_VERSION integer.
 - Append "-preview" to MICROPY_VERSION_STRING when the pre-release state
   is set.
 - Update py/makeversionhdr.py to no longer generate MICROPY_GIT_HASH.
 - Remove the one place MICROPY_GIT_HASH was used (it can use
   MICROPY_GIT_TAG instead).
 - Update py/makeversionhdr.py to also understand
   MICROPY_VERSION_PRERELEASE in mpconfig.h.
 - Update py/makeversionhdr.py to convert the git-describe output into
   semver-compatible "X.Y.Z-preview.N.gHASH".
 - Update autobuild.sh to generate filenames using the new scheme.
 - Update remove_old_firmware.py to match new scheme.
 - Update mpremote's pyproject.toml to handle the "-preview" suffix in the
   tag. setuptools_scm maps to this "rc0" to match PEP440.
 - Fix docs heading where it incorrectly said "vvX.Y.Z" for release docs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-06 12:10:14 +11:00
..
mpremote tools/mpremote: Add support for rfc2217, serial over TCP. 2023-09-29 14:40:17 +10:00
.gitignore tools/mpremote: Use hatch to build mpremote package. 2023-02-24 11:40:22 +11:00
LICENSE tools/mpremote: Add command to print the version. 2022-06-07 23:22:04 +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 all: Switch to new preview build versioning scheme. 2023-10-06 12:10:14 +11:00
README.md tools/mpremote: Only auto connect to serial device with USB VID/PID. 2022-11-25 17:20:14 -05:00
requirements.txt tools/mpremote: Use hatch to build mpremote package. 2023-02-24 11:40:22 +11: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 a USB serial port 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>
mpremote mip install <package...> -- Install packages (from micropython-lib or third-party sources)
                                     options:
                                         --target <path>
                                         --index <url>
                                         --no-mpy
mpremote help                     -- print list of commands and exit

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": {
        "command": "eval x*2",
        "help": "multiply by two"
    }
}

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/ :
mpremote mip install aioble
mpremote mip install github:org/repo@branch