mirror of
https://github.com/espressif/esptool.git
synced 2025-10-19 11:43:48 +08:00
fix(autodetection): Remove the Unsupported detection protocol stage
This commit is contained in:
@@ -34,8 +34,7 @@ The order of registers in the dump:
|
|||||||
|
|
||||||
> espefuse.py dump
|
> espefuse.py dump
|
||||||
|
|
||||||
Detecting chip type... Unsupported detection protocol, switching and trying again...
|
Connecting.........
|
||||||
Connecting....
|
|
||||||
Detecting chip type... ESP32
|
Detecting chip type... ESP32
|
||||||
BLOCK0 ( ) [0 ] read_regs: 00000000 7e5a6e58 00e294b9 0000a200 00000333 00100000 00000004
|
BLOCK0 ( ) [0 ] read_regs: 00000000 7e5a6e58 00e294b9 0000a200 00000333 00100000 00000004
|
||||||
BLOCK1 (flash_encryption) [1 ] read_regs: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
BLOCK1 (flash_encryption) [1 ] read_regs: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
||||||
|
@@ -109,8 +109,6 @@ Save Json Format Summary To File
|
|||||||
|
|
||||||
> espefuse.py summary --format json --file efuses.json
|
> espefuse.py summary --format json --file efuses.json
|
||||||
|
|
||||||
Connecting..........
|
|
||||||
Detecting chip type... Unsupported detection protocol, switching and trying again...
|
|
||||||
Connecting....
|
Connecting....
|
||||||
Detecting chip type... ESP32
|
Detecting chip type... ESP32
|
||||||
|
|
||||||
|
@@ -128,7 +128,7 @@ def detect_chip(
|
|||||||
This way we use one memory read and compare it to the magic number for each chip.
|
This way we use one memory read and compare it to the magic number for each chip.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
log.print("Detecting chip type...", end="")
|
log.print("Detecting chip type...", end="", flush=True)
|
||||||
chip_id = detect_port.get_chip_id()
|
chip_id = detect_port.get_chip_id()
|
||||||
for cls in ROM_LIST:
|
for cls in ROM_LIST:
|
||||||
# cmd not supported on ESP8266 and ESP32 + ESP32-S2 doesn't return chip-id
|
# cmd not supported on ESP8266 and ESP32 + ESP32-S2 doesn't return chip-id
|
||||||
@@ -147,39 +147,41 @@ def detect_chip(
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
err_msg = f"Unexpected chip ID value {chip_id}."
|
err_msg = f"Unexpected chip ID value {chip_id}."
|
||||||
except (UnsupportedCommandError, struct.error, FatalError) as e:
|
except (UnsupportedCommandError, struct.error, FatalError):
|
||||||
# UnsupportedCommandError: ESP8266/ESP32 ROM
|
# UnsupportedCommandError: ESP8266/ESP32 ROM
|
||||||
# struct.error: ESP32-S2
|
# struct.error: ESP32-S2
|
||||||
# FatalError: ESP8266/ESP32 STUB
|
# FatalError: ESP8266/ESP32 STUB
|
||||||
log.print(" Unsupported detection protocol, switching and trying again...")
|
|
||||||
try:
|
try:
|
||||||
# ESP32/ESP8266 are reset after an unsupported command, need to reconnect
|
|
||||||
# (not needed on ESP32-S2)
|
|
||||||
if not isinstance(e, struct.error):
|
|
||||||
detect_port.connect(
|
|
||||||
connect_mode, connect_attempts, detecting=True, warnings=False
|
|
||||||
)
|
|
||||||
log.print("Detecting chip type...", end="", flush=True)
|
|
||||||
chip_magic_value = detect_port.read_reg(
|
chip_magic_value = detect_port.read_reg(
|
||||||
ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR
|
ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR
|
||||||
)
|
)
|
||||||
|
|
||||||
for cls in ROM_LIST:
|
|
||||||
if not cls.USES_MAGIC_VALUE:
|
|
||||||
continue
|
|
||||||
if chip_magic_value == cls.MAGIC_VALUE:
|
|
||||||
inst = cls(detect_port._port, baud, trace_enabled=trace_enabled)
|
|
||||||
inst = check_if_stub(inst)
|
|
||||||
inst._post_connect()
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
err_msg = f"Unexpected chip magic value {chip_magic_value:#010x}."
|
|
||||||
except UnsupportedCommandError:
|
except UnsupportedCommandError:
|
||||||
raise FatalError(
|
raise FatalError(
|
||||||
"Unsupported Command Error received. "
|
"Unsupported Command Error received. "
|
||||||
"Probably this means Secure Download Mode is enabled, "
|
"Probably this means Secure Download Mode is enabled, "
|
||||||
"autodetection will not work. Need to manually specify the chip."
|
"autodetection will not work. Need to manually specify the chip."
|
||||||
)
|
)
|
||||||
|
except FatalError:
|
||||||
|
log.print(" Autodetection failed, trying again...")
|
||||||
|
detect_port.connect(
|
||||||
|
connect_mode, connect_attempts, detecting=True, warnings=False
|
||||||
|
)
|
||||||
|
log.print("Detecting chip type...", end="", flush=True)
|
||||||
|
chip_magic_value = detect_port.read_reg(
|
||||||
|
ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR
|
||||||
|
)
|
||||||
|
|
||||||
|
for cls in ROM_LIST:
|
||||||
|
if not cls.USES_MAGIC_VALUE:
|
||||||
|
continue
|
||||||
|
if chip_magic_value == cls.MAGIC_VALUE:
|
||||||
|
inst = cls(detect_port._port, baud, trace_enabled=trace_enabled)
|
||||||
|
inst = check_if_stub(inst)
|
||||||
|
inst._post_connect()
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
err_msg = f"Unexpected chip magic value {chip_magic_value:#010x}."
|
||||||
|
|
||||||
if inst is not None:
|
if inst is not None:
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
|
@@ -509,7 +509,8 @@ class ESPLoader(object):
|
|||||||
if byte(data, 0) != 0 and byte(data, 1) == self.ROM_INVALID_RECV_MSG:
|
if byte(data, 0) != 0 and byte(data, 1) == self.ROM_INVALID_RECV_MSG:
|
||||||
# Unsupported read_reg can result in
|
# Unsupported read_reg can result in
|
||||||
# more than one error response for some reason
|
# more than one error response for some reason
|
||||||
self.flush_input()
|
time.sleep(0.2) # Wait for input buffer to fill
|
||||||
|
self.flush_input() # Flush input buffer of hanging response
|
||||||
raise UnsupportedCommandError(self, op)
|
raise UnsupportedCommandError(self, op)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@@ -1379,8 +1379,6 @@ class TestBootloaderHeaderRewriteCases(EsptoolTestCase):
|
|||||||
class TestAutoDetect(EsptoolTestCase):
|
class TestAutoDetect(EsptoolTestCase):
|
||||||
def _check_output(self, output):
|
def _check_output(self, output):
|
||||||
expected_chip_name = esptool.util.expand_chip_name(arg_chip)
|
expected_chip_name = esptool.util.expand_chip_name(arg_chip)
|
||||||
if arg_chip not in ["esp8266", "esp32", "esp32s2"]:
|
|
||||||
assert "Unsupported detection protocol" not in output
|
|
||||||
assert f"Detecting chip type... {expected_chip_name}" in output
|
assert f"Detecting chip type... {expected_chip_name}" in output
|
||||||
assert f"{'Chip type:':<20}{expected_chip_name}" in output
|
assert f"{'Chip type:':<20}{expected_chip_name}" in output
|
||||||
|
|
||||||
|
@@ -31,9 +31,8 @@ class TestSecureDownloadMode(EsptoolTestCase):
|
|||||||
|
|
||||||
if arg_chip == "esp32s2": # no autodetection from security info, only magic no.
|
if arg_chip == "esp32s2": # no autodetection from security info, only magic no.
|
||||||
assert "Secure Download Mode is enabled" in output
|
assert "Secure Download Mode is enabled" in output
|
||||||
assert "Unsupported detection protocol" in output
|
assert "autodetection will not work" in output
|
||||||
else:
|
else:
|
||||||
assert "Unsupported detection protocol" not in output
|
|
||||||
assert f"Detecting chip type... {self.expected_chip_name}" in output
|
assert f"Detecting chip type... {self.expected_chip_name}" in output
|
||||||
assert (
|
assert (
|
||||||
f"{'Chip type:':<20}{self.expected_chip_name} "
|
f"{'Chip type:':<20}{self.expected_chip_name} "
|
||||||
|
Reference in New Issue
Block a user