gcc.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. Building with GCC
  2. =================
  3. Dependencies
  4. ------------
  5. For building U-Boot you need a GCC compiler for your host platform. If you
  6. are not building on the target platform you further need a GCC cross compiler.
  7. Debian based
  8. ~~~~~~~~~~~~
  9. On Debian based systems the cross compiler packages are named
  10. gcc-<architecture>-linux-gnu.
  11. You could install GCC and the GCC cross compiler for the ARMv8 architecture with
  12. .. code-block:: bash
  13. sudo apt-get install gcc gcc-aarch64-linux-gnu
  14. Depending on the build targets further packages maybe needed
  15. .. code-block:: bash
  16. sudo apt-get install bc bison build-essential coccinelle \
  17. device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \
  18. liblz4-tool libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev \
  19. libssl-dev lz4 lzma lzma-alone openssl pkg-config python3 \
  20. python3-coverage python3-pkg-resources python3-pycryptodome \
  21. python3-pyelftools python3-pytest python3-sphinxcontrib.apidoc \
  22. python3-sphinx-rtd-theme python3-virtualenv swig
  23. SUSE based
  24. ~~~~~~~~~~
  25. On suse based systems the cross compiler packages are named
  26. cross-<architecture>-gcc<version>.
  27. You could install GCC and the GCC 10 cross compiler for the ARMv8 architecture
  28. with
  29. .. code-block:: bash
  30. sudo zypper install gcc cross-aarch64-gcc10
  31. Depending on the build targets further packages maybe needed.
  32. .. code-block:: bash
  33. zypper install bc bison flex gcc libopenssl-devel libSDL2-devel make \
  34. ncurses-devel python3-devel python3-pytest swig
  35. Alpine Linux
  36. ~~~~~~~~~~~~
  37. For building U-Boot on Alpine Linux at least the following packages are needed:
  38. .. code-block:: bash
  39. apk add alpine-sdk bc bison dtc flex linux-headers ncurses-dev \
  40. openssl-dev perl python3 py3-setuptools python3-dev sdl2-dev
  41. Prerequisites
  42. -------------
  43. For some boards you have to build prerequisite files before you can build
  44. U-Boot, e.g. for the some boards you will need to build the ARM Trusted Firmware
  45. beforehand. Please, refer to the board specific documentation
  46. :doc:`../board/index`.
  47. Configuration
  48. -------------
  49. Directory configs/ contains the template configuration files for the maintained
  50. boards following the naming scheme::
  51. <board name>_defconfig
  52. These files have been stripped of default settings. So you cannot use them
  53. directly. Instead their name serves as a make target to generate the actual
  54. configuration file .config. For instance the configuration template for the
  55. Odroid C2 board is called odroid-c2_defconfig. The corresponding .config file
  56. is generated by
  57. .. code-block:: bash
  58. make odroid-c2_defconfig
  59. You can adjust the configuration using
  60. .. code-block:: bash
  61. make menuconfig
  62. Building
  63. --------
  64. When cross compiling you will have to specify the prefix of the cross-compiler.
  65. You can either specify the value of the CROSS_COMPILE variable on the make
  66. command line or export it beforehand.
  67. .. code-block:: bash
  68. CROSS_COMPILE=<compiler-prefix> make
  69. Assuming cross compiling on Debian for ARMv8 this would be
  70. .. code-block:: bash
  71. CROSS_COMPILE=aarch64-linux-gnu- make
  72. Build parameters
  73. ~~~~~~~~~~~~~~~~
  74. A list of available parameters for the make command can be obtained via
  75. .. code-block:: bash
  76. make help
  77. You can speed up compilation by parallelization using the -j parameter, e.g.
  78. .. code-block:: bash
  79. CROSS_COMPILE=aarch64-linux-gnu- make -j$(nproc)
  80. Further important build parameters are
  81. * O=<dir> - generate all output files in directory <dir>, including .config
  82. * V=1 - verbose build
  83. Devicetree compiler
  84. ~~~~~~~~~~~~~~~~~~~
  85. Boards that use `CONFIG_OF_CONTROL` (i.e. almost all of them) need the
  86. devicetree compiler (dtc). Those with `CONFIG_PYLIBFDT` need pylibfdt, a Python
  87. library for accessing devicetree data. Suitable versions of these are included
  88. in the U-Boot tree in `scripts/dtc` and built automatically as needed.
  89. To use the system versions of these, use the DTC parameter, for example
  90. .. code-block:: bash
  91. DTC=/usr/bin/dtc make
  92. In this case, dtc and pylibfdt are not built. The build checks that the version
  93. of dtc is new enough. It also makes sure that pylibfdt is present, if needed
  94. (see `scripts_dtc` in the Makefile).
  95. Note that the :doc:`tools` are always built with the included version of libfdt
  96. so it is not possible to build U-Boot tools with a system libfdt, at present.
  97. Other build targets
  98. ~~~~~~~~~~~~~~~~~~~
  99. A list of all make targets can be obtained via
  100. .. code-block:: bash
  101. make help
  102. Important ones are
  103. * clean - remove most generated files but keep the configuration
  104. * mrproper - remove all generated files + config + various backup files
  105. Installation
  106. ------------
  107. The process for installing U-Boot on the target device is device specific.
  108. Please, refer to the board specific documentation :doc:`../board/index`.