The new implementation of set_errno require all thread(include IDLE) initialize the stack related fields in tcb_s correctly. But many chipset forget to setup them for IDLE thread. TODO contain an item described this:
... snip ...
Hello, I think there's a problem with set_errno() in nx_start(), when CONFIG_TLS_ALIGNED is not set: I disabled SERIAL_CONSOLE and DEV_CONSOLE, because I wanted to test CDCACM_CONSOLE. Now calling fs_fdopen() in group_setupstreams() leads to a call of set_errno().
In addition, nothing within the OS should ever set the errno value. So the first bug is the fs_fdopen() should not call set_errno();
It is a secondary problem that the stack data is not initialized. It should never be needed for the purpose errno access since no logic in the OS should ever access the errno.
Greg