High-level stdio is not beginner friendly when they use asserts #20626
Description
When novice users use boards with high-level IO (eg. nrf52840-feather), they don't get good crash feedback -- system is just gone. From @MrKevinWeiss's experience, many occurrences of this happens with asserts failing. (Other than that, RIOT is rather stable, it doesn't "just" run into a hard fault).
So what do?
-
Use low level stdio? No thanks. It's not the 1990s any more, RS232 is not a prevalent connection any more, and why just add extra hardware onto devices just to compensate for software shortcomings?
-
We could improve stdio to stay usable in crash situations. There is a viable path -- high-level stdio usually have some kind of buffer, flags that to not be cleared out at startup, and coordinates that with the bootloader. The latter may be tricky especially in the nrf52840-feather case because that uses the nrfutil-adafruit bootloader which we don't control.
-
Change how an assert crashes. Compare to Rust: If a Rust panic happens in an ISR or while interrupts are off, it calls core_panic which halts or reboots the system. But in the common case of thread mode, it merely prints the error message and the sends the thread into an endless loop of thread_sleep. Unlike a full crash, this has a good chance of leaving the high-level stdio usable. (Sure, a crash in a CoAP handler will not be usable by a CoAP based stdio, but well with a USB based and vice versa).
Doing this for asserts won't break deployments because the design intention with them is to be only used during development; we could even consider taking it further by looking at other places that call core_panic to see whether they'd also be eligible (i.e., whether the corruption they correspond to is sure to be limited to the thread they are in), but let's focus on asserts first.
I suggest we go with 3., while leaving 2 as an option for further enhancement.
CC'ing @MrKevinWeiss and @bergzand who supported this during a chat, and @mguetschow who was also there but I don't remember if he supported it :-)