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