xref: /rk3399_ARM-atf/docs/getting_started/tools-build.rst (revision b50838bae79953178c3fc856c0ee015cce94e3ec)
143f35ef5SPaul BeesleyBuilding Supporting Tools
243f35ef5SPaul Beesley=========================
343f35ef5SPaul Beesley
48caf10acSJuan Pablo Conde.. note::
58caf10acSJuan Pablo Conde
68caf10acSJuan Pablo Conde    OpenSSL 3.0 is needed in order to build the tools. A custom installation
78caf10acSJuan Pablo Conde    can be used if not updating the OpenSSL version on the OS. In order to do
88caf10acSJuan Pablo Conde    this, use the ``OPENSSL_DIR`` variable after the ``make`` command to
98caf10acSJuan Pablo Conde    indicate the location of the custom OpenSSL build. Then, to run the tools,
108caf10acSJuan Pablo Conde    use the ``LD_LIBRARY_PATH`` to indicate the location of the built
118caf10acSJuan Pablo Conde    libraries. More info about ``OPENSSL_DIR`` can be found at
128caf10acSJuan Pablo Conde    :ref:`Build Options`.
138caf10acSJuan Pablo Conde
1443f35ef5SPaul BeesleyBuilding and using the FIP tool
1543f35ef5SPaul Beesley-------------------------------
1643f35ef5SPaul Beesley
17*b50838baSBoyan KaratotevThe following snippets build a :ref:`FIP<Image Terminology>` for the FVP
18*b50838baSBoyan Karatotevplatform. While it is not an intrinsic part of the FIP format, a BL33 image is
19*b50838baSBoyan Karatotevrequired for these examples. For the purposes of experimentation, `Trusted
20*b50838baSBoyan KaratotevFirmware-A Tests`_ (`tftf.bin``) may be used. Refer to to the `TFTF
21*b50838baSBoyan Karatotevdocumentation`_ for instructions on building a TFTF binary.
2243f35ef5SPaul Beesley
2343f35ef5SPaul BeesleyThe TF-A build system provides the make target ``fip`` to create a FIP file
2443f35ef5SPaul Beesleyfor the specified platform using the FIP creation tool included in the TF-A
2543f35ef5SPaul Beesleyproject. Examples below show how to build a FIP file for FVP, packaging TF-A
2643f35ef5SPaul Beesleyand BL33 images.
2743f35ef5SPaul Beesley
2843f35ef5SPaul BeesleyFor AArch64:
2943f35ef5SPaul Beesley
3043f35ef5SPaul Beesley.. code:: shell
3143f35ef5SPaul Beesley
3243f35ef5SPaul Beesley    make PLAT=fvp BL33=<path-to>/bl33.bin fip
3343f35ef5SPaul Beesley
3443f35ef5SPaul BeesleyFor AArch32:
3543f35ef5SPaul Beesley
3643f35ef5SPaul Beesley.. code:: shell
3743f35ef5SPaul Beesley
3843f35ef5SPaul Beesley    make PLAT=fvp ARCH=aarch32 AARCH32_SP=sp_min BL33=<path-to>/bl33.bin fip
3943f35ef5SPaul Beesley
4043f35ef5SPaul BeesleyThe resulting FIP may be found in:
4143f35ef5SPaul Beesley
4243f35ef5SPaul Beesley::
4343f35ef5SPaul Beesley
4443f35ef5SPaul Beesley    build/fvp/<build-type>/fip.bin
4543f35ef5SPaul Beesley
4643f35ef5SPaul BeesleyFor advanced operations on FIP files, it is also possible to independently build
4743f35ef5SPaul Beesleythe tool and create or modify FIPs using this tool. To do this, follow these
4843f35ef5SPaul Beesleysteps:
4943f35ef5SPaul Beesley
5043f35ef5SPaul BeesleyIt is recommended to remove old artifacts before building the tool:
5143f35ef5SPaul Beesley
5243f35ef5SPaul Beesley.. code:: shell
5343f35ef5SPaul Beesley
5443f35ef5SPaul Beesley    make -C tools/fiptool clean
5543f35ef5SPaul Beesley
5643f35ef5SPaul BeesleyBuild the tool:
5743f35ef5SPaul Beesley
5843f35ef5SPaul Beesley.. code:: shell
5943f35ef5SPaul Beesley
6043f35ef5SPaul Beesley    make [DEBUG=1] [V=1] fiptool
6143f35ef5SPaul Beesley
6243f35ef5SPaul BeesleyThe tool binary can be located in:
6343f35ef5SPaul Beesley
6443f35ef5SPaul Beesley::
6543f35ef5SPaul Beesley
6643f35ef5SPaul Beesley    ./tools/fiptool/fiptool
6743f35ef5SPaul Beesley
6843f35ef5SPaul BeesleyInvoking the tool with ``help`` will print a help message with all available
6943f35ef5SPaul Beesleyoptions.
7043f35ef5SPaul Beesley
7143f35ef5SPaul BeesleyExample 1: create a new Firmware package ``fip.bin`` that contains BL2 and BL31:
7243f35ef5SPaul Beesley
7343f35ef5SPaul Beesley.. code:: shell
7443f35ef5SPaul Beesley
7543f35ef5SPaul Beesley    ./tools/fiptool/fiptool create \
7643f35ef5SPaul Beesley        --tb-fw build/<platform>/<build-type>/bl2.bin \
7743f35ef5SPaul Beesley        --soc-fw build/<platform>/<build-type>/bl31.bin \
7843f35ef5SPaul Beesley        fip.bin
7943f35ef5SPaul Beesley
8043f35ef5SPaul BeesleyExample 2: view the contents of an existing Firmware package:
8143f35ef5SPaul Beesley
8243f35ef5SPaul Beesley.. code:: shell
8343f35ef5SPaul Beesley
8443f35ef5SPaul Beesley    ./tools/fiptool/fiptool info <path-to>/fip.bin
8543f35ef5SPaul Beesley
8643f35ef5SPaul BeesleyExample 3: update the entries of an existing Firmware package:
8743f35ef5SPaul Beesley
8843f35ef5SPaul Beesley.. code:: shell
8943f35ef5SPaul Beesley
9043f35ef5SPaul Beesley    # Change the BL2 from Debug to Release version
9143f35ef5SPaul Beesley    ./tools/fiptool/fiptool update \
9243f35ef5SPaul Beesley        --tb-fw build/<platform>/release/bl2.bin \
9343f35ef5SPaul Beesley        build/<platform>/debug/fip.bin
9443f35ef5SPaul Beesley
9543f35ef5SPaul BeesleyExample 4: unpack all entries from an existing Firmware package:
9643f35ef5SPaul Beesley
9743f35ef5SPaul Beesley.. code:: shell
9843f35ef5SPaul Beesley
9943f35ef5SPaul Beesley    # Images will be unpacked to the working directory
10043f35ef5SPaul Beesley    ./tools/fiptool/fiptool unpack <path-to>/fip.bin
10143f35ef5SPaul Beesley
10243f35ef5SPaul BeesleyExample 5: remove an entry from an existing Firmware package:
10343f35ef5SPaul Beesley
10443f35ef5SPaul Beesley.. code:: shell
10543f35ef5SPaul Beesley
10643f35ef5SPaul Beesley    ./tools/fiptool/fiptool remove \
10743f35ef5SPaul Beesley        --tb-fw build/<platform>/debug/fip.bin
10843f35ef5SPaul Beesley
10943f35ef5SPaul BeesleyNote that if the destination FIP file exists, the create, update and
11043f35ef5SPaul Beesleyremove operations will automatically overwrite it.
11143f35ef5SPaul Beesley
11243f35ef5SPaul BeesleyThe unpack operation will fail if the images already exist at the
11343f35ef5SPaul Beesleydestination. In that case, use -f or --force to continue.
11443f35ef5SPaul Beesley
11543f35ef5SPaul BeesleyMore information about FIP can be found in the :ref:`Firmware Design` document.
11643f35ef5SPaul Beesley
11743f35ef5SPaul Beesley.. _tools_build_cert_create:
11843f35ef5SPaul Beesley
11943f35ef5SPaul BeesleyBuilding the Certificate Generation Tool
12043f35ef5SPaul Beesley----------------------------------------
12143f35ef5SPaul Beesley
12243f35ef5SPaul BeesleyThe ``cert_create`` tool is built as part of the TF-A build process when the
12343f35ef5SPaul Beesley``fip`` make target is specified and TBB is enabled (as described in the
12443f35ef5SPaul Beesleyprevious section), but it can also be built separately with the following
12543f35ef5SPaul Beesleycommand:
12643f35ef5SPaul Beesley
12743f35ef5SPaul Beesley.. code:: shell
12843f35ef5SPaul Beesley
12943f35ef5SPaul Beesley    make PLAT=<platform> [DEBUG=1] [V=1] certtool
13043f35ef5SPaul Beesley
13143f35ef5SPaul BeesleyFor platforms that require their own IDs in certificate files, the generic
13243f35ef5SPaul Beesley'cert_create' tool can be built with the following command. Note that the target
13343f35ef5SPaul Beesleyplatform must define its IDs within a ``platform_oid.h`` header file for the
13443f35ef5SPaul Beesleybuild to succeed.
13543f35ef5SPaul Beesley
13643f35ef5SPaul Beesley.. code:: shell
13743f35ef5SPaul Beesley
13843f35ef5SPaul Beesley    make PLAT=<platform> USE_TBBR_DEFS=0 [DEBUG=1] [V=1] certtool
13943f35ef5SPaul Beesley
14043f35ef5SPaul Beesley``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
14143f35ef5SPaul Beesleyverbose. The following command should be used to obtain help about the tool:
14243f35ef5SPaul Beesley
14343f35ef5SPaul Beesley.. code:: shell
14443f35ef5SPaul Beesley
14543f35ef5SPaul Beesley    ./tools/cert_create/cert_create -h
14643f35ef5SPaul Beesley
147f97062a5SSumit Garg.. _tools_build_enctool:
148f97062a5SSumit Garg
149f97062a5SSumit GargBuilding the Firmware Encryption Tool
150f97062a5SSumit Garg~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151f97062a5SSumit Garg
152f97062a5SSumit GargThe ``encrypt_fw`` tool is built as part of the TF-A build process when the
153f97062a5SSumit Garg``fip`` make target is specified, DECRYPTION_SUPPORT and TBB are enabled, but
154f97062a5SSumit Gargit can also be built separately with the following command:
155f97062a5SSumit Garg
156f97062a5SSumit Garg.. code:: shell
157f97062a5SSumit Garg
158f97062a5SSumit Garg    make PLAT=<platform> [DEBUG=1] [V=1] enctool
159f97062a5SSumit Garg
160f97062a5SSumit Garg``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
161f97062a5SSumit Gargverbose. The following command should be used to obtain help about the tool:
162f97062a5SSumit Garg
163f97062a5SSumit Garg.. code:: shell
164f97062a5SSumit Garg
165f97062a5SSumit Garg    ./tools/encrypt_fw/encrypt_fw -h
166f97062a5SSumit Garg
167f97062a5SSumit GargNote that the enctool in its current implementation only supports encryption
168f97062a5SSumit Gargkey to be provided in plain format. A typical implementation can very well
169f97062a5SSumit Gargextend this tool to support custom techniques to protect encryption key.
170f97062a5SSumit Garg
171f97062a5SSumit GargAlso, a user may choose to provide encryption key or nonce as an input file
172f97062a5SSumit Gargvia using ``cat <filename>`` instead of a hex string.
173f97062a5SSumit Garg
17443f35ef5SPaul Beesley--------------
17543f35ef5SPaul Beesley
1768caf10acSJuan Pablo Conde*Copyright (c) 2019-2022, Arm Limited. All rights reserved.*
177*b50838baSBoyan Karatotev
178*b50838baSBoyan Karatotev.. _Trusted Firmware-A Tests: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/
179*b50838baSBoyan Karatotev.. _TFTF documentation: https://trustedfirmware-a-tests.readthedocs.io/en/latest/
180