gcc.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 liblz4-tool \
  18. libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev libssl-dev \
  19. lzma-alone openssl python3 python3-coverage python3-pyelftools \
  20. python3-pytest python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme swig
  21. Prerequisites
  22. -------------
  23. For some boards you have to build prerequisite files before you can build
  24. U-Boot, e.g. for the some boards you will need to build the ARM Trusted Firmware
  25. beforehand. Please, refer to the board specific documentation
  26. :doc:`../board/index`.
  27. Configuration
  28. -------------
  29. Directory configs/ contains the template configuration files for the maintained
  30. boards following the naming scheme::
  31. <board name>_defconfig
  32. These files have been stripped of default settings. So you cannot use them
  33. directly. Instead their name serves as a make target to generate the actual
  34. configuration file .config. For instance the configuration template for the
  35. Odroid C2 board is called odroid-c2_defconfig. The corresponding .config file
  36. is generated by
  37. .. code-block:: bash
  38. make odroid-c2_defconfig
  39. You can adjust the configuration using
  40. .. code-block:: bash
  41. make menuconfig
  42. Building
  43. --------
  44. When cross compiling you will have to specify the prefix of the cross-compiler.
  45. You can either specify the value of the CROSS_COMPILE variable on the make
  46. command line or export it beforehand.
  47. .. code-block:: bash
  48. CROSS_COMPILE=<compiler-prefix> make
  49. Assuming cross compiling on Debian for ARMv8 this would be
  50. .. code-block:: bash
  51. CROSS_COMPILE=aarch64-linux-gnu- make
  52. Build parameters
  53. ~~~~~~~~~~~~~~~~
  54. A list of available parameters for the make command can be obtained via
  55. .. code-block:: bash
  56. make help
  57. You can speed up compilation by parallelization using the -j parameter, e.g.
  58. .. code-block:: bash
  59. CROSS_COMPILE=aarch64-linux-gnu- make -j$(nproc)
  60. Further important build parameters are
  61. * O=<dir> - generate all output files in directory <dir>, including .config
  62. * V=1 - verbose build
  63. Other build targets
  64. ~~~~~~~~~~~~~~~~~~~
  65. A list of all make targets can be obtained via
  66. .. code-block:: bash
  67. make help
  68. Important ones are
  69. * clean - remove most generated files but keep the configuration
  70. * mrproper - remove all generated files + config + various backup files
  71. Installation
  72. ------------
  73. The process for installing U-Boot on the target device is device specific.
  74. Please, refer to the board specific documentation :doc:`../board/index`.