2025-06-23 8:31 AM
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
I’ve updated the configuration in stm32mp1_def.h as follows:
Modified the SD card timeout value in <tf-a_sources>/drivers/st/mmc/stm32_sdmmc2.c:
TF-A Build Process:
I applied the changes as a patch through my custom Yocto layer and rebuilt the tf-a-stm32mp recipe successfully.
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.
FIP Tool Update:
I updated the FIP image using fiptool:
The result was the new FIP file: fip-stm32mp157f-dk2-optee-sdcard.bin
Flash Layout Modification:
I modified the TSV file as follows to include the new TF-A and FIP binaries:
#Opt | Id | Name | Type | IP | Offset | Binary |
- | 0x01 | fsbl-boot | Binary | none | 0x0 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb.stm32 |
- | 0x03 | fip-boot | FIP | none | 0x0 | fip/fip-stm32mp157f-dk2-optee-emmc.bin |
P | 0x04 | fsbl1 | Binary | mmc1 | boot1 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32 |
P | 0x05 | fsbl2 | Binary | mmc1 | boot2 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32 |
P | 0x06 | metadata1 | FWU_MDATA | mmc1 | 0x00080000 | arm-trusted-firmware/metadata.bin |
P | 0x07 | metadata2 | FWU_MDATA | mmc1 | 0x00100000 | arm-trusted-firmware/metadata.bin |
P | 0x08 | fip-a | FIP | mmc1 | 0x00180000 | fip/fip-stm32mp157f-dk2-optee-emmc.bin |
PED | 0x09 | fip-b | FIP | mmc1 | 0x02180000 | none |
PED | 0x0A | u-boot-env | ENV | mmc1 | 0x02580000 | none |
P | 0x10 | bootfs | System | mmc1 | 0x02600000 | st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4 |
P | 0x11 | vendorfs | FileSystem | mmc1 | 0x06600000 | st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4 |
P | 0x12 | rootfs | FileSystem | mmc1 | 0x07600000 | st-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.
2025-06-24 3:52 AM
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.
2025-06-24 5:10 AM
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.
#Opt | Id | Name | Type | IP | Offset | Binary |
- | 0x01 | fsbl-boot | Binary | none | 0x0 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb.stm32 |
- | 0x03 | fip-boot | FIP | none | 0x0 | fip/fip-stm32mp157f-dk2-optee-sdcard.bin |
P | 0x04 | fsbl1 | Binary | mmc0 | 0x00004400 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-sdcard.stm32 |
P | 0x05 | fsbl2 | Binary | mmc0 | 0x00044400 | arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-sdcard.stm32 |
P | 0x06 | metadata1 | FWU_MDATA | mmc0 | 0x00084400 | arm-trusted-firmware/metadata.bin |
P | 0x07 | metadata2 | FWU_MDATA | mmc0 | 0x000C4400 | arm-trusted-firmware/metadata.bin |
P | 0x08 | fip-a | FIP | mmc0 | 0x00104400 | modified-fip/fip-stm32mp157f-dk2-optee-sdcard.bin |
PED | 0x09 | fip-b | FIP | mmc0 | 0x02104400 | none |
PED | 0x0A | u-boot-env | ENV | mmc0 | 0x02904400 | none |
P | 0x10 | bootfs | System | mmc0 | 0x02984400 | st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4 |
P | 0x11 | vendorfs | FileSystem | mmc0 | 0x06984400 | st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4 |
P | 0x12 | rootfs | FileSystem | mmc0 | 0x12084400 | st-image-qt-openstlinux-weston-stm32mp15-disco.ext4 |
P | 0x13 | userfs | FileSystem | mmc0 | 0x112084400 | st-image-qt-userfs-openstlinux-weston-stm32mp15-disco.ext4 |
2025-06-24 6:00 AM
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.
2025-06-25 1:17 AM
Hi @PatrickF
I’ve observed one thing — when I revert the BL33_BASE_ADDR and BL33_MAX_SIZE values to their default settings:
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
2025-06-25 2:39 AM - edited 2025-06-25 2:44 AM
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
2025-06-30 1:06 AM
Hi @PatrickF
Did you take a look at my debug logs how should i proceed from here.
Thanks.