@@ -374,6 +374,10 @@ def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_rese
374
374
if chip_id == cls .IMAGE_CHIP_ID :
375
375
inst = cls (detect_port ._port , baud , trace_enabled = trace_enabled )
376
376
inst ._post_connect ()
377
+ try :
378
+ inst .read_reg (ESPLoader .CHIP_DETECT_MAGIC_REG_ADDR ) # Dummy read to check Secure Download mode
379
+ except UnsupportedCommandError :
380
+ inst .secure_download_mode = True
377
381
except (UnsupportedCommandError , struct .error , FatalError ) as e :
378
382
# UnsupportedCmdErr: ESP8266/ESP32 ROM | struct.err: ESP32-S2 | FatalErr: ESP8266/ESP32 STUB
379
383
print (" Unsupported detection protocol, switching and trying again..." )
@@ -2376,6 +2380,11 @@ class ESP32C2ROM(ESP32C3ROM):
2376
2380
CHIP_NAME = "ESP32-C2"
2377
2381
IMAGE_CHIP_ID = 12
2378
2382
2383
+ IROM_MAP_START = 0x42000000
2384
+ IROM_MAP_END = 0x42400000
2385
+ DROM_MAP_START = 0x3c000000
2386
+ DROM_MAP_END = 0x3c400000
2387
+
2379
2388
CHIP_DETECT_MAGIC_VALUE = [0x6f51306f ]
2380
2389
2381
2390
EFUSE_BASE = 0x60008800
@@ -4730,16 +4739,21 @@ def flash_xmc_startup():
4730
4739
print ("XMC flash chip boot-up fix successful!" )
4731
4740
4732
4741
# Check flash chip connection
4733
- try :
4734
- flash_id = esp .flash_id ()
4735
- if flash_id in (0xffffff , 0x000000 ):
4736
- print ('WARNING: Failed to communicate with the flash chip, read/write operations will fail. '
4737
- 'Try checking the chip connections or removing any other hardware connected to IOs.' )
4738
- except Exception as e :
4739
- esp .trace ('Unable to verify flash chip connection ({}).' .format (e ))
4742
+ if not esp .secure_download_mode :
4743
+ try :
4744
+ flash_id = esp .flash_id ()
4745
+ if flash_id in (0xffffff , 0x000000 ):
4746
+ print ('WARNING: Failed to communicate with the flash chip, read/write operations will fail. '
4747
+ 'Try checking the chip connections or removing any other hardware connected to IOs.' )
4748
+ except Exception as e :
4749
+ esp .trace ('Unable to verify flash chip connection ({}).' .format (e ))
4740
4750
4741
4751
# Check if XMC SPI flash chip booted-up successfully, fix if not
4742
- flash_xmc_startup ()
4752
+ if not esp .secure_download_mode :
4753
+ try :
4754
+ flash_xmc_startup ()
4755
+ except Exception as e :
4756
+ esp .trace ('Unable to perform XMC flash chip startup sequence ({}).' .format (e ))
4743
4757
4744
4758
if hasattr (args , "flash_size" ):
4745
4759
print ("Configuring flash size..." )
0 commit comments