micropython-stubber 1.23.1__py3-none-any.whl → 1.23.2__py3-none-any.whl

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.
Files changed (153) hide show
  1. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/LICENSE +30 -30
  2. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/METADATA +32 -15
  3. micropython_stubber-1.23.2.dist-info/RECORD +158 -0
  4. micropython_stubber-1.23.2.dist-info/entry_points.txt +5 -0
  5. mpflash/README.md +220 -194
  6. mpflash/libusb_flash.ipynb +203 -203
  7. mpflash/mpflash/add_firmware.py +98 -98
  8. mpflash/mpflash/ask_input.py +236 -236
  9. mpflash/mpflash/basicgit.py +284 -284
  10. mpflash/mpflash/bootloader/__init__.py +2 -2
  11. mpflash/mpflash/bootloader/activate.py +60 -60
  12. mpflash/mpflash/bootloader/detect.py +82 -82
  13. mpflash/mpflash/bootloader/manual.py +101 -101
  14. mpflash/mpflash/bootloader/micropython.py +12 -12
  15. mpflash/mpflash/bootloader/touch1200.py +36 -36
  16. mpflash/mpflash/cli_download.py +129 -129
  17. mpflash/mpflash/cli_flash.py +224 -219
  18. mpflash/mpflash/cli_group.py +111 -111
  19. mpflash/mpflash/cli_list.py +87 -81
  20. mpflash/mpflash/cli_main.py +39 -39
  21. mpflash/mpflash/common.py +210 -165
  22. mpflash/mpflash/config.py +44 -44
  23. mpflash/mpflash/connected.py +96 -78
  24. mpflash/mpflash/download.py +364 -364
  25. mpflash/mpflash/downloaded.py +130 -130
  26. mpflash/mpflash/errors.py +9 -9
  27. mpflash/mpflash/flash/__init__.py +55 -55
  28. mpflash/mpflash/flash/esp.py +59 -59
  29. mpflash/mpflash/flash/stm32.py +19 -19
  30. mpflash/mpflash/flash/stm32_dfu.py +104 -104
  31. mpflash/mpflash/flash/uf2/__init__.py +88 -88
  32. mpflash/mpflash/flash/uf2/boardid.py +15 -15
  33. mpflash/mpflash/flash/uf2/linux.py +136 -130
  34. mpflash/mpflash/flash/uf2/macos.py +42 -42
  35. mpflash/mpflash/flash/uf2/uf2disk.py +12 -12
  36. mpflash/mpflash/flash/uf2/windows.py +43 -43
  37. mpflash/mpflash/flash/worklist.py +170 -170
  38. mpflash/mpflash/list.py +106 -99
  39. mpflash/mpflash/logger.py +41 -41
  40. mpflash/mpflash/mpboard_id/__init__.py +93 -93
  41. mpflash/mpflash/mpboard_id/add_boards.py +251 -251
  42. mpflash/mpflash/mpboard_id/board.py +37 -37
  43. mpflash/mpflash/mpboard_id/board_id.py +86 -86
  44. mpflash/mpflash/mpboard_id/store.py +43 -43
  45. mpflash/mpflash/mpremoteboard/__init__.py +266 -222
  46. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -141
  47. mpflash/mpflash/mpremoteboard/runner.py +140 -140
  48. mpflash/mpflash/vendor/click_aliases.py +91 -91
  49. mpflash/mpflash/vendor/dfu.py +165 -165
  50. mpflash/mpflash/vendor/pydfu.py +605 -605
  51. mpflash/mpflash/vendor/readme.md +2 -2
  52. mpflash/mpflash/versions.py +135 -135
  53. mpflash/poetry.lock +1599 -1599
  54. mpflash/pyproject.toml +65 -65
  55. mpflash/stm32_udev_rules.md +62 -62
  56. stubber/__init__.py +3 -3
  57. stubber/board/board_info.csv +193 -193
  58. stubber/board/boot.py +34 -34
  59. stubber/board/createstubs.py +1004 -986
  60. stubber/board/createstubs_db.py +826 -825
  61. stubber/board/createstubs_db_min.py +332 -331
  62. stubber/board/createstubs_db_mpy.mpy +0 -0
  63. stubber/board/createstubs_lvgl.py +741 -741
  64. stubber/board/createstubs_lvgl_min.py +741 -741
  65. stubber/board/createstubs_mem.py +767 -766
  66. stubber/board/createstubs_mem_min.py +307 -306
  67. stubber/board/createstubs_mem_mpy.mpy +0 -0
  68. stubber/board/createstubs_min.py +295 -294
  69. stubber/board/createstubs_mpy.mpy +0 -0
  70. stubber/board/fw_info.py +141 -141
  71. stubber/board/info.py +183 -183
  72. stubber/board/main.py +19 -19
  73. stubber/board/modulelist.txt +247 -247
  74. stubber/board/pyrightconfig.json +34 -34
  75. stubber/bulk/mcu_stubber.py +437 -454
  76. stubber/codemod/_partials/__init__.py +48 -48
  77. stubber/codemod/_partials/db_main.py +147 -147
  78. stubber/codemod/_partials/lvgl_main.py +77 -77
  79. stubber/codemod/_partials/modules_reader.py +80 -80
  80. stubber/codemod/add_comment.py +53 -53
  81. stubber/codemod/add_method.py +65 -65
  82. stubber/codemod/board.py +317 -317
  83. stubber/codemod/enrich.py +151 -145
  84. stubber/codemod/merge_docstub.py +284 -284
  85. stubber/codemod/modify_list.py +54 -54
  86. stubber/codemod/utils.py +56 -56
  87. stubber/commands/build_cmd.py +94 -94
  88. stubber/commands/cli.py +49 -55
  89. stubber/commands/clone_cmd.py +78 -78
  90. stubber/commands/config_cmd.py +29 -29
  91. stubber/commands/enrich_folder_cmd.py +71 -71
  92. stubber/commands/get_core_cmd.py +71 -71
  93. stubber/commands/get_docstubs_cmd.py +92 -89
  94. stubber/commands/get_frozen_cmd.py +117 -114
  95. stubber/commands/get_mcu_cmd.py +102 -61
  96. stubber/commands/merge_cmd.py +66 -66
  97. stubber/commands/publish_cmd.py +118 -118
  98. stubber/commands/stub_cmd.py +31 -31
  99. stubber/commands/switch_cmd.py +62 -62
  100. stubber/commands/variants_cmd.py +48 -48
  101. stubber/cst_transformer.py +178 -178
  102. stubber/data/board_info.csv +193 -193
  103. stubber/data/board_info.json +1729 -1729
  104. stubber/data/micropython_tags.csv +15 -15
  105. stubber/data/requirements-core-micropython.txt +38 -38
  106. stubber/data/requirements-core-pycopy.txt +39 -39
  107. stubber/downloader.py +37 -36
  108. stubber/freeze/common.py +72 -68
  109. stubber/freeze/freeze_folder.py +69 -69
  110. stubber/freeze/freeze_manifest_2.py +126 -113
  111. stubber/freeze/get_frozen.py +131 -127
  112. stubber/get_cpython.py +112 -101
  113. stubber/get_lobo.py +59 -59
  114. stubber/minify.py +423 -419
  115. stubber/publish/bump.py +86 -86
  116. stubber/publish/candidates.py +275 -256
  117. stubber/publish/database.py +18 -18
  118. stubber/publish/defaults.py +40 -40
  119. stubber/publish/enums.py +24 -24
  120. stubber/publish/helpers.py +29 -29
  121. stubber/publish/merge_docstubs.py +136 -130
  122. stubber/publish/missing_class_methods.py +51 -49
  123. stubber/publish/package.py +150 -146
  124. stubber/publish/pathnames.py +51 -51
  125. stubber/publish/publish.py +120 -120
  126. stubber/publish/pypi.py +42 -38
  127. stubber/publish/stubpackage.py +1055 -1027
  128. stubber/rst/__init__.py +9 -9
  129. stubber/rst/classsort.py +78 -77
  130. stubber/rst/lookup.py +533 -530
  131. stubber/rst/output_dict.py +401 -401
  132. stubber/rst/reader.py +814 -814
  133. stubber/rst/report_return.py +77 -69
  134. stubber/rst/rst_utils.py +541 -540
  135. stubber/stubber.py +38 -38
  136. stubber/stubs_from_docs.py +90 -90
  137. stubber/tools/manifestfile.py +654 -654
  138. stubber/tools/readme.md +6 -6
  139. stubber/update_fallback.py +117 -117
  140. stubber/update_module_list.py +123 -123
  141. stubber/utils/__init__.py +6 -6
  142. stubber/utils/config.py +137 -125
  143. stubber/utils/makeversionhdr.py +54 -54
  144. stubber/utils/manifest.py +90 -90
  145. stubber/utils/post.py +80 -79
  146. stubber/utils/repos.py +156 -150
  147. stubber/utils/stubmaker.py +139 -139
  148. stubber/utils/typed_config_toml.py +80 -77
  149. stubber/variants.py +106 -106
  150. micropython_stubber-1.23.1.dist-info/RECORD +0 -159
  151. micropython_stubber-1.23.1.dist-info/entry_points.txt +0 -3
  152. mpflash/basicgit.py +0 -288
  153. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/WHEEL +0 -0
mpflash/README.md CHANGED
@@ -1,194 +1,220 @@
1
- # MPFLASH
2
- [![pypi version](https://badgen.net/pypi/v/mpflash)](https://pypi.org/project/mpflash/)
3
- [![python versions](https://badgen.net/pypi/python/mpflash)](https://badgen.net/pypi/python/mpflash)
4
- [![Downloads](https://static.pepy.tech/badge/mpflash)](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
-
40
- ## Linux permissions to access usb devices
41
- In order to flash the firmware to the board, you need to have the correct permissions to access the USB devices.
42
- 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.
43
- [See the stm32_permissions documentation](./stm32_udev_rules.md) for more information.
44
-
45
-
46
- ## Detailed usage
47
- You can list the connected boards using the following command:
48
- ```bash
49
- $> mpflash list
50
- Connected boards
51
- ┏━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━┓
52
- Serial ┃Family ┃Port ┃Board ┃CPU ┃Version ┃build
53
- ┡━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━┩
54
- COM21 │micropython │rp2 │RPI_PICO │RP2040 │v1.23.0-preview │ 236 │
55
- │ │ │ │Raspberry Pi Pico with RP2040 │ │ │ │
56
- COM23 │micropython │rp2 │RPI_PICO_W │RP2040 │v1.23.0-preview │ 176
57
- │ │ │ │Raspberry Pi Pico W with RP2040 │ │ │ │
58
- │ COM9 │micropython │rp2 │ARDUINO_NANO_RP2040_CONNECT │RP2040 │v1.23.0-preview │ 341 │
59
- │ │ │ │Arduino Nano RP2040 Connect with RP2040 │ │ │ │
60
- └─────────┴─────────────┴──────┴───────────────────────────────────────────┴────────┴─────────────────┴──────┘
61
- ```
62
- ## Download the firmware
63
-
64
- To download the MicroPython firmware for some boards, use the following command:
65
- - `mpflash download` download the latest stable firmware for all connected boards
66
- - `mpflash download --version preview` download the current preview for all connected boards
67
- - `mpflash download --board ESP8266_GENERIC --board SEEED_WIO_TERMINAL` download these specific boards
68
- - `mpflash download --version ? --board ?` prompt to select a specific version and board to download
69
-
70
- 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.
71
- The stable version (default) is determined based on the most recent published release,
72
- other options are `--version stable`, `--version preview` and `--version x.y.z` to download the latest stable, preview or version x.y.z respectively.
73
-
74
- 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.
75
-
76
- The directory structure will be something like this:
77
-
78
- ``` text
79
- Downloads/firmware
80
- | firmware.jsonl
81
- +---esp8266
82
- | ESP8266_GENERIC-FLASH_1M-v1.22.2.bin
83
- | ESP8266_GENERIC-FLASH_512K-v1.22.2.bin
84
- | ESP8266_GENERIC-OTA-v1.22.2.bin
85
- | ESP8266_GENERIC-v1.22.2.bin
86
- \---samd
87
- SEEED_WIO_TERMINAL-v1.22.2.uf2
88
- ```
89
-
90
- ## Flashing the firmware
91
- After you have downloaded a firmware you can flash the firmware to a board using the following command: `mpflash flash`
92
- This will (try to) autodetect the connected boards, and determine the correct firmware to flash to each board.
93
-
94
- - `mpflash flash` will flash the latest stable firmware to all connected boards.
95
- If you have a board withouth a running micropython version, you will need to specify the board and the serial port to flash.
96
- - `mpflash flash --serial ? --board ?` will prompt to select a specific serial port and board to flash. (the firmware must be dowloaded earlier)
97
-
98
- 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.
99
- The supported `--bootloader` options are:
100
-
101
- - `touch1200` bootloader is activated by connecting to the board at 1200 baud
102
- - `mpy` using micropython to enter the bootloader
103
- - `manual` manual intervention is needed to enter the bootloader
104
- - `none` mpflash assumes the board is ready to flash
105
-
106
- For ESP32 and ESP8266 boards the `esptool` is used to flash the firmware, and this includes activating the bootloader.
107
-
108
- ### Flashing all connected boards with the latest stable firmware
109
- ```bash
110
- > mpflash flash
111
- 22:15:55 | ℹ️ - Using latest stable version: v1.22.2
112
- Connected boards
113
- ┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
114
- ┃ Serial ┃ Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
115
- ┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
116
- COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.20.0 │ │
117
- COM12 micropython esp8266 ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
118
- COM18 │ micropython rp2 │ RPI_PICO_W │ RP2040 │ 1.23.0-preview 155 │
119
- │ COM3 │ micropython │ samd │ SEEED_WIO_TERMINAL │ SAMD51P19A │ 1.23.0-preview │ 155 │
120
- COM5 │ micropython stm32 │ PYBV11 │ STM32F405RG 1.23.0-preview 166 │
121
- COM8 │ micropython esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview 155 │
122
- └────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
123
- 22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM11.
124
- 22:15:58 | ℹ️ - Found v1.22.2 firmware esp8266\ESP8266_GENERIC-v1.22.2.bin for ESP8266_GENERIC on COM12.
125
- 22:15:58 | ℹ️ - Found v1.22.2 firmware rp2\RPI_PICO_W-v1.22.2.uf2 for RPI_PICO_W on COM18.
126
- 22:15:58 | ℹ️ - Found v1.22.2 firmware samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 for SEEED_WIO_TERMINAL on COM3.
127
- 22:15:58 | ⚠️ - Trying to find a firmware for the board PYBV11
128
- 22:15:58 | ❌ - No v1.22.2 firmware found for PYBV11 on COM5.
129
- 22:15:58 | ⚠️ - Trying to find a firmware for the board ESP32-GENERIC-S3
130
- 22:15:58 | ❌ - No v1.22.2 firmware found for ESP32_GENERIC_S3 on COM8.
131
- 22:15:58 | ℹ️ - Updating RPI_PICO_W on COM11 to 1.22.2
132
- 22:15:58 | ℹ️ - Erasing not yet implemented for UF2 flashing.
133
- 22:15:58 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM11
134
- 22:15:58 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
135
- 22:15:59 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
136
- 22:16:00 | ℹ️ - Board is in bootloader mode
137
- 22:16:00 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:
138
- 22:16:13 | ✅ - Done copying, resetting the board and wait for it to restart
139
- 22:16:23 | ℹ️ - Updating ESP8266_GENERIC on COM12 to 1.22.2
140
- 22:16:23 | ℹ️ - Flashing firmware\esp8266\ESP8266_GENERIC-v1.22.2.bin on ESP8266_GENERIC on COM12
141
- 22:16:23 | ℹ️ - Running esptool --chip ESP8266 --port COM12 erase_flash
142
- esptool.py v4.7.0
143
- Serial port COM12
144
- Connecting....
145
- ...
146
- Chip erase completed successfully in 6.5s
147
- Hard resetting via RTS pin...
148
- 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
149
- esptool.py v4.7.0
150
- Serial port COM12
151
- Connecting....
152
- ...
153
- Leaving...
154
- Hard resetting via RTS pin...
155
- 22:16:43 | ℹ️ - Done flashing, resetting the board and wait for it to restart
156
- 22:16:49 | - Flashed 1.22.2 to ESP8266_GENERIC on COM12 done
157
- 22:16:49 | ℹ️ - Updating RPI_PICO_W on COM18 to 1.22.2
158
- 22:16:49 | ℹ️ - Erasing not yet implemented for UF2 flashing.
159
- 22:16:49 | ℹ️ - Entering UF2 bootloader on RPI_PICO_W on COM18
160
- 22:16:49 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
161
- 22:16:50 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
162
- 22:16:51 | ℹ️ - Board is in bootloader mode
163
- 22:16:51 | ℹ️ - Copying firmware\rp2\RPI_PICO_W-v1.22.2.uf2 to F:[/bold]
164
- 22:17:02 | ✅ - Done copying, resetting the board and wait for it to restart
165
- 22:17:12 | ℹ️ - Updating SEEED_WIO_TERMINAL on COM3 to 1.22.2
166
- 22:17:12 | ℹ️ - Erasing not yet implemented for UF2 flashing.
167
- 22:17:12 | ℹ️ - Entering UF2 bootloader on SEEED_WIO_TERMINAL on COM3
168
- 22:17:12 | ℹ️ - Waiting for mcu to mount as a drive : 10 seconds left
169
- 22:17:13 | ℹ️ - Waiting for mcu to mount as a drive : 9 seconds left
170
- 22:17:14 | ℹ️ - Board is in bootloader mode
171
- 22:17:14 | ℹ️ - Copying firmware\samd\SEEED_WIO_TERMINAL-v1.22.2.uf2 to F:[/bold]
172
- 22:17:17 | ✅ - Done copying, resetting the board and wait for it to restart
173
- 22:17:27 | ℹ️ - Flashed 4 boards
174
- Connected boards after flashing
175
- ┏━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┓
176
- Serial Family ┃ Port ┃ Board ┃ CPU ┃ Version ┃ build ┃
177
- ┡━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━┩
178
- │ COM11 │ micropython │ rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
179
- │ COM12 │ micropython │ esp8266 │ ESP8266_GENERIC │ ESP8266 │ 1.22.2 │ │
180
- COM18 │ micropython rp2 │ RPI_PICO_W │ RP2040 │ 1.22.2 │ │
181
- COM3 │ micropython samd │ SEEED_WIO_TERMINAL SAMD51P19A │ 1.22.2 │ │
182
- COM5 │ micropython stm32 │ PYBV11 │ STM32F405RG 1.23.0-preview │ 166 │
183
- COM8 │ micropython esp32 │ ESP32_GENERIC_S3 │ ESP32S3 │ 1.23.0-preview │ 155 │
184
- └────────┴─────────────┴─────────┴────────────────────┴─────────────┴────────────────┴───────┘
185
- ```
186
- Note that if no matching firmware can be found for a board, it will be skipped.
187
- (For example, the PYBV11 and ESP32_GENERIC_S3 boards in the example above.)
188
-
189
- ## Issues and bug reports
190
- mpflash is currently co-located in the [micropython-stubber](https://github.com/Josverl/micropython-stubber) repository.
191
- Please report any issues or bugs in the [issue tracker](https://github.com/Josverl/micropython-stubber/issues) using the MPflash feedback template.
192
-
193
- ## License
194
- mpflash is licensed under the MIT license. See the LICENSE file for more details.
1
+ # MPFLASH
2
+ [![pypi version](https://badgen.net/pypi/v/mpflash)](https://pypi.org/project/mpflash/)
3
+ [![python versions](https://badgen.net/pypi/python/mpflash)](https://badgen.net/pypi/python/mpflash)
4
+ [![Downloads](https://static.pepy.tech/badge/mpflash)](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.