trusted-board-boot-build.rst 5.9 KB

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