This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new d9454d89d system/nxinit: Give the builtin list to the kernel in a
protected build.
d9454d89d is described below
commit d9454d89d02eb9154e332a4393cfcb5e96a2fefb
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 21 17:21:32 2026 +0200
system/nxinit: Give the builtin list to the kernel in a protected build.
In a protected build the kernel cannot read the list of builtin
applications in user space: the binfmt builtin loader uses its own
copy, which user space must set with boardctl(BOARDIOC_BUILTINS). NSH
starts a builtin without the loader, so it never needed this, but
nxinit starts each service with posix_spawnp(). esp32s3-devkit:knsh,
which uses nxinit as init, therefore never got a shell:
Error Starting service 'console': 2
init_main() now gives the list to the kernel first.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
system/nxinit/init.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/system/nxinit/init.c b/system/nxinit/init.c
index d0329a114..2400edb12 100644
--- a/system/nxinit/init.c
+++ b/system/nxinit/init.c
@@ -37,6 +37,7 @@
#include <sys/param.h>
#include <sys/wait.h>
+#include <nuttx/lib/builtin.h>
#include <nuttx/usb/usbdev_trace.h>
#include "action.h"
@@ -196,6 +197,30 @@ static int init_boot_reason(FAR struct action_manager_s
*am)
# define init_boot_reason(am) (0)
#endif
+/****************************************************************************
+ * Name: init_builtins
+ *
+ * Description:
+ * In a protected build the kernel cannot read the list of builtin
+ * applications in user space, so posix_spawn() of a builtin fails with
+ * ENOENT until the list is given to the kernel.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_BUILTIN) && \
+ defined(CONFIG_BOARDCTL)
+static void init_builtins(void)
+{
+ struct boardioc_builtin_s builtin;
+
+ builtin.builtins = g_builtins;
+ builtin.count = g_builtin_count;
+ boardctl(BOARDIOC_BUILTINS, (uintptr_t)&builtin);
+}
+#else
+# define init_builtins()
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -242,6 +267,8 @@ int main(int argc, FAR char *argv[])
size_t i;
int r;
+ init_builtins();
+
#ifdef CONFIG_BMP
snprintf(ACTION_TRIGGER_KEY(&am), sizeof(ACTION_TRIGGER_KEY(&am)),
ACTION_PROP_KEY_TRIGGER ".core%d", sched_getcpu());