-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
SPIFFS use core1/CPU1 and blocks the thread (hangs forever) (IDFGH-10593) #11830
Comments
Due to the fact that access to main SPI flash requires disabling the cache, the code running on the other core has to be preempted during flash operations. This mechanism relies on interrupts and IPC. Your code disables interrupts on the CPU1, therefore IPC never completes. |
How can I selectively disable cache on CPU1? My function requires constant execution, it reads pins and pulls them. This func can be placed in IRAM. |
At least on the ESP32 (which you are using) it is not possible. Cache can be enabled or disabled only for both CPUs.
There is no support for this use case in ESP-IDF. Please see #10410 as well. That said, you might be able to avoid CPU1 suspension if you use external SPI flash (over SPI2 or 3) for Spiffs and NVS. This way flash operations won't require the cache to be disabled, and CPU1 won't get interrupted. |
On which ESP32 is this possible? What is your opinion on the ESP32-Bare-Metal-AppCPU project? |
For example, on ESP32-C6 there is an LP core which is completely independent from the main core and doesn't run an RTOS. It still has access to the same peripherals and memory as the main core.
This should be possible with WROOM. You can connect 2nd SPI flash and use it for data storage, while the main flash will be used for code execution. You can try this using storage/ext_flash_fatfs example provided in IDF. Although the example is for FAT filesystem, SPIFFS and NVS can be used in a similar fashion.
Thanks for linking to it, I haven't seen it. I can't say whether that approach will work and if there would be any issue with it, sorry. When single core mode is used in IDF, various memory regions normally allocated to the 2nd CPU (for example, stack region used by the boot ROM) are released and used as part of the heap. It looks like this can cause heap corruption, if the 2nd CPU boots up after the heap is initialized. I am not sure how that projects deals with this issue.
There's a growing amount of examples and documentation for esp-hal which should help you get started, even though the code might not be written in C. If you find any particular pain points, please let us know and we'll try to improve it! |
Thanks for the quick replies! |
CPU interrupts are masked using registers which are internal to the CPU, and aren't accessible from the other CPU. You might be able to disable some specific peripheral interrupts on the peripheral side, but disabling them on the CPU side requires the code to run on the CPU itself, unfortunately. |
Understood thanks! |
Answers checklist.
IDF version.
v5.1
Operating System used.
Windows
How did you build your project?
Command line with CMake
If you are using Windows, please specify command line type.
CMD
Development Kit.
WROOM32E
Power Supply used.
USB
What is the expected behavior?
I expect SPIFFS will not use core1/CPU1
What is the actual behavior?
Looks like SPIFFS uses interrupts on core1/CPU1 invisibly and this blocks the thread (hangs forever)
Steps to reproduce.
Use the standard example http_server/file_serving
Add this code:
stat(filepath, &file_stat)
Debug Logs.
No response
More Information.
No response
The text was updated successfully, but these errors were encountered: