xref: /arm-trusted-firmware/docs/getting_started/initial-build.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluPerforming an Initial Build
2*91f16700Schasinglulu===========================
3*91f16700Schasinglulu
4*91f16700Schasinglulu-  Before building TF-A, the environment variable ``CROSS_COMPILE`` must point
5*91f16700Schasinglulu   to your cross compiler.
6*91f16700Schasinglulu
7*91f16700Schasinglulu   For AArch64:
8*91f16700Schasinglulu
9*91f16700Schasinglulu   .. code:: shell
10*91f16700Schasinglulu
11*91f16700Schasinglulu       export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf-
12*91f16700Schasinglulu
13*91f16700Schasinglulu   For AArch32:
14*91f16700Schasinglulu
15*91f16700Schasinglulu   .. code:: shell
16*91f16700Schasinglulu
17*91f16700Schasinglulu       export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-none-eabi-
18*91f16700Schasinglulu
19*91f16700Schasinglulu   It is possible to build TF-A using Clang or Arm Compiler 6. To do so
20*91f16700Schasinglulu   ``CC`` needs to point to the clang or armclang binary, which will
21*91f16700Schasinglulu   also select the clang or armclang assembler. Arm Compiler 6 will be selected
22*91f16700Schasinglulu   when the base name of the path assigned to ``CC`` matches the string
23*91f16700Schasinglulu   'armclang'. GNU binutils are required since the TF-A build system doesn't
24*91f16700Schasinglulu   currently support Arm Scatter files. Meaning the GNU linker is used by
25*91f16700Schasinglulu   default for Arm Compiler 6. Because of this dependency, ``CROSS_COMPILE``
26*91f16700Schasinglulu   should be set as described above.
27*91f16700Schasinglulu
28*91f16700Schasinglulu   For AArch64 using Arm Compiler 6:
29*91f16700Schasinglulu
30*91f16700Schasinglulu   .. code:: shell
31*91f16700Schasinglulu
32*91f16700Schasinglulu       export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf-
33*91f16700Schasinglulu       make CC=<path-to-armclang>/bin/armclang PLAT=<platform> all
34*91f16700Schasinglulu
35*91f16700Schasinglulu   On the other hand, Clang uses LLVM linker (LLD) and other LLVM binutils by
36*91f16700Schasinglulu   default instead of GNU utilities (LLVM linker (LLD) 14.0.0 is known to
37*91f16700Schasinglulu   work with TF-A). ``CROSS_COMPILE`` need not be set for Clang. Please note,
38*91f16700Schasinglulu   that the default linker may be manually overridden using the ``LD`` variable.
39*91f16700Schasinglulu
40*91f16700Schasinglulu   Clang will be selected when the base name of the path assigned to ``CC``
41*91f16700Schasinglulu   contains the string 'clang'. This is to allow both clang and clang-X.Y
42*91f16700Schasinglulu   to work.
43*91f16700Schasinglulu
44*91f16700Schasinglulu   For AArch64 using clang:
45*91f16700Schasinglulu
46*91f16700Schasinglulu   .. code:: shell
47*91f16700Schasinglulu
48*91f16700Schasinglulu       make CC=<path-to-clang>/bin/clang PLAT=<platform> all
49*91f16700Schasinglulu
50*91f16700Schasinglulu-  Change to the root directory of the TF-A source tree and build.
51*91f16700Schasinglulu
52*91f16700Schasinglulu   For AArch64:
53*91f16700Schasinglulu
54*91f16700Schasinglulu   .. code:: shell
55*91f16700Schasinglulu
56*91f16700Schasinglulu       make PLAT=<platform> all
57*91f16700Schasinglulu
58*91f16700Schasinglulu   For AArch32:
59*91f16700Schasinglulu
60*91f16700Schasinglulu   .. code:: shell
61*91f16700Schasinglulu
62*91f16700Schasinglulu       make PLAT=<platform> ARCH=aarch32 AARCH32_SP=sp_min all
63*91f16700Schasinglulu
64*91f16700Schasinglulu   Notes:
65*91f16700Schasinglulu
66*91f16700Schasinglulu   -  If ``PLAT`` is not specified, ``fvp`` is assumed by default. See the
67*91f16700Schasinglulu      :ref:`Build Options` document for more information on available build
68*91f16700Schasinglulu      options.
69*91f16700Schasinglulu
70*91f16700Schasinglulu   -  (AArch32 only) Currently only ``PLAT=fvp`` is supported.
71*91f16700Schasinglulu
72*91f16700Schasinglulu   -  (AArch32 only) ``AARCH32_SP`` is the AArch32 EL3 Runtime Software and it
73*91f16700Schasinglulu      corresponds to the BL32 image. A minimal ``AARCH32_SP``, sp_min, is
74*91f16700Schasinglulu      provided by TF-A to demonstrate how PSCI Library can be integrated with
75*91f16700Schasinglulu      an AArch32 EL3 Runtime Software. Some AArch32 EL3 Runtime Software may
76*91f16700Schasinglulu      include other runtime services, for example Trusted OS services. A guide
77*91f16700Schasinglulu      to integrate PSCI library with AArch32 EL3 Runtime Software can be found
78*91f16700Schasinglulu      at :ref:`PSCI Library Integration guide for Armv8-A AArch32 systems`.
79*91f16700Schasinglulu
80*91f16700Schasinglulu   -  (AArch64 only) The TSP (Test Secure Payload), corresponding to the BL32
81*91f16700Schasinglulu      image, is not compiled in by default. Refer to the
82*91f16700Schasinglulu      :ref:`Test Secure Payload (TSP) and Dispatcher (TSPD)` document for
83*91f16700Schasinglulu      details on building the TSP.
84*91f16700Schasinglulu
85*91f16700Schasinglulu   -  By default this produces a release version of the build. To produce a
86*91f16700Schasinglulu      debug version instead, refer to the "Debugging options" section below.
87*91f16700Schasinglulu
88*91f16700Schasinglulu   -  The build process creates products in a ``build`` directory tree, building
89*91f16700Schasinglulu      the objects and binaries for each boot loader stage in separate
90*91f16700Schasinglulu      sub-directories. The following boot loader binary files are created
91*91f16700Schasinglulu      from the corresponding ELF files:
92*91f16700Schasinglulu
93*91f16700Schasinglulu      -  ``build/<platform>/<build-type>/bl1.bin``
94*91f16700Schasinglulu      -  ``build/<platform>/<build-type>/bl2.bin``
95*91f16700Schasinglulu      -  ``build/<platform>/<build-type>/bl31.bin`` (AArch64 only)
96*91f16700Schasinglulu      -  ``build/<platform>/<build-type>/bl32.bin`` (mandatory for AArch32)
97*91f16700Schasinglulu
98*91f16700Schasinglulu      where ``<platform>`` is the name of the chosen platform and ``<build-type>``
99*91f16700Schasinglulu      is either ``debug`` or ``release``. The actual number of images might differ
100*91f16700Schasinglulu      depending on the platform.
101*91f16700Schasinglulu
102*91f16700Schasinglulu-  Build products for a specific build variant can be removed using:
103*91f16700Schasinglulu
104*91f16700Schasinglulu   .. code:: shell
105*91f16700Schasinglulu
106*91f16700Schasinglulu       make DEBUG=<D> PLAT=<platform> clean
107*91f16700Schasinglulu
108*91f16700Schasinglulu   ... where ``<D>`` is ``0`` or ``1``, as specified when building.
109*91f16700Schasinglulu
110*91f16700Schasinglulu   The build tree can be removed completely using:
111*91f16700Schasinglulu
112*91f16700Schasinglulu   .. code:: shell
113*91f16700Schasinglulu
114*91f16700Schasinglulu       make realclean
115*91f16700Schasinglulu
116*91f16700Schasinglulu--------------
117*91f16700Schasinglulu
118*91f16700Schasinglulu*Copyright (c) 2020-2022, Arm Limited. All rights reserved.*
119