Installing

The first step to get started with NuttX is to install a series of required tools, a toolchain for the architecture you will be working with and, finally, download NuttX source code itself.

Prerequisites

First, install the following set of system dependencies according to your Operating System:

Run the following command to install packages:

$ sudo apt install \
$ bison flex gettext texinfo libncurses5-dev libncursesw5-dev xxd \
$ gperf automake libtool pkg-config build-essential gperf genromfs \
$ libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
$ libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux

KConfig frontend

NuttX configuration system uses KConfig which is exposed via a series of interactive menu-based frontends, part of the kconfig-frontends package. Depending on your OS you may use a precompiled package or you will have to build it from source, which is available in the NuttX tools repository:

$ sudo apt install kconfig-frontends

NuttX also supports kconfiglib by default, which is a Kconfig tool implemented in Python 2/3. Compared with kconfig-frontends, kconfiglib provides NuttX with the possibility of multi-platform support(configure NuttX in Winodws native/Visual Studio), and also kconfiglib has a stronger Kconfig syntax check, this will help developers to avoid some Kconfig syntax errors. Install kconfiglib via following command:

pip install kconfiglib

If you are a working on Windows, which also need the support of windows-curses:

pip install windows-curses

Tip

It should be noted that kconfiglib does not support modules attributes. (https://github.com/ulfalizer/Kconfiglib/blob/master/kconfiglib.py#L3239-L3254, the community seems to have stopped updating), if the features depends on CONFIG_BUILD_LOADABLE, kconfiglib may not be a good choice.

Toolchain

To build Apache NuttX you need the appropriate toolchain according to your target platform. Some Operating Systems such as Linux distribute toolchains for various architectures. This is usually an easy choice however you should be aware that in some cases the version offered by your OS may have problems and it may be better to use a widely used build from another source.

The following example shows how to install a toolchain for ARM architecture:

$ sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi

Tip

There are hints on how to get the latest tool chains for most supported architectures in the Apache NuttX CI helper script and Docker container

Todo

Required toolchain should be part of each arch documentation (see relevant issue).

Download NuttX

Apache NuttX is actively developed on GitHub. There are two main repositories, nuttx and apps, where the latter is technically optional (but recommended for complete set of features). If you intend to contribute changes, you need the absolute latest version or you simply prefer to work using git, you should clone these repositories (recommended). Otherwise you can choose to download any stable release archive.

$ mkdir nuttxspace
$ cd nuttxspace
$ git clone https://github.com/apache/nuttx.git nuttx
$ git clone https://github.com/apache/nuttx-apps apps

The development source code is also available as a compressed archive, should you need it:

$ mkdir nuttxspace
$ cd nuttxspace
$ curl -L https://github.com/apache/nuttx/tarball/master -o nuttx.tar.gz
$ curl -L https://github.com/apache/nuttx-apps/tarball/master -o apps.tar.gz
$ tar zxf nuttx.tar.gz --one-top-level=nuttx --strip-components 1
$ tar zxf apps.tar.gz --one-top-level=apps --strip-components 1

There are also .zip archives available (useful for Windows users): just replace tarball with zipball.