cancel
Showing results for 
Search instead for 
Did you mean: 

Direct Kernel Boot on STM32MP1

HZ890
Associate II

Hi everyone,

I'm attempting to optimize the boot process on my STM32MP157F-DK2 board by removing U-Boot and booting the Linux kernel directly via the FIP. I've followed the documented steps for STM32MP1:

  1. TF-A BL2 Modifications:

    • Updated STM32MP_BL33_BASE and STM32MP_BL33_MAX_SIZE in the STM32MP1 header file.

    • Increased the SDMMC timeout in stm32_sdmmc2.c to accommodate the larger kernel image.

  2. FIP Creation:

    • Recompiled TF-A with my modifications.

    • Created a new FIP where I replaced the U-Boot binary and its DTB with my Linux kernel Image and DTB.

    • The new FIP (fip.bin) now contains the kernel and DTB.

  3. Flash Layout TSV Modifications:
    I updated the TSV file to allocate a larger space for the FIP. Below is the relevant excerpt:

    HZ890_0-1742823828143.png

Despite these modifications, every time I execute the process, it fails. My questions are:

  • What is the purpose of the bootfs partition?
    Since my new FIP (fip.bin) already contains the Linux kernel and its DTB, I'm unclear why the flash layout still reserves a bootfs partition. Is it meant for additional boot configurations, an initial ramdisk, or something else?

  • Why is the u-boot-env partition still present?
    If U-Boot is being removed entirely from the boot chain, what role does the U-Boot environment play here? Is it kept for legacy or recovery purposes?

I would really appreciate any insights or suggestions on what might be going wrong or what additional changes I need to consider for a successful direct kernel boot setup on STM32MP157f-dk2.

Thanks in advance for your help!

20 REPLIES 20

Thank you @HZ890 for your quick test and feedback.
Once again, sorry for the delay of my previous answer.

Kind regards,
Erwan.

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.

out of curiosity, what  average boot time did you see with this falcon mode style direct booting?

adnan_pasha
Senior

Hi,

I am also trying to eliminate u-boot and directly boot into linux kernel. I am using yocto mickledore distibution package for stm32mp15-disco machine.

I have made the below changes in my TFA and kernel:-

1. change STM32MP_BL33_BASE and STM32MP_BL33_MAX_SIZE in my stm32mp1_def.h file 
#define
 STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x2008000))

#define STM32MP_BL33_MAX_SIZE U(0x3FF8000)
2. 
increased timeout in my <tf-a_sources>/drivers/st/mmc/stm32_sdmmc2.c file:

timeout = timeout_init_us(TIMEOUT_US_1_S * 10);
3. kernel:- Added below config parameters in my defconfig file

CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw earlyprintk earlycon console=ttySTM0,115200"
4. After rebuilding my image with the above chamges, I 
updated the FIP image using fiptool:

fiptool update --nt-fw kernel/uImage --hw-config kernel/stm32mp157f-dk2.dtb Modified-fip/fip-stm32mp157f-dk2-optee-sdcard.bin

5. below is my flashlayout:-
#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

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

Please let me know if i need to make any other changes or how i can resolve this and get my direct kernel boot to work?

Thanks.
 
 
adnan_pasha
Senior

Hi @Erwan SZYMANSKI 

Below is the debug log i get while trying to flash image using stm32cubeprogrammer.

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

Hi,

It looks like the FIP you’re programming at partition 0x03 is the one intended for SD‑card boot (“…-sdcard.bin”), but STM32CubeProgrammer (and the on‑board bootloader) actually expect the “programmer‑...” FIP at that slot. Try In your layout table that entry 0x03 (“fip-boot”) points to fip-stm32mp157f-dk2-optee-programmer-usb.bin.

kind Regards,
Hassan Zaalouk

adnan_pasha
Senior

Hi,

I only have sd-card and emmc fip binaries in my build directory.

./fip/fip-stm32mp157f-dk2-optee-emmc.bin
./fip/fip-stm32mp157f-dk2-optee-sdcard.bin

below is the output of files i got in my build directory.

├── arm-trusted-firmware
│   ├── bl2
│   │   ├── tf-a-stm32mp157f-dk2-optee-emmc.bin
│   │   ├── tf-a-stm32mp157f-dk2-optee-sdcard.bin
│   │   ├── tf-a-stm32mp157f-dk2-uart.bin
│   │   └── tf-a-stm32mp157f-dk2-usb.bin
│   ├── debug
│   │   ├── debug-tf-a-stm32mp157f-dk2-optee-emmc.stm32
│   │   ├── debug-tf-a-stm32mp157f-dk2-optee-sdcard.stm32
│   │   ├── debug-tf-a-stm32mp157f-dk2-uart.stm32
│   │   ├── debug-tf-a-stm32mp157f-dk2-usb.stm32
│   │   ├── tf-a-bl2-stm32mp15-optee-emmc.elf
│   │   ├── tf-a-bl2-stm32mp15-optee-sdcard.elf
│   │   ├── tf-a-bl2-stm32mp15-uart.elf
│   │   └── tf-a-bl2-stm32mp15-usb.elf
│   ├── fwconfig
│   │   ├── stm32mp157f-dk2-fw-config-optee-emmc.dtb
│   │   ├── stm32mp157f-dk2-fw-config-optee-emmc.dts
│   │   └── stm32mp157f-dk2-fw-config-optee-sdcard.dtb
│   ├── metadata.bin
│   ├── tf-a-stm32mp157f-dk2-optee-emmc.stm32
│   ├── tf-a-stm32mp157f-dk2-optee-sdcard.stm32
│   ├── tf-a-stm32mp157f-dk2-uart.stm32
│   └── tf-a-stm32mp157f-dk2-usb.stm32
├── build-st-image-qt-openstlinux-weston-stm32mp15-disco
├── fip
│   ├── fip-stm32mp157f-dk2-optee-emmc.bin
│   └── fip-stm32mp157f-dk2-optee-sdcard.bin
├── flashlayout_st-image-qt
│   ├── deleteall
│   │   └── FlashLayout_board_stm32mp157f-dk2-deleteall.tsv
│   ├── extensible
│   │   ├── FlashLayout_emmc_stm32mp157f-dk2-extensible-tfa-and-uboot.tsv
│   │   ├── FlashLayout_emmc_stm32mp157f-dk2-extensible.tsv
│   │   └── FlashLayout_sdcard_stm32mp157f-dk2-extensible.tsv
│   └── optee
│   ├── FlashLayout_emmc_stm32mp157f-dk2-optee.tsv
│   └── FlashLayout_sdcard_stm32mp157f-dk2-optee.tsv
├── kernel
│   ├── config-6.1.82
│   ├── file
│   │   ├── stm32mp157f-dk2.dtb
│   │   └── uImage
│   ├── modules--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.tgz
│   ├── modules-stm32mp15-disco.tgz
│   ├── modules-stripped--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.tgz
│   ├── modules-stripped-stm32mp15-disco.tgz
│   ├── stm32mp157f-dk2--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.dtb
│   ├── stm32mp157f-dk2-a7-examples--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.dtb
│   ├── stm32mp157f-dk2-a7-examples.dtb
│   ├── stm32mp157f-dk2-a7-examples-stm32mp15-disco.dtb
│   ├── stm32mp157f-dk2.dtb
│   ├── stm32mp157f-dk2-m4-examples--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.dtb
│   ├── stm32mp157f-dk2-m4-examples.dtb
│   ├── stm32mp157f-dk2-m4-examples-stm32mp15-disco.dtb
│   ├── stm32mp157f-dk2-stm32mp15-disco.dtb
│   ├── uImage
│   ├── uImage--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.bin
│   ├── uImage-stm32mp15-disco.bin
│   ├── vmlinux
│   ├── vmlinux--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.bin
│   ├── vmlinux-stm32mp15-disco.bin
│   ├── zImage
│   ├── zImage--6.1.82-stm32mp-r2-r0.138-stm32mp15-disco-20250612072544.bin
│   └── zImage-stm32mp15-disco.bin
├── optee
│   ├── debug
│   │   └── tee-stm32mp157f-dk2.elf
│   ├── tee-header_v2-stm32mp157f-dk2.bin
│   ├── tee-pageable_v2-stm32mp157f-dk2.bin
│   └── tee-pager_v2-stm32mp157f-dk2.bin
├── scripts
│   └── create_sdcard_from_flashlayout.sh
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco-20250617062752.bootfs.ext4
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco-20250617062752.bootfs.manifest
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco-20250617062752.bootfs.tar.xz
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco-20250617062752.testdata.json
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco.manifest
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco.tar.xz
├── st-image-bootfs-openstlinux-weston-stm32mp15-disco.testdata.json
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815.license
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815-license_content.html
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815.rootfs.ext4
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815.rootfs.manifest
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815.rootfs.tar.xz
├── st-image-qt-openstlinux-weston-stm32mp15-disco-20250617073815.testdata.json
├── st-image-qt-openstlinux-weston-stm32mp15-disco.ext4
├── st-image-qt-openstlinux-weston-stm32mp15-disco.license
├── st-image-qt-openstlinux-weston-stm32mp15-disco-license_content.html
├── st-image-qt-openstlinux-weston-stm32mp15-disco.manifest
├── st-image-qt-openstlinux-weston-stm32mp15-disco.tar.xz
├── st-image-qt-openstlinux-weston-stm32mp15-disco.testdata.json
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco-20250617062752.testdata.json
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco-20250617062752.userfs.ext4
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco-20250617062752.userfs.manifest
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco-20250617062752.userfs.tar.xz
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.ext4
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.manifest
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.tar.xz
├── st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.testdata.json
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco-20250617062752.rootfs.cpio.gz
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco-20250617062752.rootfs.manifest
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco-20250617062752.testdata.json
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco.cpio.gz
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco.manifest
├── st-image-resize-initrd-openstlinux-weston-stm32mp15-disco.testdata.json
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco-20250617062752.testdata.json
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco-20250617062752.vendorfs.ext4
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco-20250617062752.vendorfs.manifest
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco-20250617062752.vendorfs.tar.xz
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco.manifest
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco.tar.xz
├── st-image-vendorfs-openstlinux-weston-stm32mp15-disco.testdata.json
├── st-initrd-openstlinux-weston-stm32mp15-disco
└── u-boot
├── debug
│   └── u-boot-stm32mp15-default.elf
├── u-boot-nodtb-stm32mp15-default.bin
└── u-boot-stm32mp157f-dk2.dtb

The file fip‑stm32mp157f‑dk2‑optee‑programmer‑usb.bin is included in the STM32MP1 Starter Package. You can download and install this package from ST’s website here:
https://www.st.com/en/embedded-software/stm32mp1starter.html#get-software

adnan_pasha
Senior

Hi @Erwan SZYMANSKI 

Thank you for sharing the link.

I've downloaded the Starter Package and I'm currently in the process of flashing my modified image. I'll share an update once the flashing is complete.

In the meantime, I have a question. Before switching to direct Linux boot, I was using the fip-stm32mp157f-dk2-optee-sdcard.bin binary to flash the board over USB via STM32CubeProgrammer. However, following your instructions, I now need to use fip-stm32mp157f-dk2-optee-programmer-usb.bin instead.

Could you clarify why this change is necessary?

Also, when I build my image, I notice that the -programmer-usb.bin file is not generated automatically in my build directory. Is there a specific step or configuration required to produce this file?

Thanks again!

adnan_pasha
Senior

Hi @Erwan SZYMANSKI 

After replacing my fip-stm32mp157f-dk2-optee-sdcard.bin file with fip-stm32mp157f-dk2-optee-programmer-usb.bin
it still fails at partition 3 with reconnect timeout expired?

NOTICE: Model: STMicroelectronics STM32MP157F-DK2 Discovery Board
NOTICE: Board: MB1272 Var4.0 Rev.C-03
INFO: PMIC version = 0x21
INFO: Reset reason (0x15):
INFO: Power-on Reset (rst_por)
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 : 10:33:04, Jun 26 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 @Erwan SZYMANSKI 

Above issue was because i did not changed the tsv file after updating it to use usb-fip i was able to flash image to the device but not able to boot device?

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-24-g7a39a16ea-dirty(7a39a16e)
NOTICE: BL2: Built : 10:33:04, Jun 26 2025
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 16bits 533000kHz
INFO: Memory size = 0x20000000 (512 MB)
INFO: BL2: Loading image id 1
WARNING: Failed to access image id=1 (-2)
ERROR: BL2: Failed to load image id 1 (-2)