Skip to content

Commit

Permalink
image_info: Print chip ID's name if known
Browse files Browse the repository at this point in the history
Example:

Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.0, (legacy min_rev = 0)
Maximal chip revision: v655.35

An unknown ID will be printed as:

Chip ID: 42 (Unknown ID)
  • Loading branch information
xyzzy42 committed Apr 20, 2023
1 parent 0865ef1 commit 7450d1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion esptool/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,15 @@ def get_key_from_value(dict, val):
image.wp_drv,
)
)
print("Chip ID: {}".format(image.chip_id))
try:
chip = next(
chip
for chip in CHIP_DEFS.values()
if getattr(chip, "IMAGE_CHIP_ID", None) == image.chip_id
)
print(f"Chip ID: {image.chip_id} ({chip.CHIP_NAME})")
except StopIteration:
print(f"Chip ID: {image.chip_id} (Unknown ID)")
print(
"Minimal chip revision: "
f"v{image.min_rev_full // 100}.{image.min_rev_full % 100}, "
Expand Down
2 changes: 1 addition & 1 deletion test/test_image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_v2_esp32c3(self):
assert "Flash mode: DIO" in out, "Wrong flash mode"

# Extended header
assert "Chip ID: 5" in out, "Wrong chip ID"
assert "WP pin: disabled" in out, "Wrong WP pin"
assert "Chip ID: 5 (ESP32-C3)" in out, "Wrong chip ID"
assert (
"clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, "
"cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0" in out
Expand Down

0 comments on commit 7450d1a

Please sign in to comment.