Skip to main content
Senior
April 29, 2025
Solved

EMMC not being detected in DFU mode

  • April 29, 2025
  • 12 replies
  • 3492 views

Hi,

We have a custom carrier board based on STM32MP157DAC. We have built a custom yocto image.

  • Yocto Version: Mickledore
  • Machine: stm32mp15-disco
  • SoM: STM32MP157DAC
  • Distro: openstlinux-weston
  • Linux Kernel: 6.1.82-stm32mp-r2-r0

I was able to get a EMMC binaries by adding below line in my local.conf
STM32MP_DT_FILES_EMMC += "stm32mp157f-dk2"

I have also attached the modified flashlayout for EMMC.

I came across a post here saying if default pins are changes we will have to do otp for emmc to be detected.

below are the pins we are using:-

PB14SDMMC2_D0
PB15SDMMC2_D1
PB3SDMMC2_D2
PB4SDMMC2_D3
PA8SDMMC2_D4
PA15SDMMC2_D5
PC6SDMMC2_D6
PC7SDMMC2_D7
PE3SDMMC2_CLK
PG6SDMMC2_CMD


Do we need to do otp for these pins or what can be done for EMMC to be detected during dfu(0,0,0) mode for flashing to emmc.

below is my flash layout file for emmc:-

#OptIdNameTypeIPOffsetBinary
-0x01fsbl-bootBinarynone0x0arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb.stm32
-0x03fip-bootFIPnone0x0fip/fip-stm32mp157f-dk2-optee-emmc.bin
P0x04fsbl1Binarymmc1boot1arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32
P0x05fsbl2Binarymmc1boot2arm-trusted-firmware/tf-a-stm32mp157f-dk2-optee-emmc.stm32
P0x06metadata1FWU_MDATAmmc10x00084000arm-trusted-firmware/metadata.bin
P0x07metadata2FWU_MDATAmmc10x00100000arm-trusted-firmware/metadata.bin
P0x08fip-aFIPmmc10x00180000fip/fip-stm32mp157f-dk2-optee-emmc.bin
PED0x09fip-bFIPmmc10x00580000none
PED0x0Au-boot-envENVmmc10x00980000none
P0x10bootfsSystemmmc10x00A00000st-image-bootfs-openstlinux-weston-stm32mp15-disco.ext4
P0x11vendorfsFileSystemmmc10x04A00000st-image-vendorfs-openstlinux-weston-stm32mp15-disco.ext4
P0x12rootfsFileSystemmmc10x05A00000st-image-qt-openstlinux-weston-stm32mp15-disco.ext4



Thanks.

 

Best answer by adnan_pasha

Hi,

I was able to resolve this issue and the device to boot using EMMC By changing the MMC_DEFAULT_MAX_RETRIES in TFA_source/driver/mmc/mmc.c file from 5 to 10.

Below is the link to my other post where I was able to resolve it.

https://community.st.com/t5/stm32-mpus-embedded-software-and/not-able-to-boot-from-emmc-on-stm32mp157dac-panic-at-pc/m-p/799044#M4744


Thanks.

12 replies

PatrickF
Technical Moderator
April 29, 2025

Hi @adnan_pasha 

Regarding OTP for pin changes, they are required for Boot Phase on CMD/CK and D0 pins only (only those are used by BootROM).

The pins you listed above does not need OTP fusing according to the AN5031 and wiki Boot from e•MMC™

 

For uBoot or else, pins are defined by Device Tree pinmux, which might miss in your case as you seems to have started your config from stm32mp157f-dk2 which does not have eMMC. 

In your case, better to look at STM32MP157D-ED1 or STM32MP157D-EV1. See https://wiki.st.com/stm32mpu/wiki/How_to_create_your_board_device_tree and https://github.com/STMicroelectronics/dt-stm32mp/tree/v5-stm32mp

 

For Flashlayout, please refer to Typical Flashlayout for e•MMC

 

Regards.

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.NEW ! Sidekick STM32 AI agent, see here
Senior
April 29, 2025

Hi @PatrickF 

Thanks for clarification about opt configuration.

i have made the below change in my stm32mp15xx-dkx.dtsi device tree in kernel-source and modified stm32mp157f-dk2.dts where to use sdmmc3 instead of 2.

do I need to do these coniguration in STM32MP157D-ED1 or STM32MP157D-EV1 files ?

 

/* changed from 3 to 2 for emmc */
&sdmmc2 {
u-boot,dm-pre-reloc;
u-boot,dm-spl;
pinctrl-names = "default", "opendrain", "sleep";

pinctrl-0 = <&sdmmc2_b4_pins_a>;
pinctrl-1 = <&sdmmc2_b4_od_pins_a>;
pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;

non-removable;
no-sd;
no-sdio;
st,neg-edge;
bus-width = <8>;
vmmc-supply = <&v3v3>;
vqmmc-supply = <&vdd>;
mmc-ddr-3_3v;
status = "okay";

};

Senior
April 29, 2025

Hi @PatrickF ,

With the above configuration i was able to detect emmc in linux boot.
but when trying to flash OS image to emmc from stm32cubeprogrammer it shows no device found mmc1.

thanks,

PatrickF
Technical Moderator
April 29, 2025
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.NEW ! Sidekick STM32 AI agent, see here
Senior
April 29, 2025

Hi,

I had added all the 8 pins like below ,

sdmmc2_b4_pins_a: sdmmc2-b4-0 {
u-boot,dm-pre-reloc;
pins1 {
pinmux = <STM32_PINMUX('B', 14, AF9)>, /* SDMMC2_D0 */
<STM32_PINMUX('B', 15, AF9)>, /* SDMMC2_D1 */
<STM32_PINMUX('B', 3, AF9)>, /* SDMMC2_D2 */
<STM32_PINMUX('B', 4, AF9)>, /* SDMMC2_D3 */

<STM32_PINMUX('A', 8, AF9)>, /* SDMMC2_D4 */
<STM32_PINMUX('A', 15, AF9)>, /* SDMMC2_D5 */
<STM32_PINMUX('C', 6, AF10)>, /* SDMMC2_D6 */
<STM32_PINMUX('C', 7, AF10)>, /* SDMMC2_D7 */
<STM32_PINMUX('G', 6, AF10)>; /* SDMMC2_CMD */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
pins2 {
pinmux = <STM32_PINMUX('E', 3, AF9)>; /* SDMMC2_CK */
slew-rate = <2>;
drive-push-pull;
bias-pull-up;
};
};

sdmmc2_b4_od_pins_a: sdmmc2-b4-od-0 {
u-boot,dm-pre-reloc;
pins1 {
pinmux = <STM32_PINMUX('B', 14, AF9)>, /* SDMMC2_D0 */
<STM32_PINMUX('B', 15, AF9)>, /* SDMMC2_D1 */
<STM32_PINMUX('B', 3, AF9)>, /* SDMMC2_D2 */
<STM32_PINMUX('B', 4, AF9)>, /* SDMMC2_D3 */
<STM32_PINMUX('A', 8, AF9)>, /* SDMMC2_D4 */
<STM32_PINMUX('A', 15, AF9)>, /* SDMMC2_D5 */
<STM32_PINMUX('C', 6, AF10)>, /* SDMMC2_D6 */
<STM32_PINMUX('C', 7, AF10)>; /* SDMMC2_D7 */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
pins2 {
pinmux = <STM32_PINMUX('E', 3, AF9)>; /* SDMMC2_CK */
slew-rate = <2>;
drive-push-pull;
bias-pull-up;
};
pins3 {
pinmux = <STM32_PINMUX('G', 6, AF10)>; /* SDMMC2_CMD */
slew-rate = <1>;
drive-open-drain;
bias-pull-up;
};
};

sdmmc2_b4_sleep_pins_a: sdmmc2-b4-sleep-0 {
u-boot,dm-pre-reloc;
pins {
pinmux = <STM32_PINMUX('B', 14, ANALOG)>, /* SDMMC2_D0 */
<STM32_PINMUX('B', 15, ANALOG)>, /* SDMMC2_D1 */
<STM32_PINMUX('B', 3, ANALOG)>, /* SDMMC2_D2 */
<STM32_PINMUX('B', 4, ANALOG)>, /* SDMMC2_D3 */
<STM32_PINMUX('A', 8, ANALOG)>, /* SDMMC2_D4 */
<STM32_PINMUX('A', 15, ANALOG)>, /* SDMMC2_D5 */
<STM32_PINMUX('C', 6, ANALOG)>, /* SDMMC2_D6 */
<STM32_PINMUX('C', 7, ANALOG)>, /* SDMMC2_D7 */
<STM32_PINMUX('E', 3, ANALOG)>, /* SDMMC2_CK */
<STM32_PINMUX('G', 6, ANALOG)>; /* SDMMC2_CMD */
};
};

Senior
April 29, 2025

Hi @PatrickF ,

I would like some clarification on how modifying the Device Tree configuration impacts eMMC detection in DFU mode, given that there is no operating system running before the eMMC image is flashed. Do I need to update the Device Tree, flash the image to an SD card first, and then use that setup to flash the eMMC?


Thanks.

PatrickF
Technical Moderator
April 29, 2025

Hi,

during first Flashload phase, the CubeProgrammer <-> BootROM in DFU will load two images ID = 0x01 (fsbl-boot in SYSRAM) and 0x03 (fip-boot in DDR). These are not loaded in any flash, they are the supporting SW to do the real flash later. Here DT is important mostly for DDR as uboot is loaded/running from DDR.

Then this loaded FIP/uBoot is started, will reconnect to CubeProgrammer in DFU for the real external flashing phase of other partitions as listed in the Flashlayout file (CubeProgrammer <-> uBoot in DFU <-> Flash). Here Device tree is important as uBoot need to configure correctly the external flash accesses (clock, IP, pins, etc..)

You don't need to Flash SD-Card if your target is to Flash the eMMC.

 

Maybe share your Cubeprogrammer error message and most important the board UART console messages.

 

Regards.

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.NEW ! Sidekick STM32 AI agent, see here
Senior
April 30, 2025

Hi @PatrickF 

Thanks for the info.

Do I need to configure eMMC in the U-Boot Device Tree as well? If so, which Device Tree file should I modify?

Also, I attempted to clean and rebuild the U-Boot source, but in the process, I lost the files located at:
build-openstlinuxweston-stm32mp15-disco/tmp-glibc/work-shared/stm32mp15-disco/uboot-sources/

How can I recover these files?

Since modifying Device Tree files directly in the tmp directory isn't recommended (as they can be lost during cleans or rebuilds), what's the correct way to apply these changes from my custom layer?

I’m aware that one approach is to use patches, but when I try to generate a patch using git diff, I receive an error saying the directory is not a Git repository.

Thanks.

Senior
May 1, 2025

Hi @PatrickF 

I was able to get the source files back after runnning below commands

 

bitbake -ccleansstate <package_name>
bitbake <package_name>


Right now I'm looking into how I can modify my u-boot and tf-a device tree files from a custom layer.

Thanks.

Senior
May 1, 2025

Hi @PatrickF 

I was able to generate patch files for the Linux kernel, U-Boot, and TF-A sources using the devtool command shown below:

 
devtool modify virtual/kernel

 

I followed the steps provided in the link below, which I found to be extremely helpful:

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Distribution_Package

I'm sharing this here in case someone else encounters the same issue—this guide proved to be a valuable resource for me.

now I am trying to modify device tree files and try to flash emmc will let you know if i'm facing any issue or if it get resolved.

Thanks,

Senior
May 2, 2025

Hi @PatrickF 

Below is the log i am getting while trying to update os image to emmc

Core: 368 devices, 44 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 nowhere... OK
In: serial
Out: serial
Err: serial
invalid MAC address 0 in OTP 00:00:00:00:00:00
Net:
Error: ethernet@5800a000 address not set.
No ethernet found.

Card did not respond to voltage select! : -110
No EFI system partition

Error: ethernet@5800a000 address not set.

Error: ethernet@5800a000 address not set.
Hit any key to stop autoboot: 0
Boot over usb0!
DFU alt info setting: done
dwc2-udc-otg usb-otg@49000000: Type-C won't probe (ret=-5)
#
UPLOAD ... done
Ctrl+C to exit ...
#
FlashLayout received, size = 695
DOWNLOAD ... OK
Ctrl+C to exit ...
#
UPLOAD ... done
Ctrl+C to exit ...
Card did not respond to voltage select! : -110
Error: mmc device 1 not found
DFU alt info setting: done
dwc2-udc-otg usb-otg@49000000: Type-C won't probe (ret=-5)
Reset requested
#
UPLOAD ... done
Ctrl+C to exit ...

I have attached my patches please have a look

Senior
May 2, 2025

Hi @PatrickF ,

I was able to detect and flash emmc after changing in stm32mp157f-dk2-u-boot.dtsi sdmmc2 status to okay.

But while trying to boot from emmc by configuring 010 boot pins I get below error and it's not booting.

Exception mode=0x00000016 at: 0x2ffec98b
NOTICE:  CPU: STM32MP157DAC Rev.Z
NOTICE:  Model: STMicroelectronics STM32MP157F-DK2 Discovery Board
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 EMMC
INFO:      Instance 2
INFO:    Boot used partition fsbl1
ERROR:   CMD13 failed after 5 retries
ERROR:   SDMMC2 init failed
PANIC at PC : 0x2ffec98b
 
Exception mode=0x00000016 at: 0x2ffec98b