Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 Core 1 panic when going into deep sleep (QEMU-223) #105

Open
3 tasks done
InRiPa opened this issue Nov 11, 2024 · 1 comment
Open
3 tasks done

ESP32 Core 1 panic when going into deep sleep (QEMU-223) #105

InRiPa opened this issue Nov 11, 2024 · 1 comment

Comments

@InRiPa
Copy link

InRiPa commented Nov 11, 2024

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

Getting into deep sleep with a timer setup previously.

Actual behavior (suspected bug)

Guru Meditation Error: Core 1 panic'ed (LoadStorePIFAddrError). Exception was unhandled.

Error logs or terminal output

I (12415) boot: ESP-IDF v5.3-357-g6568f8c553 2nd stage bootloader
I (12416) boot: compile time Nov 11 2024 15:43:57
I (12416) boot: Multicore bootloader
I (12435) boot: chip revision: v0.0
I (12438) boot.esp32: SPI Speed      : 40MHz
I (12439) boot.esp32: SPI Mode       : DIO
I (12439) boot.esp32: SPI Flash Size : 2MB
I (12450) boot: Enabling RNG early entropy source...
I (12462) boot: Partition Table:
I (12462) boot: ## Label            Usage          Type ST Offset   Length
I (12463) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (12464) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (12464) boot:  2 factory          factory app      00 00 00010000 00100000
I (12470) boot: End of partition table
I (12477) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0a584h ( 42372) map
I (12507) esp_image: segment 1: paddr=0001a5ac vaddr=3ff80063 size=00008h (     8) load
I (12526) esp_image: segment 2: paddr=0001a5bc vaddr=3ffb0000 size=023e4h (  9188) load
I (12549) esp_image: segment 3: paddr=0001c9a8 vaddr=40080000 size=03670h ( 13936) load
I (12578) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=1506ch ( 86124) map
I (12618) esp_image: segment 5: paddr=00035094 vaddr=40083670 size=0a494h ( 42132) load
I (12661) esp_image: segment 6: paddr=0003f530 vaddr=400c0000 size=00064h (   100) load
I (12679) esp_image: segment 7: paddr=0003f59c vaddr=50000000 size=00004h (     4) load
I (12700) boot: Loaded app from partition at offset 0x10000
I (12701) boot: Disabling RNG early entropy source...
I (12723) cpu_start: Multicore app
I (17231) cpu_start: Pro cpu start user code
I (17232) cpu_start: cpu freq: 160000000 Hz
I (17232) app_init: Application information:
I (17232) app_init: Project name:     esp32-idf-mastering-rtos
I (17232) app_init: App version:      a1047cf-dirty
I (17233) app_init: Compile time:     Nov 11 2024 15:43:48
I (17233) app_init: ELF file SHA256:  165488e867d81688...
I (17233) app_init: ESP-IDF:          v5.3-357-g6568f8c553
I (17234) efuse_init: Min chip rev:     v0.0
I (17234) efuse_init: Max chip rev:     v3.99 
I (17234) efuse_init: Chip rev:         v0.0
I (17235) heap_init: Initializing. RAM available for dynamic allocation:
I (17237) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (17237) heap_init: At 3FFB2CD8 len 0002D328 (180 KiB): DRAM
I (17237) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (17238) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (17238) heap_init: At 4008DB04 len 000124FC (73 KiB): IRAM
I (17282) spi_flash: detected chip: gd
I (17289) spi_flash: flash io: dio
W (17300) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (17309) main_task: Started on CPU0
I (17319) main_task: Calling app_main()
I (17319) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[26]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[25]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (17319) gpio: GPIO[33]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
W (17329) SLEEP_DEEPTIMER: Wakeup was not caused by deep sleep: 0

I (17329) Main: I got called by IDF initially and now I'm done here!
I (17329) main_task: Returned from app_main()
I (20329) SLEEP_DEEPTIMER: Tick count before sleep: 302
I (20329) SLEEP_DEEPTIMER: Going to sleep for 30 Seconds
Guru Meditation Error: Core  1 panic'ed (LoadStorePIFAddrError). Exception was unhandled.

Core  1 register dump:
PC      : 0x400847ba  PS      : 0x00060233  A0      : 0x80084978  A1      : 0x3ffb5360  
A2      : 0x000001e3  A3      : 0x00000001  A4      : 0x00000000  A5      : 0x01c9c1f0  
A6      : 0x00000003  A7      : 0x00000000  A8      : 0x3ff80064  A9      : 0x3ffb5340  
A10     : 0x3ffb5360  A11     : 0x0000000a  A12     : 0x00029fff  A13     : 0x00000000  
A14     : 0x00000002  A15     : 0x00000001  SAR     : 0x00000009  EXCCAUSE: 0x0000000f  
EXCVADDR: 0x3ff80064  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffc  


Backtrace: 0x400847b7:0x3ffb5360 0x40084975:0x3ffb53b0 0x400849b5:0x3ffb53d0 0x400d5fac:0x3ffb53f0 0x40086ee1:0x3ffb5410




ELF file SHA256: 165488e867d81688

Rebooting...



-------------------------
-------------------------
$ ./print_trace.sh 0x400847b7:0x3ffb5360 0x40084975:0x3ffb53b0 0x400849b5:0x3ffb53d0 0x400d5fac:0x3ffb53f0 0x40086ee1:0x3ffb5410
0x400847b7: misc_modules_sleep_prepare at /opt/esp/idf/components/esp_hw_support/sleep_modes.c:670 (discriminator 1)
 (inlined by) esp_sleep_start at /opt/esp/idf/components/esp_hw_support/sleep_modes.c:846 (discriminator 1)
0x40084975: deep_sleep_start at /opt/esp/idf/components/esp_hw_support/sleep_modes.c:1163
0x400849b5: esp_deep_sleep_start at /opt/esp/idf/components/esp_hw_support/sleep_modes.c:1187
0x400d5fac: vDeepSleeperTask at /home/esp/projects/esp32-idf-mastering-rtos/components/rtostasks/task_sleep_deeptimer.c:34
0x40086ee1: vPortTaskWrapper at /opt/esp/idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134

Steps to reproduce the behavior

static const char *TAG = "SLEEP_DEEPTIMER";
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 30       /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int bootCount = 0;

void vDeepSleeperTask(void *pvParameters)
{
    TickType_t xTickCountBefore = xTaskGetTickCount();

    for (;;)
    {
        vTaskDelay(pdMS_TO_TICKS(3000));
        // Get and print current tick count
        xTickCountBefore = xTaskGetTickCount();
        ESP_LOGI(TAG, "Tick count before sleep: %lu", xTickCountBefore);

        // Set up the TIMER as a wake-up source
        esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
        ESP_LOGI(TAG, "Going to sleep for %d Seconds", TIME_TO_SLEEP);

        /* Enter the low power state. */
        esp_deep_sleep_start();

        ESP_LOGE(TAG, "Should never get here!");
    }
}
int app_main(void)
{
     print_wakeup_reason();

    xTaskCreatePinnedToCore(vDeepSleeperTask, "sleeper", 2048, NULL, 3, NULL, portNUM_PROCESSORS - 1);

    ESP_LOGI(TAG, "I got called by IDF initially and now I'm done here!");
    /* Will not reach here. */
    return 0;
}

Project release version

ESP-IDF v5.3-357-g6568f8c553

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Linux

Operating system version

FROM espressif/idf:release-v5.3

Shell

sh

Additional context

I'm not sure, maybe I'm using the deep sleep wrongly, but I also checked some online examples, and the setup seemed pretty much the same. Following the minimal example for a classic esp32.

  1. I checked existing and closed tickets for esp_deep_sleep_start.
  2. I checked the wiki for potential issues to respect in regards to deep sleep.
  3. Checked the version: /opt/esp/tools/qemu-xtensa/esp_develop_9.0.0_20240606/qemu/bin/qemu-system-xtensa
@github-actions github-actions bot changed the title ESP32 Core 1 panic when going into deep sleep ESP32 Core 1 panic when going into deep sleep (QEMU-223) Nov 11, 2024
@igrr
Copy link
Member

igrr commented Nov 14, 2024

Hi @InRiPa,
We haven't implemented any sleep-related functionality in QEMU yet. The exception (LoadStorePIFAddrError) happens because the sleep driver in IDF is trying to write to a peripheral which isn't defined in the emulator.

Since from software perspective a deep sleep is almost like a software reset (just with a variable amount of time until the next boot), I would recommend replacing the deep sleep entry with a call to esp_restart, when building for QEMU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants