ESP32S3 - Enabling CONFIG_FREERTOS_USE_TICK_HOOK causes nvs_flash_init() to panic

User avatar
dmarks_ls
Posts: 6
Joined: Fri Feb 10, 2023 4:56 pm

ESP32S3 - Enabling CONFIG_FREERTOS_USE_TICK_HOOK causes nvs_flash_init() to panic

Postby dmarks_ls » Mon May 08, 2023 10:41 pm

I've run into a rather perplexing issue. I've been developing an app on an ESP32-S3 in C and C++, using SPI and I2C and other facilities, all working fine. I then folded in code to run the Wi-Fi interface, based on the simple "station" example in IDF v5.0.1. Unfortunately, I found that my app would immediately panic at startup. I traced the panic to nvs_flash_init(); the message is:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed).

Core  0 register dump:
PC      : 0x42070e12  PS      : 0x00060034  A0      : 0x8037cea6  A1      : 0x3fc98870
A2      : 0x00000001  A3      : 0x3fc9ab84  A4      : 0x004c0000  A5      : 0x00070000
A6      : 0x00000000  A7      : 0x3fc9b070  A8      : 0x8037e6ce  A9      : 0x3fc98850
A10     : 0x3fc9ab20  A11     : 0x3fc9ab20  A12     : 0x00060021  A13     : 0x00060023
A14     : 0x00000000  A15     : 0x0000cdcd  SAR     : 0x0000000f  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0xffffffff

Backtrace:  <lots of backtrace hex>
Well, great. Question is, what's causing it? I found I could run the "station" example by itself, and it would run fine. After figuring out I could copy over all my SDK settings without any code from my custom project and make the example crash, I worked by process of elimination and determined that turning on CONFIG_FREERTOS_USE_TICK_HOOK would cause my app to crash when nvs_flash_init() is called. If I disable that option, my app works fine. Yes, I added void vApplicationTickHook(void) { } to my app.

I've attached my demo project. The sdkconfig.defaults as provided should result in a working app. Then delete sdkconfig, uncomment the option, and rebuild, and you should see the core panic. Can someone explain why adding the tick hook causes a core panic when initializing NVS? I kinda want to use the tick hook facility to run my own tick timer. Unless someone has a different way of attaching to the SysTick timer while running FreeRTOS...

Dana M.
Attachments
wifi_station_bug_demo.zip
(7.78 KiB) Downloaded 171 times

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32S3 - Enabling CONFIG_FREERTOS_USE_TICK_HOOK causes nvs_flash_init() to panic

Postby ESP_Sprite » Tue May 09, 2023 5:22 pm

Iirc the tick hook runs from interrupt context, meaning you should make sure the hook and anything it calls or uses should be in IRAM.

User avatar
dmarks_ls
Posts: 6
Joined: Fri Feb 10, 2023 4:56 pm

Re: ESP32S3 - Enabling CONFIG_FREERTOS_USE_TICK_HOOK causes nvs_flash_init() to panic

Postby dmarks_ls » Wed May 10, 2023 2:05 pm

Aye, I soon discovered/realized that as I was waiting for my post to be approved. I also discovered that ESP has a whole separate API for tick and idle hooks that handles multi-core (esp_freertos_hooks.h). Determined that I can turn off the CONFIG_FREERTOS_USE_TICK_HOOK flag and instead use esp_register_freertos_tick_hook_for_cpu(). Thanks!

Dana M.

Who is online

Users browsing this forum: No registered users and 110 guests