STM32MP1 ECO 5.0.0 TF-A, Optee. U-boot Build sequence
These are the steps in chronological order to be able to build the files for a custom board. This seems very convoluted and easily confusing. I this process correct ? The issues normally are not found with the STM board because all the pre-build files are already in the fip and other source folders, but for a custom board they are not, hence the issues.
Build sequence:
=================
* Install the SDK
* SDK source set to the arm toolchain
* Extracted all the sources and applied the patches
* Copied the device tree files from CubeMX to the respective folders.
* Updated the makefiles.sdk with the the new board name.
* Added the device tree file name to the makefiles in fdts and dts sub-folders (TF-A / u-boot)
* Set the $FIP_DEPLOYDIR_FIP' and $FIP_DEPLOYDIR_ROOT
* Deleted all the custom board files under $FIP_DEPLOYDIR_ROOT that were built before during trial (& error)
Steps and issues encountered in chronological order:
1. Build u-boot
make -f $PWD/../Makefile.sdk all UBOOT_CONFIG=optee UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb DEVICETREE="stm32mp157a-custom-board"
Missing stm32mp157a-custom-board-fw-config-optee.dtb file in folder: $FIP_DEPLOYDIR_FWCONF or '$FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig'
2. Build TF-A
make -f $PWD/../Makefile.sdk all
Missing u-boot-stm32mp157a-custom-board.dtb file in folder: '$FIP_DEPLOYDIR_UBOOT' or '$FIP_DEPLOYDIR_ROOT/u-boot'
copy u-boot-stm32mp157a-custom-board.dtb generated by u-boot to $FIP_DEPLOYDIR_ROOT/u-boot
3. Build TF-A
make -f $PWD/../Makefile.sdk all
Missing tee-header_v2-stm32mp157a-custom-board.bin file in folder: '$FIP_DEPLOYDIR_OPTEE' or '$FIP_DEPLOYDIR_ROOT/optee'
Missing tee-pager_v2-stm32mp157a-custom-board.bin file in folder: '$FIP_DEPLOYDIR_OPTEE' or '$FIP_DEPLOYDIR_ROOT/optee'
Missing tee-pageable_v2-stm32mp157a-custom-board.bin file in folder: '$FIP_DEPLOYDIR_OPTEE' or '$FIP_DEPLOYDIR_ROOT/optee'
4. Build Optee
make -f $PWD/../Makefile.sdk all
Missing stm32mp157a-custom-board-fw-config-optee.dtb file in folder: $FIP_DEPLOYDIR_FWCONF or '$FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig'
copy stm32mp157a-custom-board-fw-config-optee.dtb generated by TF-A to $FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig
5. Build Optee
make -f $PWD/../Makefile.sdk all
Optee succeeds
6. Build U-boot
make -f $PWD/../Makefile.sdk all UBOOT_CONFIG=optee UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb DEVICETREE="stm32mp157a-custom-board"
Missing tee-header_v2-stm32mp157a-custom-board.bin file in folder: '$FIP_DEPLOYDIR_OPTEE' or '$FIP_DEPLOYDIR_ROOT/optee'
7. Build TF-A
make -f $PWD/../Makefile.sdk all
Missing tee-header_v2-stm32mp157a-custom-board.bin file in folder: '$FIP_DEPLOYDIR_OPTEE' or '$FIP_DEPLOYDIR_ROOT/optee'
copy tee-header_v2-stm32mp157a-<board>.bin from optee/deploy to $FIP_DEPLOYDIR_ROOT/optee
copy tee-pager_v2-stm32mp157a-<board>.bin from optee/deploy to $FIP_DEPLOYDIR_ROOT/optee
copy tee-pageable_v2-stm32mp157a-custom-board.bin from optee/deploy to $FIP_DEPLOYDIR_ROOT/optee
8. Build TF-A
make -f $PWD/../Makefile.sdk all
TF-A succeeds but does not place the optee.bin in the /fip folder
Though, the generated fip file can be found in the fip folder under the u-boot sources.
9. Build u-boot
make -f $PWD/../Makefile.sdk all UBOOT_CONFIG=optee UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb DEVICETREE="stm32mp157a-custom-board"
u-boot succeeds
Reduced process to prevent errors
==========================================
1. Build u-boot
Fails because of missing stm32mp157a-<board>-fw-config-optee.dtb file in folder: $FIP_DEPLOYDIR_FWCONF or '$FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig'
But it generates the .dtb files needed for TF-A
copy u-boot-stm32mp157a-<board>.dtb from deploy to FIP_artifacts/u-boot
2. Build Optee
Fails because it cannot find fw-config-optee.dtb (From TF-A) but the tee-header and tee-pager file are which TF-A needs but it generates the following files needed for TF-A
copy tee-header_v2-stm32mp157a-<board>.bin from deploy to $FIP_DEPLOYDIR_ROOT/optee
copy tee-pager_v2-stm32mp157a-<board>.bin from deploy to $FIP_DEPLOYDIR_ROOT/optee
copy tee-pageable_v2-stm32mp157a-custom-board.bin from deploy to $FIP_DEPLOYDIR_ROOT/optee
3. Build TF-A
Now succeeds
copy stm32mp157a-custom-board-fw-config-optee from deploy to $FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig for Optee
get the fip-stm32mp157a-custom-board-optee.bin from the u-boot/deploy/fip folder for the flashing.
4. Build Optee
Now succeeds
5. Build u-boot
Now succeeds
Key issue:
==================
It seems there are circular dependencies where partial build outputs from one repo provides outputs to complete the other, then with those partial outputs returning the original repo to complete build: as follows:
[a] TF-A depends on the output of u-boot and outputs from OPTEE
[b] OPTEE depends on the outputs from TF-A
[c] UBOOT depends on the outputs of OPTEE and TF-A.
Can't really believe this should be normal. what is wrong in the above process ?
Issues and solutions
================
TF-A does not copy the metadata.bin and tfa-stm32mp157a-custom-board-<usb/scard/emmc/nand/nor/uart>.stm32 files to the $FIP_DEPLOYDIR_ROOTFIP/arm-trusted-firmware folder
Manually copy TF-A/deploy/metadata.bin to $FIP_DEPLOYDIR_ROOTFIP/arm-trusted-firmware
Manually copy TF-A/deploy/*.stm32 files to $FIP_DEPLOYDIR_ROOTFIP/arm-trusted-firmware
TF-A did not place the stm32mp157a-custom-board-fw-config-optee.dtb in $FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig
manually copy from tf-a/deploy/stm32mp157a-custom-board-fw-config-optee.dtb to $FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig
TF-A did not place the fip-stm32mp157a-custom-board-optee.bin in the $FIP_DEPLOYDIR_ROOT or $FIP_DEPLOYDIR_FIP folder
manually copy from u-boot/deploy/fip/fip-stm32mp157a-custom-board-optee.bin to $FIP_DEPLOYDIR_ROOT/fip
U-boot did not place the u-boot-stm32mp157a-custom-board.dtb in it's local deploy in the $FIP_DEPLOYDIR_ROOT/u-boot folder
manually copy the u-boot/deploy/u-boot-stm32mp157a-custom-board.dtb to $FIP_DEPLOYDIR_ROOT/u-boot
u-boot did not place the fip-stm32mp157a-custom-board-optee.bin in $FIP_DEPLOYDIR_ROOT/fip
manually copy trom u-boot/deployfip-stm32mp157a-custom-board-optee.bin to $FIP_DEPLOYDIR_ROOT/fip
Optee did not place the bin files in the $FIP_DEPLOYDIR_ROOTs/optee folder
manually copy optee/deploy/tee-header_v2-stm32mp157a-custom-board.bin to $FIP_DEPLOYDIR_ROOT/optee
manually copy optee/deploy/tee-pager_v2-stm32mp157a-custom-board.bin to $FIP_DEPLOYDIR_ROOT/optee
manually copy opte//deploy/tee-pageable_v2-stm32mp157a-custom-board.binto $FIP_DEPLOYDIR_ROOT/optee
