xref: /rk3399_ARM-atf/docs/design/trusted-board-boot-build.rst (revision d935b95161959d79521b83e2887ab44947208ea9)
143f35ef5SPaul BeesleyBuilding FIP images with support for Trusted Board Boot
243f35ef5SPaul Beesley=======================================================
343f35ef5SPaul Beesley
443f35ef5SPaul BeesleyTrusted Board Boot primarily consists of the following two features:
543f35ef5SPaul Beesley
643f35ef5SPaul Beesley-  Image Authentication, described in :ref:`Trusted Board Boot`, and
743f35ef5SPaul Beesley-  Firmware Update, described in :ref:`Firmware Update (FWU)`
843f35ef5SPaul Beesley
943f35ef5SPaul BeesleyThe following steps should be followed to build FIP and (optionally) FWU_FIP
1043f35ef5SPaul Beesleyimages with support for these features:
1143f35ef5SPaul Beesley
1243f35ef5SPaul Beesley#. Fulfill the dependencies of the ``mbedtls`` cryptographic and image parser
1343f35ef5SPaul Beesley   modules by checking out a recent version of the `mbed TLS Repository`_. It
1443f35ef5SPaul Beesley   is important to use a version that is compatible with TF-A and fixes any
1543f35ef5SPaul Beesley   known security vulnerabilities. See `mbed TLS Security Center`_ for more
1643f35ef5SPaul Beesley   information. See the :ref:`Prerequisites` document for the appropriate
1743f35ef5SPaul Beesley   version of mbed TLS to use.
1843f35ef5SPaul Beesley
1943f35ef5SPaul Beesley   The ``drivers/auth/mbedtls/mbedtls_*.mk`` files contain the list of mbed TLS
2043f35ef5SPaul Beesley   source files the modules depend upon.
2143f35ef5SPaul Beesley   ``include/drivers/auth/mbedtls/mbedtls_config.h`` contains the configuration
2243f35ef5SPaul Beesley   options required to build the mbed TLS sources.
2343f35ef5SPaul Beesley
2443f35ef5SPaul Beesley   Note that the mbed TLS library is licensed under the Apache version 2.0
2543f35ef5SPaul Beesley   license. Using mbed TLS source code will affect the licensing of TF-A
2643f35ef5SPaul Beesley   binaries that are built using this library.
2743f35ef5SPaul Beesley
2843f35ef5SPaul Beesley#. To build the FIP image, ensure the following command line variables are set
2943f35ef5SPaul Beesley   while invoking ``make`` to build TF-A:
3043f35ef5SPaul Beesley
3143f35ef5SPaul Beesley   -  ``MBEDTLS_DIR=<path of the directory containing mbed TLS sources>``
3243f35ef5SPaul Beesley   -  ``TRUSTED_BOARD_BOOT=1``
3343f35ef5SPaul Beesley   -  ``GENERATE_COT=1``
3443f35ef5SPaul Beesley
35*d935b951SSandrine Bailleux   By default, this will use the Chain of Trust described in the TBBR-client
36*d935b951SSandrine Bailleux   document. To select a different one, use the ``COT`` build option.
37*d935b951SSandrine Bailleux
3843f35ef5SPaul Beesley   In the case of Arm platforms, the location of the ROTPK hash must also be
39a6ffddecSMax Shvetsov   specified at build time. The following locations are currently supported (see
4043f35ef5SPaul Beesley   ``ARM_ROTPK_LOCATION`` build option):
4143f35ef5SPaul Beesley
4243f35ef5SPaul Beesley   -  ``ARM_ROTPK_LOCATION=regs``: the ROTPK hash is obtained from the Trusted
43*d935b951SSandrine Bailleux      root-key storage registers present in the platform. On Juno, these
4443f35ef5SPaul Beesley      registers are read-only. On FVP Base and Cortex models, the registers
45*d935b951SSandrine Bailleux      are also read-only, but the value can be specified using the command line
4643f35ef5SPaul Beesley      option ``bp.trusted_key_storage.public_key`` when launching the model.
47a6ffddecSMax Shvetsov      On Juno board, the default value corresponds to an ECDSA-SECP256R1 public
48a6ffddecSMax Shvetsov      key hash, whose private part is not currently available.
4943f35ef5SPaul Beesley
50a6ffddecSMax Shvetsov   -  ``ARM_ROTPK_LOCATION=devel_rsa``: use the default hash located in
51*d935b951SSandrine Bailleux      ``plat/arm/board/common/rotpk/arm_rotpk_rsa_sha256.bin``. Enforce
52*d935b951SSandrine Bailleux      generation of the new hash if ``ROT_KEY`` is specified.
5343f35ef5SPaul Beesley
54a6ffddecSMax Shvetsov   -  ``ARM_ROTPK_LOCATION=devel_ecdsa``: use the default hash located in
55*d935b951SSandrine Bailleux      ``plat/arm/board/common/rotpk/arm_rotpk_ecdsa_sha256.bin``. Enforce
56*d935b951SSandrine Bailleux      generation of the new hash if ``ROT_KEY`` is specified.
5743f35ef5SPaul Beesley
5843f35ef5SPaul Beesley   Example of command line using RSA development keys:
5943f35ef5SPaul Beesley
6043f35ef5SPaul Beesley   .. code:: shell
6143f35ef5SPaul Beesley
6243f35ef5SPaul Beesley       MBEDTLS_DIR=<path of the directory containing mbed TLS sources> \
6343f35ef5SPaul Beesley       make PLAT=<platform> TRUSTED_BOARD_BOOT=1 GENERATE_COT=1        \
6443f35ef5SPaul Beesley       ARM_ROTPK_LOCATION=devel_rsa                                    \
6543f35ef5SPaul Beesley       ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem        \
6643f35ef5SPaul Beesley       BL33=<path-to>/<bl33_image>                                     \
6743f35ef5SPaul Beesley       all fip
6843f35ef5SPaul Beesley
6943f35ef5SPaul Beesley   The result of this build will be the bl1.bin and the fip.bin binaries. This
70*d935b951SSandrine Bailleux   FIP will include the certificates corresponding to the selected Chain of
71*d935b951SSandrine Bailleux   Trust. These certificates can also be found in the output build directory.
7243f35ef5SPaul Beesley
7343f35ef5SPaul Beesley#. The optional FWU_FIP contains any additional images to be loaded from
7443f35ef5SPaul Beesley   Non-Volatile storage during the :ref:`Firmware Update (FWU)` process. To build the
7543f35ef5SPaul Beesley   FWU_FIP, any FWU images required by the platform must be specified on the
7643f35ef5SPaul Beesley   command line. On Arm development platforms like Juno, these are:
7743f35ef5SPaul Beesley
7843f35ef5SPaul Beesley   -  NS_BL2U. The AP non-secure Firmware Updater image.
7943f35ef5SPaul Beesley   -  SCP_BL2U. The SCP Firmware Update Configuration image.
8043f35ef5SPaul Beesley
8143f35ef5SPaul Beesley   Example of Juno command line for generating both ``fwu`` and ``fwu_fip``
8243f35ef5SPaul Beesley   targets using RSA development:
8343f35ef5SPaul Beesley
8443f35ef5SPaul Beesley   ::
8543f35ef5SPaul Beesley
8643f35ef5SPaul Beesley       MBEDTLS_DIR=<path of the directory containing mbed TLS sources> \
8743f35ef5SPaul Beesley       make PLAT=juno TRUSTED_BOARD_BOOT=1 GENERATE_COT=1              \
8843f35ef5SPaul Beesley       ARM_ROTPK_LOCATION=devel_rsa                                    \
8943f35ef5SPaul Beesley       ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem        \
9043f35ef5SPaul Beesley       BL33=<path-to>/<bl33_image>                                     \
9143f35ef5SPaul Beesley       SCP_BL2=<path-to>/<scp_bl2_image>                               \
9243f35ef5SPaul Beesley       SCP_BL2U=<path-to>/<scp_bl2u_image>                             \
9343f35ef5SPaul Beesley       NS_BL2U=<path-to>/<ns_bl2u_image>                               \
9443f35ef5SPaul Beesley       all fip fwu_fip
9543f35ef5SPaul Beesley
9643f35ef5SPaul Beesley   .. note::
9743f35ef5SPaul Beesley      The BL2U image will be built by default and added to the FWU_FIP.
9843f35ef5SPaul Beesley      The user may override this by adding ``BL2U=<path-to>/<bl2u_image>``
9943f35ef5SPaul Beesley      to the command line above.
10043f35ef5SPaul Beesley
10143f35ef5SPaul Beesley   .. note::
10243f35ef5SPaul Beesley      Building and installing the non-secure and SCP FWU images (NS_BL1U,
10343f35ef5SPaul Beesley      NS_BL2U and SCP_BL2U) is outside the scope of this document.
10443f35ef5SPaul Beesley
10543f35ef5SPaul Beesley   The result of this build will be bl1.bin, fip.bin and fwu_fip.bin binaries.
10643f35ef5SPaul Beesley   Both the FIP and FWU_FIP will include the certificates corresponding to the
107*d935b951SSandrine Bailleux   selected Chain of Trust. These certificates can also be found in the output
108*d935b951SSandrine Bailleux   build directory.
10943f35ef5SPaul Beesley
11043f35ef5SPaul Beesley--------------
11143f35ef5SPaul Beesley
112a6ffddecSMax Shvetsov*Copyright (c) 2019-2020, Arm Limited. All rights reserved.*
11343f35ef5SPaul Beesley
11443f35ef5SPaul Beesley.. _mbed TLS Repository: https://github.com/ARMmbed/mbedtls.git
11543f35ef5SPaul Beesley.. _mbed TLS Security Center: https://tls.mbed.org/security
116