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!

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @HZ890 ,
I am really sorry, I was preempted on other activities and I forgot your fip commentary.

I just took a look at it, and something surprised me. By looking at the content with fiptool info command (using SDK), I see this:

 fiptool info ./fip-stm32mp157f-dk2-optee-sdcard.bin 
Non-Trusted Firmware BL33: offset=0xB0, size=0x15555CC, cmdline="--nt-fw"
FW_CONFIG: offset=0x155567C, size=0x1EA, cmdline="--fw-config"
HW_CONFIG: offset=0x1555866, size=0x20E3F, cmdline="--hw-config"

In a "normal" binary FIP, you have this:

fiptool info fip-stm32mp157f-dk2-optee-sdcard.bin
Secure Payload BL32 (Trusted OS): offset=0x128, size=0x2C, cmdline="--tos-fw"
Secure Payload BL32 Extra1 (Trusted OS Extra1): offset=0x154, size=0x10B48, cmdline="--tos-fw-extra1"
Secure Payload BL32 Extra2 (Trusted OS Extra2): offset=0x10C9C, size=0x72000, cmdline="--tos-fw-extra2"
Non-Trusted Firmware BL33: offset=0x82C9C, size=0x11E500, cmdline="--nt-fw"
FW_CONFIG: offset=0x1A119C, size=0x1EA, cmdline="--fw-config"
HW_CONFIG: offset=0x1A1386, size=0x21600, cmdline="--hw-config"

In fact, I well see your new BL33 (originally U-Boot, now the Linux kernel in your setup). The size looks coherent with a Linux Image.

I well see the U-Boot Linux DTB, that's ok.

I also see the FW config DTB.

What is missing is the OP-TEE part in fact. OP-TEE is mandatory to boot, and it is possible that TF-A raises an issue by knowing that OP-TEE must be present.

There are 2 possibilities, either you created a FIP from scratch and forgot to compile and put OP-TEE inside, or you deleted silently OP-TEE from your FIP. In the context of the wiki article, we start from the original starter FIP binary, and update only the parts that change.

Can you please try to add the missing part and ping me back ? 

Kind regards,
Erwan.

(cf: https://wiki.st.com/stm32mpu/wiki/How_to_configure_TF-A_FIP for MP1)

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.

View solution in original post

10 REPLIES 10
Erwan SZYMANSKI
ST Employee

Hello @HZ890 ,
Can you please precise a bit the status when you says "everytime I execute the process it fails" ? Do you talk at boot time or during the preparation process ? 

Do you have some error logs or anything to share ? 

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.

Dear Erwan SZYMANSKI,

I received the following error during the boot time process:

 

NOTICE: CPU: STM32MP157FAC Rev.Z NOTICE: Model: STMicroelectronics STM32MP157F-DK2 Discovery Board NOTICE: Board: MB1272 Var4.0 Rev.C-03 NOTICE: BL2: v2.10-stm32mp1-r1.0(release):() NOTICE: BL2: Built : 11:26:24, Apr 7 2025 ERROR: BL2: Failed to load image id 1 (-27)

If you have any pointers or an example with those platforms, it would be much appreciated.

Best Regards,
Hassan

Hello @HZ890 ,
First, concerning the mention of bootfs partition and u-boot-env are no more needed in this setup, the article just wanted to make a parallel with the default components / flashlayout, but you are right I will remove it in the next version of the article. 

Then concerning your image load error, can you activate more TF-A  debug logs and give an attachment of all the bootlogs ? 

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.
 

Hi Erwan,

I wanted to update you on my progress with the STM32MP157F boot sequence. I've removed U-Boot from the boot sequence and configured the system to boot directly into Linux, as suggested in the guide https://wiki.st.com/stm32mpu/wiki/How_to_optimize_the_boot_time#Optimizing_boot-time_by_removing_U-Boot .

Here are the steps I followed:

  1. TF-A Configuration:

    • Updated the configuration for STM32MP_BL33_BASE and STM32MP_BL33_MAX_SIZE:

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

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

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

    • Extracted TF-A and applied patches:

      $> tar xf tf-a-stm32mp-v2.10.5-stm32mp-r1-r0.tar.xz
      $> cd tf-a-stm32mp-v2.10.5-stm32mp-r1
      $> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
      $> export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts
      $> make -f ../Makefile.sdk TF_A_DEVICETREE=stm32mp157f-dk2 TF_A_CONFIG=optee-sdcard ELF_DEBUG_ENABLE='1' all
    • The TF-A output files were:

      • tf-a-stm32mp157f-dk2-optee-sdcard.stm32

      • stm32mp157f-dk2-fw-config-optee-sdcard.dtb

  4. Kernel Configuration:

    • I followed the instructions of:
      $> tar xf linux-6.6.48.tar.xz
      $> cd linux-6.6.48
      $> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

      $> export OUTPUT_BUILD_DIR=$PWD/../build
      $> mkdir -p ${OUTPUT_BUILD_DIR}
      $> make O="${OUTPUT_BUILD_DIR}" defconfig fragment*.config

      If there are some fragments, apply them
      * manually one by one:
      $ scripts/kconfig/merge_config.sh -m -r -O ${OUTPUT_BUILD_DIR} ${OUTPUT_BUILD_DIR}/.config ../fragment-01-xxx.config
      $ scripts/kconfig/merge_config.sh -m -r -O ${OUTPUT_BUILD_DIR} ${OUTPUT_BUILD_DIR}/.config ../fragment-02-xxx.config
      ...
      $ (yes '' || true) | make oldconfig O="${OUTPUT_BUILD_DIR}"

    • Used make menuconfig to configure the kernel command line:

      • (root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw earlyprintk earlycon console=ttySTM0,115200)

      • Selected: Kernel command line type (Always use the default kernel command string)

    • Built the kernel:

      make Image vmlinux dtbs O="${OUTPUT_BUILD_DIR}"
    • This resulted in the output files:

      • Image

      • stm32mp157f-dk2.dtb

  5. FIP Tool Update:

    • Used fiptool to update the binary files:

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

  6. Flash Layout Modification:

    • Modified the tsv file to include the new TF-A and FIP files:

       
      HZ890_0-1744796844733.png

       

  7. Flashing the Board:

    • Connected the board using a USB Type-A to Type-C cable for data and a 5V 3A power adapter.

    • Used the command:

       
      STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/optee/FlashLayout_sdcard_stm32mp157f-dk2-optee-modif.tsv
    • Then powered off the board, switched the boot mode to ON, and powered it on.

  8. Boot Log Output:

    • Upon powering the board, I received the following output:

       
      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 (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_fuse
      INFO: FCONF: Reading firmware configuration information for: stm32mp_io
      INFO: Using SDMMC
      INFO: Instance 1
      INFO: Boot used partition fsbl1
      NOTICE: BL2: v2.10-stm32mp1-r1.0(debug):()
      NOTICE: BL2: Built : 14:04:05, Apr 15 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_firewal
      INFO: BL2: Loading image id 4
      WARNING: Failed to access image id=4 (-2)
      ERROR: BL2: Failed to load image id 4 (-2)

Could you please take a look and let me know if I missed anything in the setup or if there is something else that could be causing this issue?

Looking forward to your guidance.

Kind regards,

Hassan

Hello @HZ890 ,
Is it possible for you to attach your fip here ? It seems there is something wrong in the FIP content.

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.

Hello Erwan,

Sure, please find the FIP file attached for your review.

Kind regards,

Hassan

Hello Erwan,

Kindly let me know if there are any updates or if you need anything further.

Looking forward to your feedback.

Kind regards,
Hassan

Hello @HZ890 ,
I am really sorry, I was preempted on other activities and I forgot your fip commentary.

I just took a look at it, and something surprised me. By looking at the content with fiptool info command (using SDK), I see this:

 fiptool info ./fip-stm32mp157f-dk2-optee-sdcard.bin 
Non-Trusted Firmware BL33: offset=0xB0, size=0x15555CC, cmdline="--nt-fw"
FW_CONFIG: offset=0x155567C, size=0x1EA, cmdline="--fw-config"
HW_CONFIG: offset=0x1555866, size=0x20E3F, cmdline="--hw-config"

In a "normal" binary FIP, you have this:

fiptool info fip-stm32mp157f-dk2-optee-sdcard.bin
Secure Payload BL32 (Trusted OS): offset=0x128, size=0x2C, cmdline="--tos-fw"
Secure Payload BL32 Extra1 (Trusted OS Extra1): offset=0x154, size=0x10B48, cmdline="--tos-fw-extra1"
Secure Payload BL32 Extra2 (Trusted OS Extra2): offset=0x10C9C, size=0x72000, cmdline="--tos-fw-extra2"
Non-Trusted Firmware BL33: offset=0x82C9C, size=0x11E500, cmdline="--nt-fw"
FW_CONFIG: offset=0x1A119C, size=0x1EA, cmdline="--fw-config"
HW_CONFIG: offset=0x1A1386, size=0x21600, cmdline="--hw-config"

In fact, I well see your new BL33 (originally U-Boot, now the Linux kernel in your setup). The size looks coherent with a Linux Image.

I well see the U-Boot Linux DTB, that's ok.

I also see the FW config DTB.

What is missing is the OP-TEE part in fact. OP-TEE is mandatory to boot, and it is possible that TF-A raises an issue by knowing that OP-TEE must be present.

There are 2 possibilities, either you created a FIP from scratch and forgot to compile and put OP-TEE inside, or you deleted silently OP-TEE from your FIP. In the context of the wiki article, we start from the original starter FIP binary, and update only the parts that change.

Can you please try to add the missing part and ping me back ? 

Kind regards,
Erwan.

(cf: https://wiki.st.com/stm32mpu/wiki/How_to_configure_TF-A_FIP for MP1)

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.

Hello Erwan,

Thank you so much for your detailed analysis and for taking the time to highlight the missing OP-TEE component.

You were absolutely right — the OP-TEE binaries were indeed missing from my custom FIP. After updating the FIP accordingly, everything worked correctly.

I truly appreciate your guidance and effort. It helped me resolve the issue efficiently.

Kind regards,
Hassan