NMI Irq error paths call into printf which will use the newlib locks
but these can not be used within the NMI, a task switch can not occur
here. This case would be a terminal error path that is attempting to
write some debug message in the process, so just bail out of the
locking in this case. As a warning a ':' character is emitted and this
will typically prefix lines emitted in this context - it would be an
error for this path to be take in normal operation.
The locks are using a bit of the limited ram. It's probably fine to combine some
of these to use the same mutex, and this patch does so for the set initialized
early. The file locks will still be separate, and dynamically created, so a
thread blocking on them will not deadlock all uses of newlib that need a lock.
This patch gets the newlib standard stream descriptors playing well with the
lwip socket descriptors and the spiffs file descriptors. The LWIP_SOCKET_OFFSET
is now defined to be 3, rather than zero, to avoid clashing with the standard
stream descriptors, and the SPIFFS_FILEHDL_OFFSET is bumped up to start after
the lwip descriptors.
* Allow changing write function of stdout.
Required for stdout redirection.
Works on blocks, not chars - does _not_ use sdk_os_putc !
Should work even when linking with SPIFFS.
Also reduces the IRAM footprint of the fatal exception handler, as only
the prelude (which disables interrupts & enables the flash mapping) is
in IRAM now.
Closes#54, relevant to #133.
Prerequisite for calling Cache_Read_Disable() for OTA updates.
Massive thanks due to @foogod and their xtobjdis tool, creating the call
graph of where the wDev_ProcessFiq touched (including in newlib, etc.)
would have otherwise been very painful:
https://bitbucket.org/foogod/xtobjdis