Repository navigation
system/nxinit: Give the builtin list to the kernel in a protected build. - #3907
Conversation
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 <marco.casaroli@gmail.com>
cederom
left a comment
There was a problem hiding this comment.
Thank you @casaroli :-)
@JianyuWang0623 @linguini1 @michallenc @FelipeMdeO could you please take a look?
LGTM, good catch, thank you! This reminds me that a set of changes from @anjiahao1 (with a follow-up fix from @yeungao) addresses the same problem on the kernel side: the protected kernel reads the builtin list directly through |
|
Congratulations Casaroli. |
|
@casaroli Thanks again for tracking this down! The NuttX-side fix has now been merged: apache/nuttx#20964. The protected kernel now reads the builtin list directly through I had a similar idea earlier (#3821), but with the kernel change in place this PR no longer seems necessary. |
Summary
In a protected build the kernel cannot read the list of builtin applications in user space. The binfmt builtin loader uses its own copy of the list, which user space must set with
boardctl(BOARDIOC_BUILTINS). NSH starts a builtin withtask_spawn()and does not use the loader, so it never needed this. nxinit starts each service withposix_spawnp(), which goes through the loader, so in a protected build every builtin service fails withENOENT.esp32s3-devkit:knshuses nxinit as init and never gets a shell:init_main()now gives the list to the kernel first, whenCONFIG_BUILD_PROTECTED,CONFIG_BUILTINandCONFIG_BOARDCTLare set.Impact
nxinit in protected builds only. Flat and kernel builds do not compile the new code.
Testing
ESP32-S3-DevKitC with an ESP32-S3-WROOM-2-N32R8V (
esp32s3-devkit:knsh, protected build, stock defconfig with nxinit as init, plusCONFIG_TESTING_OSTEST), nuttx master:Error Starting service 'console': 2in a loop, no shellsh, NSH promptostesttools/checkpatch.sh -c -u -m -gpasses.