cancel
Showing results for 
Search instead for 
Did you mean: 

Booting directly to kernel from TFA on stm32mp157DAC

adnan_pasha
Senior

Hi,

I am working on optimizing the boot process on my STM32MP157DAC board by removing U-Boot and booting the Linux kernel directly. I’ve been following the documented procedure from ST for the STM32MP1 series:
ST Wiki - How to optimize the boot time

TF-A Configuration

I’ve updated the configuration in stm32mp1_def.h as follows:

    • #define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x2008000))
      #define STM32MP_BL33_MAX_SIZE U(0x3FF8000)
  1. SD Card Timeout Modification

    Modified the SD card timeout value in <tf-a_sources>/drivers/st/mmc/stm32_sdmmc2.c:

    • timeout = timeout_init_us(TIMEOUT_US_1_S * 10);
  2. TF-A Build Process:

    • I applied the changes as a patch through my custom Yocto layer and rebuilt the tf-a-stm32mp recipe successfully.

  3. Kernel Configuration:

      • I added the following configuration parameters to my stm32_defconfig:
        CONFIG_CMDLINE_BOOL=y
        CONFIG_CMDLINE="root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw earlyprintk earlycon console=ttySTM0,115200"

      • I created and applied a patch for this as well via my custom Yocto layer.

  4. FIP Tool Update:

    • I updated the FIP image using fiptool:

      fiptool update --nt-fw kernel/uImage --hw-config kernel/stm32mp157f-dk2.dtb fip/fip-stm32mp157f-dk2-optee-sdcard.bin
    • The result was the new FIP file: fip-stm32mp157f-dk2-optee-sdcard.bin

  5. Flash Layout Modification:

    • I modified the TSV file as follows to include the new TF-A and FIP binaries:

      #OptIdNameTypeIPOffsetBinary
      -0x01fsbl-bootBinarynone0x0arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb.stm32
      -0x03fip-bootFIPnone0x0fip/fip-stm32mp157f-dk2-optee-emmc.bin
      P0x04fsbl1Binarymmc1boot1arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32
      P0x05fsbl2Binarymmc1boot2arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32
      P0x06metadata1FWU_MDATAmmc10x00080000arm-trusted-firmware/metadata.bin
      P0x07metadata2FWU_MDATAmmc10x00100000arm-trusted-firmware/metadata.bin
      P0x08fip-aFIPmmc10x00180000fip/fip-stm32mp157f-dk2-optee-emmc.bin
      PED0x09fip-bFIPmmc10x02180000none
      PED0x0Au-boot-envENVmmc10x02580000none
      P0x10bootfsSystemmmc10x02600000st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4
      P0x11vendorfsFileSystemmmc10x06600000st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4
      P0x12rootfsFileSystemmmc10x07600000st-image-qt-openstlinux-weston-stm32mp15-disco.ext4

 

When attempting to flash the image using STM32CubeProgrammer, I receive a timeout error indicating "unable to reconnect", and the operation fails at partition 0x03.

I’ve also attached the patch with my TF-A and kernel changes. Please let me know if there’s anything I may have missed or need to correct.

For reference, I’ve reviewed a related thread on ST’s community forum:
Direct kernel boot on STM32MP1

Thanks.

6 REPLIES 6
PatrickF
ST Employee

Hi @adnan_pasha 

the 'unable to reconnect' is probably the sign that partition 0x03 uBoot FIP (required for flashing) is crashing and does not initialize the USB DFU (and so does not interact anymore with CubeProgrammer). Did you change it as well ? As partition 0x01 and 0x02 are not flashed in the eMMC, it is recommended to keep using the one provided with the Starter Package for the given board ?

 

Maybe looking at the board UART console log during flashing could help you.

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 @PatrickF 

 

Sorry, I had previously shared the wrong TSV file. I’m now trying to flash the correct one to the SD card.

I’m not manually modifying anything in the uBoot FIP. I’d like to understand where the FIP is being generated from—does it get created during the U-Boot build process?

I deleted the existing FIP files and rebuilt the image to regenerate them. However, after flashing the new image, it still fails to boot.

Additionally, there are no logs appearing on the debug UART port,But cubeprogrammer says timeout not able to reconnect to device.



#OptIdNameTypeIPOffsetBinary
-0x01fsbl-bootBinarynone0x0arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb.stm32
-0x03fip-bootFIPnone0x0fip/fip-stm32mp157f-dk2-optee-sdcard.bin
P0x04fsbl1Binarymmc00x00004400arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-sdcard.stm32
P0x05fsbl2Binarymmc00x00044400arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-sdcard.stm32
P0x06metadata1FWU_MDATAmmc00x00084400arm-trusted-firmware/metadata.bin
P0x07metadata2FWU_MDATAmmc00x000C4400arm-trusted-firmware/metadata.bin
P0x08fip-aFIPmmc00x00104400modified-fip/fip-stm32mp157f-dk2-optee-sdcard.bin
PED0x09fip-bFIPmmc00x02104400none
PED0x0Au-boot-envENVmmc00x02904400none
P0x10bootfsSystemmmc00x02984400st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4
P0x11vendorfsFileSystemmmc00x06984400st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4
P0x12rootfsFileSystemmmc00x12084400st-image-qt-openstlinux-weston-stm32mp15-disco.ext4
P0x13userfsFileSystemmmc00x112084400st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.ext4

Hi, if there is absolutely no log on the UART, the image of partition #1 and/or #3 are probably crashing.

Please try to use the original one for those 2 partitions required for flashing (and let your custom ones for the other flashed partitions).

Then you will certainly being able to flash to SD-Card successfully, but your custom image is not guaranteed to boot  after reset (if corrupted or else).

 

I'm not expert in compilation, maybe have a look to https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package

 

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.
adnan_pasha
Senior

Hi @PatrickF 

 

I’ve observed one thing — when I revert the BL33_BASE_ADDR and BL33_MAX_SIZE values to their default settings:

  • #define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x100000))
    #define STM32MP_BL33_MAX_SIZE U(0x400000)

    the image flashing does not fail at partition 0x03 during the process.

    I have attached my normal boot process log below. is my BL33 base address for liinux 0x2008000 and size correct 0x3FF8000?

    NOTICE: CPU: STM32MP157FAC Rev.Z
    NOTICE: Model: STMicroelectronics STM32MP157F-DK2 Discovery Board
    NOTICE: Board: MB1272 Var4.0 Rev.C-03
    INFO: PMIC version = 0x21
    INFO: Reset reason (0x14):
    INFO: Pad Reset from NRST
    INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe2000
    INFO: FCONF: Reading firmware configuration information for: stm32mp_io
    INFO: FCONF: Reading firmware configuration information for: stm32mp_fuse
    INFO: Using SDMMC
    INFO: Instance 1
    INFO: Boot used partition fsbl1
    NOTICE: BL2: v2.8-stm32mp1-r2.0(debug):devtool-patched-17-g73d7146af(73d7146a)
    NOTICE: BL2: Built : 06:27:17, May 3 2025
    INFO: BL2: Doing platform setup
    INFO: RAM: DDR3-DDR3L 16bits 533000kHz
    INFO: Memory size = 0x20000000 (512 MB)
    INFO: BL2: Loading image id 1
    INFO: Loading image id=1 at address 0x2ffff000
    INFO: Image id=1 loaded: 0x2ffff000 - 0x2ffff1ea
    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
    INFO: BL2: Loading image id 4
    INFO: Loading image id=4 at address 0xde000000
    INFO: Image id=4 loaded: 0xde000000 - 0xde00001c
    INFO: OPTEE ep=0xde000000
    INFO: OPTEE header info:
    INFO: magic=0x4554504f
    INFO: version=0x2
    INFO: arch=0x0
    INFO: flags=0x0
    INFO: nb_images=0x1
    INFO: BL2: Loading image id 8
    INFO: Loading image id=8 at address 0xde000000
    INFO: Image id=8 loaded: 0xde000000 - 0xde030e08
    INFO: BL2: Skip loading image id 9
    INFO: BL2: Loading image id 2
    INFO: Loading image id=2 at address 0xc0500000
    INFO: Image id=2 loaded: 0xc0500000 - 0xc0520440
    INFO: BL2: Skip loading image id 16
    INFO: BL2: Loading image id 5
    INFO: Loading image id=5 at address 0xc0100000
    INFO: Image id=5 loaded: 0xc0100000 - 0xc0214c94
    NOTICE: BL2: Booting BL32
    INFO: Entry point address = 0xde000000
    INFO: SPSR = 0x1d3
    I/TC: Early console on UART#4
    I/TC:
    I/TC: Embedded DTB found
    I/TC: OP-TEE version: 3.19.0-dev (gcc version 12.3.0 (GCC)) #1 Fri Oct 14 19:00:05 UTC 2022 arm
    I/TC: WARNING: This OP-TEE configuration might be insecure!
    I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
    I/TC: Primary CPU initializing
    I/TC: Override the OTP 18: 0x7aba0000 to 0x7aba01e0
    I/TC: WARNING: Embeds insecure stm32mp_provisioning driver
    I/TC: Platform stm32mp1: flavor PLATFORM_FLAVOR - DT stm32mp157f-dk2.dts
    I/TC: OP-TEE ST profile: system_services
    I/TC: DTB enables console (non-secure)
    I/TC: Primary CPU switching to normal world boot
    optee optee: OP-TEE: revision 3.19 (afacf356)


    U-Boot 2022.10-stm32mp-r2 (May 03 2025 - 06:27:17 +0000)

    CPU: STM32MP157FAC Rev.Z
    Model: STMicroelectronics STM32MP157F-DK2 Discovery Board
    Board: stm32mp1 in trusted mode (st,stm32mp157f-dk2)
    Board: MB1272 Var4.0 Rev.C-03
    DRAM: 512 MiB
    optee optee: OP-TEE: revision 3.19 (afacf356)
    Clocks:
    - MPU : 800 MHz
    - MCU : 208.878 MHz
    - AXI : 266.500 MHz
    - PER : 24 MHz
    - DDR : 533 MHz
    Core: 362 devices, 42 uclasses, devicetree: board
    WDT: Started watchdog with servicing (32s timeout)
    NAND: 0 MiB
    MMC: STM32 SD/MMC: 0, STM32 SD/MMC: 1
    Loading Environment from MMC... *** Warning - bad CRC, using default environment

    In: serial
    Out: serial
    Err: serial
    Previous ADC measurements was not the one expected, retry in 20ms
    ****************************************************
    * WARNING 500mA power supply detected *
    * Current too low, use a 3A power supply! *
    ****************************************************

    Net: eth0: ethernet@5800a000
    Card did not respond to voltage select! : -110
    No EFI system partition
    Hit any key to stop autoboot: 0
    Boot over mmc0!
    Saving Environment to MMC... Writing to redundant MMC(0)... OK
    switch to partitions #0, OK
    mmc0 is current device
    Scanning mmc 0:8...
    Found U-Boot script /boot.scr.uimg
    4187 bytes read in 122 ms (33.2 KiB/s)
    ## Executing script at c6100000
    Executing SCRIPT on target=mmc0
    FOUND /mmc0_extlinux/stm32mp157f-dk2_extlinux.conf
    Saving Environment to MMC... Writing to MMC(0)... OK
    switch to partitions #0, OK
    mmc0 is current device
    Scanning mmc 0:8...
    Found /mmc0_extlinux/stm32mp157f-dk2_extlinux.conf
    Retrieving file: /mmc0_extlinux/stm32mp157f-dk2_extlinux.conf
    Retrieving file: /splash_portrait.bmp
    Select the boot mode
    1: OpenSTLinux
    2: stm32mp157f-dk2-a7-examples
    3: stm32mp157f-dk2-m4-examples
    Enter choice: 1: OpenSTLinux
    Retrieving file: /uImage
    Retrieving file: /st-image-resize-initrd
    append: root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=ttySTM0,115200
    Retrieving file: /stm32mp157f-dk2.dtb
    ## Booting kernel from Legacy Image at c2000000 ...
    Image Name: Linux-6.1.82
    Created: 2025-05-14 11:30:48 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 8780688 Bytes = 8.4 MiB
    Load Address: c2000040
    Entry Point: c2000040
    Verifying Checksum ... OK
    ## Flattened Device Tree blob at c6000000
    Booting using the fdt blob at 0xc6000000
    XIP Kernel Image
    Loading Ramdisk to cfa0e000, end cffff90e ... OK
    Loading Device Tree to cf9eb000, end cfa0de4b ... OK




    Thanks.

Hi @PatrickF 

I am able to get debug logs from the debug port now for below configuration.But fails due to timeout at 0x03 partition in stm32cubeprogrammer.

Address configuration:-
#define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x2008000))
#define STM32MP_BL33_MAX_SIZE U(0x3FF8000)

Debug port logs:-
 
NOTICE: CPU: STM32MP157FAC Rev.Z
NOTICE: Model: STMicroelectronics STM32MP157F-DK2 Discovery Board
NOTICE: Board: MB1272 Var4.0 Rev.C-03
INFO: PMIC version = 0x21
INFO: Reset reason (0x114):
INFO: IWDG1 Reset (rst_iwdg1)
INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe2000
INFO: FCONF: Reading firmware configuration information for: stm32mp_io
INFO: FCONF: Reading firmware configuration information for: stm32mp_fuse
INFO: Using USB
INFO: Instance 2
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.8-stm32mp1-r2.0(debug):devtool-patched-24-g7a39a16ea-dirty(7a39a16e)
NOTICE: BL2: Built : 09:21:43, Jun 25 2025
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 16bits 533000kHz
INFO: Memory size = 0x20000000 (512 MB)
INFO: DFU USB START...
INFO: phase ID :3, Manifestation 3 at c7162202
INFO: Send detach request
INFO: Receive DFU Detach
INFO: DFU USB STOP...
INFO: BL2: Loading image id 1
INFO: Loading image id=1 at address 0x2ffff000
INFO: Image id=1 loaded: 0x2ffff000 - 0x2ffff1ea
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
INFO: BL2: Loading image id 4
INFO: Loading image id=4 at address 0xde000000
INFO: Image id=4 loaded: 0xde000000 - 0xde00001c
INFO: OPTEE ep=0xde000000
INFO: OPTEE header info:
INFO: magic=0x4554504f
INFO: version=0x2
INFO: arch=0x0
INFO: flags=0x0
INFO: nb_images=0x1
INFO: BL2: Loading image id 8
INFO: Loading image id=8 at address 0xde000000
INFO: Image id=8 loaded: 0xde000000 - 0xde02ce00
INFO: BL2: Skip loading image id 9
INFO: BL2: Loading image id 2
INFO: Loading image id=2 at address 0xc6000000
INFO: Image id=2 loaded: 0xc6000000 - 0xc6020440
INFO: BL2: Skip loading image id 16
INFO: BL2: Loading image id 5
INFO: Loading image id=5 at address 0xc2008000
INFO: Image id=5 loaded: 0xc2008000 - 0xc211cc94
NOTICE: BL2: Booting BL32
INFO: Entry point address = 0xde000000
INFO: SPSR = 0x1d3


adnan_pasha
Senior

Hi @PatrickF 

Did you take a look at my debug logs how should i proceed from here.

Thanks.