mpflash 0.5.0__py3-none-any.whl → 0.6.0__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.
- mpflash/ask_input.py +94 -23
- mpflash/cli_download.py +31 -15
- mpflash/cli_flash.py +53 -113
- mpflash/cli_list.py +2 -60
- mpflash/cli_main.py +7 -3
- mpflash/common.py +2 -126
- mpflash/download.py +15 -3
- mpflash/downloaded.py +108 -0
- mpflash/errors.py +5 -0
- mpflash/flash.py +38 -133
- mpflash/flash_esp.py +10 -15
- mpflash/flash_stm32.py +1 -3
- mpflash/flash_stm32_cube.py +0 -1
- mpflash/flash_stm32_dfu.py +19 -5
- mpflash/list.py +72 -0
- mpflash/mpboard_id/{api.py → __init__.py} +23 -16
- mpflash/mpboard_id/board_id.py +40 -22
- mpflash/mpremoteboard/__init__.py +97 -27
- mpflash/mpremoteboard/runner.py +5 -1
- mpflash/vendor/versions.py +113 -0
- mpflash/worklist.py +147 -0
- {mpflash-0.5.0.dist-info → mpflash-0.6.0.dist-info}/METADATA +4 -4
- mpflash-0.6.0.dist-info/RECORD +40 -0
- mpflash-0.5.0.dist-info/RECORD +0 -35
- /mpflash/{vendored → vendor}/dfu.py +0 -0
- /mpflash/{vendored → vendor}/pydfu.py +0 -0
- /mpflash/{vendored → vendor}/readme.md +0 -0
- {mpflash-0.5.0.dist-info → mpflash-0.6.0.dist-info}/LICENSE +0 -0
- {mpflash-0.5.0.dist-info → mpflash-0.6.0.dist-info}/WHEEL +0 -0
- {mpflash-0.5.0.dist-info → mpflash-0.6.0.dist-info}/entry_points.txt +0 -0
mpflash/worklist.py
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Dict, List, Optional, Tuple
|
3
|
+
|
4
|
+
from loguru import logger as log
|
5
|
+
|
6
|
+
from mpflash.common import FWInfo
|
7
|
+
from mpflash.errors import MPFlashError
|
8
|
+
|
9
|
+
from .config import config
|
10
|
+
from .downloaded import find_downloaded_firmware
|
11
|
+
from .list import show_mcus
|
12
|
+
from .mpboard_id import find_stored_board
|
13
|
+
from .mpremoteboard import MPRemoteBoard
|
14
|
+
|
15
|
+
# #########################################################################################################
|
16
|
+
WorkList = List[Tuple[MPRemoteBoard, FWInfo]]
|
17
|
+
# #########################################################################################################
|
18
|
+
|
19
|
+
|
20
|
+
def auto_update(
|
21
|
+
conn_boards: List[MPRemoteBoard],
|
22
|
+
target_version: str,
|
23
|
+
fw_folder: Path,
|
24
|
+
*,
|
25
|
+
selector: Optional[Dict[str, str]] = None,
|
26
|
+
) -> WorkList:
|
27
|
+
"""Builds a list of boards to update based on the connected boards and the firmware available
|
28
|
+
|
29
|
+
Args:
|
30
|
+
conn_boards (List[MPRemoteBoard]): List of connected boards
|
31
|
+
target_version (str): Target firmware version
|
32
|
+
fw_folder (Path): Path to the firmware folder
|
33
|
+
selector (Optional[Dict[str, str]], optional): Selector for filtering firmware. Defaults to None.
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
WorkList: List of boards and firmware information to update
|
37
|
+
"""
|
38
|
+
if selector is None:
|
39
|
+
selector = {}
|
40
|
+
wl: WorkList = []
|
41
|
+
for mcu in conn_boards:
|
42
|
+
if mcu.family not in ("micropython", "unknown"):
|
43
|
+
log.warning(
|
44
|
+
f"Skipping flashing {mcu.family} {mcu.port} {mcu.board} on {mcu.serialport} as it is not a MicroPython firmware"
|
45
|
+
)
|
46
|
+
continue
|
47
|
+
board_firmwares = find_downloaded_firmware(
|
48
|
+
fw_folder=fw_folder,
|
49
|
+
board_id=mcu.board,
|
50
|
+
version=target_version,
|
51
|
+
port=mcu.port,
|
52
|
+
selector=selector,
|
53
|
+
)
|
54
|
+
|
55
|
+
if not board_firmwares:
|
56
|
+
log.error(f"No {target_version} firmware found for {mcu.board} on {mcu.serialport}.")
|
57
|
+
continue
|
58
|
+
if len(board_firmwares) > 1:
|
59
|
+
log.debug(f"Multiple {target_version} firmwares found for {mcu.board} on {mcu.serialport}.")
|
60
|
+
|
61
|
+
# just use the last firmware
|
62
|
+
fw_info = board_firmwares[-1]
|
63
|
+
log.info(f"Found {target_version} firmware {fw_info['filename']} for {mcu.board} on {mcu.serialport}.")
|
64
|
+
wl.append((mcu, fw_info))
|
65
|
+
return wl
|
66
|
+
|
67
|
+
|
68
|
+
def single_auto_worklist(
|
69
|
+
*,
|
70
|
+
serial_port: str,
|
71
|
+
version: str,
|
72
|
+
fw_folder: Path,
|
73
|
+
) -> WorkList:
|
74
|
+
"""Create a worklist for a single serial-port.
|
75
|
+
|
76
|
+
Args:
|
77
|
+
serial_port (str): Serial port of the board
|
78
|
+
version (str): Firmware version
|
79
|
+
fw_folder (Path): Path to the firmware folder
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
WorkList: List of boards and firmware information to update
|
83
|
+
"""
|
84
|
+
conn_boards = [MPRemoteBoard(serial_port)]
|
85
|
+
todo = auto_update(conn_boards, version, fw_folder) # type: ignore # List / list
|
86
|
+
show_mcus(conn_boards) # type: ignore
|
87
|
+
return todo
|
88
|
+
|
89
|
+
|
90
|
+
def full_auto_worklist(*, version: str, fw_folder: Path) -> WorkList:
|
91
|
+
"""
|
92
|
+
Create a worklist for all connected micropython boards based on the information retrieved from the board.
|
93
|
+
This allows the firmware version of one or moae boards to be changed without needing to specify the port or board_id manually.
|
94
|
+
|
95
|
+
Args:
|
96
|
+
version (str): Firmware version
|
97
|
+
fw_folder (Path): Path to the firmware folder
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
WorkList: List of boards and firmware information to update
|
101
|
+
"""
|
102
|
+
try:
|
103
|
+
conn_boards = [
|
104
|
+
MPRemoteBoard(sp, update=True) for sp in MPRemoteBoard.connected_boards() if sp not in config.ignore_ports
|
105
|
+
]
|
106
|
+
except ConnectionError as e:
|
107
|
+
log.error(f"Error connecting to boards: {e}")
|
108
|
+
return []
|
109
|
+
return auto_update(conn_boards, version, fw_folder) # type: ignore
|
110
|
+
|
111
|
+
|
112
|
+
def manual_worklist(
|
113
|
+
version: str,
|
114
|
+
fw_folder: Path,
|
115
|
+
serial_port: str,
|
116
|
+
board: str,
|
117
|
+
# port: str,
|
118
|
+
) -> WorkList:
|
119
|
+
"""Create a worklist for a single board specified manually.
|
120
|
+
|
121
|
+
Args:
|
122
|
+
version (str): Firmware version
|
123
|
+
fw_folder (Path): Path to the firmware folder
|
124
|
+
serial_port (str): Serial port of the board
|
125
|
+
board (str): Board name
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
WorkList: List of boards and firmware information to update
|
129
|
+
"""
|
130
|
+
mcu = MPRemoteBoard(serial_port)
|
131
|
+
# TODO : Find a way to avoid needing to specify the port
|
132
|
+
# Lookup the matching port and cpu in board_info based in the board name
|
133
|
+
try:
|
134
|
+
info = find_stored_board(board)
|
135
|
+
mcu.port = info["port"]
|
136
|
+
# need the CPU type for the esptool
|
137
|
+
mcu.cpu = info["cpu"]
|
138
|
+
except (LookupError, MPFlashError) as e:
|
139
|
+
log.error(f"Board {board} not found in board_info.json")
|
140
|
+
return []
|
141
|
+
mcu.board = board
|
142
|
+
firmwares = find_downloaded_firmware(fw_folder=fw_folder, board_id=board, version=version, port=mcu.port)
|
143
|
+
if not firmwares:
|
144
|
+
log.error(f"No firmware found for {mcu.port} {board} version {version}")
|
145
|
+
return []
|
146
|
+
# use the most recent matching firmware
|
147
|
+
return [(mcu, firmwares[-1])] # type: ignore
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mpflash
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.6.0
|
4
4
|
Summary: Flash and download tool for MicroPython firmwares
|
5
5
|
Home-page: https://github.com/Josverl/micropython-stubber/blob/main/src/mpflash/README.md
|
6
6
|
License: MIT
|
@@ -48,7 +48,7 @@ mpflash has been tested on Windows x64, Linux X64 and ARM64, but not (yet) macOS
|
|
48
48
|
1. List the connected boards including their firmware details, in a tabular or json format
|
49
49
|
2. Download MicroPython firmware for specific boards and versions.
|
50
50
|
3. Flash one or all connected MicroPython boards with a specific firmware or version.
|
51
|
-
Tested ports: rp2, samd, esp32, esp32s3, esp8266 and stm32
|
51
|
+
Tested ports: rp2, samd, esp32, esp32s3, esp8266 and stm32
|
52
52
|
|
53
53
|
## Installation
|
54
54
|
To install mpflash, you can use pip: `pip install mpflash`
|
@@ -63,10 +63,10 @@ You can use mpflash to perform various operations on your MicroPython boards. He
|
|
63
63
|
| `mpflash flash` | Flash the latest stable firmware to the connected board(s) |
|
64
64
|
|
65
65
|
|
66
|
-
## Linux permissions
|
66
|
+
## Linux permissions to access usb devices
|
67
67
|
In order to flash the firmware to the board, you need to have the correct permissions to access the USB devices.
|
68
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
|
69
|
+
[See the stm32_permissions documentation](./stm32_udev_rules.md) for more information.
|
70
70
|
|
71
71
|
|
72
72
|
## Advanced use
|
@@ -0,0 +1,40 @@
|
|
1
|
+
mpflash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
mpflash/ask_input.py,sha256=NGjCcOx49gW8xuDZK1BQXNOMPy7fUQ5pQamasez1wHI,7793
|
3
|
+
mpflash/cli_download.py,sha256=9Rxwo-j7h9_rwMeAgITmfkdiNVi-Wunr1vpx2VjjUNM,3090
|
4
|
+
mpflash/cli_flash.py,sha256=bp2AXHYqusVQbIOt12gqkbC4OoVMVV2gsY1fI-Js63M,5482
|
5
|
+
mpflash/cli_group.py,sha256=hdyFrxkA_ye5r5bAsOnPr99KV2pfzgDoNXGPjTvEpW0,1946
|
6
|
+
mpflash/cli_list.py,sha256=uxTRPdjFWv5ev4E_pz1JYv8DSFLOtZvTKmVmCiRpEC4,1005
|
7
|
+
mpflash/cli_main.py,sha256=VxIpmvk3-2Sr1uB1AMT5bRa0TlrbY28ZaYd6NGZnEe0,632
|
8
|
+
mpflash/common.py,sha256=lucFGMLl03qz-5Ic2XVv4g5XVt6hloUU6N5v0tSaUYE,1049
|
9
|
+
mpflash/config.py,sha256=G6TxliEGxoYXy1SHQYBKgywnKccz9QzD3mGq_Vv1frg,419
|
10
|
+
mpflash/download.py,sha256=HhL97PFTts_QhI1121QcWS7Z2nbfqvJ7mof_KFARx6k,10765
|
11
|
+
mpflash/downloaded.py,sha256=ADMJqZn7WVcU-Rm2X6RqA8ejtBNBYXcpwxVyT3v7r6s,3803
|
12
|
+
mpflash/errors.py,sha256=Q5LR12Wo8iUCg5n_qq4GjdBdBflbvCOdKsRJ5InYRfI,96
|
13
|
+
mpflash/flash.py,sha256=YGYXuNNbjro4QvZmpwpLCo86nFsh4UxWrOJHOowUYDY,2490
|
14
|
+
mpflash/flash_esp.py,sha256=TjBOk2y1eLrcE8T3iYGypsiskPX7BFNfxYmCuUo_3v4,2316
|
15
|
+
mpflash/flash_stm32.py,sha256=d4BoQl3a9Tchnvn2ZTuq2MpYBB4MTaRukwtEncI95k0,823
|
16
|
+
mpflash/flash_stm32_cube.py,sha256=w7aGWjReeWUKl0Q3ZjXH8BRqNO1Tk9AO7gtRNUg1c9Y,3970
|
17
|
+
mpflash/flash_stm32_dfu.py,sha256=G70EZodWb-aRi507Jxbys-VEwbBGU1oZacow3_nq-d4,2972
|
18
|
+
mpflash/flash_uf2.py,sha256=nTbp8MbSZeNVPWPPsQxN1ppTtBGESXMfwZ_qL4Bwkv0,2029
|
19
|
+
mpflash/flash_uf2_boardid.py,sha256=WZKucGu_hJ8ymb236uuZbiR6pD6AA_l4LA-7LwtQhq8,414
|
20
|
+
mpflash/flash_uf2_linux.py,sha256=LAGkzTImVq-wKo7LGUNlwkUHv1L4rGO7igR5dwxY07o,4298
|
21
|
+
mpflash/flash_uf2_windows.py,sha256=dcmA-koavH7duOuNwI0n2aDDbhF1_5ZZ-mXFAXgj8z4,1072
|
22
|
+
mpflash/list.py,sha256=7-yW_J-TDGMvRrRfz7clJseiMy4uEgcwyhOaiw5fj1w,2248
|
23
|
+
mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
|
24
|
+
mpflash/mpboard_id/__init__.py,sha256=JYGe7VwpBV4ig2M9a6vJUQrMtgdNjZKHt_Z5N13Ycrs,3509
|
25
|
+
mpflash/mpboard_id/board_id.py,sha256=NjKkIUv3sw6X60qy--mieQWrle3WNKw5NwAepMenTHI,2230
|
26
|
+
mpflash/mpboard_id/board_info.csv,sha256=KPWDo-zHWfrPGQn9oInsDH-5IdCzhBCs6K_YAmqqSpQ,96983
|
27
|
+
mpflash/mpboard_id/board_info.json,sha256=JtVyOMIO1O7vLKzJ0hyXQ4JSxXiQBJyay2hjdNLnZM0,674442
|
28
|
+
mpflash/mpremoteboard/__init__.py,sha256=NSp71Qynz3hYqLLy0foVqdkURbNxfjUjiQBmaxKFF64,6951
|
29
|
+
mpflash/mpremoteboard/mpy_fw_info.py,sha256=6AQbN3jtQgllqWQYl4e-63KeEtV08EXk8_JnM6XBkvo,4554
|
30
|
+
mpflash/mpremoteboard/runner.py,sha256=H3W_xGJvjz7TLtlkDQrCLibgegRWGfsaBOABNbAfP_U,4783
|
31
|
+
mpflash/vendor/dfu.py,sha256=oK_MRSOyDJrUuS6D24IMIsfL7oLcrvUq0yp_h4WIY2U,5739
|
32
|
+
mpflash/vendor/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
|
33
|
+
mpflash/vendor/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
|
34
|
+
mpflash/vendor/versions.py,sha256=ooRZjeeYepQHwp12hMu2m0p8nZXQ5s942w5mGkKmgeI,3629
|
35
|
+
mpflash/worklist.py,sha256=TGVFugEyWn83WKr0wahBBimcfsHMWGo8_QTu4g3ao-0,5266
|
36
|
+
mpflash-0.6.0.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
|
37
|
+
mpflash-0.6.0.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
|
38
|
+
mpflash-0.6.0.dist-info/METADATA,sha256=wlr-kNnhL5NmvIbM9LIquNRymrf_sPsLcv7MQYx0-Ic,13778
|
39
|
+
mpflash-0.6.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
40
|
+
mpflash-0.6.0.dist-info/RECORD,,
|
mpflash-0.5.0.dist-info/RECORD
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
mpflash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
mpflash/ask_input.py,sha256=ZVTh_OO9K3y1YYSzZ-xMg1RA2feGI5S3M_FdWJitTis,5248
|
3
|
-
mpflash/cli_download.py,sha256=JDsSfpsx84eGIwXwBD2va1FkpzT8dfmf-zjyQu1OOec,2446
|
4
|
-
mpflash/cli_flash.py,sha256=gqubLsKM39m7F6RxIuyYFWRE1DWWjxxeojeTFNoGZ5A,7341
|
5
|
-
mpflash/cli_group.py,sha256=hdyFrxkA_ye5r5bAsOnPr99KV2pfzgDoNXGPjTvEpW0,1946
|
6
|
-
mpflash/cli_list.py,sha256=3xYHiWrDJfuXZ5JWcOg84U0NqrZ76SOZmprAO3Ijmug,2832
|
7
|
-
mpflash/cli_main.py,sha256=82SfeyqyZLgypW8stiiy4ufIMIpolAt8-ko0p8ZIlWA,529
|
8
|
-
mpflash/common.py,sha256=w06KZID4klKKrKPmgOE0LbiPix_lQ5ICGWc3LR-qrGU,5066
|
9
|
-
mpflash/config.py,sha256=G6TxliEGxoYXy1SHQYBKgywnKccz9QzD3mGq_Vv1frg,419
|
10
|
-
mpflash/download.py,sha256=rRMA9J3Nee-8RCQFukjbfgxeEJZhSE8DAMFO0Kh3DbI,10357
|
11
|
-
mpflash/flash.py,sha256=_RUnQX7o1EUu9Xd9pqnjM5K1K7PwfC1QqiR9eQvwmvk,5692
|
12
|
-
mpflash/flash_esp.py,sha256=TeGaKTIBD9NoE_VpRreLW_32XeRW6UYKBJf0DH1WCWo,2396
|
13
|
-
mpflash/flash_stm32.py,sha256=NszC1p256sy3OgpDx1v3CXKVGDaC1H5YAVzlnG6B12o,869
|
14
|
-
mpflash/flash_stm32_cube.py,sha256=GUzlcteZRkANO6j7KrHb-QqRX7SyDAph07McR2vE4bs,4010
|
15
|
-
mpflash/flash_stm32_dfu.py,sha256=GXk_dh5l1RreAmv8GdzRsKumm3t8RdYH1NXOmOMyFfA,2509
|
16
|
-
mpflash/flash_uf2.py,sha256=nTbp8MbSZeNVPWPPsQxN1ppTtBGESXMfwZ_qL4Bwkv0,2029
|
17
|
-
mpflash/flash_uf2_boardid.py,sha256=WZKucGu_hJ8ymb236uuZbiR6pD6AA_l4LA-7LwtQhq8,414
|
18
|
-
mpflash/flash_uf2_linux.py,sha256=LAGkzTImVq-wKo7LGUNlwkUHv1L4rGO7igR5dwxY07o,4298
|
19
|
-
mpflash/flash_uf2_windows.py,sha256=dcmA-koavH7duOuNwI0n2aDDbhF1_5ZZ-mXFAXgj8z4,1072
|
20
|
-
mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
|
21
|
-
mpflash/mpboard_id/api.py,sha256=m356OarUEG1kD4fAh68CJzhM-dLRTD4Lfr52IRi7jZA,3143
|
22
|
-
mpflash/mpboard_id/board_id.py,sha256=y_vdTrU0BAlkyXKpm4J6iRG9KnLIAcDAxYY6dXRma6w,1778
|
23
|
-
mpflash/mpboard_id/board_info.csv,sha256=KPWDo-zHWfrPGQn9oInsDH-5IdCzhBCs6K_YAmqqSpQ,96983
|
24
|
-
mpflash/mpboard_id/board_info.json,sha256=JtVyOMIO1O7vLKzJ0hyXQ4JSxXiQBJyay2hjdNLnZM0,674442
|
25
|
-
mpflash/mpremoteboard/__init__.py,sha256=JpFwECSiH_oxEnAkLayK9z8Jffwj0sshqbiK6lhF7pk,4726
|
26
|
-
mpflash/mpremoteboard/mpy_fw_info.py,sha256=6AQbN3jtQgllqWQYl4e-63KeEtV08EXk8_JnM6XBkvo,4554
|
27
|
-
mpflash/mpremoteboard/runner.py,sha256=G0LLqVS9ngB2y2pZoDvZK5d03RrK7gPo9Lo9dzq5NZA,4583
|
28
|
-
mpflash/vendored/dfu.py,sha256=oK_MRSOyDJrUuS6D24IMIsfL7oLcrvUq0yp_h4WIY2U,5739
|
29
|
-
mpflash/vendored/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
|
30
|
-
mpflash/vendored/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
|
31
|
-
mpflash-0.5.0.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
|
32
|
-
mpflash-0.5.0.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
|
33
|
-
mpflash-0.5.0.dist-info/METADATA,sha256=_cujxzCg9wH2GBmVtNKWS2faSnvMBS5XnAVdRU4n7SY,13797
|
34
|
-
mpflash-0.5.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
35
|
-
mpflash-0.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|