[Techblog] Creating startup application for nuttx
Creating startup app for nuttx is actually simple, but not well documented on the official website. Follow those steps:
- Create folder
etc/init.d/
undernuttx/boards/[your board]/include
- Create
rcS
file underetc/init.d/
, in my example, thercS
path would like like:nuttx/boards/arm/stm32/stm32f407vgt6/include/etc/init.d/rcS
- Populate
rcS
with your start up script content, for example:
mount -t vfat /dev/mmcsd0 /mnt/fs
myapp &
Nuttx supports running app in the background, that is how myapp &
come.
- Under the path
nuttx/boards/[your board]/include
, generate romfs file andnsh_romfsimg.h
:
genromfs -f romfs_img -d etc
xxd -i romfs_img >nsh_romfsimg.h
-
Then include
nsh_romfsimg.h
in your image, let nuttx support romfs inmake menuconfig
(1) CheckFile Systems
->ROMFS file system
(2) CheckApplication Configuration → NSH Library → NSH Library → Scripting Support
->Support ROMFS start-up script
(3) SelectROMFS header location
asArchitecture-specific ROMFS path
, then it will find thensh_romfsimg.h
we have generated undernuttx/boards/[your board]/include
It should look like:[ ] Disable script support [ ] Disable if-then-else-fi [ ] Disable loops [*] Support ROMFS start-up script [ ] Support ROMFS login script (/etc) ROMFS mount point (init.d/rc.sysinit) Relative path to sysinit script (init.d/rcS) Relative path to startup script (0) ROMFS block device minor number (64) ROMFS sector size ROMFS header location (Architecture-specific ROMFS path) ---> (1) FAT block device minor number (512) FAT sector size (1024) FAT number of sectors (/tmp) FAT mount point () rcS redirect output
-
The next make would include the startup script in your system, and it can be checked under
etc/init.d/rcS
in your board console