Skip to content

Commit c2f5d21

Browse files
committed
fix: enable auto-detection of ESP32-S2 in secure download mode
1 parent 6fc3e44 commit c2f5d21

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

esptool/cmds.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,16 @@ def check_if_stub(instance: ESPLoader) -> ESPLoader:
165165
ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR
166166
)
167167
except UnsupportedCommandError:
168-
raise FatalError(
169-
"Unsupported Command Error received. "
170-
"Probably this means Secure Download Mode is enabled, "
171-
"autodetection will not work. Need to manually specify the chip."
168+
# Only ESP32-S2 does not support chip id detection
169+
# and supports secure download mode
170+
inst = CHIP_DEFS["esp32s2"](
171+
detect_port._port, baud, trace_enabled=trace_enabled
172172
)
173+
si = inst.get_security_info()
174+
inst.secure_download_mode = si["parsed_flags"]["SECURE_DOWNLOAD_ENABLE"]
175+
inst = check_if_stub(inst)
176+
inst._post_connect()
177+
return inst
173178
except FatalError:
174179
log.print(" Autodetection failed, trying again...")
175180
detect_port.connect(

0 commit comments

Comments
 (0)