How to deploy personal fip.bin for TF-A binaries

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to deploy personal fip.bin for TF-A binaries

1,669 Views
notshure
Contributor IV

Hello everyone.
I have been trying to perform this task for several days:

Target:

With flex-builder you can generate the following files: bl2_sd.pbl and fip.bin.

The figure below shows the different components that are part of the two files

TF-A.PNG

These two files (bl2_sd.pbl and fip.bin) are also used to generate the image file  firmware_ls1043ardb_sdboot.img using a flex-builder command flex-builder -i mkfw -m ls1043ardb-b sd. This image file is then written to SD to be able to boot from SD with this command: sudo dd if=firmware_ls1043ardb_sdboot.img of=/dev/sdb1 bs=512 seek=8

My goal is to generate a custom boot, which when it arrives at the BL32 executes my custom code instead of U-Boot.

How can you write a very simple program, like a "hello world" and replace the uboot code?

If it can be done, I can use flex-builder to generate the fip.bin?

Is this the startup sequence?
Bootrom –> TF-A BL1 –> TF-A BL2 –> TF-A BL1 –> TF-A BL31 –> BL32(Tee OS) –> TF-A BL31 –> BL33(u-boot) –> OS

 Thanks in advance.

0 Kudos
1 Reply

1,648 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the following document

https://interrupt.memfault.com/blog/how-to-write-a-bootloader-from-scratch

 

Please refer to the following section in flexbuild_lsdk2108/packages/firmware/atf.mk.

if [ $(BL33TYPE) = uboot -a $(SOCFAMILY) = LS ]; then \
ubootcfg=$(PACKAGES_PATH)/firmware/$(UBOOT_TREE)/configs/$${platform}_tfa_defconfig; \
bl33=$(FBOUTDIR)/firmware/u-boot/$${platform}/uboot_$${platform}_tfa.bin; \

You could modify bl33 to the path of your bootloader binary file.

 

TF-A boot flow
1. BootROM (BL1)
a. When the CPU is released from reset, hardware executes PBL commands that copy the BL2 binary (bl2.bin) for platform initialization to OCRAM. The PBI commands also populate the BOOTLOC ptr to the location where bl2.bin is copied.
b. Upon successful execution of the PBI commands, Boot ROM passes control to the BL2 image at EL3.
2. BL2
a. BL2 initializes the DRAM, configures TZASC
b. BL2 validates BL31, BL32, and BL33 images to the DDR memory after validating these images. BL31, BL32, and BL33 images form FIP image, fip.bin.
c. Post validation of all the components of the FIP image, BL2 passes execution control to the EL3 runtime firmware image named as “BL31”,
3. BL31
a. Sets up exception vector table at EL3
b. Configures security-related settings (TZPC)
c. Provides services to both bootloader and operating system, such as controlling core power state and bringing
additional cores out of reset
d. [Optional] Passes execution control to Trusted OS (OP-TEE) image, BL32, if BL32 image is present.
4. BL32
a. [Optional] After initialization, BL32 returns control to BL31.
5. BL31
a. Passes execution control to bootloader U-Boot/UEFI, BL33 at EL2
6. BL33
a. Loads and starts the kernel and other firmware (if any) images.

 

0 Kudos