install.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. .. include:: /substitutions.rst
  2. .. _install:
  3. ==========
  4. Installing
  5. ==========
  6. The first step to get started with NuttX is to install a series of required tools, a toolchain for the architecture
  7. you will be working with and, finally, download NuttX source code itself.
  8. Prerequisites
  9. =============
  10. First, install the following set of system dependencies according to your Operating System:
  11. .. tabs::
  12. .. tab:: Linux (debian based)
  13. Run the following command to install packages:
  14. .. code-block:: console
  15. $ sudo apt install \
  16. bison flex gettext texinfo libncurses5-dev libncursesw5-dev \
  17. gperf automake libtool pkg-config build-essential gperf genromfs \
  18. libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
  19. libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux
  20. .. tab:: macOS
  21. Run the following command to install packages:
  22. .. code-block:: console
  23. $ brew install x86_64-elf-gcc # Used by simulator
  24. $ brew install u-boot-tools # Some platform integrate with u-boot
  25. .. tab:: Windows / WSL
  26. If you are are building Apache NuttX on Windows and using WSL follow
  27. that installation guide for Linux. This has been verified against the
  28. Ubuntu 18.04 version.
  29. There may be complications interacting with
  30. programming tools over USB. Recently support for USBIP was added to WSL 2
  31. which has been used with the STM32 platform, but it is not trivial to configure:
  32. https://github.com/rpasek/usbip-wsl2-instructions
  33. .. tab:: Windows/Cygwin
  34. Download and install `Cygwin <https://www.cygwin.com/>`_ using the minimal
  35. installation in addition to these packages::
  36. make bison libmpc-devel
  37. gcc-core byacc automake-1.15
  38. gcc-g++ gperf libncurses-devel
  39. flex gdb libmpfr-devel
  40. git unzip zlib-devel
  41. KConfig frontend
  42. ----------------
  43. 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/>`_:
  44. .. tabs::
  45. .. code-tab:: console Ubuntu 20.04 LTS and later
  46. $ apt install kconfig-frontends
  47. .. code-tab:: console MacOS, Ubuntu 18.04 LTS and earlier
  48. $ git clone https://bitbucket.org/nuttx/tools.git
  49. $ cd tools/kconfig-frontends
  50. $ # on MacOS do the following:
  51. $ patch < ../kconfig-macos.diff -p 1
  52. $ ./configure --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf
  53. $ # on Linux do the following:
  54. $ ./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf
  55. $ make
  56. $ make install
  57. Toolchain
  58. =========
  59. To build Apache NuttX you need the appropriate toolchain
  60. according to your target platform. Some Operating Systems
  61. such as Linux distribute toolchains for various architectures.
  62. This is usually an easy choice however you should be aware
  63. that in some cases the version offered by your OS may have
  64. problems and it may better to use a widely used build from
  65. another source.
  66. The following example shows how to install a toolchain for
  67. ARM architecture:
  68. .. tabs::
  69. .. code-tab:: console Ubuntu (deb)
  70. $ apt install gcc-arm-none-eabi binutils-arm-none-eabi
  71. .. tab:: From arm.com
  72. First, create a directory to hold the toolchain:
  73. .. code-block:: console
  74. $ usermod -a -G users $USER
  75. $ # get a login shell that knows we're in this group:
  76. $ su - $USER
  77. $ sudo mkdir /opt/gcc
  78. $ sudo chgrp -R users /opt/gcc
  79. $ sudo chmod -R u+rw /opt/gcc
  80. $ cd /opt/gcc
  81. Download and extract toolchain:
  82. .. code-block:: console
  83. $ HOST_PLATFORM=x86_64-linux # use "mac" for macOS.
  84. $ # For Windows there is a zip instead (gcc-arm-none-eabi-9-2019-q4-major-win32.zip)
  85. $ curl -L -O https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-${HOST_PLATFORM}.tar.bz2
  86. $ tar xf gcc-arm-none-eabi-9-2019-q4-major-${HOST_PLATFORM}.tar.bz2
  87. Add the toolchain to your `PATH`:
  88. .. code-block:: console
  89. $ echo "export PATH=/opt/gcc/gcc-arm-none-eabi-9-2019-q4-major/bin:$PATH" >> ~/.bashrc
  90. You can edit your shell's rc files if you don't use bash.
  91. .. tip::
  92. There are hints on how to get the latest tool chains for most supported
  93. architectures in the Apache NuttX CI helper
  94. `script <https://github.com/apache/incubator-nuttx-testing/blob/master/cibuild.sh>`_
  95. and Docker `container <https://github.com/apache/incubator-nuttx-testing/blob/master/docker/linux/Dockerfile>`_
  96. .. todo::
  97. Required toolchain should be part of each arch documentation (see `relevant issue <https://github.com/apache/incubator-nuttx/issues/2409>`_).
  98. Download NuttX
  99. ==============
  100. Apache NuttX is actively developed on GitHub. There are two main repositories, `nuttx <https://github.com/apache/incubator-nuttx>`_ and `apps <https://github.com/apache/incubator-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.
  101. .. tabs::
  102. .. tab:: Clone git repositories
  103. .. code-block:: console
  104. $ mkdir nuttx
  105. $ cd nuttx
  106. $ git clone https://github.com/apache/incubator-nuttx.git nuttx
  107. $ git clone https://github.com/apache/incubator-nuttx-apps apps
  108. The development source code is also available as a compressed archive, should you need it:
  109. .. code-block:: console
  110. $ mkdir nuttx
  111. $ cd nuttx
  112. $ curl -L https://github.com/apache/incubator-nuttx/tarball/master -o nuttx.tar.gz
  113. $ curl -L https://github.com/apache/incubator-nuttx-apps/tarball/master -o apps.tar.gz
  114. $ tar zxf nuttx.tar.gz
  115. $ tar zxf apps.tar.gz
  116. There are also ``.zip`` archives available (useful for Windows users): just replace ``tarball`` with
  117. ``zipball``.
  118. .. tab:: Download stable release
  119. Go to `releases <https://nuttx.apache.org/download/>`_ and choose a version to download. The following
  120. example uses version 9.1.0:
  121. .. code-block:: console
  122. $ mkdir nuttx
  123. $ cd nuttx
  124. $ curl -L https://downloads.apache.org/incubator/nuttx/9.1.0/apache-nuttx-9.1.0-incubating.tar.gz -o nuttx.tar.gz
  125. $ curl -L https://downloads.apache.org/incubator/nuttx/9.1.0/apache-nuttx-apps-9.1.0-incubating.tar.gz -o apps.tar.gz
  126. $ tar zxf nuttx.tar.gz
  127. $ tar zxf apps.tar.gz