Hi, I am working on a project required to erase/write flash memory on Raspberry Pi Pico inside a FreeRTOS task. I know in order to erase/write flash I need to disable interrupt, I tried wrap around flash function with taskENTER_CRITICAL() and taskExit_CRITICAL() but no luck, still freeze when flash erase is call. I removed FreeRTOS and just run the flash code by itself, it works fine. Below is the snippet of the flash function I am using.
Thanks for the reply, is there a way to disable interrupt for both core? I don’t have anything running on second core yet. I thought about could be the issue with second core but I didn’t find any info on it.
I don’t know the SMP code well enough to say, but it is unlikely. If you don’t need the second core, maybe you should just be running in single processor mode on just one core.
I didn’t try the single core version of FreeRTOS yet, not sure if thats the issue. I don’t have a debugger set up yet, I need to figure out how to add debugging flag in my CMake.
I have same problem.
The debug breakpoint information was as follows.
Please let me know what additional GDB information you need and I will try to find more.
The call stack is of the idle task. We need to find what happened to the task that called flash erase. Can you see if that task is on the ready list? Also, have you defined configASSERT and enabled stack overflow check?
Thanks for your answer.
I am studying the ready list and assert you mentioned.
However, I have a question because there are some things that occur in common.
When a function located in RAM is called from Rtos, the operation stops as shown below.
The save_to_flash() function was located in RAM and when executed, the OS stopped operating. The flash_range_erase() function we asked about earlier is also located in RAM.
I wonder if there is a way to reliably execute functions located in RAM(0x20000000 over). (RP2040, pico w)
When using RTOS in pico_sdk, there is a flash_safe_execute(…) function in flash.c for using flash. I solved the current problem using this function. Thanks a lot for your help.