How to put your application to be called from NuttX terminal

In my previous post I explained how to compile NuttX to Freedom board, then a guy asked me how to add his application on NuttX. This tutorial will explain step by step how to do it.

It will use the Freedom Board (FRDM-KL25Z) as reference, but it could be adapted to any other board.

First add support to BUILT-IN applications on configs/freedom-kl25z/nsh/defconfig :


Also make sure CONFIG_BINFMT_DISABLE is not defined or is defined as NOT :


To make our life easy just use original “hello” example as base:

$ cd ..
$ cp -a apps/examples/hello apps/examples/myapp
$ cd apps/examples/myapp
$ mv hello_main.c myapp.c

Edit Kconfig file changing it to reflect your application name:

        bool "My First NuttX Application"
        default n
                Enable the \"MyAPP\" example


Edit Makefile replacing APPNAME and CSRCS to reflect our application name:

APPNAME         = myapp
CSRCS           = myapp.c

Also remember to edit your myapp.c replacing hello_main by myapp_main.

Edit apps/examples/Kconfig and add:

source "$APPSDIR/examples/myapp/Kconfig"

Edit apps/examples/Make.defs and add:

CONFIGURED_APPS += examples/myapp

Now you should to compile the frontend to kconfig interface:

$ cd ../misc/tools/kconfig-frontends
$ ./configure --enable-mconf
$ make
$ sudo make install

Inside nuttx directory execute this command to clear apps directory:

$ cd ../../../nuttx
$ make apps_distclean

Now execute the menuconfig to select your application:

$ make menuconfig

Choose “myapp” following this path:

Application Configuration  --->
    Examples  --->
        [*] My First NuttX Application

Now just compile everything:

$ make

Copy the firmware to the board and open the serial console:

NuttShell (NSH)

nsh> help
help usage:  help [-v] []

  ?           exec        help        ls          mw          usleep      
  cat         exit        hexdump     mb          ps          xd          
  echo        free        kill        mh          sleep       

Builtin Apps:

nsh> myapp
This is my first application!!


Next time you execute “make distclean” the “myapp” will be remove from compilation.

If you want to keep it in the final Nuttx firmware you need to add into configs/freedom-kl25z/nsh/defconfig :


That is it!!! Now keep going and create your nice application to run on NuttX!