This page explains how to manually update the U-Boot binaries on an SD card.
1. Copying a binary to an SD card with the Linux dd command[edit source]
When you have access to the SD card device partitions:
- on Linux PC, with the card reader of a PC or with the
ums
command executed on a target U-Boot console, - on target, with Linux console
The 3 first GPT partitions on the SD card are:
- FSBL1
- FSBL2
- SSBL
See Boot_chains_overview for the bootloader definitions.
You can use the Linux dd
command to copy the FSBL and SSBL directly to the correct partition:
dd if=<file> of=/dev/<dev> conv=fdatasync
<dev> is:
- mmcblk<X>p<n> : PC-embedded card reader case or target Linux console
- sd<X><n> : USB-connected SD card reader case
where <X> is the ID of the device, and <n> the ID of the partition.
Note: the dd option conv=fdatasync is used to force synchronous copying.
1.1. U-Boot environment[edit source]
The environment of U-Boot is saved at the end of the U-Boot partition, named "ssbl" : ID = 3.
To clear this environment, erase the U-Boot partition before any update; for example, write 0 to this partition:
dd if=/dev/zero of=/dev/mmcblk<X>p3 conv=fdatasync
dd if=/dev/zero of=sd<X>3 conv=fdatasync
1.2. SD card update example[edit source]
The internal card reader is /dev/mmcblk0, GPT partition <n> is /dev/mmcblk0p<n>:
dd if=tf-a.stm32 of=/dev/mmcblk0p1 conv=fdatasync dd if=tf-a.stm32 of=/dev/mmcblk0p2 conv=fdatasync dd if=/dev/zero of=/dev/mmcblk0p3 conv=fdatasync dd if=u-boot.stm32 of=/dev/mmcblk0p3 conv=fdatasync
1.3. SD card update example with SPL as FSBL[edit source]
The USB card reader is /dev/sdb, GPT partition <n> is /dev/sdb<n>:
dd if=u-boot-spl.stm32 of=/dev/sdb1 conv=fdatasync dd if=u-boot-spl.stm32 of=/dev/sdb2 conv=fdatasync dd if=/dev/zero of=/dev/sdb3 conv=fdatasync dd if=u-boot.img of=/dev/sdb3 conv=fdatasync
2. update of e•MMC with the Linux dd command[edit source]
The same command, dd
, can be used to update e•MMC memory mapping :
- For the user area, with GPT partitioning, SSBL U-Boot is the first user partition (the indexes of other partitions need to be adapted).
- For the SSBL = TF-A (or SPL) is saved at the beginning of the cached boot partitions: access to the 2 boot partition needs to requested:
2.1. on Linux console[edit source]
If dev = mmcblk1 for e•MMC device (default on ST Microelectronics board)
The boot partition are available in /dev/mmcblk1boot0 and /dev/mmcblk1boot1 [1].
User perhaps need to allow access, for example with:
echo 0 > /sys/class/block/mmcblk1boot0/force_ro
The mmc tools allows to select the boot partition [2]; <send_ack> =1 is required by STM32MP15x ROM code
This ROM code also requires that the eMMC boot configuration is: 1 wire configuration and 25Mz, it is done with the command:
mmc bootbus set single_backward x1 x1 dev/mmcblk1
To update TF-A in boot1 and select this boot partition:
dd if=tf-a.stm32 of=/dev/mmcblk1boot0 conv=fdatasync mmc bootpart enable 1 1 /dev/mmcblk1
To update TF-A in boot2 and select this boot partition
dd if=tf-a.stm32 of=/dev//mmcblk1boot1 conv=fdatasync mmc bootpart enable 2 1 /dev/mmcblk1
To update U-Boot in the first GPT partition:
dd if=/dev/zero of=/dev/mmcblk1p1 conv=fdatasync dd if=u-boot.stm32 of=/dev//mmcblk1p1 conv=fdatasync
2.2. on U-Boot console[edit source]
The e•MMC update is done with the ums
command but
the targeted e•MMC HW partition is selected in U-Boot by the third parameter partition_access of command mmc partconf
:
- 0: user data partition
- 1: boot partition 1
- 2: boot partition 2
help mmc
...
mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode
- Set the BOOT_BUS_WIDTH field of the specified device
mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>
- Change sizes of boot and RPMB partitions of specified device
mmc partconf dev [boot_ack boot_partition partition_access]
- Show or change the bits of the PARTITION_CONFIG field of the specified device
..
For example :
* dev = 1 (e•MMC device on ST Microelectronics board) * boot_ack=1 (Boot Acknowledge is needed by ROM code) * boot_partition = 1 (Boot partition 1 enabled for boot) * partition_access = 0 (No access to boot partition - default) * or partition_access = 1 (R/W boot partition 1)
And on PC, the mass storage is mounted as /dev/sda
To update FSBL=TF-A, select boot1 HW partition and come back to the user area at the end.
mmc dev 1 mmc partconf 1 1 1 1 ums 0 mmc 1 dd if=tf-a.stm32 of=/dev/sda conv=fdatasync mmc partconf 1 1 1 0
To update SSBL = U-Boot in the first GPT partition in user partition
mmc dev 1 ums 0 mmc 1 dd if=u-boot.stm32 of=/dev/sda1 conv=fdatasync
The STM32MP15x ROM code also require the eMMC boot configuration set to 1 wire configuration and to 25Mz with the command on mmc device {HighlightParam|1}} (one need one time to configure eMMC):
mmc bootbus 1 0 0 0
3. References[edit source]
Please refer to the following links for additional information: