Now that we’ve installed Apache NuttX prerequisites and downloaded the source code, we are ready to compile the source code into an executable binary file that can be run on the embedded board.
- Initialize Configuration
The first step is to initialize Apache NuttX configuration for a given board, based from a pre-existing configuration. To list all supported configurations you can do:
./tools/configure.sh -L | grep spresense
The output is in the format :. You will see that there are various configurations but in general nsh configuration is a good starting point since it enables booting into the interactive command line NuttShell (NSH).
To choose a configuration, you pass the : option to configure.sh and indicate your host platform, such as:
./tools/configure.sh -l spresense:nsh
The -l tells use that we’re on Linux (macOS and Windows builds are possible). Use the -h argument to see all available options.
2. Customizing the features(optional)
Apache NuttX is 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).
3. Build NuttX
We can now build NuttX. To do so, you can simply run:
The build will complete by generating the binary outputs inside nuttx directory. Typically this includes the nuttx ELF file (suitable for debugging using gdb) and a spresense.spk file that can be flashed to the board.
To clean the build, you can do: