ESP32S2 Restart Via Software Causes Exception

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

ESP32S2 Restart Via Software Causes Exception

Postby esp_programmer » Sat Feb 24, 2024 4:53 am

Hi,

I am attempting to reset an ESP32S2 into download mode via the following code (explained in viewtopic.php?t=33180:

Code: Select all

REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
esp_restart();
The CPU appears to reset, but it looks like the bootloader exceptions out. Here is the output from idf.py monitor:

Code: Select all


Build:Oct 25 2019
rst:0xc (RTC_SW_CPU_RST),boot:0x0 (DOWNLOAD(USB/UART0/1/SPI))
Saved PC:0x400261a4
0x400261a4: esp_restart_noos at /opt/esp/idf/components/esp32s2/system_api_esp32s2.c:109 (discriminator 1)

waiting for download
Panic at 40013191
Fatal exception (28): LoadProhibited
epc1=0x4000ff4b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

Is this supposed to work on the S2? Is the bootloader source published anywhere for debug? I am using IDF version 4.3.

Thanks
EP

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

Re: ESP32S2 Restart Via Software Causes Exception

Postby esp_programmer » Sun Feb 25, 2024 4:34 am

Well, it seems the esp_start() function just reboots the core (CPU Reset). All the peripherals remain in their original state and this appeared to break the bootloader.

I got the functionality I required by forcing a Core Reset. This resets all but the RTC peripherals. I did this by going into deep sleep and waking up on an RTC timer:

Code: Select all

REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
esp_sleep_enable_timer_wakeup(500000);

Who is online

Users browsing this forum: nonagon and 97 guests