99from .esp32c6 import ESP32C6ROM
1010from ..loader import ESPLoader
1111from ..reset import HardReset
12+ from ..util import FatalError
1213
1314
1415class ESP32C5ROM (ESP32C6ROM ):
@@ -29,7 +30,7 @@ class ESP32C5ROM(ESP32C6ROM):
2930 UARTDEV_BUF_NO = 0x4085F51C # Variable in ROM .bss which indicates the port in use
3031
3132 # Magic value for ESP32C5
32- CHIP_DETECT_MAGIC_VALUE = [0x8082C5DC ]
33+ CHIP_DETECT_MAGIC_VALUE = [0x1101406F ]
3334
3435 FLASH_FREQUENCY = {
3536 "80m" : 0xF ,
@@ -119,5 +120,33 @@ def change_baud(self, baud):
119120 else :
120121 ESPLoader .change_baud (self , baud )
121122
123+ def check_spi_connection (self , spi_connection ):
124+ if not set (spi_connection ).issubset (set (range (0 , 29 ))):
125+ raise FatalError ("SPI Pin numbers must be in the range 0-28." )
126+ if any ([v for v in spi_connection if v in [13 , 14 ]]):
127+ print (
128+ "WARNING: GPIO pins 13 and 14 are used by USB-Serial/JTAG, "
129+ "consider using other pins for SPI flash connection."
130+ )
131+
132+
133+ class ESP32C5StubLoader (ESP32C5ROM ):
134+ """Access class for ESP32C5 stub loader, runs on top of ROM.
135+
136+ (Basically the same as ESP32StubLoader, but different base class.
137+ Can possibly be made into a mixin.)
138+ """
139+
140+ FLASH_WRITE_SIZE = 0x4000 # matches MAX_WRITE_BLOCK in stub_loader.c
141+ STATUS_BYTES_LENGTH = 2 # same as ESP8266, different to ESP32 ROM
142+ IS_STUB = True
143+
144+ def __init__ (self , rom_loader ):
145+ self .secure_download_mode = rom_loader .secure_download_mode
146+ self ._port = rom_loader ._port
147+ self ._trace_enabled = rom_loader ._trace_enabled
148+ self .cache = rom_loader .cache
149+ self .flush_input () # resets _slip_reader
150+
122151
123- # TODO: [ESP32C5] ESPTOOL-825, IDF-8631 support stub flasher
152+ ESP32C5ROM . STUB_CLASS = ESP32C5StubLoader
0 commit comments