xref: /arm-trusted-firmware/docs/design/trusted-board-boot-build.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluBuilding FIP images with support for Trusted Board Boot
2*91f16700Schasinglulu=======================================================
3*91f16700Schasinglulu
4*91f16700SchasingluluTrusted Board Boot primarily consists of the following two features:
5*91f16700Schasinglulu
6*91f16700Schasinglulu-  Image Authentication, described in :ref:`Trusted Board Boot`, and
7*91f16700Schasinglulu-  Firmware Update, described in :ref:`Firmware Update (FWU)`
8*91f16700Schasinglulu
9*91f16700SchasingluluThe following steps should be followed to build FIP and (optionally) FWU_FIP
10*91f16700Schasingluluimages with support for these features:
11*91f16700Schasinglulu
12*91f16700Schasinglulu#. Fulfill the dependencies of the ``mbedtls`` cryptographic and image parser
13*91f16700Schasinglulu   modules by checking out a recent version of the `mbed TLS Repository`_. It
14*91f16700Schasinglulu   is important to use a version that is compatible with TF-A and fixes any
15*91f16700Schasinglulu   known security vulnerabilities. See `mbed TLS Security Center`_ for more
16*91f16700Schasinglulu   information. See the :ref:`Prerequisites` document for the appropriate
17*91f16700Schasinglulu   version of mbed TLS to use.
18*91f16700Schasinglulu
19*91f16700Schasinglulu   The ``drivers/auth/mbedtls/mbedtls_*.mk`` files contain the list of mbed TLS
20*91f16700Schasinglulu   source files the modules depend upon.
21*91f16700Schasinglulu   ``include/drivers/auth/mbedtls/mbedtls_config.h`` contains the configuration
22*91f16700Schasinglulu   options required to build the mbed TLS sources.
23*91f16700Schasinglulu
24*91f16700Schasinglulu   Note that the mbed TLS library is licensed under the Apache version 2.0
25*91f16700Schasinglulu   license. Using mbed TLS source code will affect the licensing of TF-A
26*91f16700Schasinglulu   binaries that are built using this library.
27*91f16700Schasinglulu
28*91f16700Schasinglulu#. To build the FIP image, ensure the following command line variables are set
29*91f16700Schasinglulu   while invoking ``make`` to build TF-A:
30*91f16700Schasinglulu
31*91f16700Schasinglulu   -  ``MBEDTLS_DIR=<path of the directory containing mbed TLS sources>``
32*91f16700Schasinglulu   -  ``TRUSTED_BOARD_BOOT=1``
33*91f16700Schasinglulu   -  ``GENERATE_COT=1``
34*91f16700Schasinglulu
35*91f16700Schasinglulu   By default, this will use the Chain of Trust described in the TBBR-client
36*91f16700Schasinglulu   document. To select a different one, use the ``COT`` build option.
37*91f16700Schasinglulu
38*91f16700Schasinglulu   If using a custom build of OpenSSL, set the ``OPENSSL_DIR`` variable
39*91f16700Schasinglulu   accordingly so it points at the OpenSSL installation path, as explained in
40*91f16700Schasinglulu   :ref:`Build Options`. In addition, set the ``LD_LIBRARY_PATH`` variable
41*91f16700Schasinglulu   when running to point at the custom OpenSSL path, so the OpenSSL libraries
42*91f16700Schasinglulu   are loaded from that path instead of the default OS path. Export this
43*91f16700Schasinglulu   variable if necessary.
44*91f16700Schasinglulu
45*91f16700Schasinglulu   In the case of Arm platforms, the location of the ROTPK must also be
46*91f16700Schasinglulu   specified at build time. The following locations are currently supported (see
47*91f16700Schasinglulu   ``ARM_ROTPK_LOCATION`` build option):
48*91f16700Schasinglulu
49*91f16700Schasinglulu   -  ``ARM_ROTPK_LOCATION=regs``: the ROTPK hash is obtained from the Trusted
50*91f16700Schasinglulu      root-key storage registers present in the platform. On Juno, these
51*91f16700Schasinglulu      registers are read-only. On FVP Base and Cortex models, the registers
52*91f16700Schasinglulu      are also read-only, but the value can be specified using the command line
53*91f16700Schasinglulu      option ``bp.trusted_key_storage.public_key`` when launching the model.
54*91f16700Schasinglulu      On Juno board, the default value corresponds to an ECDSA-SECP256R1 public
55*91f16700Schasinglulu      key hash, whose private part is not currently available.
56*91f16700Schasinglulu
57*91f16700Schasinglulu   -  ``ARM_ROTPK_LOCATION=devel_rsa``: use the default hash located in
58*91f16700Schasinglulu      ``plat/arm/board/common/rotpk/arm_rotpk_rsa_sha256.bin``. Enforce
59*91f16700Schasinglulu      generation of the new hash if ``ROT_KEY`` is specified.
60*91f16700Schasinglulu
61*91f16700Schasinglulu   -  ``ARM_ROTPK_LOCATION=devel_ecdsa``: use the default hash located in
62*91f16700Schasinglulu      ``plat/arm/board/common/rotpk/arm_rotpk_ecdsa_sha256.bin``. Enforce
63*91f16700Schasinglulu      generation of the new hash if ``ROT_KEY`` is specified.
64*91f16700Schasinglulu
65*91f16700Schasinglulu   -  ``ARM_ROTPK_LOCATION=devel_full_dev_rsa_key``: use the key located in
66*91f16700Schasinglulu      ``plat/arm/board/common/rotpk/arm_full_dev_rsa_rotpk.S``.
67*91f16700Schasinglulu
68*91f16700Schasinglulu   Example of command line using RSA development keys:
69*91f16700Schasinglulu
70*91f16700Schasinglulu   .. code:: shell
71*91f16700Schasinglulu
72*91f16700Schasinglulu       MBEDTLS_DIR=<path of the directory containing mbed TLS sources> \
73*91f16700Schasinglulu       make PLAT=<platform> TRUSTED_BOARD_BOOT=1 GENERATE_COT=1        \
74*91f16700Schasinglulu       ARM_ROTPK_LOCATION=devel_rsa                                    \
75*91f16700Schasinglulu       ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem        \
76*91f16700Schasinglulu       BL33=<path-to>/<bl33_image> OPENSSL_DIR=<path-to>/<openssl>     \
77*91f16700Schasinglulu       all fip
78*91f16700Schasinglulu
79*91f16700Schasinglulu   The result of this build will be the bl1.bin and the fip.bin binaries. This
80*91f16700Schasinglulu   FIP will include the certificates corresponding to the selected Chain of
81*91f16700Schasinglulu   Trust. These certificates can also be found in the output build directory.
82*91f16700Schasinglulu
83*91f16700Schasinglulu#. The optional FWU_FIP contains any additional images to be loaded from
84*91f16700Schasinglulu   Non-Volatile storage during the :ref:`Firmware Update (FWU)` process. To build the
85*91f16700Schasinglulu   FWU_FIP, any FWU images required by the platform must be specified on the
86*91f16700Schasinglulu   command line. On Arm development platforms like Juno, these are:
87*91f16700Schasinglulu
88*91f16700Schasinglulu   -  NS_BL2U. The AP non-secure Firmware Updater image.
89*91f16700Schasinglulu   -  SCP_BL2U. The SCP Firmware Update Configuration image.
90*91f16700Schasinglulu
91*91f16700Schasinglulu   Example of Juno command line for generating both ``fwu`` and ``fwu_fip``
92*91f16700Schasinglulu   targets using RSA development:
93*91f16700Schasinglulu
94*91f16700Schasinglulu   ::
95*91f16700Schasinglulu
96*91f16700Schasinglulu       MBEDTLS_DIR=<path of the directory containing mbed TLS sources> \
97*91f16700Schasinglulu       make PLAT=juno TRUSTED_BOARD_BOOT=1 GENERATE_COT=1              \
98*91f16700Schasinglulu       ARM_ROTPK_LOCATION=devel_rsa                                    \
99*91f16700Schasinglulu       ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem        \
100*91f16700Schasinglulu       BL33=<path-to>/<bl33_image> OPENSSL_DIR=<path-to>/<openssl>     \
101*91f16700Schasinglulu       SCP_BL2=<path-to>/<scp_bl2_image>                               \
102*91f16700Schasinglulu       SCP_BL2U=<path-to>/<scp_bl2u_image>                             \
103*91f16700Schasinglulu       NS_BL2U=<path-to>/<ns_bl2u_image>                               \
104*91f16700Schasinglulu       all fip fwu_fip
105*91f16700Schasinglulu
106*91f16700Schasinglulu   .. note::
107*91f16700Schasinglulu      The BL2U image will be built by default and added to the FWU_FIP.
108*91f16700Schasinglulu      The user may override this by adding ``BL2U=<path-to>/<bl2u_image>``
109*91f16700Schasinglulu      to the command line above.
110*91f16700Schasinglulu
111*91f16700Schasinglulu   .. note::
112*91f16700Schasinglulu      Building and installing the non-secure and SCP FWU images (NS_BL1U,
113*91f16700Schasinglulu      NS_BL2U and SCP_BL2U) is outside the scope of this document.
114*91f16700Schasinglulu
115*91f16700Schasinglulu   The result of this build will be bl1.bin, fip.bin and fwu_fip.bin binaries.
116*91f16700Schasinglulu   Both the FIP and FWU_FIP will include the certificates corresponding to the
117*91f16700Schasinglulu   selected Chain of Trust. These certificates can also be found in the output
118*91f16700Schasinglulu   build directory.
119*91f16700Schasinglulu
120*91f16700Schasinglulu--------------
121*91f16700Schasinglulu
122*91f16700Schasinglulu*Copyright (c) 2019-2022, Arm Limited. All rights reserved.*
123*91f16700Schasinglulu
124*91f16700Schasinglulu.. _mbed TLS Repository: https://github.com/ARMmbed/mbedtls.git
125*91f16700Schasinglulu.. _mbed TLS Security Center: https://tls.mbed.org/security
126