The stdin/stdout FILEs have an internal mutex which needs to be initted
to a FreeRTOS one, or any sketch with ::printf will hang. Automatically
create and acquire/release the shadowed mutex.
Requires new build of pico-quick-toolchain to function properly. Tested
on preliminary local build.
Fixes#795
Replace all CoreMutex and Newlib mutex accesses with FreeRTOS calls
when in FreeRTOS mode. Avoid issues with hange/etc. due to priority
inversion.
No changes to normal operating mode.
Add a FreeRTOS stress test that caught the issue fixed here.
Minor change to keep the core all CPP. Patch just made it into pico-sdk
develop branch allowing recursive mutexes to be auto_init in C++.
Update and rebuild libpico.a.
There was a race condition in making mutexes that were only init in
an __attribute((constructor)) code block. For example, a global
object might do a `malloc` in its constructor which would depend on
the malloc mutex...which may not yet have been initted.
Make them initted in the .data section, instead, which is guaranteed
good before any global constructors are called.
Instead of wrapping the memory functions in the link stage, rebuild
Newlib and enable retargetable locks. Override the weak definitions
in the libc.a with our own, SDK based ones.
The wrapping utilized before catches app-level memory allocations
but misses allocations inside Newlib libc (like printf/etc.).
Each core needs its own _impure_ptr or else crashes like the one seen
in parallel printf_floats can happen. Enable it in the toolchain
build and implement a simple swapper here.
FreeRTOS SMP doesn't support Newlib's dynamic reent which is needed
to allow save MT support. Minor patch to FreeRTOS and update the
FreeRTOS variant.cpp and setup to support it.