Increase the chance for _assert to work early in the boot

This commit is contained in:
YAMAMOTO Takashi 2024-08-29 20:00:21 +09:00 committed by Xiang Xiao
parent 1086a05e50
commit 52baca0a89

View File

@ -28,6 +28,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include <nuttx/coredump.h> #include <nuttx/coredump.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/init.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/tls.h> #include <nuttx/tls.h>
#include <nuttx/signal.h> #include <nuttx/signal.h>
@ -569,6 +570,7 @@ static void pause_all_cpu(void)
void _assert(FAR const char *filename, int linenum, void _assert(FAR const char *filename, int linenum,
FAR const char *msg, FAR void *regs) FAR const char *msg, FAR void *regs)
{ {
const bool os_ready = OSINIT_OS_READY();
FAR struct tcb_s *rtcb = running_task(); FAR struct tcb_s *rtcb = running_task();
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
FAR struct tcb_s *ptcb = NULL; FAR struct tcb_s *ptcb = NULL;
@ -585,14 +587,18 @@ void _assert(FAR const char *filename, int linenum,
} }
#endif #endif
flags = enter_critical_section(); flags = 0; /* suppress GCC warning */
if (os_ready)
{
flags = enter_critical_section();
}
if (g_fatal_assert) if (g_fatal_assert)
{ {
goto reset; goto reset;
} }
if (fatal) if (os_ready && fatal)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
pause_all_cpu(); pause_all_cpu();
@ -738,5 +744,8 @@ reset:
#endif #endif
} }
leave_critical_section(flags); if (os_ready)
{
leave_critical_section(flags);
}
} }