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