Skip to content

Commit

Permalink
mpflash: list unknown boards as such
Browse files Browse the repository at this point in the history
  • Loading branch information
Josverl committed Apr 30, 2024
1 parent acd3983 commit da20703
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/mpflash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ Note that if no matching firmware can be found for a board, it will be skipped.
(For example, the PYBV11 and ESP32_GENERIC_S3 boards in the example above.)

## Issues and bug reports
mpflash is currently co-located in the [micropython-stubber](https://github.com/Josverl/micropython-stubber) repository.
Please report any issues or bugs in the [issue tracker](https://github.com/Josverl/micropython-stubber/issues) with '[mpflash]' in the subject.
mpflash is currently co-located in the [micropython-stubber](https://github.com/Josverl/micropython-stubber) repository.
Please report any issues or bugs in the [issue tracker](https://github.com/Josverl/micropython-stubber/issues) using the MPflash feedback template.

## License
mpflash is licensed under the MIT license. See the LICENSE file for more details.
25 changes: 14 additions & 11 deletions src/mpflash/mpflash/mpboard_id/board_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@
def find_board_id(
descr: str, short_descr: str, board_info: Optional[Path] = None, version: str = "stable"
) -> Optional[str]:
# TODO: use the json file instead of the csv and get the cpu
boards = find_board_by_description(
descr=descr,
short_descr=short_descr,
board_info=board_info,
version=clean_version(version),
)
return boards[-1]["board"]
"""Find the MicroPython BOARD_ID based on the description in the firmware"""
try:
boards = find_board_id_by_description(
descr=descr,
short_descr=short_descr,
board_info=board_info,
version=clean_version(version),
)
return boards[-1]["board"]
except MPFlashError:
return "UNKNOWN_BOARD"


@functools.lru_cache(maxsize=20)
def find_board_by_description(*, descr: str, short_descr: str, version="v1.21.0", board_info: Optional[Path] = None):
def find_board_id_by_description(*, descr: str, short_descr: str, version="v1.21.0", board_info: Optional[Path] = None):
"""
Find the MicroPython BOARD designator based on the description in the firmware
Find the MicroPython BOARD_ID based on the description in the firmware
using the pre-built board_info.json file
"""
if not board_info:
Expand All @@ -52,7 +55,7 @@ def find_board_by_description(*, descr: str, short_descr: str, version="v1.21.0"
if not matches and short_descr:
matches = [b for b in version_matches if b["description"] == short_descr]
if not matches:
raise MPFlashError(f"No board info found for description {descr}")
raise MPFlashError(f"No board info found for description '{descr}' or '{short_descr}'")
return sorted(matches, key=lambda x: x["version"])


Expand Down
2 changes: 1 addition & 1 deletion src/mpflash/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mpflash"
version = "0.7.1"
version = "0.7.2"
description = "Flash and download tool for MicroPython firmwares"
authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
license = "MIT"
Expand Down

0 comments on commit da20703

Please sign in to comment.