xref: /rk3399_ARM-atf/docs/getting_started/initial-build.rst (revision ee87353cc41245023e5cf858b6715c5c5cbdc234)
143f35ef5SPaul BeesleyPerforming an Initial Build
243f35ef5SPaul Beesley===========================
343f35ef5SPaul Beesley
443f35ef5SPaul Beesley-  Before building TF-A, the environment variable ``CROSS_COMPILE`` must point
5b50838baSBoyan Karatotev   to your cross compiler.
643f35ef5SPaul Beesley
743f35ef5SPaul Beesley   For AArch64:
843f35ef5SPaul Beesley
943f35ef5SPaul Beesley   .. code:: shell
1043f35ef5SPaul Beesley
11f35e5ab3SMadhukar Pappireddy       export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf-
1243f35ef5SPaul Beesley
1343f35ef5SPaul Beesley   For AArch32:
1443f35ef5SPaul Beesley
1543f35ef5SPaul Beesley   .. code:: shell
1643f35ef5SPaul Beesley
17f35e5ab3SMadhukar Pappireddy       export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-none-eabi-
1843f35ef5SPaul Beesley
1943f35ef5SPaul Beesley   It is possible to build TF-A using Clang or Arm Compiler 6. To do so
2043f35ef5SPaul Beesley   ``CC`` needs to point to the clang or armclang binary, which will
21a5d36574SHarrison Mutai   also select the clang or armclang assembler. Arm Compiler 6 will be selected
22a5d36574SHarrison Mutai   when the base name of the path assigned to ``CC`` matches the string
23a5d36574SHarrison Mutai   'armclang'. GNU binutils are required since the TF-A build system doesn't
24a5d36574SHarrison Mutai   currently support Arm Scatter files. Meaning the GNU linker is used by
25a5d36574SHarrison Mutai   default for Arm Compiler 6. Because of this dependency, ``CROSS_COMPILE``
26a5d36574SHarrison Mutai   should be set as described above.
2743f35ef5SPaul Beesley
2843f35ef5SPaul Beesley   For AArch64 using Arm Compiler 6:
2943f35ef5SPaul Beesley
3043f35ef5SPaul Beesley   .. code:: shell
3143f35ef5SPaul Beesley
32f35e5ab3SMadhukar Pappireddy       export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf-
3343f35ef5SPaul Beesley       make CC=<path-to-armclang>/bin/armclang PLAT=<platform> all
3443f35ef5SPaul Beesley
35a5d36574SHarrison Mutai   On the other hand, Clang uses LLVM linker (LLD) and other LLVM binutils by
36a5d36574SHarrison Mutai   default instead of GNU utilities (LLVM linker (LLD) 14.0.0 is known to
37a5d36574SHarrison Mutai   work with TF-A). ``CROSS_COMPILE`` need not be set for Clang. Please note,
38a5d36574SHarrison Mutai   that the default linker may be manually overridden using the ``LD`` variable.
39a5d36574SHarrison Mutai
4043f35ef5SPaul Beesley   Clang will be selected when the base name of the path assigned to ``CC``
4143f35ef5SPaul Beesley   contains the string 'clang'. This is to allow both clang and clang-X.Y
4243f35ef5SPaul Beesley   to work.
4343f35ef5SPaul Beesley
4443f35ef5SPaul Beesley   For AArch64 using clang:
4543f35ef5SPaul Beesley
4643f35ef5SPaul Beesley   .. code:: shell
4743f35ef5SPaul Beesley
4843f35ef5SPaul Beesley       make CC=<path-to-clang>/bin/clang PLAT=<platform> all
4943f35ef5SPaul Beesley
5043f35ef5SPaul Beesley-  Change to the root directory of the TF-A source tree and build.
5143f35ef5SPaul Beesley
5243f35ef5SPaul Beesley   For AArch64:
5343f35ef5SPaul Beesley
5443f35ef5SPaul Beesley   .. code:: shell
5543f35ef5SPaul Beesley
5643f35ef5SPaul Beesley       make PLAT=<platform> all
5743f35ef5SPaul Beesley
5843f35ef5SPaul Beesley   For AArch32:
5943f35ef5SPaul Beesley
6043f35ef5SPaul Beesley   .. code:: shell
6143f35ef5SPaul Beesley
6243f35ef5SPaul Beesley       make PLAT=<platform> ARCH=aarch32 AARCH32_SP=sp_min all
6343f35ef5SPaul Beesley
6443f35ef5SPaul Beesley   Notes:
6543f35ef5SPaul Beesley
6643f35ef5SPaul Beesley   -  If ``PLAT`` is not specified, ``fvp`` is assumed by default. See the
6743f35ef5SPaul Beesley      :ref:`Build Options` document for more information on available build
6843f35ef5SPaul Beesley      options.
6943f35ef5SPaul Beesley
7043f35ef5SPaul Beesley   -  (AArch32 only) Currently only ``PLAT=fvp`` is supported.
7143f35ef5SPaul Beesley
7243f35ef5SPaul Beesley   -  (AArch32 only) ``AARCH32_SP`` is the AArch32 EL3 Runtime Software and it
7343f35ef5SPaul Beesley      corresponds to the BL32 image. A minimal ``AARCH32_SP``, sp_min, is
7443f35ef5SPaul Beesley      provided by TF-A to demonstrate how PSCI Library can be integrated with
7543f35ef5SPaul Beesley      an AArch32 EL3 Runtime Software. Some AArch32 EL3 Runtime Software may
7643f35ef5SPaul Beesley      include other runtime services, for example Trusted OS services. A guide
7743f35ef5SPaul Beesley      to integrate PSCI library with AArch32 EL3 Runtime Software can be found
78*b5f120b5SBoyan Karatotev      at :ref:`Porting Guide`.
7943f35ef5SPaul Beesley
8043f35ef5SPaul Beesley   -  (AArch64 only) The TSP (Test Secure Payload), corresponding to the BL32
8143f35ef5SPaul Beesley      image, is not compiled in by default. Refer to the
8243f35ef5SPaul Beesley      :ref:`Test Secure Payload (TSP) and Dispatcher (TSPD)` document for
8343f35ef5SPaul Beesley      details on building the TSP.
8443f35ef5SPaul Beesley
8543f35ef5SPaul Beesley   -  By default this produces a release version of the build. To produce a
8643f35ef5SPaul Beesley      debug version instead, refer to the "Debugging options" section below.
8743f35ef5SPaul Beesley
8843f35ef5SPaul Beesley   -  The build process creates products in a ``build`` directory tree, building
8943f35ef5SPaul Beesley      the objects and binaries for each boot loader stage in separate
9043f35ef5SPaul Beesley      sub-directories. The following boot loader binary files are created
9143f35ef5SPaul Beesley      from the corresponding ELF files:
9243f35ef5SPaul Beesley
9343f35ef5SPaul Beesley      -  ``build/<platform>/<build-type>/bl1.bin``
9443f35ef5SPaul Beesley      -  ``build/<platform>/<build-type>/bl2.bin``
9543f35ef5SPaul Beesley      -  ``build/<platform>/<build-type>/bl31.bin`` (AArch64 only)
9643f35ef5SPaul Beesley      -  ``build/<platform>/<build-type>/bl32.bin`` (mandatory for AArch32)
9743f35ef5SPaul Beesley
9843f35ef5SPaul Beesley      where ``<platform>`` is the name of the chosen platform and ``<build-type>``
9943f35ef5SPaul Beesley      is either ``debug`` or ``release``. The actual number of images might differ
10043f35ef5SPaul Beesley      depending on the platform.
10143f35ef5SPaul Beesley
10243f35ef5SPaul Beesley-  Build products for a specific build variant can be removed using:
10343f35ef5SPaul Beesley
10443f35ef5SPaul Beesley   .. code:: shell
10543f35ef5SPaul Beesley
10643f35ef5SPaul Beesley       make DEBUG=<D> PLAT=<platform> clean
10743f35ef5SPaul Beesley
10843f35ef5SPaul Beesley   ... where ``<D>`` is ``0`` or ``1``, as specified when building.
10943f35ef5SPaul Beesley
11043f35ef5SPaul Beesley   The build tree can be removed completely using:
11143f35ef5SPaul Beesley
11243f35ef5SPaul Beesley   .. code:: shell
11343f35ef5SPaul Beesley
11443f35ef5SPaul Beesley       make realclean
11543f35ef5SPaul Beesley
11643f35ef5SPaul Beesley--------------
11743f35ef5SPaul Beesley
118*b5f120b5SBoyan Karatotev*Copyright (c) 2020-2025, Arm Limited. All rights reserved.*
119