4fdf795efa
Because vPortCleanUpTCB is called by the FreeRTOS idle task, and it checks thread, but didn't check the thread_mutex. And if thread is not NULL, but thread_mutex not ready then it will crash with an error when calling mp_thread_mutex_lock(&thread_mutex, 1). As suggested by @dpgeorge, move the thread = &thread_entry0 line to the end of mp_thread_init(). Signed-off-by: leo chung <gewalalb@gmail.com>