cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP157 eMMC not booting

drew
Associate III

We have a custom STM32MP157 board running Linux that is not booting over eMMC. The STM32MP157 image boots from SD card on SDMMC1 but not from a Toshiba THGBMNG5D1LBAIL eMMC chip connected to SDMMC2. We have confirmed the Boot pins are correct, and the device tree is correct in uBoot and Linux

We can see 4 partitions of the SD card, and the hardware partitions of the eMMC:

  /dev/mmcblk0    (SD Card)

  /dev/mmcblk0p1   (fsbl1)

  /dev/mmcblk0p2   (fsbl2)

  /dev/mmcblk0p3   (ssbl)

  /dev/mmcblk0p4   (rootfs)

   

  /dev/mmcblk1 (eMMC)

  /dev/mmcblk1rpmb

  /dev/mmcblk1boot0

  /dev/mmcblk1boot1

I have tried copying the entire SD card over to mmcblk1 using:

dd if=/dev/mmcblk0 of=/dev/mmcblk1

I've also tried unlocking the mmcblk1bootX partitions and copying over the SPL and uboot partitions. Schemes I have tried are a copy of single partitions, and even copying over the entire GPT table and partitions 1-3

dd if=/dev/mmcblk0p1 of=/dev/mmcblk1boot0

dd if=/dev/mmcblk0 of=/dev/mmcblk1boot0 count=xxxx

etc.

Unfortunately, nothing results in a boot from eMMC

How does the STM32MP157 boot from eMMC? Does it access boot0 or boot1 partitions or only the user partition?  Are any changes to the CONFIG_PARTITION register on the eMMC needed?

Is a valid GPT required or only a raw image of the SPL?

Build system: Buildroot 2019.11

Kernel: https://github.com/STMicroelectronics/linux

U-Boot build from ST repo: https://github.com/STMicroelectronics/u-boot

MMC_UTILS available

CPU as reported by U-Boot: "CPU: STM32MP157C?? Rev.B"

Thank you,

Drew

1 ACCEPTED SOLUTION

Accepted Solutions
drew
Associate III

Solved the problem and will share here for others.

The TF-A firmware image is required to boot from eMMC. The build of TF-A from the ST github will generate an .stm32 file which is the FSBL with a special header for the STM32. Uboot SPL might work, but I didn't test. https://github.com/STMicroelectronics/arm-trusted-firmware

The TF-A stm32 image must be programmed to the boot0 and boot1 partitions of the eMMC device. By default the THGBMNG5D1LBAIL eMMC on the board was configured with 0x00 in the PARTITION_CONFIG register. View the settings from Linux with

mmc extcsd read /dev/mmcblk1|grep "PARTITION_CONFIG"

The eMMC must be configured to boot from the boot0 partition. The uboot documentation section 8.b shows how to enable this from uboot (https://github.com/STMicroelectronics/u-boot/tree/v2018.11-stm32mp/board/st/stm32mp1). To enable via linux use the mmc command:

mmc bootpart enable 1 1 /dev/mmcblk1

* This appears to be the original problem, programming a valid TF-A to the boot partition and enabling the boot from that partition.

The TF-A bootloader will boot and then read the GPT for a partition 'ssbl'. The Wiki documentation says this needs to be at a specific offset behind the GPT but from my testing that is not needed. TF-A finds the ssbl partition at sector 2048.

* The second part of the problem was our board has different D5 and D6 lines to the eMMC from the EV1 board. This caused the TF-A from EV1 to boot via 1 (or 4) data lines, but could not read the GPT using the 8 data lines.

If manually building uboot you must disable building the SPL, with the SPL enabled uboot adds the STM32 header to the SPL but not the uboot image. Disabling SPL in the build results in a u-boot.stm32 image which is what is required in the ssbl partition.

Here is some more information on how to boot a system:

The uboot image from the branch provided by ST try and boot any GPT that is marked with the legacy bootable flag. While the wiki mentions a specific partition scheme there appears to be no requirement for this. We make a rootfs partition after ssbl and write the bootable flag and uboot finds it.

Hope this helps

View solution in original post

5 REPLIES 5
mleo
Senior II

Hello,

endeed you can not copy directly SDcard content to emmc.

See differences in layouts

https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#NOR_Flash_memory_and_SD_card

https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#e-E2-80-A2MMC

You can also compare generated tsv files for CubeProgrammer.

If you don't use CubeProgrammer for you board, here you can find a nice tutorial how to flash emmc manually:

https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#e-E2-80-A2MMC

Hope this helps

Best regards,

Milan

drew
Associate III

Milan,

Thank you for the response. I have reviewed the resources you shared and I understand that the layouts are different from SD Card to eMMC. It appears that for eMMC the TF-A bootloader is in the boot0 and boot1 partitions, and then there is a GPT in the main partition with the uboot bootloader as the first partition, correct?

I have downloaded the STM32MP1Starter package which includes the tf-a-stm32mp157c-ev1-trusted.stm32 image file for the EV1 board. Our board is designed similar to the EV1 and uses the same eMMC chip. I have programmed this image to the boot0 and boot1 locations, and created a new GTP with 1 partition on the main eMMC partition, and copied over u-boot-stm32mp157c-ev1-trusted.stm32 to the GPT partition. The system appears to boot the TF-A however there is an issue with accessing the additional partitions.

NOTICE: CPU: STM32MP157C?? Rev.B

NOTICE: Model: STMicroelectronics STM32MP157C eval daughter on eval mother

INFO: Reset reason (0x14):

INFO:  Pad Reset from NRST

INFO: PMIC version = 0x10

INFO: Using EMMC

INFO:  Instance 2

INFO: Boot used partition fsbl1

ERROR: stm32_sdmmc2_read: timeout 1s (status = 281000)

INFO: SDMMC_POWER = 0x3

INFO: SDMMC_CLKCR = 0x38002

INFO: SDMMC_ARGR  = 0x0

INFO: SDMMC_CMDR  = 0x148

INFO: SDMMC_RESPCMDR = 0x8

INFO: SDMMC_RESP1R = 0x900

INFO: SDMMC_RESP2R = 0x0

INFO: SDMMC_RESP3R = 0x0

INFO: SDMMC_RESP4R = 0x0

INFO: SDMMC_DTIMER = 0xffffffff

INFO: SDMMC_DLENR = 0x200

INFO: SDMMC_DCTRLR = 0x92

INFO: SDMMC_DCNTR = 0x200

INFO: SDMMC_MASKR = 0x0

INFO: SDMMC_ACKTIMER = 0x0

ERROR: stm32_sdmmc2_send_cmd_req: CTIMEOUT (cmd = 12,status = 200804)

WARNING: CMD12, Retry: 0, Error: -60

ERROR: stm32_sdmmc2_send_cmd_req: CTIMEOUT (cmd = 12,status = 200804)

WARNING: CMD12, Retry: 1, Error: -60

ERROR: stm32_sdmmc2_send_cmd_req: CTIMEOUT (cmd = 12,status = 200804)

WARNING: CMD12, Retry: 2, Error: -60

ERROR: stm32_sdmmc2_send_cmd_req: CTIMEOUT (cmd = 12,status = 200804)

WARNING: CMD12, Retry: 3, Error: -60

ERROR: SDMMC2 init failed

PANIC at PC : 0x2ffd9981

Exception mode=0x00000016 at: 0x2ffd8000

Can you provide some insight on the errors?

STM32MP157Starter package: https://my.st.com/content/my_st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-mpu-openstlinux-distribution/stm32mp1starter.html

Thank you,

Drew

drew
Associate III

Still no successful boot from MMC. Here is a breakdown of what was attempted, resulting in a partial boot from MMC of the TF-A firmware from the EV1 board.

According to the STM32CubeMX documentation, the eMMC must have the TF-A SPL bootloader loaded in to the boot0 and boot1 partitions of eMMC, and then a valid GPT partition table with uboot as partition 1, named 'ssbl' at 17Kbyte offset

I downloaded the STM32MP157 Starter Package which includes TF-A and uboot binaries used on the EV1 board.

STM32MP157Starter package: https://my.st.com/content/my_st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-mpu-openstlinux-distribution/stm32mp1starter.html

From the Linux system, we unlock the boot segments and copy over the TF-A SPL firmware from the starter package:

# Unlock the boot segment

echo 0 > /sys/block/mmcblk1boot0/force_ro

echo 0 > /sys/block/mmcblk1boot1/force_ro

# Write the TF-A firmware to the boot segment

dd if=./tf-a-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk1boot0

dd if=./tf-a-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk1boot1

I then created a new GPT on the /dev/mmcblk1 device with the uboot partition at sector 34 (512*34=17Kbytes). I copied the EV1 uboot from the starter package over to the ssbl partition. I also use the mmc command to enable the first boot partition based on the uboot documentation for the STM32MP157 (Section 8 https://github.com/STMicroelectronics/u-boot/tree/v2018.11-stm32mp/board/st/stm32mp1)

# Output from gdisk -l /dev/mmcblk1

GPT fdisk (gdisk) version 1.0.4

Partition table scan:

 MBR: protective

 BSD: not present

 APM: not present

 GPT: present

Found valid GPT with protective MBR; using GPT.

Disk /dev/mmcblk1: 7733248 sectors, 3.7 GiB

Sector size (logical/physical): 512/512 bytes

Disk identifier (GUID): 80753DE9-322F-41EA-9599-E21194FE1B2D

Partition table holds up to 128 entries

Main partition table begins at sector 2 and ends at sector 33

First usable sector is 34, last usable sector is 7733214

Partitions will be aligned on 2-sector boundaries

Total free space is 7598013 sectors (3.6 GiB)

Number Start (sector)  End (sector) Size    Code Name

  1       34      4129  2.0 MiB   8300 ssbl

  2      4130     135201  64.0 MiB  8300 bootfs

# Copy over the uboot

dd if=./u-boot-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk1p0

# Enable booting from partition 1 on the emmc (Section 8 from https://github.com/STMicroelectronics/u-boot/tree/v2018.11-stm32mp/board/st/stm32mp1)

mmc bootpart enable 1 1 /dev/mmcblk1

Setting the boot switches correctly and resetting the board results in the SPL for the EV1 executing from MMC, however, it appears unable to access the ssbl partition on the MMC

  NOTICE: CPU: STM32MP157C?? Rev.B

  NOTICE: Model: STMicroelectronics STM32MP157C eval daughter on eval mother

  INFO:  Reset reason (0x14):

  INFO:   Pad Reset from NRST

  INFO:  PMIC version = 0x10

  INFO:  Using EMMC

  INFO:   Instance 2

  INFO:  Boot used partition fsbl1

  WARNING: Failed to access image id=28 (-2)

  ERROR:  Partition ssbl not found

  PANIC at PC : 0x2ffd9981

  Exception mode=0x00000016 at: 0x2ffd8000

Any input on the operations we are doing, the alignment of our partitions, boot modes?

drew
Associate III

Solved the problem and will share here for others.

The TF-A firmware image is required to boot from eMMC. The build of TF-A from the ST github will generate an .stm32 file which is the FSBL with a special header for the STM32. Uboot SPL might work, but I didn't test. https://github.com/STMicroelectronics/arm-trusted-firmware

The TF-A stm32 image must be programmed to the boot0 and boot1 partitions of the eMMC device. By default the THGBMNG5D1LBAIL eMMC on the board was configured with 0x00 in the PARTITION_CONFIG register. View the settings from Linux with

mmc extcsd read /dev/mmcblk1|grep "PARTITION_CONFIG"

The eMMC must be configured to boot from the boot0 partition. The uboot documentation section 8.b shows how to enable this from uboot (https://github.com/STMicroelectronics/u-boot/tree/v2018.11-stm32mp/board/st/stm32mp1). To enable via linux use the mmc command:

mmc bootpart enable 1 1 /dev/mmcblk1

* This appears to be the original problem, programming a valid TF-A to the boot partition and enabling the boot from that partition.

The TF-A bootloader will boot and then read the GPT for a partition 'ssbl'. The Wiki documentation says this needs to be at a specific offset behind the GPT but from my testing that is not needed. TF-A finds the ssbl partition at sector 2048.

* The second part of the problem was our board has different D5 and D6 lines to the eMMC from the EV1 board. This caused the TF-A from EV1 to boot via 1 (or 4) data lines, but could not read the GPT using the 8 data lines.

If manually building uboot you must disable building the SPL, with the SPL enabled uboot adds the STM32 header to the SPL but not the uboot image. Disabling SPL in the build results in a u-boot.stm32 image which is what is required in the ssbl partition.

Here is some more information on how to boot a system:

The uboot image from the branch provided by ST try and boot any GPT that is marked with the legacy bootable flag. While the wiki mentions a specific partition scheme there appears to be no requirement for this. We make a rootfs partition after ssbl and write the bootable flag and uboot finds it.

Hope this helps

asadullah4571
Associate III

hi @drew 
i have the custom board with same processor STM32mp157DAC , sdmmc1 is connected to the sd card and sdmmc 2 is connected to the emmc 
Note:  i am using the distribution package of STm32mp1 where my images do not have the sdmmc2 configuration,
Actually in the pacakge the sdmmc2 is connected with wifi card , i removed this card and added the emmc , so please let me know the changes in device tree.
i used the same Toshiba THGBMNG5D1LBAIL eMMC.
Actuall i changes into the device tree for Activate the emmc but i did not find in u-boot 
stm32> mmc list 
mmc : SDmmc 0
i only found this . where i need to modify that my mmc would be find in the u-boot as well as linux 
please help me out

and also when you detected the emmc hardware and you find emmc in U-boot .So  what voltage is made in VDDI pin.