Introduction to TF-A architecture, download, compile and burn
Trusted Firmware for Arm Cortex-A
>>> This article introduces the architecture of TF-A, code download, compilation, and how to burn it to the target board.
TF-A is composed of four parts, namely BL1, BL2, BL32 and BL33.
application processor trusted ROM
trusted boot firmware
runtime software
non-trusted firmware
Note:
The BL1 function has been solidified into the ROM on the STM32MP1, so this part cannot be modified by the user.
BL2 mainly initializes DDR and clock tree, and initializes security-related components
BL32 mainly provides secure monitor security services and implements SP-MIN solutions
BL33 is a non-secure code firmware managed by U-Boot on the STM32MP1 platform
TF-A uses a device tree to manage configuration, during which it initializes some devices. The device tree can be configured using STM32CubeMX.
BL2, BL32 and the device tree are compiled together to form an image, which is loaded into SYSRAM by BootROM for execution.
The steps for loading TF-A are as follows:
1. ROM code loads TF-A firmware and calls BL2
2. BL2 is ready to load BL32
3. BL2 loads BL33
4. BL2 calls BL32
5. BL32 calls BL33
1. Download address 1:
https://www.st.com/content/ccc/resource/technical/sw-updater/firmware2/group0/83/c8/98/d3/5c/32/42/77/stm32cube_standard_a7_bsp_components_tf_a/files/SOURCES-tf-a-stm32mp1-openstlinux-20-02-19.tar.xz/jcr:content/translations/en.SOURCES-tf-a-stm32mp1-openstlinux-20-02-19.tar.xz
2. Download address 2: github
It is recommended to use Git Hub. You can use Git Hub to get the latest code, and you don't need to manually apply patches when compiling like the official tarball.
The command is as follows: git clone
https://github.com/STMicroelectronics/arm-trusted-firmware.git
Copy the Makefile.SDK file in the tarball to the source code package downloaded from git hub. Place it in the same directory as the source code package (be careful not to place it inside the source code package).
1. To set up the SDK environment, you need to run the following command:
source <SDK installation directory>/environment-setup-cortexa7hf-neon-vfpv4-ostl-linux-gnueabi
2. Compile, use make -f ../Makefile.sdk all (compile all)
You can also choose to compile an image suitable for your own development board. The command is as follows:
make -f Makefile.sdk TF_A_CONFIG=trusted TFA_DEVICETREE= stm32mp157c-<board>
The compiled image is stored in:
build/stm32mp1/debug/tf-a-stm32mp157c-ev1.stm32
I. If you are using Ubuntu system, you can use dd command to burn
First, confirm the partition where FSBL is located, use the following command:
PC $> ls -l /dev/disk/by-partlabel/
total 0
lrwxrwxrwx 1 root root 10 Jan 17 17:38 bootfs -> ../../mmcblk0p4 lrwxrwxrwx 1 root root 10 Jan 17 17:38 fsbl1 -> ../../mmcblk0p1 ➔ FSBL1 (TF-A)
lrwxrwxrwx 1 root root 10 Jan 17 17:38 fsbl2 -> ../../mmcblk0p2 ➔ FSBL2 (TF-A backup – same content as FSBL)
lrwxrwxrwx 1 root root 10 Jan 17 17:38 rootfs -> ../../mmcblk0p5
lrwxrwxrwx 1 root root 10 Jan 17 17:38 ssbl -> ../../mmcblk0p3 ➔ SSBL (U-Boot)
lrwxrwxrwx 1 root root 10 Jan 17 17:38 userfs -> ../../mmcblk0p6
Then use the command
dd if=<tf-a file> of=/dev/<device partition> bs=1M conv=fdatasync
II. If you are using Windows, you can use STM32CubeProgramer to download
Add a print message in plat/st/stm32mp1/bl2_plat_setup.c:
PC $> cd tf-a-stm32mp-2.0-r0/arm-trusted-firmware-2.0
PC $> vim ./plat/st/stm32mp1/bl2_plat_setup.c
1. After modification, compile TF-A: make -f ../Makefile.sdk all
2. The STM32MP157C-EV1 development board is used in the example. Set the dip switch to flashing mode:
3. Use STM32CubeProgramer V2.3.0 under Windows to download the compiled new image of TF-A to the board:
4. After the download is complete, turn off the power and turn the DIP switch to boot from SDCARD, as follows:
5. Power on and start, and observe the serial port log output as follows:
The log added in the code can be displayed in the console, indicating that the compilation and downloading have been successfully completed.
The recommended way to obtain TF-A code is to use git hub to obtain the latest code. This can also avoid the need to manually apply patches after using the tarball.
Compilation needs to be done in Linux environment, and burning can be done using STM32CubeProgramer under Windows or dd command under Linux.
When using the dd command, you need to know the partition where TF-A is located, because the dd command does not check the partition, but directly overwrites the data according to the partition specified by the command.
References:
https://wiki.st.com/stm32mpu/index.php/STM32MP1_Developer_Package_-_TF-A