2121from mpflash .common import PORT_FWTYPES , FWInfo
2222from mpflash .errors import MPFlashError
2323from mpflash .mpboard_id import get_known_ports
24+ from mpflash .vendor .versions import clean_version
2425
2526# avoid conflict with the ujson used by MicroPython
2627jsonlines .ujson = None # type: ignore
@@ -157,7 +158,7 @@ def get_boards(ports: List[str], boards: List[str], clean: bool) -> List[FWInfo]
157158 # board["firmware"] = _url
158159 # board["preview"] = "preview" in _url # type: ignore
159160 if ver_match := re .search (RE_VERSION_PREVIEW , _url ):
160- fw_info .version = ver_match .group (1 )
161+ fw_info .version = clean_version ( ver_match .group (1 ) )
161162 fw_info .build = ver_match .group (2 ) or "0"
162163 fw_info .preview = fw_info .build != "0"
163164 # # else:
@@ -194,8 +195,9 @@ def download_firmwares(
194195 clean : bool = True ,
195196) -> int :
196197 skipped = downloaded = 0
197- if versions is None :
198- versions = []
198+ versions = [] if versions is None else [clean_version (v ) for v in versions ]
199+ # handle renamed boards
200+ boards = add_renamed_boards (boards )
199201
200202 unique_boards = get_firmware_list (ports , boards , versions , clean )
201203
@@ -305,6 +307,7 @@ def download(
305307 if not boards :
306308 log .critical ("No boards found, please connect a board or specify boards to download firmware for." )
307309 raise MPFlashError ("No boards found" )
310+
308311 # versions = [clean_version(v, drop_v=True) for v in versions] # remove leading v from version
309312 try :
310313 destination .mkdir (exist_ok = True , parents = True )
@@ -318,3 +321,28 @@ def download(
318321 raise MPFlashError ("Could not connect to micropython.org" ) from e
319322
320323 return result
324+
325+
326+ def add_renamed_boards (boards : List [str ]) -> List [str ]:
327+ """
328+ Adds the renamed boards to the list of boards.
329+
330+ Args:
331+ boards : The list of boards to add the renamed boards to.
332+
333+ Returns:
334+ List[str]: The list of boards with the renamed boards added.
335+
336+ """
337+ renamed = {
338+ "PICO" : ["RPI_PICO" ],
339+ "PICO_W" : ["RPI_PICO_W" ],
340+ "GENERIC" : ["ESP32_GENERIC" , "ESP8266_GENERIC" ], # just add both of them
341+ }
342+ _boards = boards .copy ()
343+ for board in boards :
344+ if board in renamed and renamed [board ] not in boards :
345+ _boards .extend (renamed [board ])
346+ if board != board .upper () and board .upper () not in boards :
347+ _boards .append (board .upper ())
348+ return _boards
0 commit comments