mpflash 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mpflash-1.0.0 → mpflash-1.0.2}/LICENSE +20 -20
- {mpflash-1.0.0 → mpflash-1.0.2}/PKG-INFO +1 -1
- {mpflash-1.0.0 → mpflash-1.0.2}/README.md +220 -220
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/add_firmware.py +98 -98
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/ask_input.py +236 -236
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/basicgit.py +284 -284
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/__init__.py +2 -2
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/activate.py +60 -60
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/detect.py +82 -82
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/manual.py +101 -101
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/micropython.py +12 -12
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/bootloader/touch1200.py +36 -36
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/cli_download.py +129 -129
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/cli_flash.py +224 -216
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/cli_group.py +111 -111
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/cli_list.py +87 -87
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/cli_main.py +39 -39
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/common.py +210 -166
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/config.py +44 -44
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/connected.py +104 -77
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/download.py +364 -364
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/downloaded.py +130 -130
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/errors.py +9 -9
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/__init__.py +55 -55
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/esp.py +59 -59
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/stm32.py +19 -19
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/stm32_dfu.py +104 -104
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/__init__.py +88 -88
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/boardid.py +15 -15
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/linux.py +136 -130
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/macos.py +42 -42
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/uf2disk.py +12 -12
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/uf2/windows.py +43 -43
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/flash/worklist.py +170 -170
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/list.py +106 -106
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/logger.py +41 -41
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/__init__.py +93 -93
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/add_boards.py +251 -251
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/board.py +37 -37
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/board_id.py +86 -86
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/store.py +43 -43
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpremoteboard/__init__.py +266 -266
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpremoteboard/mpy_fw_info.py +141 -141
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpremoteboard/runner.py +140 -140
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/vendor/click_aliases.py +91 -91
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/vendor/dfu.py +165 -165
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/vendor/pydfu.py +605 -605
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/vendor/readme.md +2 -2
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/versions.py +135 -135
- {mpflash-1.0.0 → mpflash-1.0.2}/pyproject.toml +65 -65
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/__init__.py +0 -0
- {mpflash-1.0.0 → mpflash-1.0.2}/mpflash/mpboard_id/board_info.zip +0 -0
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2024 Jos Verlinde
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
11
|
-
copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
SOFTWARE.
|
20
|
-
|
1
|
+
Copyright (c) 2024 Jos Verlinde
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
20
|
+
|
@@ -1,220 +1,220 @@
|
|
1
|
-
# MPFLASH
|
2
|
-
[](https://pypi.org/project/mpflash/)
|
3
|
-
[](https://badgen.net/pypi/python/mpflash)
|
4
|
-
[](https://pepy.tech/project/mpflash)
|
5
|
-
|
6
|
-
|
7
|
-
`mpflash` is a command-line tool for working with MicroPython firmware. It provides features to help you flash and update Micropython on one or more .
|
8
|
-
|
9
|
-
This tool was initially created to be used in a CI/CD pipeline to automate the process of downloading and flashing MicroPython firmware to multiple boards, but it has been extend with a TUI to be used for manual downloadig, flashing and development.
|
10
|
-
|
11
|
-
`mpflash` has been tested on:
|
12
|
-
- OS: Windows x64, Linux X64, but not (yet) macOS.
|
13
|
-
- Micropython (hardware) ports:
|
14
|
-
- `rp2`, using `.uf2`, using filecopy
|
15
|
-
- `samd`, using ` .uf2`, using filecopy
|
16
|
-
- `esp32`, using `.bin`, using esptool,
|
17
|
-
- `esp8266`, using `.bin`, using esptool
|
18
|
-
- `stm32`, using ` .dfu`, using pydfu
|
19
|
-
|
20
|
-
Not yet implemented: `nrf`, `cc3200`, `mimxrt`
|
21
|
-
|
22
|
-
## Features
|
23
|
-
1. List the connected boards including their firmware details, in a tabular or json format
|
24
|
-
2. Download MicroPython firmware for versions, and matching a specified board or matches your current attached board.
|
25
|
-
3. Flash one or all connected MicroPython boards with a specific firmware or version.
|
26
|
-
|
27
|
-
## Installation
|
28
|
-
To install mpflash, you can use: `pipx install mpflash` or `pip install mpflash`
|
29
|
-
|
30
|
-
## Basic usage
|
31
|
-
You can use mpflash to perform various operations on your MicroPython boards. Here is an example of basic usage:
|
32
|
-
|
33
|
-
| Command | Description |
|
34
|
-
|---------|-------------|
|
35
|
-
| `mpflash list` | List the connected board(s) including their firmware details |
|
36
|
-
| `mpflash download` | Download the MicroPython firmware(s) for the connected board(s) |
|
37
|
-
| `mpflash flash` | Flash the latest stable firmware to the connected board(s) |
|
38
|
-
|
39
|
-
## selecting or ignoring specific serial ports
|
40
|
-
|
41
|
-
You can use the `--serial` option to select a specific serial port to flash, or the `--ignore` option to ignore a specific serial port.
|
42
|
-
both options can be specified multiple times
|
43
|
-
Both can be globs (e.g. COM*) or exact port names (e.g. COM1)
|
44
|
-
in addition there is a --bluetooth option to simplify ignoring bluetooth ports
|
45
|
-
|
46
|
-
```
|
47
|
-
--serial,--serial-port -s SERIALPORT Serial port(s) (or globs) to list. [default: *] > > --ignore -i SERIALPORT Serial port(s) (or globs) to ignore. Defaults to MPFLASH_IGNORE. │
|
48
|
-
--bluetooth/--no-bluetooth -b/-nb Include bluetooth ports in the list [default: no-bluetooth]
|
49
|
-
```
|
50
|
-
|
51
|
-
## Distinguishing similar boards
|
52
|
-
The `mpflash list` command will list all connected boards, but sometimes you have multiple boards of the same type connected.
|
53
|
-
To help you identify the boards, you can add a board_info.toml file to the top/default folder for the board.
|
54
|
-
This file can contain a description of the board, which will be shown in the list and json output.
|
55
|
-
```toml
|
56
|
-
description = "Blue Norwegian actuator"
|
57
|
-
```
|
58
|
-
|
59
|
-
If you want the board to be ignored by mpflash, you can add the following to the board_info.toml file:
|
60
|
-
```toml
|
61
|
-
[mpflash]
|
62
|
-
ignore = true
|
63
|
-
```
|
64
|
-
|
65
|
-
|
66
|
-
## Linux permissions to access usb devices
|
67
|
-
In order to flash the firmware to the board, you need to have the correct permissions to access the USB devices.
|
68
|
-
On Windows this will not be an issue, but on Linux you can use udev rules to give non-root users access to the USB devices.
|
69
|
-
[See the stm32_permissions documentation](./stm32_udev_rules.md) for more information.
|
70
|
-
|
71
|
-
|
72
|
-
## Detailed usage
|
73
|
-
You can list the connected boards using the following command:
|
74
|
-
```bash
|
75
|
-
$> mpflash list
|
76
|
-
Connected boards
|
77
|
-
┏━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━┓
|
78
|
-
┃ Serial ┃Family ┃Port ┃Board ┃CPU ┃Version ┃build ┃
|
79
|
-
┡━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━┩
|
80
|
-
│ COM21 │micropython │rp2 │RPI_PICO │RP2040 │v1.23.0-preview │ 236 │
|
81
|
-
│ │ │ │Raspberry Pi Pico with RP2040 │ │ │ │
|
82
|
-
│ COM23 │micropython │rp2 │RPI_PICO_W │RP2040 │v1.23.0-preview │ 176 │
|
83
|
-
│ │ │ │Raspberry Pi Pico W with RP2040 │ │ │ │
|
84
|
-
│ COM9 │micropython │rp2 │ARDUINO_NANO_RP2040_CONNECT │RP2040 │v1.23.0-preview │ 341 │
|
85
|
-
│ │ │ │Arduino Nano RP2040 Connect with RP2040 │ │ │ │
|
86
|
-
└─────────┴─────────────┴──────┴───────────────────────────────────────────┴────────┴─────────────────┴──────┘
|
87
|
-
```
|
88
|
-
## Download the firmware
|
89
|
-
|
90
|
-
To download the MicroPython firmware for some boards, use the following command:
|
91
|
-
- `mpflash download` download the latest stable firmware for all connected boards
|
92
|
-
- `mpflash download --version preview` download the current preview for all connected boards
|
93
|
-
- `mpflash download --board ESP8266_GENERIC --board SEEED_WIO_TERMINAL` download these specific boards
|
94
|
-
- `mpflash download --version ? --board ?` prompt to select a specific version and board to download
|
95
|
-
|
96
|
-
These will try to download the prebuilt MicroPython firmware for the boards from https://micropython.org/download/ and save it in your downloads folder in the `firmware` directory.
|
97
|
-
The stable version (default) is determined based on the most recent published release,
|
98
|
-
other options are `--version stable`, `--version preview` and `--version x.y.z` to download the latest stable, preview or version x.y.z respectively.
|
99
|
-
|
100
|
-
By default the firmware will be downloaded to your OS's preferred `Downloads/firmware` folder, but you can speciy a different directory using the `--dir` option.
|
101
|
-
|
102
|
-
The directory structure will be something like this:
|
103
|
-
|
104
|
-
``` text
|
105
|
-
Downloads/firmware
|
106
|
-
| firmware.jsonl
|
107
|
-
+---esp8266
|
108
|
-
| ESP8266_GENERIC-FLASH_1M-v1.22.2.bin
|
109
|
-
| ESP8266_GENERIC-FLASH_512K-v1.22.2.bin
|
110
|
-
| ESP8266_GENERIC-OTA-v1.22.2.bin
|
111
|
-
| ESP8266_GENERIC-v1.22.2.bin
|
112
|
-
\---samd
|
113
|
-
SEEED_WIO_TERMINAL-v1.22.2.uf2
|
114
|
-
```
|
115
|
-
|
116
|
-
## Flashing the firmware
|
117
|
-
After you have downloaded a firmware you can flash the firmware to a board using the following command: `mpflash flash`
|
118
|
-
This will (try to) autodetect the connected boards, and determine the correct firmware to flash to each board.
|
119
|
-
|
120
|
-
- `mpflash flash` will flash the latest stable firmware to all connected boards.
|
121
|
-
If you have a board withouth a running micropython version, you will need to specify the board and the serial port to flash.
|
122
|
-
- `mpflash flash --serial ? --board ?` will prompt to select a specific serial port and board to flash. (the firmware must be dowloaded earlier)
|
123
|
-
|
124
|
-
In order to flash the firmware some boards need to be put in bootloader mode, this is done automatically by mpflash where possible and supported by the boards hardware and current bootloader.
|
125
|
-
The supported `--bootloader` options are:
|
126
|
-
|
127
|
-
- `touch1200` bootloader is activated by connecting to the board at 1200 baud
|
128
|
-
- `mpy` using micropython to enter the bootloader
|
129
|
-
- `manual` manual intervention is needed to enter the bootloader
|
130
|
-
- `none` mpflash assumes the board is ready to flash
|
131
|
-
|
132
|
-
For ESP32 and ESP8266 boards the `esptool` is used to flash the firmware, and this includes activating the bootloader.
|
133
|
-
|
134
|
-
### Flashing all connected boards with the latest stable firmware
|
135
|
-
```bash
|
136
|
-
> mpflash flash
|
137
|
-
22:15:55 | ℹ️ - Using latest stable version: v1.22.2
|
138
|
-
Connected boards
|
139
|
-
┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
|
140
|
-
┃ Serial ┃ Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
|
141
|
-
┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
|
142
|
-
│ COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.20.0 │ │
|
143
|
-
│ COM12 │ micropython │ esp8266 │ ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
|
144
|
-
│ COM18 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.23.0-preview │ 155 │
|
145
|
-
│ COM3 │ micropython │ samd │ SEEED_WIO_TERMINAL │ SAMD51P19A │ 1.23.0-preview │ 155 │
|
146
|
-
│ COM5 │ micropython │ stm32 │ PYBV11 │ STM32F405RG │ 1.23.0-preview │ 166 │
|
147
|
-
│ COM8 │ micropython │ esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview │ 155 │
|
148
|
-
└────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
|
149
|
-
22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM11.
|
150
|
-
22:15:58 | ℹ️ - Found v1.22.2 firmware esp8266\ESP8266_GENERIC-v1.22.2.bin for ESP8266_GENERIC on COM12.
|
151
|
-
22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM18.
|
152
|
-
22:15:58 | ℹ️ - Found v1.22.2 firmware samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 for SEEED_WIO_TERMINAL on COM3.
|
153
|
-
22:15:58 | ⚠️ - Trying to find a firmware for the board PYBV11
|
154
|
-
22:15:58 | ❌ - No v1.22.2 firmware found for PYBV11 on COM5.
|
155
|
-
22:15:58 | ⚠️ - Trying to find a firmware for the board ESP32-GENERIC-S3
|
156
|
-
22:15:58 | ❌ - No v1.22.2 firmware found for ESP32_GENERIC_S3 on COM8.
|
157
|
-
22:15:58 | ℹ️ - Updating RPI_PICO_W on COM11 to 1.22.2
|
158
|
-
22:15:58 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
159
|
-
22:15:58 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM11
|
160
|
-
22:15:58 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
161
|
-
22:15:59 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
162
|
-
22:16:00 | ℹ️ - Board is in bootloader mode
|
163
|
-
22:16:00 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:
|
164
|
-
22:16:13 | ✅ - Done copying, resetting the board and wait for it to restart
|
165
|
-
22:16:23 | ℹ️ - Updating ESP8266_GENERIC on COM12 to 1.22.2
|
166
|
-
22:16:23 | ℹ️ - Flashing firmware\esp8266\ESP8266_GENERIC-v1.22.2.bin on ESP8266_GENERIC on COM12
|
167
|
-
22:16:23 | ℹ️ - Running esptool --chip ESP8266 --port COM12 erase_flash
|
168
|
-
esptool.py v4.7.0
|
169
|
-
Serial port COM12
|
170
|
-
Connecting....
|
171
|
-
...
|
172
|
-
Chip erase completed successfully in 6.5s
|
173
|
-
Hard resetting via RTS pin...
|
174
|
-
22:16:31 | ℹ️ - Running esptool --chip ESP8266 --port COM12 -b 460800 write_flash --flash_size=detect 0x0 firmware\esp8266\ESP8266_GENERIC-v1.22.2.bin
|
175
|
-
esptool.py v4.7.0
|
176
|
-
Serial port COM12
|
177
|
-
Connecting....
|
178
|
-
...
|
179
|
-
Leaving...
|
180
|
-
Hard resetting via RTS pin...
|
181
|
-
22:16:43 | ℹ️ - Done flashing, resetting the board and wait for it to restart
|
182
|
-
22:16:49 | ✅ - Flashed 1.22.2 to ESP8266_GENERIC on COM12 done
|
183
|
-
22:16:49 | ℹ️ - Updating RPI_PICO_W on COM18 to 1.22.2
|
184
|
-
22:16:49 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
185
|
-
22:16:49 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM18
|
186
|
-
22:16:49 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
187
|
-
22:16:50 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
188
|
-
22:16:51 | ℹ️ - Board is in bootloader mode
|
189
|
-
22:16:51 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:[/bold]
|
190
|
-
22:17:02 | ✅ - Done copying, resetting the board and wait for it to restart
|
191
|
-
22:17:12 | ℹ️ - Updating SEEED_WIO_TERMINAL on COM3 to 1.22.2
|
192
|
-
22:17:12 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
193
|
-
22:17:12 | ℹ️ - Entering UF2 bootloader on SEEED_WIO_TERMINAL on COM3
|
194
|
-
22:17:12 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
195
|
-
22:17:13 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
196
|
-
22:17:14 | ℹ️ - Board is in bootloader mode
|
197
|
-
22:17:14 | ℹ️ - Copying firmware\samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 to F:[/bold]
|
198
|
-
22:17:17 | ✅ - Done copying, resetting the board and wait for it to restart
|
199
|
-
22:17:27 | ℹ️ - Flashed 4 boards
|
200
|
-
Connected boards after flashing
|
201
|
-
┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
|
202
|
-
┃ Serial ┃ Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
|
203
|
-
┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
|
204
|
-
│ COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
|
205
|
-
│ COM12 │ micropython │ esp8266 │ ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
|
206
|
-
│ COM18 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
|
207
|
-
│ COM3 │ micropython │ samd │ SEEED_WIO_TERMINAL │ SAMD51P19A │ 1.22.2 │ │
|
208
|
-
│ COM5 │ micropython │ stm32 │ PYBV11 │ STM32F405RG │ 1.23.0-preview │ 166 │
|
209
|
-
│ COM8 │ micropython │ esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview │ 155 │
|
210
|
-
└────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
|
211
|
-
```
|
212
|
-
Note that if no matching firmware can be found for a board, it will be skipped.
|
213
|
-
(For example, the PYBV11 and ESP32_GENERIC_S3 boards in the example above.)
|
214
|
-
|
215
|
-
## Issues and bug reports
|
216
|
-
mpflash is currently co-located in the [micropython-stubber](https://github.com/Josverl/micropython-stubber) repository.
|
217
|
-
Please report any issues or bugs in the [issue tracker](https://github.com/Josverl/micropython-stubber/issues) using the MPflash feedback template.
|
218
|
-
|
219
|
-
## License
|
220
|
-
mpflash is licensed under the MIT license. See the LICENSE file for more details.
|
1
|
+
# MPFLASH
|
2
|
+
[](https://pypi.org/project/mpflash/)
|
3
|
+
[](https://badgen.net/pypi/python/mpflash)
|
4
|
+
[](https://pepy.tech/project/mpflash)
|
5
|
+
|
6
|
+
|
7
|
+
`mpflash` is a command-line tool for working with MicroPython firmware. It provides features to help you flash and update Micropython on one or more .
|
8
|
+
|
9
|
+
This tool was initially created to be used in a CI/CD pipeline to automate the process of downloading and flashing MicroPython firmware to multiple boards, but it has been extend with a TUI to be used for manual downloadig, flashing and development.
|
10
|
+
|
11
|
+
`mpflash` has been tested on:
|
12
|
+
- OS: Windows x64, Linux X64, but not (yet) macOS.
|
13
|
+
- Micropython (hardware) ports:
|
14
|
+
- `rp2`, using `.uf2`, using filecopy
|
15
|
+
- `samd`, using ` .uf2`, using filecopy
|
16
|
+
- `esp32`, using `.bin`, using esptool,
|
17
|
+
- `esp8266`, using `.bin`, using esptool
|
18
|
+
- `stm32`, using ` .dfu`, using pydfu
|
19
|
+
|
20
|
+
Not yet implemented: `nrf`, `cc3200`, `mimxrt`
|
21
|
+
|
22
|
+
## Features
|
23
|
+
1. List the connected boards including their firmware details, in a tabular or json format
|
24
|
+
2. Download MicroPython firmware for versions, and matching a specified board or matches your current attached board.
|
25
|
+
3. Flash one or all connected MicroPython boards with a specific firmware or version.
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
To install mpflash, you can use: `pipx install mpflash` or `pip install mpflash`
|
29
|
+
|
30
|
+
## Basic usage
|
31
|
+
You can use mpflash to perform various operations on your MicroPython boards. Here is an example of basic usage:
|
32
|
+
|
33
|
+
| Command | Description |
|
34
|
+
|---------|-------------|
|
35
|
+
| `mpflash list` | List the connected board(s) including their firmware details |
|
36
|
+
| `mpflash download` | Download the MicroPython firmware(s) for the connected board(s) |
|
37
|
+
| `mpflash flash` | Flash the latest stable firmware to the connected board(s) |
|
38
|
+
|
39
|
+
## selecting or ignoring specific serial ports
|
40
|
+
|
41
|
+
You can use the `--serial` option to select a specific serial port to flash, or the `--ignore` option to ignore a specific serial port.
|
42
|
+
both options can be specified multiple times
|
43
|
+
Both can be globs (e.g. COM*) or exact port names (e.g. COM1)
|
44
|
+
in addition there is a --bluetooth option to simplify ignoring bluetooth ports
|
45
|
+
|
46
|
+
```
|
47
|
+
--serial,--serial-port -s SERIALPORT Serial port(s) (or globs) to list. [default: *] > > --ignore -i SERIALPORT Serial port(s) (or globs) to ignore. Defaults to MPFLASH_IGNORE. │
|
48
|
+
--bluetooth/--no-bluetooth -b/-nb Include bluetooth ports in the list [default: no-bluetooth]
|
49
|
+
```
|
50
|
+
|
51
|
+
## Distinguishing similar boards
|
52
|
+
The `mpflash list` command will list all connected boards, but sometimes you have multiple boards of the same type connected.
|
53
|
+
To help you identify the boards, you can add a board_info.toml file to the top/default folder for the board.
|
54
|
+
This file can contain a description of the board, which will be shown in the list and json output.
|
55
|
+
```toml
|
56
|
+
description = "Blue Norwegian actuator"
|
57
|
+
```
|
58
|
+
|
59
|
+
If you want the board to be ignored by mpflash, you can add the following to the board_info.toml file:
|
60
|
+
```toml
|
61
|
+
[mpflash]
|
62
|
+
ignore = true
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
## Linux permissions to access usb devices
|
67
|
+
In order to flash the firmware to the board, you need to have the correct permissions to access the USB devices.
|
68
|
+
On Windows this will not be an issue, but on Linux you can use udev rules to give non-root users access to the USB devices.
|
69
|
+
[See the stm32_permissions documentation](./stm32_udev_rules.md) for more information.
|
70
|
+
|
71
|
+
|
72
|
+
## Detailed usage
|
73
|
+
You can list the connected boards using the following command:
|
74
|
+
```bash
|
75
|
+
$> mpflash list
|
76
|
+
Connected boards
|
77
|
+
┏━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━┓
|
78
|
+
┃ Serial ┃Family ┃Port ┃Board ┃CPU ┃Version ┃build ┃
|
79
|
+
┡━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━┩
|
80
|
+
│ COM21 │micropython │rp2 │RPI_PICO │RP2040 │v1.23.0-preview │ 236 │
|
81
|
+
│ │ │ │Raspberry Pi Pico with RP2040 │ │ │ │
|
82
|
+
│ COM23 │micropython │rp2 │RPI_PICO_W │RP2040 │v1.23.0-preview │ 176 │
|
83
|
+
│ │ │ │Raspberry Pi Pico W with RP2040 │ │ │ │
|
84
|
+
│ COM9 │micropython │rp2 │ARDUINO_NANO_RP2040_CONNECT │RP2040 │v1.23.0-preview │ 341 │
|
85
|
+
│ │ │ │Arduino Nano RP2040 Connect with RP2040 │ │ │ │
|
86
|
+
└─────────┴─────────────┴──────┴───────────────────────────────────────────┴────────┴─────────────────┴──────┘
|
87
|
+
```
|
88
|
+
## Download the firmware
|
89
|
+
|
90
|
+
To download the MicroPython firmware for some boards, use the following command:
|
91
|
+
- `mpflash download` download the latest stable firmware for all connected boards
|
92
|
+
- `mpflash download --version preview` download the current preview for all connected boards
|
93
|
+
- `mpflash download --board ESP8266_GENERIC --board SEEED_WIO_TERMINAL` download these specific boards
|
94
|
+
- `mpflash download --version ? --board ?` prompt to select a specific version and board to download
|
95
|
+
|
96
|
+
These will try to download the prebuilt MicroPython firmware for the boards from https://micropython.org/download/ and save it in your downloads folder in the `firmware` directory.
|
97
|
+
The stable version (default) is determined based on the most recent published release,
|
98
|
+
other options are `--version stable`, `--version preview` and `--version x.y.z` to download the latest stable, preview or version x.y.z respectively.
|
99
|
+
|
100
|
+
By default the firmware will be downloaded to your OS's preferred `Downloads/firmware` folder, but you can speciy a different directory using the `--dir` option.
|
101
|
+
|
102
|
+
The directory structure will be something like this:
|
103
|
+
|
104
|
+
``` text
|
105
|
+
Downloads/firmware
|
106
|
+
| firmware.jsonl
|
107
|
+
+---esp8266
|
108
|
+
| ESP8266_GENERIC-FLASH_1M-v1.22.2.bin
|
109
|
+
| ESP8266_GENERIC-FLASH_512K-v1.22.2.bin
|
110
|
+
| ESP8266_GENERIC-OTA-v1.22.2.bin
|
111
|
+
| ESP8266_GENERIC-v1.22.2.bin
|
112
|
+
\---samd
|
113
|
+
SEEED_WIO_TERMINAL-v1.22.2.uf2
|
114
|
+
```
|
115
|
+
|
116
|
+
## Flashing the firmware
|
117
|
+
After you have downloaded a firmware you can flash the firmware to a board using the following command: `mpflash flash`
|
118
|
+
This will (try to) autodetect the connected boards, and determine the correct firmware to flash to each board.
|
119
|
+
|
120
|
+
- `mpflash flash` will flash the latest stable firmware to all connected boards.
|
121
|
+
If you have a board withouth a running micropython version, you will need to specify the board and the serial port to flash.
|
122
|
+
- `mpflash flash --serial ? --board ?` will prompt to select a specific serial port and board to flash. (the firmware must be dowloaded earlier)
|
123
|
+
|
124
|
+
In order to flash the firmware some boards need to be put in bootloader mode, this is done automatically by mpflash where possible and supported by the boards hardware and current bootloader.
|
125
|
+
The supported `--bootloader` options are:
|
126
|
+
|
127
|
+
- `touch1200` bootloader is activated by connecting to the board at 1200 baud
|
128
|
+
- `mpy` using micropython to enter the bootloader
|
129
|
+
- `manual` manual intervention is needed to enter the bootloader
|
130
|
+
- `none` mpflash assumes the board is ready to flash
|
131
|
+
|
132
|
+
For ESP32 and ESP8266 boards the `esptool` is used to flash the firmware, and this includes activating the bootloader.
|
133
|
+
|
134
|
+
### Flashing all connected boards with the latest stable firmware
|
135
|
+
```bash
|
136
|
+
> mpflash flash
|
137
|
+
22:15:55 | ℹ️ - Using latest stable version: v1.22.2
|
138
|
+
Connected boards
|
139
|
+
┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
|
140
|
+
┃ Serial ┃ Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
|
141
|
+
┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
|
142
|
+
│ COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.20.0 │ │
|
143
|
+
│ COM12 │ micropython │ esp8266 │ ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
|
144
|
+
│ COM18 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.23.0-preview │ 155 │
|
145
|
+
│ COM3 │ micropython │ samd │ SEEED_WIO_TERMINAL │ SAMD51P19A │ 1.23.0-preview │ 155 │
|
146
|
+
│ COM5 │ micropython │ stm32 │ PYBV11 │ STM32F405RG │ 1.23.0-preview │ 166 │
|
147
|
+
│ COM8 │ micropython │ esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview │ 155 │
|
148
|
+
└────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
|
149
|
+
22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM11.
|
150
|
+
22:15:58 | ℹ️ - Found v1.22.2 firmware esp8266\ESP8266_GENERIC-v1.22.2.bin for ESP8266_GENERIC on COM12.
|
151
|
+
22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM18.
|
152
|
+
22:15:58 | ℹ️ - Found v1.22.2 firmware samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 for SEEED_WIO_TERMINAL on COM3.
|
153
|
+
22:15:58 | ⚠️ - Trying to find a firmware for the board PYBV11
|
154
|
+
22:15:58 | ❌ - No v1.22.2 firmware found for PYBV11 on COM5.
|
155
|
+
22:15:58 | ⚠️ - Trying to find a firmware for the board ESP32-GENERIC-S3
|
156
|
+
22:15:58 | ❌ - No v1.22.2 firmware found for ESP32_GENERIC_S3 on COM8.
|
157
|
+
22:15:58 | ℹ️ - Updating RPI_PICO_W on COM11 to 1.22.2
|
158
|
+
22:15:58 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
159
|
+
22:15:58 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM11
|
160
|
+
22:15:58 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
161
|
+
22:15:59 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
162
|
+
22:16:00 | ℹ️ - Board is in bootloader mode
|
163
|
+
22:16:00 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:
|
164
|
+
22:16:13 | ✅ - Done copying, resetting the board and wait for it to restart
|
165
|
+
22:16:23 | ℹ️ - Updating ESP8266_GENERIC on COM12 to 1.22.2
|
166
|
+
22:16:23 | ℹ️ - Flashing firmware\esp8266\ESP8266_GENERIC-v1.22.2.bin on ESP8266_GENERIC on COM12
|
167
|
+
22:16:23 | ℹ️ - Running esptool --chip ESP8266 --port COM12 erase_flash
|
168
|
+
esptool.py v4.7.0
|
169
|
+
Serial port COM12
|
170
|
+
Connecting....
|
171
|
+
...
|
172
|
+
Chip erase completed successfully in 6.5s
|
173
|
+
Hard resetting via RTS pin...
|
174
|
+
22:16:31 | ℹ️ - Running esptool --chip ESP8266 --port COM12 -b 460800 write_flash --flash_size=detect 0x0 firmware\esp8266\ESP8266_GENERIC-v1.22.2.bin
|
175
|
+
esptool.py v4.7.0
|
176
|
+
Serial port COM12
|
177
|
+
Connecting....
|
178
|
+
...
|
179
|
+
Leaving...
|
180
|
+
Hard resetting via RTS pin...
|
181
|
+
22:16:43 | ℹ️ - Done flashing, resetting the board and wait for it to restart
|
182
|
+
22:16:49 | ✅ - Flashed 1.22.2 to ESP8266_GENERIC on COM12 done
|
183
|
+
22:16:49 | ℹ️ - Updating RPI_PICO_W on COM18 to 1.22.2
|
184
|
+
22:16:49 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
185
|
+
22:16:49 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM18
|
186
|
+
22:16:49 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
187
|
+
22:16:50 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
188
|
+
22:16:51 | ℹ️ - Board is in bootloader mode
|
189
|
+
22:16:51 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:[/bold]
|
190
|
+
22:17:02 | ✅ - Done copying, resetting the board and wait for it to restart
|
191
|
+
22:17:12 | ℹ️ - Updating SEEED_WIO_TERMINAL on COM3 to 1.22.2
|
192
|
+
22:17:12 | ℹ️ - Erasing not yet implemented for UF2 flashing.
|
193
|
+
22:17:12 | ℹ️ - Entering UF2 bootloader on SEEED_WIO_TERMINAL on COM3
|
194
|
+
22:17:12 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
|
195
|
+
22:17:13 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
|
196
|
+
22:17:14 | ℹ️ - Board is in bootloader mode
|
197
|
+
22:17:14 | ℹ️ - Copying firmware\samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 to F:[/bold]
|
198
|
+
22:17:17 | ✅ - Done copying, resetting the board and wait for it to restart
|
199
|
+
22:17:27 | ℹ️ - Flashed 4 boards
|
200
|
+
Connected boards after flashing
|
201
|
+
┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
|
202
|
+
┃ Serial ┃ Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
|
203
|
+
┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
|
204
|
+
│ COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
|
205
|
+
│ COM12 │ micropython │ esp8266 │ ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
|
206
|
+
│ COM18 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
|
207
|
+
│ COM3 │ micropython │ samd │ SEEED_WIO_TERMINAL │ SAMD51P19A │ 1.22.2 │ │
|
208
|
+
│ COM5 │ micropython │ stm32 │ PYBV11 │ STM32F405RG │ 1.23.0-preview │ 166 │
|
209
|
+
│ COM8 │ micropython │ esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview │ 155 │
|
210
|
+
└────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
|
211
|
+
```
|
212
|
+
Note that if no matching firmware can be found for a board, it will be skipped.
|
213
|
+
(For example, the PYBV11 and ESP32_GENERIC_S3 boards in the example above.)
|
214
|
+
|
215
|
+
## Issues and bug reports
|
216
|
+
mpflash is currently co-located in the [micropython-stubber](https://github.com/Josverl/micropython-stubber) repository.
|
217
|
+
Please report any issues or bugs in the [issue tracker](https://github.com/Josverl/micropython-stubber/issues) using the MPflash feedback template.
|
218
|
+
|
219
|
+
## License
|
220
|
+
mpflash is licensed under the MIT license. See the LICENSE file for more details.
|