tools-build.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Building Supporting Tools
  2. =========================
  3. .. note::
  4. OpenSSL 3.0 is needed in order to build the tools. A custom installation
  5. can be used if not updating the OpenSSL version on the OS. In order to do
  6. this, use the ``OPENSSL_DIR`` variable after the ``make`` command to
  7. indicate the location of the custom OpenSSL build. Then, to run the tools,
  8. use the ``LD_LIBRARY_PATH`` to indicate the location of the built
  9. libraries. More info about ``OPENSSL_DIR`` can be found at
  10. :ref:`Build Options`.
  11. Building and using the FIP tool
  12. -------------------------------
  13. The following snippets build a :ref:`FIP<Image Terminology>` for the FVP
  14. platform. While it is not an intrinsic part of the FIP format, a BL33 image is
  15. required for these examples. For the purposes of experimentation, `Trusted
  16. Firmware-A Tests`_ (`tftf.bin``) may be used. Refer to to the `TFTF
  17. documentation`_ for instructions on building a TFTF binary.
  18. The TF-A build system provides the make target ``fip`` to create a FIP file
  19. for the specified platform using the FIP creation tool included in the TF-A
  20. project. Examples below show how to build a FIP file for FVP, packaging TF-A
  21. and BL33 images.
  22. For AArch64:
  23. .. code:: shell
  24. make PLAT=fvp BL33=<path-to>/bl33.bin fip
  25. For AArch32:
  26. .. code:: shell
  27. make PLAT=fvp ARCH=aarch32 AARCH32_SP=sp_min BL33=<path-to>/bl33.bin fip
  28. The resulting FIP may be found in:
  29. ::
  30. build/fvp/<build-type>/fip.bin
  31. For advanced operations on FIP files, it is also possible to independently build
  32. the tool and create or modify FIPs using this tool. To do this, follow these
  33. steps:
  34. It is recommended to remove old artifacts before building the tool:
  35. .. code:: shell
  36. make -C tools/fiptool clean
  37. Build the tool:
  38. .. code:: shell
  39. make [DEBUG=1] [V=1] fiptool
  40. The tool binary can be located in:
  41. ::
  42. ./tools/fiptool/fiptool
  43. Invoking the tool with ``help`` will print a help message with all available
  44. options.
  45. Example 1: create a new Firmware package ``fip.bin`` that contains BL2 and BL31:
  46. .. code:: shell
  47. ./tools/fiptool/fiptool create \
  48. --tb-fw build/<platform>/<build-type>/bl2.bin \
  49. --soc-fw build/<platform>/<build-type>/bl31.bin \
  50. fip.bin
  51. Example 2: view the contents of an existing Firmware package:
  52. .. code:: shell
  53. ./tools/fiptool/fiptool info <path-to>/fip.bin
  54. Example 3: update the entries of an existing Firmware package:
  55. .. code:: shell
  56. # Change the BL2 from Debug to Release version
  57. ./tools/fiptool/fiptool update \
  58. --tb-fw build/<platform>/release/bl2.bin \
  59. build/<platform>/debug/fip.bin
  60. Example 4: unpack all entries from an existing Firmware package:
  61. .. code:: shell
  62. # Images will be unpacked to the working directory
  63. ./tools/fiptool/fiptool unpack <path-to>/fip.bin
  64. Example 5: remove an entry from an existing Firmware package:
  65. .. code:: shell
  66. ./tools/fiptool/fiptool remove \
  67. --tb-fw build/<platform>/debug/fip.bin
  68. Note that if the destination FIP file exists, the create, update and
  69. remove operations will automatically overwrite it.
  70. The unpack operation will fail if the images already exist at the
  71. destination. In that case, use -f or --force to continue.
  72. More information about FIP can be found in the :ref:`Firmware Design` document.
  73. .. _tools_build_cert_create:
  74. Building the Certificate Generation Tool
  75. ----------------------------------------
  76. The ``cert_create`` tool is built as part of the TF-A build process when the
  77. ``fip`` make target is specified and TBB is enabled (as described in the
  78. previous section), but it can also be built separately with the following
  79. command:
  80. .. code:: shell
  81. make PLAT=<platform> [DEBUG=1] [V=1] certtool
  82. For platforms that require their own IDs in certificate files, the generic
  83. 'cert_create' tool can be built with the following command. Note that the target
  84. platform must define its IDs within a ``platform_oid.h`` header file for the
  85. build to succeed.
  86. .. code:: shell
  87. make PLAT=<platform> USE_TBBR_DEFS=0 [DEBUG=1] [V=1] certtool
  88. ``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
  89. verbose. The following command should be used to obtain help about the tool:
  90. .. code:: shell
  91. ./tools/cert_create/cert_create -h
  92. .. _tools_build_enctool:
  93. Building the Firmware Encryption Tool
  94. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. The ``encrypt_fw`` tool is built as part of the TF-A build process when the
  96. ``fip`` make target is specified, DECRYPTION_SUPPORT and TBB are enabled, but
  97. it can also be built separately with the following command:
  98. .. code:: shell
  99. make PLAT=<platform> [DEBUG=1] [V=1] enctool
  100. ``DEBUG=1`` builds the tool in debug mode. ``V=1`` makes the build process more
  101. verbose. The following command should be used to obtain help about the tool:
  102. .. code:: shell
  103. ./tools/encrypt_fw/encrypt_fw -h
  104. Note that the enctool in its current implementation only supports encryption
  105. key to be provided in plain format. A typical implementation can very well
  106. extend this tool to support custom techniques to protect encryption key.
  107. Also, a user may choose to provide encryption key or nonce as an input file
  108. via using ``cat <filename>`` instead of a hex string.
  109. --------------
  110. *Copyright (c) 2019-2022, Arm Limited. All rights reserved.*
  111. .. _Trusted Firmware-A Tests: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/
  112. .. _TFTF documentation: https://trustedfirmware-a-tests.readthedocs.io/en/latest/