Last edited 2 years ago

How to configure TF-A FIP


1. Article purpose[edit source]

This section details the Trusted Firmware-A FIP (Firmware Image Package) usage in the STM32 MPU boot chain. It explains how to use it in STM32 MPU context and describes the build/update process that is required to deploy it on your target.

2. Overview[edit source]

The FIP is used by the Trusted Firmware-A BL2 firmware to load and authenticate the next stage binaries.

The FIP follows the Trusted Firmware-A specification[1].

It must contains:

3. Firmware Image Package creation tool[edit source]

Trusted Firmware-A provides a dedicated tool name fiptool to create a FIP.[2]

If you want to regenerate it, you must follow the official documentation..[3]
The official documentation introduces the different available options.

Here is the list of the most useful options:

Options Description Example
help Show all available options supported fiptool help
info List the content of a FIP:
  • offset in the FIP
  • size in the FIP
  • cmdline option to modify the binary
fiptool info fip.bin
Secure Payload BL32 (Trusted OS): offset=0x128, size=0x2C, cmdline="--tos-fw"
Secure Payload BL32 Extra1 (Trusted OS Extra1): offset=0x154,
size=0x18750, cmdline="--tos-fw-extra1" Secure Payload BL32 Extra2 (Trusted OS Extra2): offset=0x188A4,
size=0x56000, cmdline="--tos-fw-extra2" Non-Trusted Firmware BL33: offset=0x6E8A4, size=0xECE98, cmdline="--nt-fw" FW_CONFIG: offset=0x15B73C, size=0x1FA, cmdline="--fw-config" HW_CONFIG: offset=0x15B936, size=0x1BC08, cmdline="--hw-config"
update Update allows one or more images to be replaced in an existing FIP binary fiptool update --tos-fw bl32.bin fip.bin
unpack Extracts all binaries from a FIP binary fiptool unpack fip.bin
remove Removes a binary from FIP binary fiptool remove --tos-fw bl32.bin fip.bin

4. FIP binary creation[edit source]

Below the list of the different ways by which the FIP binary can be generated:

  • Using the dedicated fiptool command
  • Using the Trusted Firmware-A official Makefile

4.1. STM32MP1[edit source]

The OpenSTLinux boot flow requires the following stages to be loaded:

  • BL32: Secure OS OP-TEE OS (or Secure Monitor SP-MIN on STM32MP15x lines More info.png)
  • BL33: The non-secure firmware (recommended U-Boot)
  • HW_config: The OpenSTLinux uses the hw_config as the non-secure device tree
  • FW_config: Firmware configuration file listing the previous images and defining their size and the load address

The Trusted Firmware-A Makefile with fip target and some variables uses fiptool to automatically create the new FIP after the Trusted Firmware-A compilation.

With U-Boot as a non-secure firmware, the paths for the files used in next chapters are the following:

Description Makefile
variable
fiptool option File path for OP-TEE File path for SP_MIN
Limited to STM32MP15x lines More info.png
Secure OS (OP-TEE)
or Secure Monitor (SPMIN)
BL32 --tos-fw <optee_path>/tee-header_v2.bin <tfa_path>/bl32.bin
OP-TEE pager BL32_EXTRA1 --tos-fw-extra1 <optee_path>/tee-pager_v2.bin -
OPTEE pageable BL32_EXTRA2 --tos-fw-extra2 <optee_path>/tee-pageable_v2.bin -
Firmware configuration file FW_CONFIG --fw-config <tfa_path>/fw-config.dtb
U-Boot device tree BL33_CFG --hw-config <u-boot_path>/u-boot.dtb
U-Boot BL33 --nt-fw <u-boot_path>/u-boot-nodtb.bin

4.2. Updating the FIP binary[edit source]

When modifying a component included in the FIP binary, it is possible to update only part of the binary. To do this, use the fiptool update command.

Example when a new U-Boot is generated, the FIP must be updated using the following commands:

 fiptool update --nt-fw <u-boot_path>/u-boot-nodtb.bin --hw-config <u-boot_path>/u-boot.dtb fip.bin

5. Updating the software on board[edit source]

5.1. Partitioning of binaries[edit source]

The FIP build provides a binary named fip.bin (or fip-<board-name>-<bootchain>.bin from official release) that MUST be copied to a dedicated partition named fip, fip-a or fip-b when Secure Firmware Update is enabled.

5.2. Updating via SDCard[edit source]

If you use an SDCard, simply update the FIP binary by using the dd command on your host.
Plug your SDCard into the computer and copy the binary to the dedicated partition; on an SDCard/USB disk the fip partition or fip-a/fip-b when Secure Firmware Update is enabled:

 - SDCard: /dev/mmcblkXpY (where X is the instance number, Y is the partition number of the FIP)
 - SDCard via USB reader: /dev/sdXY (where X is the instance number, Y is the partition number of the FIP))
   dd if=<fip binary file> of=/dev/<device partition> bs=1M conv=fdatasync


  • Under Windows®

CoreUtils [4] that includes the dd command is available for Windows.

5.3. Updating via USB mass storage on U-boot[edit source]

See How to use USB mass storage in U-Boot.

Refer to the previous section to put FIP binary into SDCard/USB disk.

5.4. Updating your boot device via STM32CubeProgrammer[edit source]

Refer to the STM32CubeProgrammer documentation for details on how to update your target.

6. References[edit source]