Configuring

Apache NuttX is a very configurable: nearly all features can be configured in or out of the system. This makes it possible to compile a build tailored for your hardware and application.

The Apache NuttX configuration system uses Linux’s kconfig system which includes various frontends that allow you to modify configuration easily. Usually, the menuconfig frontend is used, which is a console based menu system (more info here).

As previously explained in Compiling, the first step is to load a premade configuration for your board. Then, you can modify this configuration to your liking. In this example, we will show how you modify the default configuration of the sim build, a build of NuttX which runs on your own computer.

  1. Initialize Board Configuration

    $ cd nuttx
    $ ./tools/configure.sh -l sim:nsh
      Copy files
      Select CONFIG_HOST_LINUX=y
      Refreshing...
    
  2. Build & run

    $ make clean; make
    $ ./nuttx
    login:
    

    From another terminal window, kill the simulator:

    $ pkill nuttx
    
  3. Modify configuration

    In this case we will remove the login feature (which will boot straight to the prompt). To do so, we use the menuconfig frontend.

    $ make menuconfig
    

    Here’s what you should see:

    Screenshot of menuconfig system main screen


    The NSH Login setting is under Application Configuration ‣ NSH Library. You can use 🢁 and 🢃 keys to navigate and to enter a submenu. To disable the corresponding setting go to Console Login and press spacebar to it (so that it has a blank space instead of a star in it).

    Now you need to exit menuconfig and save the modified configuration. Use the 🡸 and 🡺 arrow keys to navigate the lower menu. If you select Exit you will be prompted to save the config.

  4. Build with the new Configuration

    $ make
    
  5. Run

    $ ./nuttx
    NuttShell (NSH) NuttX-8.2
    MOTD: username=admin password=Administrator
    

    Success!

Tip

If you find that message of the day (MOTD) annoying and want to turn that off, it’s configured in Application Configuration ‣ NSH Library ‣ Message of the Day (MOTD).

Fast configuration changes

If you know exactly which configuration symbol you want to change, you can use the kconfig-tweak tool (comes with the kconfig-frontends package) to quickly change a setting without going into the configuration frontend. This is useful to change settings such as debug options:

$ kconfig-tweak --disable CONFIG_DEBUG_NET
$ make olddefconfig  # needed to have the kconfig system check the config
$ kconfig-tweak --enable CONFIG_DEBUG_NET
$ make olddefconfig

This is also useful to script configuration changes that you perform often:

#!/bin/bash

kconfig-tweak --disable CONFIG_DEBUG_ALERT
kconfig-tweak --disable CONFIG_DEBUG_FEATURES
kconfig-tweak --disable CONFIG_DEBUG_ERROR
kconfig-tweak --disable CONFIG_DEBUG_WARN
kconfig-tweak --disable CONFIG_DEBUG_INFO
kconfig-tweak --disable CONFIG_DEBUG_ASSERTIONS
kconfig-tweak --disable CONFIG_DEBUG_NET
kconfig-tweak --disable CONFIG_DEBUG_NET_ERROR
kconfig-tweak --disable CONFIG_DEBUG_NET_WARN
kconfig-tweak --disable CONFIG_DEBUG_NET_INFO
kconfig-tweak --disable CONFIG_DEBUG_SYMBOLS
kconfig-tweak --disable CONFIG_DEBUG_NOOPT
kconfig-tweak --disable CONFIG_SYSLOG_TIMESTAMP
make oldconfig