Nuttx, Techblog

[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/ under nuttx/boards/[your board]/include
  • Create rcS file under etc/init.d/, in my example, the rcS 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 and nsh_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 in make menuconfig
    (1) Check File Systems->ROMFS file system
    (2) Check Application Configuration → NSH Library → NSH Library → Scripting Support->Support ROMFS start-up script
    (3) Select ROMFS header location as Architecture-specific ROMFS path, then it will find the nsh_romfsimg.h we have generated under nuttx/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

Leave a Reply

Your email address will not be published. Required fields are marked *