compiling.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .. include:: /substitutions.rst
  2. .. _compiling:
  3. =========
  4. Compiling
  5. =========
  6. Now that we've installed Apache NuttX prerequisites and downloaded the source code,
  7. we are ready to compile the source code into an executable binary file that can
  8. be run on the embedded board.
  9. Initialize Configuration
  10. ========================
  11. The first step is to initialize NuttX configuration for a given board, based from
  12. a pre-existing configuration. To list all supported configurations you can do:
  13. .. code-block:: console
  14. $ cd nuttx
  15. $ ./tools/configure.sh -L | less
  16. The output is in the format ``<board name>:<board configuration>``. You will see that
  17. generally all boards support the ``nsh`` configuration which is a good starting point
  18. since it enables booting into the interactive command line
  19. :doc:`/applications/nsh/index`.
  20. To choose a configuration you pass the ``<board name>:<board configuration>`` option
  21. to ``configure.sh`` and indicate your host platform, such as:
  22. .. code-block:: console
  23. $ cd nuttx
  24. $ ./tools/configure.sh -l stm32f4discovery:nsh
  25. The ``-l`` tells use that we're on Linux (macOS and Windows builds are
  26. possible). Use the ``-h`` argument to see all available options.
  27. You can then customize this configuration by using the menu based
  28. configuration system with:
  29. .. code-block:: console
  30. $ cd nuttx/
  31. $ make menuconfig
  32. Modifying the configuration is covered in :doc:`configuring`.
  33. Build NuttX
  34. ===========
  35. We can now build NuttX. To do so, you can simply run:
  36. .. code-block:: console
  37. $ cd nuttx/
  38. $ make
  39. The build will complete by generating the binary outputs
  40. inside ``nuttx`` directory. Typically this includes the ``nuttx``
  41. ELF file (suitable for debugging using ``gdb``) and a ``nuttx.bin``
  42. file that can be flashed to the board.
  43. To clean the build, you can do:
  44. .. code-block:: console
  45. $ make clean
  46. .. tip::
  47. To increase build speed (or of any other target such as ``clean``), you can
  48. pass the ``-jN`` flag to ``make``, where ``N`` is the number of parallel jobs
  49. to start (usually, the number of processors on your machine).