From 52baca0a893a093f60ccc38b10e57aff0379606e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 29 Aug 2024 20:00:21 +0900 Subject: [PATCH] Increase the chance for _assert to work early in the boot --- sched/misc/assert.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sched/misc/assert.c b/sched/misc/assert.c index 31419abaec..921a8422e8 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -569,6 +570,7 @@ static void pause_all_cpu(void) void _assert(FAR const char *filename, int linenum, FAR const char *msg, FAR void *regs) { + const bool os_ready = OSINIT_OS_READY(); FAR struct tcb_s *rtcb = running_task(); #if CONFIG_TASK_NAME_SIZE > 0 FAR struct tcb_s *ptcb = NULL; @@ -585,14 +587,18 @@ void _assert(FAR const char *filename, int linenum, } #endif - flags = enter_critical_section(); + flags = 0; /* suppress GCC warning */ + if (os_ready) + { + flags = enter_critical_section(); + } if (g_fatal_assert) { goto reset; } - if (fatal) + if (os_ready && fatal) { #ifdef CONFIG_SMP pause_all_cpu(); @@ -738,5 +744,8 @@ reset: #endif } - leave_critical_section(flags); + if (os_ready) + { + leave_critical_section(flags); + } }