cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with creating custom flash image for stm32mp157f-dk2 board

DevESG
Associate II

I am trying to create custom sd card image for the stm32mp157f-dk2 board. For device tree I used dts files from basic project created by STM32CubeIDE for that board, for now I didn''t do any changes to device tree. 
I used latest sources from v.25.08.27 and sdk v.25.06.11 to build kernel, modules and all required loaders.
But when I try to flash sd card with created loaders, STM32CubeProgrammer gets stuck on trying to reconnect to the board over USB connection:
10:21:44 : STM32CubeProgrammer API v2.20.0 | Linux-64Bits
10:22:15 : Read TSV File: /home/ivan/workspace/DeviceTree/FIP_artifacts_MP1/FlashLayout_sdcard_p6_mp1-optee.tsv
10:22:15 : Number of partitions: 13
10:22:28 : USB speed : High Speed (480MBit/s)
10:22:28 : Manuf. ID : STMicroelectronics
10:22:28 : Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
10:22:28 : SN : 002700353133511735343431
10:22:28 : DFU protocol: 1.1
10:22:28 : Board : --
10:22:28 : Device ID : 0x0500
10:22:29 : Start Embedded Flashing service
10:22:29 : Opening and parsing file: tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:22:29 : Memory Programming ...
10:22:29 : File : tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:22:29 : Size : 220.41 KB
10:22:29 : Partition ID : 0x01
10:22:29 : Download in Progress:
10:22:31 : File download complete
10:22:31 : Time elapsed during download operation: 00:00:02.146
10:22:31 : RUNNING Program ...
10:22:31 : PartID: :0x01
10:22:31 : Start operation done successfully at partition 0x01
10:22:31 : Opening and parsing file: fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:22:31 : Memory Programming ...
10:22:31 : File : fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:22:31 : Size : 1.46 MB
10:22:31 : Partition ID : 0x03
10:22:31 : Download in Progress:
10:22:34 : File download complete
10:22:34 : Time elapsed during download operation: 00:00:02.102
10:22:34 : RUNNING Program ...
10:22:34 : PartID: :0x03
10:22:34 : Reconnecting the device ...
10:23:04 : USB speed : High Speed (480MBit/s)
10:23:04 : Manuf. ID : STMicroelectronics
10:23:04 : Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
10:23:04 : SN : 002700353133511735343431
10:23:04 : DFU protocol: 1.1
10:23:04 : Board : --
10:23:04 : Device ID : 0x0500
10:23:04 : Device name :
10:23:04 : Device type :
10:23:04 : Device CPU :
10:23:04 : Start operation done successfully at partition 0x03
10:23:04 : Opening and parsing file: tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:23:04 : Memory Programming ...
10:23:04 : File : tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:23:04 : Size : 220.41 KB
10:23:04 : Partition ID : 0x01
10:23:04 : Download in Progress:
10:23:06 : File download complete
10:23:06 : Time elapsed during download operation: 00:00:02.140
10:23:06 : RUNNING Program ...
10:23:06 : PartID: :0x01
10:23:06 : Start operation done successfully at partition 0x01
10:23:06 : Opening and parsing file: fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:23:06 : Memory Programming ...
10:23:06 : File : fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:23:06 : Size : 1.46 MB
10:23:06 : Partition ID : 0x03
10:23:06 : Download in Progress:
10:23:08 : File download complete
10:23:08 : Time elapsed during download operation: 00:00:02.032
10:23:08 : RUNNING Program ...
10:23:08 : PartID: :0x03
10:23:09 : Reconnecting the device ...
10:23:39 : USB speed : High Speed (480MBit/s)
10:23:39 : Manuf. ID : STMicroelectronics
10:23:39 : Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
10:23:39 : SN : 002700353133511735343431
10:23:39 : DFU protocol: 1.1
10:23:39 : Board : --
10:23:39 : Device ID : 0x0500
10:23:39 : Device name :
10:23:39 : Device type :
10:23:39 : Device CPU :
10:23:39 : Start operation done successfully at partition 0x03
10:23:39 : Opening and parsing file: tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:23:39 : Memory Programming ...
10:23:39 : File : tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:23:39 : Size : 220.41 KB
10:23:39 : Partition ID : 0x01
10:23:39 : Download in Progress:
10:23:41 : File download complete
10:23:41 : Time elapsed during download operation: 00:00:02.048
10:23:41 : RUNNING Program ...
10:23:41 : PartID: :0x01
10:23:41 : Start operation done successfully at partition 0x01
10:23:41 : Opening and parsing file: fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:23:41 : Memory Programming ...
10:23:41 : File : fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:23:41 : Size : 1.46 MB
10:23:41 : Partition ID : 0x03
10:23:41 : Download in Progress:
10:23:43 : File download complete
10:23:43 : Time elapsed during download operation: 00:00:02.009
10:23:43 : RUNNING Program ...
10:23:43 : PartID: :0x03
10:23:44 : Reconnecting the device ...
10:24:14 : USB speed : High Speed (480MBit/s)
10:24:14 : Manuf. ID : STMicroelectronics
10:24:14 : Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
10:24:14 : SN : 002700353133511735343431
10:24:14 : DFU protocol: 1.1
10:24:14 : Board : --
10:24:14 : Device ID : 0x0500
10:24:14 : Device name :
10:24:14 : Device type :
10:24:14 : Device CPU :
10:24:14 : Start operation done successfully at partition 0x03
10:24:14 : Opening and parsing file: tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:24:14 : Memory Programming ...
10:24:14 : File : tf-a-stm32mp157f-p6_mp1-mx-optee-programmer-usb.stm32
10:24:14 : Size : 220.41 KB
10:24:14 : Partition ID : 0x01
10:24:14 : Download in Progress:
10:24:16 : File download complete
10:24:16 : Time elapsed during download operation: 00:00:02.027
10:24:16 : RUNNING Program ...
10:24:16 : PartID: :0x01
10:24:16 : Start operation done successfully at partition 0x01
10:24:16 : Opening and parsing file: fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:24:16 : Memory Programming ...
10:24:16 : File : fip-stm32mp157f-p6_mp1-mx-optee-programmer-usb.bin
10:24:16 : Size : 1.46 MB
10:24:16 : Partition ID : 0x03
10:24:16 : Download in Progress:
10:24:18 : File download complete
10:24:18 : Time elapsed during download operation: 00:00:01.986
10:24:18 : RUNNING Program ...
10:24:18 : PartID: :0x03
10:24:18 : Reconnecting the device ...

When I tried images from FLASH package for this board, everything is flashed fine, but I see what is missing in flashing of my custom loaders:

Opening and parsing file: fip-stm32mp157f-dk2-optee-programmer-usb.bin
10:31:11 : Memory Programming ...
10:31:11 : File : fip-stm32mp157f-dk2-optee-programmer-usb.bin
10:31:11 : Size : 1.76 MB
10:31:11 : Partition ID : 0x03
10:31:11 : Download in Progress:
10:31:14 : File download complete
10:31:14 : Time elapsed during download operation: 00:00:02.513
10:31:14 : RUNNING Program ...
10:31:14 : PartID: :0x03
10:31:14 : Reconnecting the device ...
10:31:18 : USB speed : High Speed (480MBit/s)
10:31:18 : Manuf. ID : STMicroelectronics
10:31:18 : Product ID : USB download gadget@Device ID /0x500, @Revision ID /0x2001, @Name /STM32MP157FAC Rev.Z,
10:31:18 : SN : 002700353133511735343431
10:31:18 : DFU protocol: 1.1
10:31:18 : Board : --
10:31:18 : Device ID : 0x0500
10:31:18 : Device name : STM32MP157FAC Rev.Z
10:31:18 : Device type :
10:31:18 : Device CPU :
10:31:18 : Start operation done successfully at partition 0x03

It seems that custom dts for tf-a loaders is missing some USB initialization? How can I fixed this issue?
Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Olivier GALLIEN
ST Employee

Hi @DevESG 

DTS generated by CubeMX/CubeIDE are indeed not "bootable" as such

Some user section likely to be completed. 

The recommended approach is to compare DTS with one generated by CubeMX for a ST board such as DK or EV. 

Hope this help

Olivier 

 

Olivier GALLIEN
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

4 REPLIES 4
DevESG
Associate II

I couldn't figure out what's wrong with CubeProgrammer not able to flash my SD card, so I decided to use shell script from Starter Package create_sdcard_from_flashlayout.sh to flash the card. This time flash succeeded, but board wouldn't boot, throwing an exception:
NOTICE: CPU: STM32MP157FAC Rev.Z
NOTICE: Model: P6 MP1 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_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-r2.0(debug):()
NOTICE: BL2: Built : 02:50:41, Dec 16 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
INFO: Loading image id=4 at address 0x2ffc0000
INFO: Image id=4 loaded: 0x2ffc0000 - 0x2ffc001c
INFO: OPTEE ep=0x2ffc0000
INFO: OPTEE header info:
INFO: magic=0x4554504f
INFO: version=0x2
INFO: arch=0x0
INFO: flags=0x0
INFO: nb_images=0x1
WARNING: The load address in optee header 0xde000000 - 0xde037b58 is not in res.
ERROR: OPTEE headePANIC at PC : 0x2fff2df1


which is very strange as dts file for u-boot has that region defined:

/ {
model = "P6 MP1 board";
compatible = "st,stm32mp157f-p6_mp1-mx", "st,stm32mp157f-dk2", "st,stm32mp157";
 
memory@c0000000 {
device_type = "memory";
reg = <0xc0000000 0x20000000>;
 
/* USER CODE BEGIN memory */
/* USER CODE END memory */
};
 
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;
 
/* USER CODE BEGIN reserved-memory */
 
mcuram2:mcuram2@10000000{
compatible = "shared-dma-pool";
reg = <0x10000000 0x40000>;
no-map;
};
 
vdev0vring0:vdev0vring0@10040000{
compatible = "shared-dma-pool";
reg = <0x10040000 0x1000>;
no-map;
};
 
vdev0vring1:vdev0vring1@10041000{
compatible = "shared-dma-pool";
reg = <0x10041000 0x1000>;
no-map;
};
 
vdev0buffer:vdev0buffer@10042000{
compatible = "shared-dma-pool";
reg = <0x10042000 0x4000>;
no-map;
};
 
mcu_rsc_table:mcu-rsc-table@10048000{
compatible = "shared-dma-pool";
reg = <0x10048000 0x8000>;
no-map;
};
 
mcuram:mcuram@30000000{
compatible = "shared-dma-pool";
reg = <0x30000000 0x40000>;
no-map;
};
 
retram:retram@38000000{
compatible = "shared-dma-pool";
reg = <0x38000000 0x10000>;
no-map;
};
 
gpu_reserved:gpu@d4000000{
reg = <0xd4000000 0x4000000>;
no-map;
};
 
linux,cma{
compatible = "shared-dma-pool";
reusable;
size = <0x8000000>;
alignment = <0x2000>;
linux,cma-default;
};
 
optee@de000000{
reg = <0xde000000 0x2000000>;
no-map;
};
/* USER CODE END reserved-memory */
};



DevESG
Associate II

If I replace my custom optee-programmer-usb.bin file in tsv fip-boot partition with file from FLASH package:
fip/fip-stm32mp157f-dk2-optee-programmer-usb.bin
then CubeProgrammer successfully flashes SD card with the rest of my files, but board cannot boot, giving the same error  'optee header address is not in res', which I showed in previous message. 
If I also replace my optee-sdcard.bin file in fip-a partition of tsv with file from FLASH fip/fip-stm32mp157f-dk2-optee-sdcard.bin, then flash succeeds and board boots, but it boots by default with dk2 dtb even though the only dtb file in boot/ is my dtb file. The only way I was able to use my custom dtb was to modify /boot/mmc0_extlinux/stm32mp157f-dk2_extlinux.conf file so that the default option was pointing to my dtb file.
This is very non-straightforward way of making custom dtb, so I can't accept it as a solution. Hopefully somebody has ideas what needs to be changed in either dts files that CubeIDE generates or in code of tf loaders so that instructions provided on web site would work.


Olivier GALLIEN
ST Employee

Hi @DevESG 

DTS generated by CubeMX/CubeIDE are indeed not "bootable" as such

Some user section likely to be completed. 

The recommended approach is to compare DTS with one generated by CubeMX for a ST board such as DK or EV. 

Hope this help

Olivier 

 

Olivier GALLIEN
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.
DevESG
Associate II

Hi Olivier,

So, as I understand it, instead of relying on CubeIDE to generate dts files, I should start from dts files for my board that are found in sources of DeveloperPackage. This way I for sure will start with code that is 'bootable' and I can modify those dts files as needed for my custom project. 

Thank you.