From 3430ad2e1ca113cd0a34b1753840617a8da0dc83 Mon Sep 17 00:00:00 2001 From: wangchengdong Date: Wed, 27 Aug 2025 19:42:21 +0800 Subject: [PATCH] sched/init/nx_bringup.c: Add support for CONFIG_INIT_NONE in a flat build In a flat build, a separate init thread should not be mandatory, users can create a user task in the board early initialization or late initialization hook. --- sched/init/nx_bringup.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c index 336fad5ed4..5ba9806df9 100644 --- a/sched/init/nx_bringup.c +++ b/sched/init/nx_bringup.c @@ -65,10 +65,9 @@ /* Configuration */ #if defined(CONFIG_INIT_NONE) - /* Kconfig logic will set CONFIG_INIT_NONE if dependencies are not met */ - -# error No initialization mechanism selected (CONFIG_INIT_NONE) - +# ifndef CONFIG_BUILD_FLAT +# error No initialization mechanism selected (CONFIG_INIT_NONE) +# endif #else # if !defined(CONFIG_INIT_ENTRY) && !defined(CONFIG_INIT_FILE) /* For backward compatibility with older defconfig files when this was @@ -326,6 +325,14 @@ static inline void nx_start_application(void) coredump_initialize(); #endif +#ifdef CONFIG_INIT_NONE + + UNUSED(ret); + + /* In a flat build, init thread is not mandatory */ + + sinfo("No init thread\n"); +#else posix_spawnattr_init(&attr); attr.priority = CONFIG_INIT_PRIORITY; attr.stacksize = CONFIG_INIT_STACKSIZE; @@ -378,6 +385,7 @@ static inline void nx_start_application(void) #endif posix_spawnattr_destroy(&attr); DEBUGASSERT(ret > 0); +#endif /* CONFIG_INIT_NONE */ } /****************************************************************************