-
Notifications
You must be signed in to change notification settings - Fork 447
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
PicoW hang during init when using FreeRTOS #1394
Comments
From the discussion.... 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
|
Moved to an issue since we have a nice simple MCVE! |
Fixes #1394 The Pico_Rand SDK calls gather bits from the HW ROSC at precise intervals. If there is jitter in the sleep_until() call then the ROSC bit collection will always think it's failed to acquire the right bit and retry infintitely. Avoid by wrapping the HW random number calls and the sleep_until() routine. Only when in FreeRTOS set a flag to silently make sleep_until() into a busy wait loop while in a random number generation step. When not in the random code, do the normal sleep_until call.
Fixes #1394 The Pico_Rand SDK calls gather bits from the HW ROSC at precise intervals. If there is jitter in the sleep_until() call then the ROSC bit collection will always think it's failed to acquire the right bit and retry infintitely. Avoid by wrapping the HW random number calls and the sleep_until() routine. Only when in FreeRTOS set a flag to silently make sleep_until() into a busy wait loop while in a random number generation step. When not in the random code, do the normal sleep_until call.
Fixes #1394 The Pico_Rand SDK calls gather bits from the HW ROSC at precise intervals. If there is jitter in the sleep_until() call then the ROSC bit collection will always think it's failed to acquire the right bit and retry infintitely. Avoid by wrapping the HW random number calls and the sleep_until() routine. Only when in FreeRTOS set a flag to silently make sleep_until() into a busy wait loop while in a random number generation step. When not in the random code, do the normal sleep_until call.
Discussed in #1390
Originally posted by ruifig April 22, 2023
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.
The text was updated successfully, but these errors were encountered: