cancel
Showing results for 
Search instead for 
Did you mean: 

Can't flash my eMMC on STM32MP157

LaurentC_FDI
Associate

Hi all, we are trying to start our own board running a STM32MP157DAC1

We have so far been able to load the TF-A, OPTEE (only when configured in SYSRAM) and u-boot, our starting point is the openst-linux framework (5.0.2 - mickledore), on top of which we have added our layer to add our dts* and defconfig.

Right now, I am not able to program anything into eMMC (set to mmc1)

I got this message from STM32CubeProgrammer_CLI : 

-------------------------------------------------------------------
STM32CubeProgrammer v2.14.0
-------------------------------------------------------------------

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
SN : 002A00173432510E33363738
DFU protocol: 1.1
Board : --
Device ID : 0x0500
Device name : STM32MP15xx
Device type : MPU
Revision ID : --
Device CPU : Cortex-A7

Start Embedded Flashing service

Memory Programming ...
Opening and parsing file: tf-a-stm32mp157d-copro-usb.stm32
File : tf-a-stm32mp157d-copro-usb.stm32
Size : 220,40 KB
Partition ID : 0x01

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:02.548

RUNNING Program ...
PartID: :0x01
Start operation done successfully at partition 0x01

Memory Programming ...

Opening and parsing file: fip-stm32mp157d-copro-optee.bin
File : fip-stm32mp157d-copro-optee.bin
Size : 1,51 MB
Partition ID : 0x03

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:02.354

RUNNING Program ...
PartID: :0x03

Reconnecting the device ...

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : USB download gadget@Device ID /0x500, @Revision ID /0x2001, @Name /STM32MP157DAC Rev.Z,
SN : 002A00173432510E33363738
DFU protocol: 1.1
Board : --
Device ID : 0x0500
Device name : STM32MP157DAC Rev.Z
Device type : MPU
Device CPU : Cortex-A7
Start operation done successfully at partition 0x03
Error: an error occured while uploading data from the virtual partition 0xF1
Received PhaseID == 0xFF, system is going to reboot

On the serial line of the device, I stay at :

NOTICE: CPU: STM32MP157DAC Rev.Z
NOTICE: Model: FDI STM32MP157D Copro
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: Using USB
INFO: Instance 2
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.8-stm32mp1-r1.0(debug):lts-v2.8.6-dirty(ff0bd5f9)
NOTICE: BL2: Built : 17:57:15, Apr 21 2023
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 32bits 533000kHz
INFO: Memory size = 0x40000000 (1024 MB)
INFO: DFU USB START...
INFO: phase ID :3, Manifestation 3 at c7182ed2
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 0x2ffc0000
INFO: Image id=4 loaded: 0x2ffc0000 - 0x2ffc002c
INFO: OPTEE ep=0x2ffc0000
INFO: OPTEE header info:
INFO: magic=0x4554504f
INFO: version=0x2
INFO: arch=0x0
INFO: flags=0x0
INFO: nb_images=0x2
INFO: BL2: Loading image id 8
INFO: Loading image id=8 at address 0x2ffc0000
INFO: Image id=8 loaded: 0x2ffc0000 - 0x2ffd38a0
INFO: BL2: Loading image id 9
INFO: Loading image id=9 at address 0xfe000000
INFO: Image id=9 loaded: 0xfe000000 - 0xfe05b000
INFO: BL2: Loading image id 2
INFO: Loading image id=2 at address 0xc0500000
INFO: Image id=2 loaded: 0xc0500000 - 0xc051e5a0
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 - 0xc01f5d54
NOTICE: BL2: Booting BL32
INFO: Entry point address = 0x2ffc0000
INFO: SPSR = 0x1d3
I/TC: Early console on UART#4
I/TC:
I/TC: Pager is enabled. Hashes: 3008 bytes
I/TC: Pager pool size: 92kB
I/TC: Embedded DTB found
I/TC: OP-TEE version: 3.19.0-dev (gcc version 12.3.0 (GCC)) #2 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: Platform stm32mp1: flavor PLATFORM_FLAVOR - DT stm32mp157d-copro.dts
I/TC: DTB enables console (non-secure)
I/TC: HUK unlocked
I/TC: Primary CPU switching to normal world boot
optee optee: OP-TEE: revision 3.19 (afacf356)


U-Boot 2022.10-stm32mp-r1.1 (Mar 12 2024 - 14:17:18 +0000)

CPU: STM32MP157DAC Rev.Z
Model: FDI STM32MP157D Copro
Board: stm32mp1 in trusted mode (st,stm32mp157d-ev1)
DRAM: 1 GiB
optee optee: OP-TEE: revision 3.19 (afacf356)
Clocks:
- MPU : 800 MHz
- MCU : 200 MHz
- AXI : 266.500 MHz
- PER : 0 MHz
- DDR : 533 MHz
Core: 372 devices, 37 uclasses, devicetree: board
NAND: 0 MiB
MMC: STM32 SD/MMC: 0, STM32 SD/MMC: 1
Loading Environment from nowhere... OK
In: serial
Out: serial
Err: serial
invalid MAC address 0 in OTP 00:00:00:00:00:00
stm32-display-dsi dsi@5a000000: pll reference clock get error -22
Net: No ethernet found.
Hit any key to stop autoboot: 0
Boot over 0!
DFU alt info setting: done
#

 The TSV I use is as follow :

#Opt Id Name Type IP Offset Binary
- 0x01 fsbl-boot Binary none 0x0 arm-trusted-firmware/tf-a-stm32mp157d-copro-usb.stm32
- 0x03 fip-boot FIP none 0x0 fip/fip-stm32mp157d-copro-optee.bin
P 0x04 fsbl1 Binary mmc1 boot1 arm-trusted-firmware/tf-a-stm32mp157d-copro-emmc.stm32
P 0x05 fsbl2 Binary mmc1 boot2 arm-trusted-firmware/tf-a-stm32mp157d-copro-emmc.stm32

 In addition, when i run the mmc commands in u-boot, I got the followings :

STM32MP> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
STM32MP> mmc info
Device: STM32 SD/MMC
Manufacturer ID: 70
OEM: 0
Name: TB2916
Bus Speed: 52000000
Mode: MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.6 GiB
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
STM32MP> mmc part

Partition Map for MMC device 1 -- Partition Type: EFI

Part Start LBA End LBA Name
Attributes
Type GUID
Partition GUID
1 0x00000022 0x00001021 "ssbl"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: ef0cb786-3a30-4182-a162-b22a1a5a38b8
2 0x00001022 0x00021021 "bootfs"
attrs: 0x0000000000000004
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: b69e693a-4917-443e-b74b-102bc0e2b96f
3 0x00021022 0x00029021 "vendorfs"
attrs: 0x0000000000000000
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: 3b5af1f9-603f-4c84-a8eb-9771f916b710
4 0x00029022 0x00169021 "rootfs"
attrs: 0x0000000000000000
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: 0eb5edf1-a883-46ae-9122-c4a85e875cbf
5 0x00169022 0x00189021 "userfs"
attrs: 0x0000000000000000
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: 8c819506-1e01-4f62-9883-9cc307f60a2c

Could you please kindly give some hints to understand where I should look at ? Should you need the dts for analysis ?

As an additional note, we don't have a STLink connector, we use UART4 for the debug and USB OTG for the DFU. My boot jumpers are currently in Engineering mode.

When the system fails to write, the board is still present under "lsusb | grep ST" : 

Bus 003 Device 090: ID 0483:df11 STMicroelectronics STM Device in DFU Mode

Also, can anyone tell me why I have to run optee in sysram (it never works when optee configured to run from DDR)

Thanks in advance for you support 

Regards

Laurent

2 REPLIES 2
PatrickD
ST Employee

Hi,

your problem is caused by the STM32CubeProgrammer reconnection after U-Boot start:

1/ on U-Boot start, the USB stack is started with DFU configuration to request the FlashLayout file (Phase 0x0)

2/ on Host side, the STM32Programmer try to access the requested phase after USB enumeration, by reading a specific alternate identify by Id 0xF1 

 

Sometime a reconnection issue occurs here because the USB enumeration is not completed when ST32CubeProgrammer try to access to USB resources so it doesn't find the alternates exposed by U-Boot (it is a libusb issue, we have to mean to wait the USB enumeration end).

 

In trace:

a) phase 0x3 is started => U-Boot start = USB disconnection and USB reconnection with new enumeration

Start operation done successfully at partition 0x03

b) as the PhaseId (located in the alternate identify with Id=0xF1) can't be read  the STM32CubeProgrammer reconnection failed

Error: an error occured while uploading data from the virtual partition 0xF1

=> normally this error can't occur except for this reconnection issue.

 

If you relaunch the same STM32CubeProgrammer command on host side, as U-Boot is still running and waiting the DFU requests, the programming sequence will be performed after USB connection (as now the USB enumeration is finished on the host).

To avoid this issue, you can try the latest STM32CubeProgrammer version, as some improvement of reconnection sequence have be done.

 

A other solution is to use the "-tm option  <timeout>".

See UM2237 = User manual, STM32CubeProgrammer software description

  Note: While programming the Flashlayout.tsv file, U-boot can spend a long time to start correctly,

  for this reason configure the timeout value by using the timeout command (-tm ).

 

NB: to test programmer support in U-Boot without reconnection, you can also start the programmer on the U-Boot console with the command:

Board$> stm32prog usb 0

then you can start STM32CubeProgrammer command on host with the same FlashLayout file.

 

Regards

Patrick

 

Hi @PatrickD and @LaurentC_FDI 

I got the exactly same issue and debug-log. I want to know the status of this issue. Is it fixed?

 

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer