xref: /arm-trusted-firmware/docs/getting_started/tools-build.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluBuilding Supporting Tools
2*91f16700Schasinglulu=========================
3*91f16700Schasinglulu
4*91f16700Schasinglulu.. note::
5*91f16700Schasinglulu
6*91f16700Schasinglulu    OpenSSL 3.0 is needed in order to build the tools. A custom installation
7*91f16700Schasinglulu    can be used if not updating the OpenSSL version on the OS. In order to do
8*91f16700Schasinglulu    this, use the ``OPENSSL_DIR`` variable after the ``make`` command to
9*91f16700Schasinglulu    indicate the location of the custom OpenSSL build. Then, to run the tools,
10*91f16700Schasinglulu    use the ``LD_LIBRARY_PATH`` to indicate the location of the built
11*91f16700Schasinglulu    libraries. More info about ``OPENSSL_DIR`` can be found at
12*91f16700Schasinglulu    :ref:`Build Options`.
13*91f16700Schasinglulu
14*91f16700SchasingluluBuilding and using the FIP tool
15*91f16700Schasinglulu-------------------------------
16*91f16700Schasinglulu
17*91f16700SchasingluluThe following snippets build a :ref:`FIP<Image Terminology>` for the FVP
18*91f16700Schasingluluplatform. While it is not an intrinsic part of the FIP format, a BL33 image is
19*91f16700Schasinglulurequired for these examples. For the purposes of experimentation, `Trusted
20*91f16700SchasingluluFirmware-A Tests`_ (`tftf.bin``) may be used. Refer to to the `TFTF
21*91f16700Schasingluludocumentation`_ for instructions on building a TFTF binary.
22*91f16700Schasinglulu
23*91f16700SchasingluluThe TF-A build system provides the make target ``fip`` to create a FIP file
24*91f16700Schasinglulufor the specified platform using the FIP creation tool included in the TF-A
25*91f16700Schasingluluproject. Examples below show how to build a FIP file for FVP, packaging TF-A
26*91f16700Schasingluluand BL33 images.
27*91f16700Schasinglulu
28*91f16700SchasingluluFor AArch64:
29*91f16700Schasinglulu
30*91f16700Schasinglulu.. code:: shell
31*91f16700Schasinglulu
32*91f16700Schasinglulu    make PLAT=fvp BL33=<path-to>/bl33.bin fip
33*91f16700Schasinglulu
34*91f16700SchasingluluFor AArch32:
35*91f16700Schasinglulu
36*91f16700Schasinglulu.. code:: shell
37*91f16700Schasinglulu
38*91f16700Schasinglulu    make PLAT=fvp ARCH=aarch32 AARCH32_SP=sp_min BL33=<path-to>/bl33.bin fip
39*91f16700Schasinglulu
40*91f16700SchasingluluThe resulting FIP may be found in:
41*91f16700Schasinglulu
42*91f16700Schasinglulu::
43*91f16700Schasinglulu
44*91f16700Schasinglulu    build/fvp/<build-type>/fip.bin
45*91f16700Schasinglulu
46*91f16700SchasingluluFor advanced operations on FIP files, it is also possible to independently build
47*91f16700Schasingluluthe tool and create or modify FIPs using this tool. To do this, follow these
48*91f16700Schasinglulusteps:
49*91f16700Schasinglulu
50*91f16700SchasingluluIt is recommended to remove old artifacts before building the tool:
51*91f16700Schasinglulu
52*91f16700Schasinglulu.. code:: shell
53*91f16700Schasinglulu
54*91f16700Schasinglulu    make -C tools/fiptool clean
55*91f16700Schasinglulu
56*91f16700SchasingluluBuild the tool:
57*91f16700Schasinglulu
58*91f16700Schasinglulu.. code:: shell
59*91f16700Schasinglulu
60*91f16700Schasinglulu    make [DEBUG=1] [V=1] fiptool
61*91f16700Schasinglulu
62*91f16700SchasingluluThe tool binary can be located in:
63*91f16700Schasinglulu
64*91f16700Schasinglulu::
65*91f16700Schasinglulu
66*91f16700Schasinglulu    ./tools/fiptool/fiptool
67*91f16700Schasinglulu
68*91f16700SchasingluluInvoking the tool with ``help`` will print a help message with all available
69*91f16700Schasingluluoptions.
70*91f16700Schasinglulu
71*91f16700SchasingluluExample 1: create a new Firmware package ``fip.bin`` that contains BL2 and BL31:
72*91f16700Schasinglulu
73*91f16700Schasinglulu.. code:: shell
74*91f16700Schasinglulu
75*91f16700Schasinglulu    ./tools/fiptool/fiptool create \
76*91f16700Schasinglulu        --tb-fw build/<platform>/<build-type>/bl2.bin \
77*91f16700Schasinglulu        --soc-fw build/<platform>/<build-type>/bl31.bin \
78*91f16700Schasinglulu        fip.bin
79*91f16700Schasinglulu
80*91f16700SchasingluluExample 2: view the contents of an existing Firmware package:
81*91f16700Schasinglulu
82*91f16700Schasinglulu.. code:: shell
83*91f16700Schasinglulu
84*91f16700Schasinglulu    ./tools/fiptool/fiptool info <path-to>/fip.bin
85*91f16700Schasinglulu
86*91f16700SchasingluluExample 3: update the entries of an existing Firmware package:
87*91f16700Schasinglulu
88*91f16700Schasinglulu.. code:: shell
89*91f16700Schasinglulu
90*91f16700Schasinglulu    # Change the BL2 from Debug to Release version
91*91f16700Schasinglulu    ./tools/fiptool/fiptool update \
92*91f16700Schasinglulu        --tb-fw build/<platform>/release/bl2.bin \
93*91f16700Schasinglulu        build/<platform>/debug/fip.bin
94*91f16700Schasinglulu
95*91f16700SchasingluluExample 4: unpack all entries from an existing Firmware package:
96*91f16700Schasinglulu
97*91f16700Schasinglulu.. code:: shell
98*91f16700Schasinglulu
99*91f16700Schasinglulu    # Images will be unpacked to the working directory
100*91f16700Schasinglulu    ./tools/fiptool/fiptool unpack <path-to>/fip.bin
101*91f16700Schasinglulu
102*91f16700SchasingluluExample 5: remove an entry from an existing Firmware package:
103*91f16700Schasinglulu
104*91f16700Schasinglulu.. code:: shell
105*91f16700Schasinglulu
106*91f16700Schasinglulu    ./tools/fiptool/fiptool remove \
107*91f16700Schasinglulu        --tb-fw build/<platform>/debug/fip.bin
108*91f16700Schasinglulu
109*91f16700SchasingluluNote that if the destination FIP file exists, the create, update and
110*91f16700Schasingluluremove operations will automatically overwrite it.
111*91f16700Schasinglulu
112*91f16700SchasingluluThe unpack operation will fail if the images already exist at the
113*91f16700Schasingluludestination. In that case, use -f or --force to continue.
114*91f16700Schasinglulu
115*91f16700SchasingluluMore information about FIP can be found in the :ref:`Firmware Design` document.
116*91f16700Schasinglulu
117*91f16700Schasinglulu.. _tools_build_cert_create:
118*91f16700Schasinglulu
119*91f16700SchasingluluBuilding the Certificate Generation Tool
120*91f16700Schasinglulu----------------------------------------
121*91f16700Schasinglulu
122*91f16700SchasingluluThe ``cert_create`` tool is built as part of the TF-A build process when the
123*91f16700Schasinglulu``fip`` make target is specified and TBB is enabled (as described in the
124*91f16700Schasingluluprevious section), but it can also be built separately with the following
125*91f16700Schasinglulucommand:
126*91f16700Schasinglulu
127*91f16700Schasinglulu.. code:: shell
128*91f16700Schasinglulu
129*91f16700Schasinglulu    make PLAT=<platform> [DEBUG=1] [V=1] certtool
130*91f16700Schasinglulu
131*91f16700SchasingluluFor platforms that require their own IDs in certificate files, the generic
132*91f16700Schasinglulu'cert_create' tool can be built with the following command. Note that the target
133*91f16700Schasingluluplatform must define its IDs within a ``platform_oid.h`` header file for the
134*91f16700Schasinglulubuild to succeed.
135*91f16700Schasinglulu
136*91f16700Schasinglulu.. code:: shell
137*91f16700Schasinglulu
138*91f16700Schasinglulu    make PLAT=<platform> USE_TBBR_DEFS=0 [DEBUG=1] [V=1] certtool
139*91f16700Schasinglulu
140*91f16700Schasinglulu``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
141*91f16700Schasingluluverbose. The following command should be used to obtain help about the tool:
142*91f16700Schasinglulu
143*91f16700Schasinglulu.. code:: shell
144*91f16700Schasinglulu
145*91f16700Schasinglulu    ./tools/cert_create/cert_create -h
146*91f16700Schasinglulu
147*91f16700Schasinglulu.. _tools_build_enctool:
148*91f16700Schasinglulu
149*91f16700SchasingluluBuilding the Firmware Encryption Tool
150*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151*91f16700Schasinglulu
152*91f16700SchasingluluThe ``encrypt_fw`` tool is built as part of the TF-A build process when the
153*91f16700Schasinglulu``fip`` make target is specified, DECRYPTION_SUPPORT and TBB are enabled, but
154*91f16700Schasingluluit can also be built separately with the following command:
155*91f16700Schasinglulu
156*91f16700Schasinglulu.. code:: shell
157*91f16700Schasinglulu
158*91f16700Schasinglulu    make PLAT=<platform> [DEBUG=1] [V=1] enctool
159*91f16700Schasinglulu
160*91f16700Schasinglulu``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
161*91f16700Schasingluluverbose. The following command should be used to obtain help about the tool:
162*91f16700Schasinglulu
163*91f16700Schasinglulu.. code:: shell
164*91f16700Schasinglulu
165*91f16700Schasinglulu    ./tools/encrypt_fw/encrypt_fw -h
166*91f16700Schasinglulu
167*91f16700SchasingluluNote that the enctool in its current implementation only supports encryption
168*91f16700Schasinglulukey to be provided in plain format. A typical implementation can very well
169*91f16700Schasingluluextend this tool to support custom techniques to protect encryption key.
170*91f16700Schasinglulu
171*91f16700SchasingluluAlso, a user may choose to provide encryption key or nonce as an input file
172*91f16700Schasingluluvia using ``cat <filename>`` instead of a hex string.
173*91f16700Schasinglulu
174*91f16700Schasinglulu--------------
175*91f16700Schasinglulu
176*91f16700Schasinglulu*Copyright (c) 2019-2022, Arm Limited. All rights reserved.*
177*91f16700Schasinglulu
178*91f16700Schasinglulu.. _Trusted Firmware-A Tests: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/
179*91f16700Schasinglulu.. _TFTF documentation: https://trustedfirmware-a-tests.readthedocs.io/en/latest/
180