2020-09-04 23:00:59 +02:00
.. include :: /substitutions.rst
.. _install:
2020-12-06 03:24:34 +01:00
==========
2020-09-04 23:00:59 +02:00
Installing
==========
2020-12-06 03:24:34 +01:00
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.
2020-09-04 23:00:59 +02:00
Prerequisites
2020-12-06 03:24:34 +01:00
=============
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
First, install the following set of system dependencies according to your Operating System:
2020-10-18 18:48:44 +02:00
2020-12-06 03:24:34 +01:00
.. tabs ::
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
.. tab :: Linux (debian based)
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
Run the following command to install packages:
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
.. code-block :: console
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
$ sudo apt install \
2023-08-22 13:29:11 +02:00
$ 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
2020-09-04 23:00:59 +02:00
2023-08-22 13:29:11 +02:00
.. tab :: Linux (Fdora / RPM based)
2023-08-21 13:59:21 +02:00
Run the following command to install packages:
.. code-block :: console
2023-08-22 13:29:11 +02:00
$ sudo dnf install \
$ bison flex gettext texinfo ncurses-devel ncurses ncurses-compat-libs \
$ gperf automake libtool pkgconfig @development-tools gperf genromfs \
$ gmp-devel mpfr-devel libmpc-devel isl-devel binutils-devel elfutils-libelf-devel \
$ expat-devel gcc-c++ g++ picocom uboot-tools util-linux
2023-08-21 13:59:21 +02:00
2020-09-11 23:55:50 +02:00
.. tab :: macOS
2020-12-06 03:24:34 +01:00
Run the following command to install packages:
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-09-04 23:00:59 +02:00
nuttx/build: Restore ARLOCK to improve compile speed in incremental case
To solve the issue of carrying object files from previous builds,
Matias changed the archiving process to re-archive libapps.a on every compilation,
if libapps.a carries more object files, incremental compilation will waste too
many time in re-archiving, compared with the previous implement, this is a degradation
of the build system. Referring to mature engineering projects such as cmake, if there
is configuration or source file changed, the best solution should be to reconfigure
the environment.
Revert this PR to ensure the compilation speed during incremental compilation.
| commit 34b34e2d4519956f9a61f5985aca29947c4b8b23 (tag: nuttx-20200914-172150)
| Author: Matias N <matias@protobits.dev>
| Date: Fri Sep 11 22:31:38 2020 -0300
|
| Fix: ensure archive files do not carry object files from prior builds
|
| In some cases, when NuttX configuration changes and this makes the
| object list used to build one of the .a libraries change as well,
| since the command used to build it is "ar crs" and this simply appends
| the list of object files, the library could still include object
| files from prior builds. This commit modifies the ARCHIVE macro to
| erase the .a file if it already exists.
|
| Since in some cases this behavior was actually expected (object
| files from a subdirectory were appended to a library created one
| level above) I added a ARCHIVE_ADD which works as ARCHIVE did.
|
| This change should greatly improve behavior of building after
| configuration changes.
Testing:
sim:nsh
-------------------------------
| Patched | Current
-------------------------------
|$ time make | $ time make
|real 0m1.270s | real 0m1.728s
|user 0m0.971s | user 0m1.276s
|sys 0m0.363s | sys 0m0.530s
-------------------------------
Private project (20+ 3rd library needs archive to libapps.a)
-------------------------------
| Patched | Current
-------------------------------
|$ time make | $ time make
|real 0m21.181s | real 0m39.721s
|user 0m14.638s | user 0m24.837s
|sys 0m6.919s | sys 0m14.394s
-------------------------------
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-11 05:50:36 +02:00
$ brew tap discoteq/discoteq
$ brew install flock
2020-09-11 23:55:50 +02:00
$ brew install x86_64-elf-gcc # Used by simulator
$ brew install u-boot-tools # Some platform integrate with u-boot
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
.. tab :: Windows / WSL
2020-09-04 23:00:59 +02:00
2021-02-08 02:11:47 +01:00
If you are are building Apache NuttX on Windows and using WSL follow
2020-09-11 23:55:50 +02:00
that installation guide for Linux. This has been verified against the
2021-02-08 02:11:47 +01:00
Ubuntu 18.04 version.
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
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:
2023-03-20 03:55:10 +01:00
https://learn.microsoft.com/en-us/windows/wsl/connect-usb
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
.. tab :: Windows/Cygwin
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
Download and install `Cygwin <https://www.cygwin.com/> `_ using the minimal
installation in addition to these packages::
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
make bison libmpc-devel
gcc-core byacc automake-1.15
gcc-g++ gperf libncurses-devel
flex gdb libmpfr-devel
git unzip zlib-devel
2020-10-18 18:48:44 +02:00
2020-12-06 03:24:34 +01:00
KConfig frontend
----------------
2021-06-10 19:46:56 +02:00
NuttX configuration system uses `KConfig <https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt> `_ 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 <https://bitbucket.org/nuttx/tools/src/master/kconfig-frontends/> `_ :
2020-12-06 03:24:34 +01:00
2023-08-22 13:29:11 +02:00
.. tabs ::
2020-12-06 03:24:34 +01:00
2023-08-22 13:29:11 +02:00
.. code-tab :: console Ubuntu 20.04 LTS and later
2020-12-06 03:24:34 +01:00
2023-08-22 13:29:11 +02:00
$ sudo apt install kconfig-frontends
2020-12-06 03:24:34 +01:00
2023-08-22 13:29:11 +02:00
.. code-tab :: console Ubuntu 18.04 LTS and earlier
2023-08-22 11:49:42 +02:00
2023-08-22 13:29:11 +02:00
$ git clone https://bitbucket.org/nuttx/tools.git
$ cd tools/kconfig-frontends
$ ./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf
$ make
$ make install
2023-08-22 11:49:42 +02:00
2023-08-22 13:29:11 +02:00
.. code-tab :: console Fedora
2023-08-22 11:49:42 +02:00
2023-08-22 13:29:11 +02:00
$ git clone https://bitbucket.org/nuttx/tools.git
$ cd tools/kconfig-frontends
$ ./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf
$ aclocal
$ automake
$ make
$ sudo make install
2023-08-22 11:49:42 +02:00
2023-08-22 13:29:11 +02:00
.. code-tab :: console MacOS
2020-09-04 23:00:59 +02:00
2023-08-22 13:29:11 +02:00
$ git clone https://bitbucket.org/nuttx/tools.git
$ cd tools/kconfig-frontends
$ patch < ../kconfig-macos.diff -p 1
$ ./configure --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf
$ make
$ make install
2020-12-06 03:24:34 +01:00
2023-02-20 05:23:04 +01:00
NuttX also supports `kconfiglib <https://github.com/ulfalizer/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:
2023-08-22 13:29:11 +02:00
.. code-block :: shell
pip install kconfiglib
2023-02-20 05:23:04 +01:00
If you are a working on Windows, which also need the support of windows-curses:
2023-08-22 13:29:11 +02:00
.. code-block :: shell
pip install windows-curses
2023-02-20 05:23:04 +01:00
.. 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.
2020-12-06 03:24:34 +01:00
Toolchain
=========
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
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
2020-10-18 18:48:44 +02:00
that in some cases the version offered by your OS may have
2023-08-22 13:29:11 +02:00
problems and it may be better to use a widely used build from
2020-09-11 23:55:50 +02:00
another source.
The following example shows how to install a toolchain for
ARM architecture:
.. tabs ::
.. code-tab :: console Ubuntu (deb)
2020-10-18 18:48:44 +02:00
2023-05-20 05:51:27 +02:00
$ sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
.. tab :: From arm.com
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
First, create a directory to hold the toolchain:
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
$ usermod -a -G users $USER
$ # get a login shell that knows we're in this group:
$ su - $USER
$ sudo mkdir /opt/gcc
$ sudo chgrp -R users /opt/gcc
$ sudo chmod -R u+rw /opt/gcc
$ cd /opt/gcc
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
Download and extract toolchain:
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
$ HOST_PLATFORM=x86_64-linux # use "mac" for macOS.
2023-09-28 09:59:05 +02:00
$ # For Windows there is a zip instead (gcc-arm-none-eabi-10.3-2021.10-win32.zip)
2023-10-02 10:40:39 +02:00
$ curl -L -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-${HOST_PLATFORM}.tar.bz2
2023-09-28 09:59:05 +02:00
$ tar xf gcc-arm-none-eabi-10.3-2021.10-${HOST_PLATFORM}.tar.bz2
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
Add the toolchain to your `PATH` :
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-10-18 18:48:44 +02:00
2023-09-28 09:59:05 +02:00
$ echo "export PATH=/opt/gcc/gcc-arm-none-eabi-10.3-2021.10/bin:$PATH" >> ~/.bashrc
2020-10-18 18:48:44 +02:00
2020-09-11 23:55:50 +02:00
You can edit your shell's rc files if you don't use bash.
2020-09-04 23:00:59 +02:00
2020-10-18 18:48:44 +02:00
.. tip ::
2020-09-11 23:55:50 +02:00
There are hints on how to get the latest tool chains for most supported
architectures in the Apache NuttX CI helper
2022-11-22 19:59:48 +01:00
`script <https://github.com/apache/nuttx/tree/master/tools/ci/cibuild.sh> `_
and Docker `container <https://github.com/apache/nuttx/tree/master/tools/ci/docker/linux/Dockerfile> `_
2020-12-06 03:24:34 +01:00
.. todo ::
2022-11-22 19:59:48 +01:00
Required toolchain should be part of each arch documentation (see `relevant issue <https://github.com/apache/nuttx/issues/2409> `_ ).
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
Download NuttX
==============
2020-09-04 23:00:59 +02:00
2022-11-22 19:59:48 +01:00
Apache NuttX is actively developed on GitHub. There are two main repositories, `nuttx <https://github.com/apache/nuttx> `_ and `apps <https://github.com/apache/nuttx-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 <https://nuttx.apache.org/download/> `_ archive.
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
.. tabs ::
2020-10-18 18:48:44 +02:00
2020-12-06 03:24:34 +01:00
.. tab :: Clone git repositories
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-09-04 23:00:59 +02:00
2022-03-16 18:08:00 +01:00
$ mkdir nuttxspace
$ cd nuttxspace
2022-11-22 19:59:48 +01:00
$ git clone https://github.com/apache/nuttx.git nuttx
$ git clone https://github.com/apache/nuttx-apps apps
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
The development source code is also available as a compressed archive, should you need it:
2020-09-04 23:00:59 +02:00
2020-09-11 23:55:50 +02:00
.. code-block :: console
2020-09-04 23:00:59 +02:00
2022-03-16 18:08:00 +01:00
$ mkdir nuttxspace
$ cd nuttxspace
2022-11-22 19:59:48 +01:00
$ 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
2021-09-16 17:49:45 +02:00
$ tar zxf nuttx.tar.gz --one-top-level=nuttx --strip-components 1
$ tar zxf apps.tar.gz --one-top-level=apps --strip-components 1
2020-12-06 03:24:34 +01:00
There are also `` .zip `` archives available (useful for Windows users): just replace `` tarball `` with
`` zipball `` .
.. tab :: Download stable release
Go to `releases <https://nuttx.apache.org/download/> `_ and choose a version to download. The following
2023-08-25 15:47:46 +02:00
example uses version 12.2.1:
2020-09-04 23:00:59 +02:00
2020-12-06 03:24:34 +01:00
.. code-block :: console
2022-03-16 18:08:00 +01:00
$ mkdir nuttxspace
$ cd nuttxspace
2023-08-25 15:47:46 +02:00
$ curl -L https://www.apache.org/dyn/closer.lua/nuttx/12.2.1/apache-nuttx-12.2.1.tar.gz?action=download -o nuttx.tar.gz
$ curl -L https://www.apache.org/dyn/closer.lua/nuttx/12.2.1/apache-nuttx-apps-12.2.1.tar.gz?action=download -o apps.tar.gz
2020-12-06 03:24:34 +01:00
$ tar zxf nuttx.tar.gz
$ tar zxf apps.tar.gz