Replies: 2 comments
-
Can you grab both cores' stacks to see where everything is at? The FreeRTOS here is SMP (and it is pre-emptive) and the Pico-SDK 1.5 added a new random generator module. I would guess that it's not compatible with either multiple cores or multi-threads on the same core calling it. The task switching in SMP FreeRTOS used the PendSV exception and is pretty heavy handed. Extreme blocking was required to get any flash accesses going (since both cores not only need to be stopped in RAM loops, the PendSV exception...which is not maskable...needs to not switch out the tasks on either core). FWIW, you will need to make sure only core0 is used to access any WiFi-related calls. That's a function of the hardware/SDK (the SDK assumes Core0 AIUI, and even if it didn't then the necessary IRQs/mutexes/etc. would not work if you tried doing anything related to WiFi on the other core). Re: the WDT task you're running, I'm not so sure it's really a good idea to ping the WDT in a |
Beta Was this translation helpful? Give feedback.
-
Seems like the other core is not doing anything yet: Also, figured out why the sample application worked and my real application didn't.
The sample application was setup to use a Pico while my real application uses a PicoW. Regarding pinging the WDT in a while loop in a separate task, that's just a workaround to avoid the WTD triggering while calling code that takes too long and I can't or don't want to change, like connecting to WiFi. So, back to the freeze, seems like the easiest way to repro this is to simply create a minimal application for PicoW and include the FreeRTOS.h header. It has nothing to do with using the WTD. That was just a coincidence.
My platformio.ini
|
Beta Was this translation helpful? Give feedback.
-
I'm experimenting with adding FreeRTOS tasks.
With a minimal application it works fine but with my actual project, it's freezing at startup with this callstack:
Still investigating to see if I can pinpoint why it works with one and fails with another, but any tips are welcome if this rings any bells. :)
The only thing that crosses my mind is that maybe I have some global objects with non-trivial constructors that somehow messes things up before main is called, but don't think that's the case.
For context, what I'm trying to do is to make use of the rp2040 watchdog in my application, which works fine using Arduino-Pico's
rp2040
object.But as far I've noticed, there is no way to disable the watchdog once enabled, so if we call into any third-party code or Arduino-Pico's code that takes too long to complete, like for example connecting to Wifi, then there a good chance it will trigger a watchdog reboot.
The workaround I'm trying is to create a very simple FreeRTOS task that allows me to implement a watchdog pause of sorts.
For example, I created a task like this (stays suspended)
Under normal circumstances, my application calls
rp2040.wtd_reset()
periodically, then when I know I'm calling code that potentially can take longer than 8300ms, I wrap that code with a vTaskResume / vTasSuspend to enable/disable the watchdog auto reset.This is all working fine with a minimal(ish) sample application I was playing around with, but with my actual application if freezes at startup as explained above.
I know this won't work with cooperative multitasking (I think Arduino-Pico's FreeRTOS uses cooperative, right?), but I'm not too bothered, since Wifi code does a few delays when connecting.
Beta Was this translation helpful? Give feedback.
All reactions