micropython-stubber 1.23.0__py3-none-any.whl → 1.23.1__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.
- {micropython_stubber-1.23.0.dist-info → micropython_stubber-1.23.1.dist-info}/METADATA +4 -3
- {micropython_stubber-1.23.0.dist-info → micropython_stubber-1.23.1.dist-info}/RECORD +80 -80
- mpflash/README.md +14 -4
- mpflash/mpflash/add_firmware.py +1 -1
- mpflash/mpflash/ask_input.py +1 -1
- {stubber → mpflash/mpflash}/basicgit.py +3 -13
- mpflash/mpflash/bootloader/__init__.py +2 -37
- mpflash/mpflash/bootloader/activate.py +60 -0
- mpflash/mpflash/bootloader/detect.py +82 -0
- mpflash/mpflash/bootloader/manual.py +10 -11
- mpflash/mpflash/bootloader/micropython.py +2 -0
- mpflash/mpflash/bootloader/touch1200.py +13 -22
- mpflash/mpflash/cli_download.py +1 -1
- mpflash/mpflash/cli_flash.py +3 -3
- mpflash/mpflash/cli_group.py +18 -5
- mpflash/mpflash/cli_main.py +3 -5
- mpflash/mpflash/common.py +1 -0
- mpflash/mpflash/config.py +2 -1
- mpflash/mpflash/connected.py +9 -5
- mpflash/mpflash/download.py +9 -5
- mpflash/mpflash/downloaded.py +1 -1
- mpflash/mpflash/{flash.py → flash/__init__.py} +3 -3
- mpflash/mpflash/{flash_esp.py → flash/esp.py} +1 -1
- mpflash/mpflash/{flash_stm32.py → flash/stm32.py} +4 -3
- mpflash/mpflash/{flash_stm32_dfu.py → flash/stm32_dfu.py} +1 -1
- mpflash/mpflash/{flash_uf2.py → flash/uf2/__init__.py} +19 -20
- mpflash/mpflash/{flash_uf2_linux.py → flash/uf2/linux.py} +12 -11
- mpflash/mpflash/{flash_uf2_macos.py → flash/uf2/macos.py} +11 -6
- mpflash/mpflash/{flash_uf2_windows.py → flash/uf2/windows.py} +11 -6
- mpflash/mpflash/{worklist.py → flash/worklist.py} +8 -9
- mpflash/mpflash/list.py +13 -3
- mpflash/mpflash/mpboard_id/__init__.py +1 -1
- mpflash/mpflash/mpboard_id/add_boards.py +3 -7
- mpflash/mpflash/mpboard_id/board_id.py +1 -1
- mpflash/mpflash/mpremoteboard/__init__.py +7 -11
- {stubber/utils → mpflash/mpflash}/versions.py +31 -24
- mpflash/poetry.lock +16 -5
- mpflash/pyproject.toml +4 -3
- stubber/__init__.py +1 -1
- stubber/board/createstubs.py +4 -4
- stubber/board/createstubs_db.py +5 -5
- stubber/board/createstubs_db_min.py +1 -1
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +5 -5
- stubber/board/createstubs_mem_min.py +1 -1
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +1 -1
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/codemod/utils.py +2 -3
- stubber/commands/cli.py +1 -1
- stubber/commands/clone_cmd.py +2 -1
- stubber/commands/get_docstubs_cmd.py +1 -1
- stubber/commands/get_frozen_cmd.py +1 -1
- stubber/commands/get_mcu_cmd.py +1 -1
- stubber/commands/merge_cmd.py +1 -2
- stubber/commands/publish_cmd.py +1 -2
- stubber/commands/switch_cmd.py +2 -2
- stubber/commands/variants_cmd.py +1 -2
- stubber/freeze/get_frozen.py +1 -1
- stubber/minify.py +4 -3
- stubber/publish/candidates.py +4 -10
- stubber/publish/defaults.py +4 -9
- stubber/publish/missing_class_methods.py +1 -1
- stubber/publish/package.py +1 -1
- stubber/publish/pathnames.py +1 -1
- stubber/publish/publish.py +1 -1
- stubber/publish/stubpackage.py +3 -5
- stubber/rst/reader.py +5 -13
- stubber/tools/manifestfile.py +0 -1
- stubber/update_fallback.py +1 -1
- stubber/utils/__init__.py +2 -1
- stubber/utils/config.py +3 -5
- stubber/utils/manifest.py +2 -4
- stubber/utils/repos.py +5 -12
- mpflash/mpflash/flash_stm32_cube.py +0 -111
- mpflash/mpflash/vendor/versions.py +0 -119
- {micropython_stubber-1.23.0.dist-info → micropython_stubber-1.23.1.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.23.0.dist-info → micropython_stubber-1.23.1.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.23.0.dist-info → micropython_stubber-1.23.1.dist-info}/entry_points.txt +0 -0
- /mpflash/{mpflash/vendor/basicgit.py → basicgit.py} +0 -0
- /mpflash/mpflash/{flash_uf2_boardid.py → flash/uf2/boardid.py} +0 -0
- /mpflash/mpflash/{uf2disk.py → flash/uf2/uf2disk.py} +0 -0
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
"""
|
2
|
+
Enter bootloader using Touch 1200Bd for boards with bootloaders that support this.
|
3
|
+
|
4
|
+
"""
|
5
|
+
|
2
6
|
import time
|
3
7
|
|
4
8
|
import serial
|
@@ -7,32 +11,19 @@ from mpflash.errors import MPFlashError
|
|
7
11
|
from mpflash.logger import log
|
8
12
|
from mpflash.mpremoteboard import MPRemoteBoard
|
9
13
|
|
10
|
-
from .manual import enter_bootloader_manual
|
11
|
-
|
12
14
|
|
13
|
-
def
|
14
|
-
if sys.platform == "win32":
|
15
|
-
log.warning("Touch 1200bps method is currently not supported on Windows, switching to manual")
|
16
|
-
return enter_bootloader_manual(mcu, timeout=timeout)
|
17
|
-
|
18
|
-
log.info(f"Entering bootloader on {mcu.board} on {mcu.serialport} using CDC 1200bps")
|
19
|
-
# if port argument is present perform soft reset
|
15
|
+
def enter_bootloader_touch_1200bps(mcu: MPRemoteBoard, timeout: int = 10):
|
20
16
|
if not mcu.serialport:
|
21
17
|
raise MPFlashError("No serial port specified")
|
18
|
+
log.info(f"Attempting bootloader on {mcu.serialport} using 'Touch 1200Bd'")
|
19
|
+
# if port argument is present perform soft reset
|
22
20
|
# try to initiate serial port connection on PORT with 1200 baudrate
|
23
21
|
try:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
bytesize=serial.EIGHTBITS,
|
30
|
-
rtscts=True,
|
31
|
-
) as connection:
|
32
|
-
print("Connection established")
|
33
|
-
connection.rts = True
|
34
|
-
connection.dtr = False
|
35
|
-
time.sleep(0.4)
|
22
|
+
com = serial.Serial(mcu.serialport, 1200, dsrdtr=True)
|
23
|
+
com.rts = False # required
|
24
|
+
com.dtr = False # might as well
|
25
|
+
time.sleep(0.2)
|
26
|
+
com.close()
|
36
27
|
|
37
28
|
except serial.SerialException as e:
|
38
29
|
log.exception(e)
|
mpflash/mpflash/cli_download.py
CHANGED
@@ -8,7 +8,7 @@ from loguru import logger as log
|
|
8
8
|
from mpflash.connected import connected_ports_boards
|
9
9
|
from mpflash.errors import MPFlashError
|
10
10
|
from mpflash.mpboard_id import find_known_board
|
11
|
-
from mpflash.
|
11
|
+
from mpflash.versions import clean_version
|
12
12
|
|
13
13
|
from .ask_input import ask_missing_params
|
14
14
|
from .cli_group import cli
|
mpflash/mpflash/cli_flash.py
CHANGED
@@ -8,7 +8,7 @@ from mpflash.common import BootloaderMethod
|
|
8
8
|
from mpflash.errors import MPFlashError
|
9
9
|
from mpflash.mpboard_id import find_known_board
|
10
10
|
from mpflash.mpremoteboard import MPRemoteBoard
|
11
|
-
from mpflash.
|
11
|
+
from mpflash.versions import clean_version
|
12
12
|
|
13
13
|
from .ask_input import ask_missing_params
|
14
14
|
from .cli_download import connected_ports_boards
|
@@ -17,7 +17,7 @@ from .cli_list import show_mcus
|
|
17
17
|
from .common import FlashParams
|
18
18
|
from .config import config
|
19
19
|
from .flash import flash_list
|
20
|
-
from .worklist import (WorkList, full_auto_worklist, manual_worklist,
|
20
|
+
from .flash.worklist import (WorkList, full_auto_worklist, manual_worklist,
|
21
21
|
single_auto_worklist)
|
22
22
|
|
23
23
|
# #########################################################################################################
|
@@ -106,7 +106,7 @@ from .worklist import (WorkList, full_auto_worklist, manual_worklist,
|
|
106
106
|
"-bl",
|
107
107
|
"bootloader",
|
108
108
|
type=click.Choice([e.value for e in BootloaderMethod]),
|
109
|
-
default="
|
109
|
+
default="auto",
|
110
110
|
show_default=True,
|
111
111
|
help="""How to enter the (MicroPython) bootloader before flashing.""",
|
112
112
|
)
|
mpflash/mpflash/cli_group.py
CHANGED
@@ -27,7 +27,7 @@ def cb_verbose(ctx, param, value):
|
|
27
27
|
return value
|
28
28
|
|
29
29
|
|
30
|
-
def cb_interactive(ctx, param, value:bool):
|
30
|
+
def cb_interactive(ctx, param, value: bool):
|
31
31
|
log.trace(f"Setting interactive mode to {value}")
|
32
32
|
config.interactive = value
|
33
33
|
return value
|
@@ -39,6 +39,10 @@ def cb_test(ctx, param, value):
|
|
39
39
|
config.tests = value
|
40
40
|
return value
|
41
41
|
|
42
|
+
def cb_usb(ctx, param, value: bool):
|
43
|
+
config.usb = bool(value)
|
44
|
+
return value
|
45
|
+
|
42
46
|
|
43
47
|
def cb_quiet(ctx, param, value):
|
44
48
|
log.trace(f"Setting quiet mode to {value}")
|
@@ -78,19 +82,28 @@ def cb_quiet(ctx, param, value):
|
|
78
82
|
help="Enables verbose mode.",
|
79
83
|
callback=cb_verbose,
|
80
84
|
)
|
85
|
+
@click.option(
|
86
|
+
"--usb",
|
87
|
+
"-u",
|
88
|
+
is_eager=True,
|
89
|
+
is_flag=True,
|
90
|
+
default=False,
|
91
|
+
help="Shows USB location of the connected boards.",
|
92
|
+
callback=cb_usb,
|
93
|
+
show_default=True,
|
94
|
+
)
|
81
95
|
@click.option(
|
82
96
|
"--test",
|
83
97
|
is_eager=True,
|
84
|
-
help="
|
98
|
+
help="Test a specific feature.",
|
85
99
|
callback=cb_test,
|
86
100
|
multiple=True,
|
87
101
|
default=[],
|
88
102
|
envvar="MPFLASH_TEST",
|
89
|
-
|
90
|
-
metavar="TEST",
|
103
|
+
metavar="FLAG",
|
91
104
|
)
|
92
105
|
def cli(**kwargs):
|
93
|
-
"""mpflash - MicroPython
|
106
|
+
"""mpflash - MicroPython flashing tool.
|
94
107
|
|
95
108
|
A CLI to download and flash MicroPython firmware to different ports and boards.
|
96
109
|
"""
|
mpflash/mpflash/cli_main.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
"""mpflash is a CLI to download and flash MicroPython firmware to various boards."""
|
2
2
|
|
3
|
-
# import rich_click as click
|
4
|
-
|
5
3
|
import os
|
6
4
|
|
7
|
-
import
|
5
|
+
import click.exceptions as click_exceptions
|
8
6
|
from loguru import logger as log
|
9
7
|
|
10
8
|
from .cli_download import cli_download
|
@@ -29,10 +27,10 @@ def mpflash():
|
|
29
27
|
except AttributeError as e:
|
30
28
|
log.error(f"Error: {e}")
|
31
29
|
exit(-1)
|
32
|
-
except
|
30
|
+
except click_exceptions.ClickException as e:
|
33
31
|
log.error(f"Error: {e}")
|
34
32
|
exit(-2)
|
35
|
-
except
|
33
|
+
except click_exceptions.Abort as e:
|
36
34
|
# Aborted - Ctrl-C
|
37
35
|
exit(-3)
|
38
36
|
|
mpflash/mpflash/common.py
CHANGED
mpflash/mpflash/config.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
"""centralized configuration for mpflash"""
|
2
2
|
|
3
3
|
import os
|
4
|
+
from importlib.metadata import version
|
4
5
|
from pathlib import Path
|
5
6
|
from typing import List
|
6
7
|
|
7
8
|
import platformdirs
|
8
|
-
from importlib.metadata import version
|
9
9
|
|
10
10
|
from mpflash.logger import log
|
11
11
|
|
@@ -20,6 +20,7 @@ class MPtoolConfig:
|
|
20
20
|
|
21
21
|
quiet: bool = False
|
22
22
|
verbose: bool = False
|
23
|
+
usb: bool = False
|
23
24
|
ignore_ports: List[str] = []
|
24
25
|
firmware_folder: Path = platformdirs.user_downloads_path() / "firmware"
|
25
26
|
# test options specified on the commandline
|
mpflash/mpflash/connected.py
CHANGED
@@ -9,9 +9,7 @@ from mpflash.mpremoteboard import MPRemoteBoard
|
|
9
9
|
from .common import filtered_comports
|
10
10
|
|
11
11
|
|
12
|
-
def connected_ports_boards(
|
13
|
-
*, include: List[str], ignore: List[str]
|
14
|
-
) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
|
12
|
+
def connected_ports_boards(*, include: List[str], ignore: List[str]) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
|
15
13
|
"""
|
16
14
|
Returns a tuple containing lists of unique ports and boards from the connected MCUs.
|
17
15
|
Boards that are physically connected, but give no tangible response are ignored.
|
@@ -50,11 +48,17 @@ def list_mcus(*, ignore: List[str], include: List[str], bluetooth: bool = False)
|
|
50
48
|
include=include,
|
51
49
|
bluetooth=bluetooth,
|
52
50
|
)
|
53
|
-
conn_mcus = [MPRemoteBoard(c.device) for c in comports]
|
51
|
+
conn_mcus = [MPRemoteBoard(c.device, location=c.location or "?") for c in comports]
|
54
52
|
|
55
53
|
# a lot of boilerplate to show a progress bar with the comport currently scanned
|
56
54
|
# low update rate to facilitate screen readers/narration
|
57
|
-
with Progress(
|
55
|
+
with Progress(
|
56
|
+
rp_spinner,
|
57
|
+
rp_text,
|
58
|
+
rp_bar,
|
59
|
+
TimeElapsedColumn(),
|
60
|
+
refresh_per_second=1,
|
61
|
+
) as progress:
|
58
62
|
tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
|
59
63
|
progress.tasks[tsk_scan].fields["device"] = "..."
|
60
64
|
progress.tasks[tsk_scan].visible = True
|
mpflash/mpflash/download.py
CHANGED
@@ -21,7 +21,7 @@ from rich.progress import track
|
|
21
21
|
from mpflash.common import PORT_FWTYPES, FWInfo
|
22
22
|
from mpflash.errors import MPFlashError
|
23
23
|
from mpflash.mpboard_id import get_known_ports
|
24
|
-
from mpflash.
|
24
|
+
from mpflash.versions import clean_version
|
25
25
|
|
26
26
|
# avoid conflict with the ujson used by MicroPython
|
27
27
|
jsonlines.ujson = None # type: ignore
|
@@ -134,7 +134,13 @@ def get_boards(ports: List[str], boards: List[str], clean: bool) -> List[FWInfo]
|
|
134
134
|
for board in urls:
|
135
135
|
board["port"] = port
|
136
136
|
|
137
|
-
for board in track(
|
137
|
+
for board in track(
|
138
|
+
urls,
|
139
|
+
description=f"Checking {port} download pages",
|
140
|
+
transient=True,
|
141
|
+
refresh_per_second=1,
|
142
|
+
show_speed=False,
|
143
|
+
):
|
138
144
|
# add a board to the list for each firmware found
|
139
145
|
firmware_urls: List[str] = []
|
140
146
|
for ext in PORT_FWTYPES[port]:
|
@@ -273,9 +279,7 @@ def get_firmware_list(ports: List[str], boards: List[str], versions: List[str],
|
|
273
279
|
log.debug(f"Total {len(board_urls)} firmwares")
|
274
280
|
|
275
281
|
relevant = [
|
276
|
-
board
|
277
|
-
for board in board_urls
|
278
|
-
if board.version in versions and board.build == "0" and board.board in boards and not board.preview
|
282
|
+
board for board in board_urls if board.version in versions and board.build == "0" and board.board in boards and not board.preview
|
279
283
|
]
|
280
284
|
|
281
285
|
if preview:
|
mpflash/mpflash/downloaded.py
CHANGED
@@ -5,9 +5,9 @@ from loguru import logger as log
|
|
5
5
|
from mpflash.bootloader import enter_bootloader
|
6
6
|
from mpflash.common import PORT_FWTYPES, BootloaderMethod
|
7
7
|
|
8
|
-
from .
|
9
|
-
from .
|
10
|
-
from .
|
8
|
+
from .esp import flash_esp
|
9
|
+
from .stm32 import flash_stm32
|
10
|
+
from .uf2 import flash_uf2
|
11
11
|
from .worklist import WorkList
|
12
12
|
|
13
13
|
# #########################################################################################################
|
@@ -53,7 +53,7 @@ def flash_esp(mcu: MPRemoteBoard, fw_file: Path, *, erase: bool = True) -> Optio
|
|
53
53
|
log.error(f"Failed to flash {mcu.board} on {mcu.serialport} : {e}")
|
54
54
|
return None
|
55
55
|
|
56
|
-
log.info("Done flashing, resetting the board
|
56
|
+
log.info("Done flashing, resetting the board...")
|
57
57
|
mcu.wait_for_restart()
|
58
58
|
log.success(f"Flashed {mcu.serialport} to {mcu.board} {mcu.version}")
|
59
59
|
return mcu
|
@@ -4,12 +4,13 @@ from pathlib import Path
|
|
4
4
|
|
5
5
|
from loguru import logger as log
|
6
6
|
|
7
|
-
# from .flash_stm32_cube import flash_stm32_cubecli
|
8
|
-
from .flash_stm32_dfu import dfu_init, flash_stm32_dfu
|
9
7
|
from mpflash.mpremoteboard import MPRemoteBoard
|
10
8
|
|
9
|
+
# from .flash_stm32_cube import flash_stm32_cubecli
|
10
|
+
from .stm32_dfu import dfu_init, flash_stm32_dfu
|
11
|
+
|
11
12
|
|
12
|
-
def flash_stm32(mcu: MPRemoteBoard, fw_file: Path, *, erase: bool
|
13
|
+
def flash_stm32(mcu: MPRemoteBoard, fw_file: Path, *, erase: bool):
|
13
14
|
# sourcery skip: lift-return-into-if
|
14
15
|
dfu_init()
|
15
16
|
if updated := flash_stm32_dfu(mcu, fw_file=fw_file, erase=erase):
|
@@ -4,22 +4,21 @@ Flash SAMD and RP2 via UF2
|
|
4
4
|
|
5
5
|
import shutil
|
6
6
|
import sys
|
7
|
-
import time
|
8
7
|
from pathlib import Path
|
9
8
|
from typing import Optional
|
10
9
|
|
10
|
+
import tenacity
|
11
11
|
from loguru import logger as log
|
12
|
-
from rich.progress import track
|
13
12
|
|
14
|
-
from mpflash.mpremoteboard import MPRemoteBoard
|
15
|
-
import tenacity
|
16
13
|
from tenacity import stop_after_attempt, wait_fixed
|
17
14
|
|
18
|
-
from .
|
19
|
-
|
20
|
-
from .
|
21
|
-
from .
|
22
|
-
from .
|
15
|
+
from mpflash.mpremoteboard import MPRemoteBoard
|
16
|
+
|
17
|
+
from mpflash.common import PORT_FWTYPES
|
18
|
+
from .boardid import get_board_id
|
19
|
+
from .linux import dismount_uf2_linux, wait_for_UF2_linux
|
20
|
+
from .macos import wait_for_UF2_macos
|
21
|
+
from .windows import wait_for_UF2_windows
|
23
22
|
|
24
23
|
|
25
24
|
def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemoteBoard]:
|
@@ -39,7 +38,9 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
|
|
39
38
|
log.error(f"UF2 not supported on {mcu.board} on {mcu.serialport}")
|
40
39
|
return None
|
41
40
|
if erase:
|
42
|
-
|
41
|
+
log.warning("Erase not (yet) supported on .UF2, skipping erase.")
|
42
|
+
|
43
|
+
destination = waitfor_uf2(board_id=mcu.port.upper())
|
43
44
|
|
44
45
|
if not destination or not destination.exists() or not (destination / "INFO_UF2.TXT").exists():
|
45
46
|
log.error("Board is not in bootloader mode")
|
@@ -49,8 +50,8 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
|
|
49
50
|
board_id = get_board_id(destination) # type: ignore
|
50
51
|
log.info(f"Board ID: {board_id}")
|
51
52
|
try:
|
52
|
-
|
53
|
-
log.success("Done copying, resetting the board
|
53
|
+
copy_firmware_to_uf2(fw_file, destination)
|
54
|
+
log.success("Done copying, resetting the board.")
|
54
55
|
except tenacity.RetryError:
|
55
56
|
log.error("Failed to copy the firmware file to the board.")
|
56
57
|
return None
|
@@ -59,31 +60,29 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
|
|
59
60
|
dismount_uf2_linux()
|
60
61
|
|
61
62
|
mcu.wait_for_restart()
|
62
|
-
# time.sleep(1) # 5 secs to short on linux
|
63
63
|
return mcu
|
64
64
|
|
65
65
|
|
66
|
-
def waitfor_uf2():
|
66
|
+
def waitfor_uf2(board_id: str):
|
67
67
|
"""
|
68
68
|
Wait for the UF2 drive to mount
|
69
69
|
"""
|
70
70
|
if sys.platform == "linux":
|
71
|
-
return wait_for_UF2_linux()
|
71
|
+
return wait_for_UF2_linux(board_id=board_id)
|
72
72
|
elif sys.platform == "win32":
|
73
|
-
return wait_for_UF2_windows()
|
73
|
+
return wait_for_UF2_windows(board_id=board_id)
|
74
74
|
elif sys.platform == "darwin":
|
75
|
-
|
76
|
-
return wait_for_UF2_macos()
|
75
|
+
return wait_for_UF2_macos(board_id=board_id)
|
77
76
|
else:
|
78
77
|
log.warning(f"OS {sys.platform} not tested/supported")
|
79
78
|
return None
|
80
79
|
|
81
80
|
|
82
81
|
@tenacity.retry(stop=stop_after_attempt(3), wait=wait_fixed(1), reraise=False)
|
83
|
-
def
|
82
|
+
def copy_firmware_to_uf2(fw_file: Path, destination: Path):
|
84
83
|
"""
|
85
84
|
Copy the firmware file to the destination,
|
86
85
|
Retry 3 times with 1s delay
|
87
86
|
"""
|
88
87
|
log.info(f"Copying {fw_file} to {destination}.")
|
89
|
-
shutil.copy(fw_file, destination)
|
88
|
+
return shutil.copy(fw_file, destination)
|
@@ -12,7 +12,7 @@ from typing import List
|
|
12
12
|
from loguru import logger as log
|
13
13
|
from rich.progress import track
|
14
14
|
|
15
|
-
from .
|
15
|
+
from .boardid import get_board_id
|
16
16
|
from .uf2disk import UF2Disk
|
17
17
|
|
18
18
|
glb_dismount_me: List[UF2Disk] = []
|
@@ -42,10 +42,7 @@ def get_uf2_drives():
|
|
42
42
|
uf2.mountpoint = uf2_part["mountpoint"]
|
43
43
|
yield uf2
|
44
44
|
elif disk["type"] == "disk" and disk.get("children") and len(disk.get("children")) > 0:
|
45
|
-
if (
|
46
|
-
disk.get("children")[0]["type"] == "part"
|
47
|
-
and disk.get("children")[0]["fstype"] == "vfat"
|
48
|
-
):
|
45
|
+
if disk.get("children")[0]["type"] == "part" and disk.get("children")[0]["fstype"] == "vfat":
|
49
46
|
uf2_part = disk.get("children")[0]
|
50
47
|
# print( json.dumps(uf2_part, indent=4))
|
51
48
|
uf2 = UF2Disk()
|
@@ -98,16 +95,17 @@ def dismount_uf2_linux():
|
|
98
95
|
glb_dismount_me = []
|
99
96
|
|
100
97
|
|
101
|
-
def wait_for_UF2_linux(s_max: int = 10):
|
98
|
+
def wait_for_UF2_linux(board_id: str, s_max: int = 10):
|
102
99
|
destination = ""
|
103
100
|
wait = 10
|
104
101
|
uf2_drives = []
|
105
102
|
# while not destination and wait > 0:
|
106
103
|
for _ in track(
|
107
104
|
range(s_max),
|
108
|
-
description="Waiting for mcu to mount as a drive",
|
105
|
+
description=f"Waiting for mcu to mount as a drive ({s_max}s)",
|
109
106
|
transient=True,
|
110
|
-
|
107
|
+
show_speed=False,
|
108
|
+
refresh_per_second=1,
|
111
109
|
total=s_max,
|
112
110
|
):
|
113
111
|
uf2_drives += list(get_uf2_drives())
|
@@ -116,9 +114,12 @@ def wait_for_UF2_linux(s_max: int = 10):
|
|
116
114
|
time.sleep(1)
|
117
115
|
try:
|
118
116
|
if Path(drive.mountpoint, "INFO_UF2.TXT").exists():
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
this_board_id = get_board_id(Path(drive.mountpoint))
|
118
|
+
if not board_id or board_id.upper() in this_board_id.upper():
|
119
|
+
# is it the correct board?
|
120
|
+
destination = Path(drive.mountpoint)
|
121
|
+
break
|
122
|
+
continue
|
122
123
|
except PermissionError:
|
123
124
|
log.debug(f"Permission error on {drive.mountpoint}")
|
124
125
|
continue
|
@@ -9,26 +9,31 @@ from typing import Optional
|
|
9
9
|
|
10
10
|
from rich.progress import track
|
11
11
|
|
12
|
+
from .boardid import get_board_id
|
12
13
|
|
13
|
-
|
14
|
+
|
15
|
+
def wait_for_UF2_macos(board_id: str, s_max: int = 10) -> Optional[Path]:
|
14
16
|
"""Wait for the MCU to mount as a drive"""
|
15
17
|
if s_max < 1:
|
16
18
|
s_max = 10
|
17
19
|
destination = None
|
18
20
|
for _ in track(
|
19
21
|
range(s_max),
|
20
|
-
description="Waiting for mcu to mount as a drive",
|
22
|
+
description=f"Waiting for mcu to mount as a drive ({s_max}s)",
|
21
23
|
transient=True,
|
22
|
-
|
24
|
+
show_speed=False,
|
25
|
+
refresh_per_second=1,
|
23
26
|
total=s_max,
|
24
27
|
):
|
25
|
-
# log.info(f"Waiting for mcu to mount as a drive : {n} seconds left")
|
26
28
|
vol_mounts = Path("/Volumes").iterdir()
|
27
29
|
for vol in vol_mounts:
|
28
30
|
try:
|
29
31
|
if Path(vol, "INFO_UF2.TXT").exists():
|
30
|
-
|
31
|
-
|
32
|
+
this_board_id = get_board_id(Path(vol))
|
33
|
+
if not board_id or board_id.upper() in this_board_id.upper():
|
34
|
+
destination = Path(vol)
|
35
|
+
break
|
36
|
+
continue
|
32
37
|
except OSError:
|
33
38
|
pass
|
34
39
|
if destination:
|
@@ -7,29 +7,34 @@ import time
|
|
7
7
|
from pathlib import Path
|
8
8
|
from typing import Optional
|
9
9
|
|
10
|
+
from .boardid import get_board_id
|
10
11
|
import psutil
|
11
12
|
from rich.progress import track
|
12
13
|
|
13
14
|
|
14
|
-
def wait_for_UF2_windows(s_max: int = 10)
|
15
|
+
def wait_for_UF2_windows(board_id: str, s_max: int = 10)-> Optional[Path]:
|
15
16
|
"""Wait for the MCU to mount as a drive"""
|
16
17
|
if s_max < 1:
|
17
18
|
s_max = 10
|
18
19
|
destination = None
|
19
20
|
for _ in track(
|
20
21
|
range(s_max),
|
21
|
-
description="Waiting for mcu to mount as a drive",
|
22
|
+
description=f"Waiting for mcu to mount as a drive ({s_max}s)",
|
22
23
|
transient=True,
|
23
|
-
|
24
|
+
show_speed=False,
|
25
|
+
refresh_per_second=1,
|
24
26
|
total=s_max,
|
25
27
|
):
|
26
|
-
# log.info(f"Waiting for mcu to mount as a drive : {n} seconds left")
|
27
28
|
drives = [drive.device for drive in psutil.disk_partitions()]
|
28
29
|
for drive in drives:
|
29
30
|
try:
|
30
31
|
if Path(drive, "INFO_UF2.TXT").exists():
|
31
|
-
|
32
|
-
|
32
|
+
this_board_id = get_board_id(Path(drive))
|
33
|
+
if not board_id or board_id.upper() in this_board_id.upper():
|
34
|
+
# is it the correct board?
|
35
|
+
destination = Path(drive)
|
36
|
+
break
|
37
|
+
continue
|
33
38
|
except OSError:
|
34
39
|
pass
|
35
40
|
if destination:
|
@@ -1,15 +1,16 @@
|
|
1
|
+
"""Worklist for updating boards"""
|
2
|
+
|
1
3
|
from pathlib import Path
|
2
4
|
from typing import Dict, List, Optional, Tuple
|
3
5
|
|
4
6
|
from loguru import logger as log
|
5
7
|
|
6
|
-
from mpflash.common import FWInfo, filtered_comports
|
8
|
+
from mpflash.common import FWInfo, filtered_comports
|
9
|
+
from mpflash.downloaded import find_downloaded_firmware
|
7
10
|
from mpflash.errors import MPFlashError
|
8
|
-
|
9
|
-
from .
|
10
|
-
from .
|
11
|
-
from .mpboard_id import find_known_board
|
12
|
-
from .mpremoteboard import MPRemoteBoard
|
11
|
+
from mpflash.list import show_mcus
|
12
|
+
from mpflash.mpboard_id import find_known_board
|
13
|
+
from mpflash.mpremoteboard import MPRemoteBoard
|
13
14
|
|
14
15
|
# #########################################################################################################
|
15
16
|
WorkList = List[Tuple[MPRemoteBoard, FWInfo]]
|
@@ -39,9 +40,7 @@ def auto_update(
|
|
39
40
|
wl: WorkList = []
|
40
41
|
for mcu in conn_boards:
|
41
42
|
if mcu.family not in ("micropython", "unknown"):
|
42
|
-
log.warning(
|
43
|
-
f"Skipping flashing {mcu.family} {mcu.port} {mcu.board} on {mcu.serialport} as it is not a MicroPython firmware"
|
44
|
-
)
|
43
|
+
log.warning(f"Skipping flashing {mcu.family} {mcu.port} {mcu.board} on {mcu.serialport} as it is not a MicroPython firmware")
|
45
44
|
continue
|
46
45
|
board_firmwares = find_downloaded_firmware(
|
47
46
|
fw_folder=fw_folder,
|
mpflash/mpflash/list.py
CHANGED
@@ -3,8 +3,9 @@ from typing import List
|
|
3
3
|
from rich.progress import track
|
4
4
|
from rich.table import Table
|
5
5
|
|
6
|
+
from mpflash.config import config
|
6
7
|
from mpflash.mpremoteboard import MPRemoteBoard
|
7
|
-
from mpflash.
|
8
|
+
from mpflash.versions import clean_version
|
8
9
|
|
9
10
|
from .logger import console
|
10
11
|
|
@@ -64,8 +65,15 @@ def mcu_table(
|
|
64
65
|
table.add_column("Version", overflow="fold", min_width=5, max_width=16)
|
65
66
|
if needs_build:
|
66
67
|
table.add_column("Build" if is_wide else "Bld", justify="right")
|
67
|
-
|
68
|
-
|
68
|
+
if config.usb:
|
69
|
+
table.add_column("Location", overflow="fold", max_width=40)
|
70
|
+
for mcu in track(
|
71
|
+
conn_mcus,
|
72
|
+
description="Updating board info",
|
73
|
+
transient=True,
|
74
|
+
show_speed=False,
|
75
|
+
refresh_per_second=1,
|
76
|
+
):
|
69
77
|
if refresh:
|
70
78
|
try:
|
71
79
|
mcu.get_mcu_info()
|
@@ -84,6 +92,8 @@ def mcu_table(
|
|
84
92
|
row.append(clean_version(mcu.version))
|
85
93
|
if needs_build:
|
86
94
|
row.append(mcu.build)
|
95
|
+
if config.usb:
|
96
|
+
row.append(mcu.location)
|
87
97
|
|
88
98
|
table.add_row(*row)
|
89
99
|
return table
|
@@ -10,7 +10,7 @@ from typing import List, Optional, Tuple
|
|
10
10
|
from mpflash.errors import MPFlashError
|
11
11
|
from mpflash.mpboard_id.board import Board
|
12
12
|
from mpflash.mpboard_id.store import read_known_boardinfo
|
13
|
-
from mpflash.
|
13
|
+
from mpflash.versions import clean_version
|
14
14
|
|
15
15
|
# KNOWN ports and boards are sourced from the micropython repo,
|
16
16
|
# this info is stored in the board_info.json file
|
@@ -12,11 +12,11 @@ import rich.table
|
|
12
12
|
from rich.console import Console
|
13
13
|
from rich.progress import track
|
14
14
|
|
15
|
-
import mpflash.
|
15
|
+
import mpflash.basicgit as git
|
16
16
|
from mpflash.logger import log
|
17
17
|
from mpflash.mpboard_id import Board
|
18
18
|
from mpflash.mpboard_id.store import write_boardinfo_json
|
19
|
-
from mpflash.
|
19
|
+
from mpflash.versions import micropython_versions
|
20
20
|
|
21
21
|
# look for all mpconfigboard.h files and extract the board name
|
22
22
|
# from the #define MICROPY_HW_BOARD_NAME "PYBD_SF6"
|
@@ -222,11 +222,7 @@ def make_table(board_list: List[Board]) -> rich.table.Table:
|
|
222
222
|
|
223
223
|
def ask_mpy_path():
|
224
224
|
"""Ask the user for the path to the MicroPython repository."""
|
225
|
-
questions = [
|
226
|
-
inquirer.Text(
|
227
|
-
"mpy_path", message="Enter the path to the MicroPython repository", default=".\\repos\\micropython"
|
228
|
-
)
|
229
|
-
]
|
225
|
+
questions = [inquirer.Text("mpy_path", message="Enter the path to the MicroPython repository", default=".\\repos\\micropython")]
|
230
226
|
if answers := inquirer.prompt(questions):
|
231
227
|
return Path(answers["mpy_path"])
|
232
228
|
else:
|