Skip to content

Commit c6f1839

Browse files
KonstantinKondrashovradimkarnis
authored andcommitted
feat(esptool): Update chip description for ESP32-C2/ESP8684H
1 parent b3d4e15 commit c6f1839

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

esptool/targets/esp32c2.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,24 @@ def get_pkg_version(self):
7777
def get_chip_description(self):
7878
chip_name = {
7979
0: "ESP32-C2",
80-
1: "ESP32-C2",
80+
1: "ESP8684H",
8181
}.get(self.get_pkg_version(), "Unknown ESP32-C2")
8282
major_rev = self.get_major_chip_version()
8383
minor_rev = self.get_minor_chip_version()
8484
return f"{chip_name} (revision v{major_rev}.{minor_rev})"
8585

8686
def get_chip_features(self):
87-
return ["Wi-Fi", "BT 5 (LE)", "Single Core", "120MHz"]
87+
features = ["Wi-Fi", "BT 5 (LE)", "Single Core", "120MHz"]
88+
89+
flash = {
90+
0: None,
91+
1: "Embedded Flash 4MB",
92+
2: "Embedded Flash 2MB",
93+
3: "Embedded Flash 1MB",
94+
}.get(self.get_flash_cap(), "Unknown Embedded Flash")
95+
if flash is not None:
96+
features += [flash + f" ({self.get_flash_vendor()})"]
97+
return features
8898

8999
def get_minor_chip_version(self):
90100
num_word = 1
@@ -95,14 +105,13 @@ def get_major_chip_version(self):
95105
return (self.read_reg(self.EFUSE_BLOCK2_ADDR + (4 * num_word)) >> 20) & 0x3
96106

97107
def get_flash_cap(self):
98-
# ESP32-C2 doesn't have eFuse field FLASH_CAP.
99-
# Can't get info about the flash chip.
100-
return 0
108+
num_word = 7
109+
return (self.read_reg(self.EFUSE_BLOCK2_ADDR + (4 * num_word)) >> 29) & 0x7
101110

102111
def get_flash_vendor(self):
103-
# ESP32-C2 doesn't have eFuse field FLASH_VENDOR.
104-
# Can't get info about the flash chip.
105-
return ""
112+
num_word = 7
113+
vendor_id = (self.read_reg(self.EFUSE_BLOCK2_ADDR + (4 * num_word)) >> 24) & 0x7
114+
return {1: "XMC", 2: "GD", 3: "FM", 4: "TT", 5: "ZBIT"}.get(vendor_id, "")
106115

107116
def get_crystal_freq(self):
108117
# The crystal detection algorithm of ESP32/ESP8266 works for ESP32-C2 as well.

test/test_esptool.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,22 +1082,6 @@ def test_flash_id_trace(self):
10821082
assert "Manufacturer:" in res
10831083
assert "Device:" in res
10841084

1085-
@pytest.mark.quick_test
1086-
@pytest.mark.skipif(
1087-
arg_chip not in ["esp32c2"],
1088-
reason="This test make sense only for EPS32-C2",
1089-
)
1090-
def test_flash_size(self):
1091-
"""Test ESP32-C2 efuse block for flash size feature"""
1092-
# ESP32-C2 class inherits methods from ESP32-C3 class
1093-
# but it does not have the same amount of efuse blocks
1094-
# the methods are overwritten
1095-
# in case anything changes this test will fail to remind us
1096-
res = self.run_esptool("flash-id")
1097-
lines = res.splitlines()
1098-
for line in lines:
1099-
assert "embedded flash" not in line.lower()
1100-
11011085
@pytest.mark.quick_test
11021086
def test_flash_sfdp(self):
11031087
"""Test manufacturer and device response of flash detection."""
@@ -1492,6 +1476,9 @@ class TestAutoDetect(EsptoolTestCase):
14921476
def _check_output(self, output):
14931477
expected_chip_name = esptool.util.expand_chip_name(arg_chip)
14941478
assert f"Detecting chip type... {expected_chip_name}" in output
1479+
if arg_chip == "esp32c2":
1480+
# chip_name depends on the package, for example ESP8684H.
1481+
expected_chip_name = ""
14951482
assert f"{'Chip type:':<20}{expected_chip_name}" in output
14961483

14971484
@pytest.mark.quick_test

0 commit comments

Comments
 (0)