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
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
|
The first step is to initialize NuttX configuration for a given board, based from
|
|
|
|
|
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-09-11 23:55:50 +02:00
|
|
|
|
|
|
|
|
|
The output is in the format ``<board name>:<board configuration>``. You will see that
|
|
|
|
|
generally all boards support the ``nsh`` configuration which is a good sarting point
|
|
|
|
|
since it enables booting into the interactive command line
|
|
|
|
|
:doc:`/components/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
|
|
|
|
|
|
|
|
|
|
The ``-l`` tells use that we're on Linux (macOS and Windows builds are
|
|
|
|
|
possible). Use the ``-h`` argument to see all available options.
|
|
|
|
|
|
|
|
|
|
Customize Your Configuration (Optional)
|
|
|
|
|
=======================================
|
2020-09-04 23:00:59 +02:00
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
|
This step is optional. Right now, this is mainly to get familiar with how it
|
|
|
|
|
works– you don't need to change any of the options now, but knowing how
|
|
|
|
|
to do this will come in handy later.
|
2020-09-04 23:00:59 +02:00
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
|
There are a lot of options. We'll cover a few of them here.
|
|
|
|
|
Don't worry about the complexity– you don't have to use most of the options.
|
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
|
|
|
|
$ cd nuttx/
|
|
|
|
|
$ make menuconfig
|
|
|
|
|
|
|
|
|
|
.. todo::
|
|
|
|
|
Explain some useful options.
|
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
|
|
|
|
|
2020-09-11 23:55:50 +02:00
|
|
|
|
$ cd nuttx/
|
|
|
|
|
$ make make
|
|
|
|
|
|
|
|
|
|
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 `nuttx.bin`
|
|
|
|
|
file that can be flashed to the board.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
It is recommended that after manually modifying the configuration you first clean
|
|
|
|
|
before building.
|
2020-09-04 23:00:59 +02:00
|
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
Next up is :ref:`running`.
|
|
|
|
|
|