Heinrich Schuchardt | 16327a2 | 2020-09-05 10:58:53 +0200 | [diff] [blame] | 1 | Building with GCC |
| 2 | ================= |
| 3 | |
| 4 | Dependencies |
| 5 | ------------ |
| 6 | |
| 7 | For building U-Boot you need a GCC compiler for your host platform. If you |
| 8 | are not building on the target platform you further need a GCC cross compiler. |
| 9 | |
| 10 | Debian based |
| 11 | ~~~~~~~~~~~~ |
| 12 | |
| 13 | On Debian based systems the cross compiler packages are named |
| 14 | gcc-<architecture>-linux-gnu. |
| 15 | |
| 16 | You could install GCC and the GCC cross compiler for the ARMv8 architecture with |
| 17 | |
| 18 | .. code-block:: bash |
| 19 | |
Heinrich Schuchardt | c78ffd1 | 2020-09-20 12:31:47 +0200 | [diff] [blame] | 20 | sudo apt-get install gcc gcc-aarch64-linux-gnu |
Heinrich Schuchardt | 16327a2 | 2020-09-05 10:58:53 +0200 | [diff] [blame] | 21 | |
| 22 | Depending on the build targets further packages maybe needed |
| 23 | |
| 24 | .. code-block:: bash |
| 25 | |
| 26 | sudo apt-get install bc bison build-essential coccinelle \ |
| 27 | device-tree-compiler dfu-util efitools flex gdisk liblz4-tool \ |
| 28 | libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev libssl-dev \ |
| 29 | lzma-alone openssl python3 python3-coverage python3-pyelftools \ |
| 30 | python3-pytest python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme swig |
| 31 | |
Heinrich Schuchardt | 0a79392 | 2020-09-20 12:01:30 +0200 | [diff] [blame] | 32 | SUSE based |
| 33 | ~~~~~~~~~~ |
| 34 | |
| 35 | On suse based systems the cross compiler packages are named |
| 36 | cross-<architecture>-gcc<version>. |
| 37 | |
| 38 | You could install GCC and the GCC 10 cross compiler for the ARMv8 architecture |
| 39 | with |
| 40 | |
| 41 | .. code-block:: bash |
| 42 | |
| 43 | sudo zypper install gcc cross-aarch64-gcc10 |
| 44 | |
| 45 | Depending on the build targets further packages maybe needed. |
| 46 | |
| 47 | .. code-block:: bash |
| 48 | |
| 49 | zypper install bc bison flex gcc libopenssl-devel libSDL2-devel make \ |
| 50 | ncurses-devel python3-devel python3-pytest swig |
| 51 | |
Heinrich Schuchardt | 16327a2 | 2020-09-05 10:58:53 +0200 | [diff] [blame] | 52 | Prerequisites |
| 53 | ------------- |
| 54 | |
| 55 | For some boards you have to build prerequisite files before you can build |
| 56 | U-Boot, e.g. for the some boards you will need to build the ARM Trusted Firmware |
| 57 | beforehand. Please, refer to the board specific documentation |
| 58 | :doc:`../board/index`. |
| 59 | |
| 60 | Configuration |
| 61 | ------------- |
| 62 | |
| 63 | Directory configs/ contains the template configuration files for the maintained |
| 64 | boards following the naming scheme:: |
| 65 | |
| 66 | <board name>_defconfig |
| 67 | |
| 68 | These files have been stripped of default settings. So you cannot use them |
| 69 | directly. Instead their name serves as a make target to generate the actual |
| 70 | configuration file .config. For instance the configuration template for the |
| 71 | Odroid C2 board is called odroid-c2_defconfig. The corresponding .config file |
| 72 | is generated by |
| 73 | |
| 74 | .. code-block:: bash |
| 75 | |
| 76 | make odroid-c2_defconfig |
| 77 | |
| 78 | You can adjust the configuration using |
| 79 | |
| 80 | .. code-block:: bash |
| 81 | |
| 82 | make menuconfig |
| 83 | |
| 84 | Building |
| 85 | -------- |
| 86 | |
| 87 | When cross compiling you will have to specify the prefix of the cross-compiler. |
| 88 | You can either specify the value of the CROSS_COMPILE variable on the make |
| 89 | command line or export it beforehand. |
| 90 | |
| 91 | .. code-block:: bash |
| 92 | |
| 93 | CROSS_COMPILE=<compiler-prefix> make |
| 94 | |
| 95 | Assuming cross compiling on Debian for ARMv8 this would be |
| 96 | |
| 97 | .. code-block:: bash |
| 98 | |
| 99 | CROSS_COMPILE=aarch64-linux-gnu- make |
| 100 | |
| 101 | Build parameters |
| 102 | ~~~~~~~~~~~~~~~~ |
| 103 | |
| 104 | A list of available parameters for the make command can be obtained via |
| 105 | |
| 106 | .. code-block:: bash |
| 107 | |
| 108 | make help |
| 109 | |
| 110 | You can speed up compilation by parallelization using the -j parameter, e.g. |
| 111 | |
| 112 | .. code-block:: bash |
| 113 | |
| 114 | CROSS_COMPILE=aarch64-linux-gnu- make -j$(nproc) |
| 115 | |
| 116 | Further important build parameters are |
| 117 | |
| 118 | * O=<dir> - generate all output files in directory <dir>, including .config |
| 119 | * V=1 - verbose build |
| 120 | |
| 121 | Other build targets |
| 122 | ~~~~~~~~~~~~~~~~~~~ |
| 123 | |
| 124 | A list of all make targets can be obtained via |
| 125 | |
| 126 | .. code-block:: bash |
| 127 | |
| 128 | make help |
| 129 | |
| 130 | Important ones are |
| 131 | |
| 132 | * clean - remove most generated files but keep the configuration |
| 133 | * mrproper - remove all generated files + config + various backup files |
| 134 | |
| 135 | Installation |
| 136 | ------------ |
| 137 | |
| 138 | The process for installing U-Boot on the target device is device specific. |
| 139 | Please, refer to the board specific documentation :doc:`../board/index`. |