esp_restart() results in Guru Meditation Error

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

esp_restart() results in Guru Meditation Error

Postby rtborg » Wed Jun 07, 2023 7:23 am

I am attemting to restart an ESP32S3 into DFU mode, but each time I issue esp_restart(), I get an error:

Code: Select all

/*---------------------------------------------------------------------------*/
/* CODE */
static void reboot_to_dfu(void)
{
    ESP_ERROR_CHECK(esp_register_shutdown_handler(usb_persist_shutdown_handler));
    s_queue_reboot = REBOOT_BOOTLOADER_DFU;
    esp_restart();
}

/*---------------------------------------------------------------------------*/

static void IRAM_ATTR usb_persist_shutdown_handler(void)
{
    if (s_queue_reboot == REBOOT_BOOTLOADER)
    {
        // USB CDC Download
        chip_usb_set_persist_flags(USBDC_PERSIST_ENA);
        REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
    }
    else if (s_queue_reboot == REBOOT_BOOTLOADER_DFU)
    {
        // DFU Download
        chip_usb_set_persist_flags(USBDC_BOOT_DFU);
        REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
    }
    else
    {
        // USB Persist reboot
        chip_usb_set_persist_flags(USBDC_PERSIST_ENA);
    }
}

/* RESULTS */ 
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x3 (DOWNLOAD(USB/UART0))
Saved PC:0x40375bed
0x40375bed: esp_restart_noos_dig at C:/Users/null/esp/esp-idf/components/esp_system/esp_system.c:64 (discriminator 1)

waiting for download
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
Core 0 register dump:
PC      : 0x400511b1  PS      : 0x00060330  A0      : 0x80049188  A1      : 0x3fceb640
A2      : 0x00000000  A3      : 0x3ff1e3fb  A4      : 0x00000001  A5      : 0x00000000
A6      : 0x00000000  A7      : 0x00000088  A8      : 0x800533dc  A9      : 0x3fceb620
A10     : 0xfffffffb  A11     : 0x3fceeebc  A12     : 0x3fceefbc  A13     : 0x00000000
A14     : 0x00000000  A15     : 0x00000006  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400570e8  LEND    : 0x400570f3  LCOUNT  : 0x00000000

Backtrace: 0x400511b1:0x3fceb640 0x40049185:0x3fceb670 0x400491e5:0x3fceb690 0x40043917:0x3fceb6b0 0x4004392a:0x3fceb6d0 0x40043c33:0x3fceb6f0 0x40034c45:0x3fceb710
Value of EXCVADDR hints that my code is dereferencing a NULL pointer. How can I find the offending code? My assumption was that tasks are stopped at the time esp_restart() finishes, but that appears to not be the case.

Thanks

EDIT: Running xtensa-esp32s3-elf-addr2line.exe does not do any good. The addresses are also not found in the map file.

Code: Select all

xtensa-esp32s3-elf-addr2line.exe -pfiaC -e .\build\firmware.elf 0x400511b1:0x3fceb640 0x40049185:0x3fceb670 0x400491e5:0x3fceb690 0x40043917:0x3fceb6b0 0x4004392a:0x3fceb6d0 0x40043c33:0x3fceb6f0 0x40034c45:0x3fceb710
0x400511b1: ?? ??:0
0x40049185: ?? ??:0
0x400491e5: ?? ??:0
0x40043917: ?? ??:0
0x4004392a: ?? ??:0
0x40043c33: ?? ??:0
0x40034c45: ?? ??:0

MicroController
Posts: 1692
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp_restart() results in Guru Meditation Error

Postby MicroController » Wed Jun 07, 2023 1:41 pm

Are you sure a) you need to call chip_usb_set_persist_flags(...) and b) it is ok to call it in your context?
The original code seems to apply to the usb_console and also calls usb_dc_prepare_persist(), which may or may not be required before chip_usb_set_persist_flags(...).

What happens if you only use REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT) in the shutdown handler?

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: esp_restart() results in Guru Meditation Error

Postby rtborg » Wed Jun 07, 2023 2:08 pm

Hi, tried the code without the chip_usb_set_persist_flags(USBDC_BOOT_DFU) statement, the result is the same.

MicroController
Posts: 1692
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp_restart() results in Guru Meditation Error

Postby MicroController » Wed Jun 07, 2023 4:20 pm

Oh, wait a minute.

Code: Select all

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x3 (DOWNLOAD(USB/UART0))
Saved PC:0x40375bed
0x40375bed: esp_restart_noos_dig at C:/Users/null/esp/esp-idf/components/esp_system/esp_system.c:64 (discriminator 1)

waiting for download
...
Seems like the chip did restart, and enter download mode.
So the panic looks like it's coming from the bootloader, not from your shutdown code; which would also explain why the backtrace cannot be mapped to your application. Can you try addr2line on build\bootloader\bootloader.elf?

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: esp_restart() results in Guru Meditation Error

Postby rtborg » Wed Jun 07, 2023 8:09 pm

Thank you for the suggestion. Running addr2line on the bootloader .elf file also does not return any functions; inspected the map file - these addresses are not in there.

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: esp_restart() results in Guru Meditation Error

Postby rtborg » Thu Jun 08, 2023 10:20 am

Updates:

1. I could not get the CDC console example working on esp32s3, due to compilation error:

Code: Select all

C:/Users/null/esp/esp-idf/components/esp_system/port/soc/esp32s3/usb_console.c:69:1: error: static assertion failed: "usb_osglue_*_int is not multicore capable"
The flag CONFIG_ESP_CONSOLE_USB_CDC is set.
From reading the docs here, it looks that DFU will not work unless the CONFIG_ESP_CONSOLE_USB_CDC is set.
2. Setting CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG in menuconfig works; however when trying to reboot into DFU, I get the same Guru Meditation Error as before:

Code: Select all

Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x3 (DOWNLOAD(USB/UART0))
Saved PC:0x403758b9
0x403758b9: esp_restart_noos_dig at C:/Users/null/esp/esp-idf/components/esp_system/esp_system.c:64 (discriminator 1)

waiting for download
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
Core 0 register dump:
PC      : 0x400511b1  PS      : 0x00060330  A0      : 0x80049188  A1      : 0x3fceb640
A2      : 0x00000000  A3      : 0x3ff1e3fb  A4      : 0x00000001  A5      : 0x00000000
A6      : 0x00000000  A7      : 0x00000088  A8      : 0x800533dc  A9      : 0x3fceb620
A10     : 0xfffffffb  A11     : 0x3fceeebc  A12     : 0x3fceefbc  A13     : 0x00000000
A14     : 0x00000000  A15     : 0x00000006  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400570e8  LEND    : 0x400570f3  LCOUNT  : 0x00000000
Backtrace: 0x400511b1:0x3fceb640 0x40049185:0x3fceb670 0x400491e5:0x3fceb690 0x40043917:0x3fceb6b0 0x4004392a:0x3fceb6d0 0x40043c33:0x3fceb6f0 0x40034c45:0x3fceb710


What I am trying to do is enter DFU mode from firmware. Is that possible on the S3 chip at all?

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: esp_restart() results in Guru Meditation Error

Postby rtborg » Tue Jun 13, 2023 7:10 am

I would really appreciate input from ESP support here. I've spent a few days with no results and I need to know if I am on the wrong path.

levipope
Posts: 2
Joined: Thu Aug 31, 2023 10:09 pm

Re: esp_restart() results in Guru Meditation Error

Postby levipope » Thu Aug 31, 2023 10:50 pm

I am seeing that exact same error. I am not trying to reboot into DFU but rather in to serial download mode.
My app is using TinyUSB if that makes any difference. I was not sure if the USB peripheral needed to be reset somehow in that case.

Code: Select all

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x2 (DOWNLOAD(USB/UART0))
Saved PC:0x40375ba9
waiting for download
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
Core 0 register dump:
PC      : 0x400511b1  PS      : 0x00060330  A0      : 0x80049188  A1      : 0x3fceb640
A2      : 0x00000000  A3      : 0x3ff1e3fb  A4      : 0x00000001  A5      : 0x00000000
A6      : 0x00000000  A7      : 0x00000088  A8      : 0x800533dc  A9      : 0x3fceb620
A10     : 0xfffffffb  A11     : 0x3fceeebc  A12     : 0x3fceefbc  A13     : 0x00000000
A14     : 0x00000000  A15     : 0x00000006  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400570e8  LEND    : 0x400570f3  LCOUNT  : 0x00000000
Backtrace: 0x400511b1:0x3fceb640 0x40049185:0x3fceb670 0x400491e5:0x3fceb690 0x40043917:0
x3fceb6b0 0x4004392a:0x3fceb6d0 0x40043c33:0x3fceb6f0 0x40034c45:0x3fceb710

Who is online

Users browsing this forum: No registered users and 143 guests