2020-09-04 23:00:59 +02:00
|
|
|
.. include:: /substitutions.rst
|
|
|
|
.. _compiling:
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
=========
|
2020-09-04 23:00:59 +02:00
|
|
|
Compiling
|
|
|
|
=========
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
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.
|
2020-09-04 23:00:59 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
Initialize Configuration
|
|
|
|
========================
|
2020-09-04 23:00:59 +02:00
|
|
|
|
2023-08-22 14:06:52 +02:00
|
|
|
The first step is to initialize NuttX configuration for a given board, based on
|
2020-09-11 23:55:50 +02:00
|
|
|
a pre-existing configuration. To list all supported configurations you can do:
|
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
|
|
|
|
|
|
|
$ cd nuttx
|
|
|
|
$ ./tools/configure.sh -L | less
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
The output is in the format ``<board name>:<board configuration>``. You will see that
|
2021-04-28 21:14:44 +02:00
|
|
|
generally all boards support the ``nsh`` configuration which is a good starting point
|
2020-09-11 23:55:50 +02:00
|
|
|
since it enables booting into the interactive command line
|
2020-10-20 10:40:45 +02:00
|
|
|
:doc:`/applications/nsh/index`.
|
2020-09-04 23:00:59 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
To choose a configuration you pass the ``<board name>:<board configuration>`` option
|
|
|
|
to ``configure.sh`` and indicate your host platform, such as:
|
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
|
|
|
|
|
|
|
$ cd nuttx
|
2020-09-11 23:55:50 +02:00
|
|
|
$ ./tools/configure.sh -l stm32f4discovery:nsh
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
The ``-l`` tells use that we're on Linux (macOS and Windows builds are
|
|
|
|
possible). Use the ``-h`` argument to see all available options.
|
|
|
|
|
2020-11-21 23:55:16 +01:00
|
|
|
You can then customize this configuration by using the menu based
|
|
|
|
configuration system with:
|
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
|
|
|
$ cd nuttx
|
2020-09-11 23:55:50 +02:00
|
|
|
$ make menuconfig
|
2021-04-28 21:14:44 +02:00
|
|
|
|
2020-11-21 23:55:16 +01:00
|
|
|
Modifying the configuration is covered in :doc:`configuring`.
|
2020-09-04 23:00:59 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
Build NuttX
|
|
|
|
===========
|
2020-09-04 23:00:59 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
We can now build NuttX. To do so, you can simply run:
|
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
|
|
|
$ cd nuttx
|
2020-11-21 23:55:16 +01:00
|
|
|
$ make
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
The build will complete by generating the binary outputs
|
2020-11-21 23:55:16 +01:00
|
|
|
inside ``nuttx`` directory. Typically this includes the ``nuttx``
|
|
|
|
ELF file (suitable for debugging using ``gdb``) and a ``nuttx.bin``
|
2020-10-18 18:48:44 +02:00
|
|
|
file that can be flashed to the board.
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
To clean the build, you can do:
|
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
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
$ make clean
|
2021-04-28 21:14:44 +02:00
|
|
|
|
2020-12-06 03:24:34 +01:00
|
|
|
.. tip::
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-12-06 03:24:34 +01:00
|
|
|
To increase build speed (or of any other target such as ``clean``), you can
|
|
|
|
pass the ``-jN`` flag to ``make``, where ``N`` is the number of parallel jobs
|
|
|
|
to start (usually, the number of processors on your machine).
|
2020-09-04 23:00:59 +02:00
|
|
|
|