Installing NuttX Tools and Source Code

To start developing on Apache NuttX, we need to get the source code, configure it, compile it, and get it uploaded onto an embedded computing board. These instructions are for Ubuntu Linux and macOS Catalina. If you’re using a different version, you may need to change some of the commands.

Prerequisites

Install prerequisites for building and using Apache NuttX (Linux)

  1. Install system packages

$ sudo apt install \
    bison flex gettext texinfo libncurses5-dev libncursesw5-dev \
    gperf automake libtool pkg-config build-essential gperf \
    libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
    libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux
  1. Give yourself access to the serial console device

    This is done by adding your Linux user to the dialout group:

$ sudo usermod -a -G dialout $USER
$ # now get a login shell that knows we're in the dialout group:
$ su - $USER

Install prerequisites for building and using Apache NuttX (macOS)

$ brew tap discoteq/discoteq
$ brew install flock
$ brew install x86_64-elf-gcc  # Used by simulator
$ brew install u-boot-tools  # Some platform integrate with u-boot

Install prerequisites for building and using Apache NuttX (Windows – WSL)

If you are are building Apache NuttX on windows and using WSL follow that installation guide for Linux. This has been verified against the Ubuntu 18.04 version.

There may be complications interacting with programming tools over USB. Recently support for USBIP was added to WSL 2 which has been used with the STM32 platform, but it is not trivial to configure: https://github.com/rpasek/usbip-wsl2-instructions

Install prerequisites for building and using Apache NuttX (Windows – Cygwin)

Download and install Cygwin using the minimal installation in addition to these packages:

make              bison             libmpc-devel
gcc-core          byacc             automake-1.15
gcc-g++           gperf             libncurses-devel
flex              gdb               libmpfr-devel
git               unzip             zlib-devel

Install Required Tools (All Platforms)

There are a collection of required tools that need to be built to build most Apache NuttX configurations:

$ mkdir buildtools
$ export NUTTXTOOLS=`pwd`/buildtools
$ export NUTTXTOOLS_PATH=$NUTTXTOOLS/bin:$NUTTXTOOLS/usr/bin
$ git clone https://bitbucket.org/nuttx/tools.git tools

NOTE: You will need to add NUTTXTOOLS_PATH to your environment PATH

  1. Install kconfig-frontends tool

This is necessary to run the ./nuttx/tools/configure.sh script as well as using the ncurses-based menuconfig system.

$ cd tools/
$ cd kconfig-frontends
$ ./configure --prefix=$NUTTXTOOLS \
     --enable-mconf --disable-gconf --disable-qconf
$ touch aclocal.m4 Makefile.in
$ make
$ make install
  1. Install gperf tool (optional)

$ cd tools/
$ wget http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz
$ tar zxf gperf-3.1.tar.gz
$ cd gperf-3.1
$ ./configure --prefix=$NUTTXTOOLS
$ make
$ make install
  1. Install gen-romfs (optional)

$ cd tools/
$ tar zxf genromfs-0.5.2.tar.gz
$ cd genromfs-0.5.2
$ make install PREFIX=$NUTTXTOOLS

Install a Cross-Compiler Toolchain

This is the software you will use to actually compile NuttX. The official NuttX version of this for different platforms is located here: NuttX installation instructions.

Get Source Code (Development)

Apache NuttX is actively developed on GitHub. If you want to use it, modify it or help develop it, you’ll need the source code.

The Jupiter Nano support branch from the NuttX clone in the Starcat GitHub repository has not been merged into the Apache NuttX mainline yet, so you will need to clone the Starcat version for now:

$ mkdir nuttx
$ cd nuttx
$ # Starcat version of NuttX
$ git clone https://github.com:starcat-io/incubator-nuttx.git nuttx
$ # no changes to apps are needed, so you can clone the regular version:
$ git clone https://github.com/apache/incubator-nuttx-apps apps
$ # now switch to the Jupiter Nano support branch
$ cd nuttx
$ git checkout feature/jupiter-nano-support

Later if we want to make modifications (for instance, to improve NuttX and save them in our own branch, or submit them back to the project), we can do that easily. It’s covered in the NuttX documentation under Contributing.

Here’s a link to the official Apache NuttX GitHub repository – as noted, this does not yet have Jupiter Nano support integrated yet.

Get Source Code (Stable)

Apache NuttX releases are published on the project Downloads page and distributed by the Apache mirrors. Be sure to download both the nuttx and apps tarballs.

The nuttx tarballs will not have the Jupiter Nano changes in them. The app release tarballs can be used as-is because no Jupiter Nano specific modifications are needed.


Next: Compiling NuttX