cancel
Showing results for 
Search instead for 
Did you mean: 

tf-a and u-boot custom compile fails

ASkri.1
Senior

Hi, Everybody!

Referring to this issue:

https://community.st.com/s/question/0D53W00000oVNtqSAG/qaudspi-spinand-flash-device-tree-for-tfa-and-uboot

PatrickF suggested to manually configure U-BOOT for my board. I have downloaded tf-a sources patched it, of course installed and configured SDK and trying to do all according to it's README.HOW_TO.txt file.

As I have my specific DT I need to specify it in makefile parameters:

README.HOW_TO.txt has this example:

make -f $PWD/../Makefile.sdk TFA_DEVICETREE=stm32mp157c-ev1 TF_A_CONFIG=trusted ELF_DEBUG_ENABLE='1' all

But in fact TFA_DEVICETREE var-name should be TF_A_DEVICETREE. Is this correct?

Then, file format. We have .stm32, also .fip file format avaialble

I can compile both .stm32 tf-a and u-boot, but u-boot fail to start with following error:

NOTICE: CPU: STM32MP157DAB Rev.Z

NOTICE: Model: STMicroelectronics STM32MP157A-DK1 STM32CubeMX board

INFO:  Reset reason (0x14):

INFO:   Pad Reset from NRST

INFO:  PMIC version = 0x21

INFO:  FCONF: Reading TB_FW firmware configuration file from: 0x2ffe3000

INFO:  FCONF: Reading firmware configuration information for: stm32mp_io

INFO:  Using USB

INFO:   Instance 2

INFO:  Boot used partition fsbl1

NOTICE: BL2: v2.4-r1.0(debug):

NOTICE: BL2: Built : 11:12:52, May 27 2021

INFO:  BL2: Doing platform setup

INFO:  RAM: DDR3-DDR3L 16bits 533000Khz

WARNING: Couldn't find property st,phy-cal in dtb

INFO:  Memory size = 0x20000000 (512 MB)

INFO:  DFU USB START...

INFO:  phase ID :0, Manifestation 0 at c00001d9

INFO:  phase ID :3, Manifestation 3 at c80e1fa2

ERROR:  FIP Header check failed for phase 3

ERROR:  usb_core_ctl_error : Send an ERROR

INFO:  handle USB : Suspend int

INFO:  USB Suspend mode

Then I'm trying to compile tf-a with fip option, but it fails with following error:

 make -f ../Makefile.sdk TF_A_CONFIG=trusted TF_A_DEVICETREE=stm32mp157a-stm32mp151-dk1-mx fip

fiptool-stm32mp config:

 optee:

  bl32 config value: optee

 trusted:

  bl32 config value: tfa

 FIP_DEVICETREE: stm32mp157a-stm32mp151-dk1-mx

 FIP_DEPLOYDIR_FIP  : /home/screep/Distribution-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/FIP_artifacts//fip

 FIP_DEPLOYDIR_TFA  : /home/screep/Distribution-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/tf-a-stm32mp-2.4.r1-r0/tf-a-sources/../deploy/bl32

 FIP_DEPLOYDIR_FWCONF: /home/screep/Distribution-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/tf-a-stm32mp-2.4.r1-r0/tf-a-sources/../deploy/fwconfig

 FIP_DEPLOYDIR_OPTEE : /home/screep/Distribution-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/FIP_artifacts//optee

 FIP_DEPLOYDIR_UBOOT : /home/screep/Distribution-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/FIP_artifacts//u-boot

Missing stm32mp157a-stm32mp151-dk1-mx-fw-config-optee.dtb file in folder: $FIP_DEPLOYDIR_FWCONF or '$FIP_DEPLOYDIR_ROOT/arm-trusted-firmware/fwconfig'

Why optee? I don;t need optee.

Can anybody help me with correct sequence compiling tf-a and u-boot starting from source download and finishing with success kernel load...

Thank you in advance

Looking forward for your reply

20 REPLIES 20
PatrickF
ST Employee

Hi,

This wiki page might help you: https://wiki.st.com/stm32mpu/wiki/How_to_compile_the_device_tree_with_the_Developer_Package.

Please note that with a defined Ecosystem SDK (here v3), you should also be careful with the tools versions (e.g. CubePro, CubeMX and CubeIDE) as listed in https://wiki.st.com/stm32mpu/wiki/STM32MP15_ecosystem_release_note

some useful pages too:

https://wiki.st.com/stm32mpu/wiki/How_to_create_your_board_device_tree

https://wiki.st.com/stm32mpu/wiki/How_to_bring-up_a_custom_board_:_procedure

MPU Forum FAQ

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Hi, Patrick!
Thank you very much for your reply. Finally I've got tf-a and u-boot assembled and FIP image generated.
(using this wiki page: https://wiki.st.com/stm32mpu/wiki/How_to_compile_the_device_tree_with_the_Developer_Package#U-boot_-_unpack_and_patch_sources
)
But u-boot load fails with following log:
NOTICE: CPU: STM32MP157DAB Rev.Z
NOTICE: Model: STMicroelectronics STM32MP157A-DK1 STM32CubeMX board
INFO: Reset reason (0x14):
INFO: Pad Reset from NRST
INFO: PMIC version = 0x21
INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe3000
INFO: FCONF: Reading firmware configuration information for: stm32mp_io
INFO: Using USB
INFO: Instance 2
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.4-r1.0(debug):
NOTICE: BL2: Built : 13:48:10, May 31 2021
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 16bits 533000Khz
WARNING: Couldn't find property st,phy-cal in dtb
INFO: Memory size = 0x20000000 (512 MB)
INFO: DFU USB START...
INFO: phase ID :0, Manifestation 0 at c0000141
INFO: phase ID :3, Manifestation 3 at c80feba4
INFO: Send detach request
INFO: Receive DFU Detach
INFO: DFU USB STOP...
INFO: BL2: Loading image id 31
INFO: Loading image id=31 at address 0x2ffff000
WARNING: Image id=31 size out of bounds
ERROR: BL2: Failed to load image id 31 (-27)
Here is flash-layout file:
#Opt Id Name Type IP Offset Binary
- 0x01 fsbl-boot Binary none 0x0
./tf-a-stm32mp157a-stm32mp151-dk1-mx-usb.stm32
- 0x03 fip-boot Binary none 0x0
./fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin
#P 0x04 fsbl1 Binary mmc0 boot1
../../arm-trusted-firmware/tf-a-stm32mp157a-stm32mp151-dk1-mx-trusted.stm32
#P 0x05 fsbl2 Binary mmc0 boot2
../../arm-trusted-firmware/tf-a-stm32mp157a-stm32mp151-dk1-mx-trusted.stm32
#P 0x06 ssbl Binary mmc0 0x00080000
../../bootloader/u-boot-stm32mp157a-stm32mp151-dk1-mx-trusted.stm32
#P 0x21 boot System mmc0 0x00280000
../../st-image-bootfs-openstlinux-weston-stm32mp1-disco-mx.ext4
#P 0x22 vendorfs FileSystem mmc0 0x04280000
../../st-image-vendorfs-openstlinux-weston-stm32mp1-disco-mx.ext4
#P 0x23 rootfs FileSystem mmc0 0x05280000
../../st-image-weston-openstlinux-weston-stm32mp1-disco-mx.ext4
#P 0x24 userfs FileSystem mmc0 0x33C80000
../../st-image-userfs-openstlinux-weston-stm32mp1-disco-mx.ext4
Here is CubeMXProgrammer output:

Hi,

Btw, your fail is within TF-A.

I suspect something not well formed in the uBoot FIP image around FW_CONFIG size.

On Flashing DK2, I see :

INFO:   Loading image id=31 at address 0x2ffff000

INFO:   Image id=31 loaded: 0x2ffff000 - 0x2ffff226

INFO:   FCONF: Reading FW_CONFIG firmware configuration file from: 0x2ffff000

INFO:   FCONF: Reading firmware configuration information for: dyn_cfg

INFO:   FCONF: Reading firmware configuration information for: stm32mp1_firewall

Note that device column = mmc0 mean SD-Card on SDMMC.

To build a Serial-NAND CubeProgrammer Flashlayout, please have a look to https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#NAND_Flash_memory_with_FIP

Device column should be spi-nand0 and offset to be carefully selected (see also https://wiki.st.com/stm32mpu/wiki/STM32MP15_Flash_mapping#NAND_memory_mapping)

Regards

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Hi, Patrick! Could you please be more specific about FW_SIZE? I've just executed steps from Wiki. About flashlayout - I've copied it from the emmc version and I know that I need to spacifi spi-nand0 device to load. And, yes, I've read a wiki-page about flash-layouts :) But at this step I want to see U-BOOT loaded with qspi-nand recognized... Thank you in advance Looking forward for your reply пн, 31 ма�? 2021 г. в 17:37, ST Community :

Could you please try this (adapt the path if required):

fiptool info ./sources/arm-ostl-linux-gnueabi/FIP_artifacts/fip/fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin

example of result when using the scripts from wiki.

Secure Payload BL32 (Trusted OS): offset=0x100, size=0x1347C, cmdline="--tos-fw"
Non-Trusted Firmware BL33: offset=0x1357C, size=0xCF9D8, cmdline="--nt-fw"
FW_CONFIG: offset=0xE2F54, size=0x226, cmdline="--fw-config"
HW_CONFIG: offset=0xE317A, size=0x1D0A0, cmdline="--hw-config"
TOS_FW_CONFIG: offset=0x10021A, size=0x4748, cmdline="--tos-fw-config"

Seems you FW_CONFIG is not well defined. I'm not a strong SW guy, Maybe try:

pushd $WORKDIR/sources/arm-ostl-linux-gnueabi/u-boot-stm32mp-[0-9]*/u-boot-sources
make stm32mp15_trusted_defconfig
make mrproper
make -f ../Makefile.sdk DEVICE_TREE=<device tree> DEPLOYDIR=$FIP_DEPLOYDIR_ROOT/u-boot FIP_CONFIG=" trusted" FIP_BL32_CONF="tfa," all
popd

Regards

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Please find fiptiil info output below: /FIP_artifacts/fip$ fiptool info ./fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin Secure Payload BL32 (Trusted OS): offset=0x100, size=0x1347C, cmdline="--tos-fw" Non-Trusted Firmware BL33: offset=0x1357C, size=0xCFA18, cmdline="--nt-fw" FW_CONFIG: offset=0xE2F94, size=0x4F27, cmdline="--fw-config" HW_CONFIG: offset=0xE7EBB, size=0x12A91, cmdline="--hw-config" TOS_FW_CONFIG: offset=0xFA94C, size=0x4258, cmdline="--tos-fw-config" It looks similar to yours... Not clear with stm32mp157a-stm32mp151-dk1-mx-fw-config.dts file (TF-A). According to this wiki page: https://wiki.st.com/stm32mpu/wiki/How_to_configure_TF-A_FW_CONFIG It has some complex structure. But mine (generated by CubeMX) have just one include: // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* * Copyright (c) 2020, STMicroelectronics - All Rights Reserved */ #include "stm32mp157a-stm32mp151-dk1-mx.dts" Maybe this is wrong? In this case where to get the correct fw-config file? Thank you in advance Looking forward for your reply пн, 31 ма�? 2021 г. в 18:51, ST Community :

Finally got U-BOOT loaded and qspi visible:

UPLOAD ... done

Ctrl+C to exit ...

Download done

STM32MP> sf probe

Invalid bus 0 (err=-19)

Failed to initialize SPI flash at 0:0 (error -19)

STM32MP> mtdpard

Unknown command 'mtdpard' - try 'help'

STM32MP> mtdpards

Unknown command 'mtdpards' - try 'help'

STM32MP> mtdparts

device spi-nand0 <spi-nand0>, # parts = 4

#: name size offset mask_flags

0: fsbl 0x00200000 0x00000000 0

1: ssbl1 0x00200000 0x00200000 0

2: ssbl2 0x00200000 0x00400000 0

3: UBI 0x07a00000 0x00600000 0

active partition: spi-nand0,0 - (fsbl) 0x00200000 @ 0x00000000

defaults:

mtdids : spi-nand0=spi-nand0

mtdparts: mtdparts=spi-nand0:2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)

STM32MP>

There was a problem: stm32mp157a-stm32mp151-dk1-mx-fw-config.dts file - "stm32mp15-ddr-512m-fw-config.dts" should be included.

Thank you very much for your support - I will go on with kernel loading :)

Next.

Finally I have modified flash-layout file and tried to download all to nand:

Here is flash_layout file - it matches to mtd partitions above:

#Opt

Id Name Type IP Offset Binary

- 0x01 fsbl-boot Binary none 0x0 ./tf-a-stm32mp157a-stm32mp151-dk1-mx-usb.stm32

- 0x03 fip-boot Binary none 0x0 ./fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin

P 0x04 fsbl Binary(2) spi-nand0 0x000000 ./tf-a-stm32mp157a-stm32mp151-dk1-mx-nand.stm32

P 0x05 fip1 Binary spi-nand0 0x200000 ./fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin

P 0x06 fip2 Binary spi-nand0 0x400000 ./fip-stm32mp157a-stm32mp151-dk1-mx-trusted.bin

P 0x10 UBI System spi-nand0 0x600000 ./st-image-weston-openstlinux-weston-stm32mp1-disco-mx_nand_4_256_multivolume.ubi

Fortunately all flashed correctly :) Now I want to boot from qspi flash :)

But setting BOOT0-2=111 gives no result - only science in console output..

I can check spi ins activity during boot - there IS activity during a few seconds. So, at least it is trying to boot.

Could you please give me a hint again :)

Thank you very much. Today is a lucky day :)

Hi,

If fail in BootROM, PA13 will toggle at about 5Hz (open-drain, need external resistor to watch it) and should go back to USB DFU.

See https://wiki.st.com/stm32mpu/wiki/STM32MP15_ROM_code_overview#Debug_and_error_cases

Please provide BootROM traces https://wiki.st.com/stm32mpu/wiki/STM32MP15_ROM_trace_analyzer, got after the fail.

Otherwise, it could be TF-A which crash once loaded.

Regards

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Hi, Patrick! Thank you very much for your reply Please find trace-log below: < @ 00007507 | [INFO] - BOOTCORE_BootRomMaskVer ( 0x00000000 ) > < @ 00008803 | [INFO] - BOOTCORE_BootRomVer ( 0x00000102 ) > < @ 00009979 | [INFO] - BOOTCORE_FreezeIWDG12Clocks > < @ 00011338 | [INFO] - BOOTCORE_HwResetPOR > < @ 00023922 | [INFO] - BOOTCORE_ChipModeSecOpen > < @ 00026267 | [INFO] - BOOTCORE_LogicalResetSystem > < @ 00028025 | [INFO] - BOOTCORE_BootActionColdBootProcess > < @ 00086684 | [INFO] - BOOTCORE_BootCfgOtpWordValue ( 0x00080002, 0x00000000 ) > < @ 00088147 | [INFO] - BOOTCORE_BootPinsFirstSelQspiNand > < @ 00089255 | [INFO] - BOOTCORE_OtpPrimarySrcForceNothing > < @ 00090319 | [INFO] - BOOTCORE_OtpSecondarySrcForceNothing > < @ 00091424 | [INFO] - BOOTCORE_OtpBootSrcDisableMaskVal ( 0x00000008 ) > < @ 00092563 | [INFO] - BOOTCORE_OtpBootUartInstanceDisableMaskVal ( 0x00000000 ) > < @ 00094000 | [INFO] - BOOTCORE_eMmcUseSingle128KBytesBootPartition ( 0x00000000 ) > < @ 00096321 | [INFO] - BOOTCORE_BootCfgAfmuxOtpWord1Value ( 0x38C43CC1 ) > < @ 00097673 | [INFO] - BOOTCORE_BootCfgAfmuxOtpWord2Value ( 0x000042C4 ) > < @ 00099089 | [INFO] - BOOTCORE_BootCfgAfmuxOtpWord3Value ( 0x00000000 ) > < @ 00100580 | [INFO] - BOOTCORE_BootCfgHseValue ( 0x00000000 ) > < @ 00103569 | [INFO] - BOOTCORE_EnabledSrcMaskVal ( 0x00000660 ) > < @ 00104921 | [INFO] - BOOTCORE_BootModeCOLDBOOT > < @ 00640284 | [INFO] - BOOTCORE_StartupWaitTime ( 0x00002700 ) > < @ 00641814 | [INFO] - BOOTCORE_NoCpuPllOtpBitValue ( 0x00000000 ) > < @ 00644049 | [INFO] - BOOTCORE_Pll12StartNotDisabledByOtpBit > < @ 00646123 | [INFO] - BOOTCORE_Pll1Started > < @ 00650223 | [INFO] - BOOTCORE_Pll1Locked > < @ 00651595 | [INFO] - BOOTCORE_Pll2Started > < @ 00655774 | [INFO] - BOOTCORE_Pll2Locked > < @ 00657376 | [INFO] - BOOTCORE_CkMpuSsSwitchedOnPll1 > < @ 00658855 | [INFO] - BOOTCORE_CkAxiSsSwitchedOnPll2 > < @ 00659434 | [INFO] - BOOTCORE_Pll12StartReqStatusPllStarted > < @ 00903150 | [INFO] - NANDCORE_DirectFsblFound > < @ 00903575 | [INFO] - NANDCORE_TryingDirectFSBL ( 0x00000000 ) > < @ 06759413 | [INFO] - BOOTCORE_AuthHashAreaStartAdd ( 0x2FFC2448 ) > < @ 06759735 | [INFO] - BOOTCORE_AuthImageLength ( 0x00036FBD ) > < @ 06760034 | [INFO] - BOOTCORE_AuthImageSizeToHash ( 0x00037075 ) > < @ 06760339 | [INFO] - BOOTCORE_AuthImageEntryPoint ( 0x2FFEA000 ) > < @ 06760910 | [INFO] - BOOTCORE_AuthEccAlgoP256NIST > < @ 06761172 | [INFO] - BOOTCORE_AuthNoSigCheckValue ( 0x00000001 ) > < @ 06761568 | [INFO] - BOOTCORE_AuthIsAuthenticationMandatory ( 0x00000000 ) > < @ 06761853 | [INFO] - BOOTCORE_AuthIsAuthenticationSkipRequestedAndAllowed ( 0x00000001 ) > < @ 08590563 | [ERR ] - BOOTCORE_AuthWrongImageChecksum > < @ 08711507 | [INFO] - NANDCORE_DirectFsblFound > < @ 08711884 | [INFO] - NANDCORE_TryingDirectFSBL ( 0x00000002 ) > < @ 14567605 | [INFO] - BOOTCORE_AuthHashAreaStartAdd ( 0x2FFC2448 ) > < @ 14567902 | [INFO] - BOOTCORE_AuthImageLength ( 0x00036FBD ) > < @ 14568189 | [INFO] - BOOTCORE_AuthImageSizeToHash ( 0x00037075 ) > < @ 14568492 | [INFO] - BOOTCORE_AuthImageEntryPoint ( 0x2FFEA000 ) > < @ 14569056 | [INFO] - BOOTCORE_AuthEccAlgoP256NIST > < @ 14569318 | [INFO] - BOOTCORE_AuthNoSigCheckValue ( 0x00000001 ) > < @ 14569701 | [INFO] - BOOTCORE_AuthIsAuthenticationMandatory ( 0x00000000 ) > < @ 14569986 | [INFO] - BOOTCORE_AuthIsAuthenticationSkipRequestedAndAllowed ( 0x00000001 ) > < @ 16398676 | [ERR ] - BOOTCORE_AuthWrongImageChecksum > < @ 77800130 | [INFO] - BOOTCORE_HseNoBypass > < @ 77812369 | [INFO] - BOOTCORE_HseFrequencyDetected ( 0x00000018 ) > < @ 77812784 | [INFO] - USB_Init > < @ 77883158 | [INFO] - BOOTCORE_PllUsbLocked > < @ 81474574 | [INFO] - UART_PeripheralSerialBootLoopStart > Hope to your reply. вт, 1 июн. 2021 г. в 09:31, ST Community :