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!

6 REPLIES 6
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