Difference between revisions of "How to manually update bootloaders"
[unchecked revision] | [quality revision] |
m (→Select boot partition)
|
m
|
Applicable for | STM32MP13x lines, STM32MP15x lines |
This page explains how to manually update the bootloaders binary (including U-Boot and TF-A) on an SD card or on the e•MMC.
Contents
1 Update of SD card[edit]
User has access to the SD card device partitions:
- on a Linux®PC, with a card reader of this PC
- on target, with Linux® console or U-Boot console.
The 7 first GPT partitions on the SD card are by default in OpenSTLinux BSP:
- fsbl1 = TF-A BL2
- fbsl2 = TF-A BL2: second copy (a manual update is not needed by default, only used for fail-safe update)
- metadata1 = TF-A firmware update data : select FIP-A
- metadata2 = TF-A firmware update data : select FIP-A, second copy of the same binary
- fip-a = FIP, first slot
- fip-b = FIP, second slot, not required as the first slot is selected in metadata
- u-boot-env = U-Boot environment
See Boot_chain_overview for the bootloader definitions.
1.1 On a Linux® console with the Linux® dd command[edit]
You can use the Linux®dd
command to copy the bootloader files 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.
The dd
command needs to be repeated for each GPT partition to update.
Note: the dd option conv=fdatasync is used to force synchronous copying. The U-Boot environment is saved in the partition, named "u-boot-env": ID = 7 in OpenSTLinux BSP.
You can erase this partition to clear this environment; for example, by using the dd
command this input file: if=/dev/zero.
When SD card device is mmcblk0, the GPT partition p<n> is /dev/mmcblk0p<n> (for example in OpenSTLinux target console or for a PC internal card reader), the update of the SD card is done with:
dd if=tf-a-sdcard.stm32 of=/dev/mmcblk0p1 conv=fdatasync dd if=tf-a-sdcard.stm32 of=/dev/mmcblk0p2 conv=fdatasync dd if=metadata.bin of=/dev/mmcblk0p3 conv=fdatasync dd if=metadata.bin of=/dev/mmcblk0p4 conv=fdatasync dd if=fip.bin of=/dev/mmcblk0p5 conv=fdatasync dd if=/dev/zero of=/dev/mmcblk0p7 conv=fdatasync
1.2 On a U-Boot console[edit]
1.2.1 With ums command[edit]
Alternatively, with U-Boot ums
command, on mmc dev = 0,the SD card device on STMicroelectronics board:
STM32MP> ums 0 mmc 0
The exported SD card is mounted on the Linux® PC as a block device named sd<X> and the GPT partitions are exported by sd<X><n> where:
- <X> is the ID of the device starting at a
- <n> the ID of the partition.
If the block device SD card is available in /dev/sda (with <X> = a but this value need to be verified on your PC), the partitions are updated with the dd command:
dd if=tf-a-sdcard.stm32 of=/dev/sda1 conv=fdatasync dd if=tf-a-sdcard.stm32 of=/dev/sda2 conv=fdatasync dd if=metadata.bin of=/dev/sda3 conv=fdatasync dd if=metadata.bin of=/dev/sda4 conv=fdatasync dd if=fip.bin of=/dev/sda5 conv=fdatasync dd if=/dev/zero of=/dev/sda7 conv=fdatasync
1.2.2 With mmc command[edit]
The command mmc
can be use also to directly write file previously loaded in memory by other U-boot command.
For example, to check partition offset on dev 0, SD Card on STMicroelectonics boards:
STM32MP> mmc dev 0 STM32MP> mmc part Partition Map for MMC device 0 -- Partition Type: EFI
Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x00000221 "fsbl1" ....
To write TF-A, loaded at 0xC000000 at blk# = 22 for 256KB (0x200*512)
STM32MP> mmc write 0xC0000000 22 200
With block address (blk#) and clock count (ctn), multiple of block size = LBA of 512 bytes.
2 Update of e•MMC[edit]
User has access to the e•MMC device partitions on target, with Linux® console or U-Boot console.
The e•MMC memory mapping are by default:
- FSBL = TF-A is saved in the e•MMC boot partitions (2 copy for fail-safe update)
- Other binaries are in the GPT partitions of the e•MMC user area
- metadata1 = TF-A firmware update data : select FIP-A
- metadata2 = TF-A firmware update data : select FIP-A, second copy of the same binary
- fip-a = FIP, first slot
- fip-b = FIP, second slot, not required as the first slot is selected in metadata
- u-boot-env = U-Boot environment
The user needs to select the e•MMC hardware partition to update: user data, boot1, or boot2.
2.1 On a Linux® console[edit]
If dev = mmcblk1 for e•MMC device (default on STMicroelectronics board).
The boot partitions are available in /dev/mmcblk1boot0 and /dev/mmcblk1boot1 [1].
The user could need to allow access, for example with:
echo 0 > /sys/class/block/mmcblk1boot0/force_ro
The mmc
tools allow the boot partition that can be selected [2].
The ROM code requires:
- <send_ack> =1 to enable the boot acknowledge bit in the e•MMC ext_csd register
- the eMMC boot configuration is: 1 wire configuration and 25 MHz, 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 (default):
dd if=tf-a-emmc.stm32 of=/dev/mmcblk1boot0 conv=fdatasync mmc bootpart enable 1 1 /dev/mmcblk1
To update TF-A in boot2 and select this boot partition (not needed by default, only required for fail-safe update):
dd if=tf-a-emmc.stm32 of=/dev/mmcblk1boot1 conv=fdatasync mmc bootpart enable 2 1 /dev/mmcblk1
To update the GPT partitions:
dd if=/dev/zero of=/dev/mmcblk1p1 conv=fdatasync dd if=metadata.bin of=/dev/mmcblk1p1 conv=fdatasync dd if=metadata.bin of=/dev/mmcblk1p2 conv=fdatasync dd if=fip.bin of=/dev/mmcblk1p3 conv=fdatasync
The U-Boot environment is saved in the partition, named "u-boot-env": ID = 5 in OpenSTLinux.
You can erase this partition to clear this environment; for example, by using the dd command this input file: if=/dev/zero.
dd if=/dev/zero of=/dev/mmcblk1p5 conv=fdatasync
See also [3].
2.2 On a U-Boot console[edit]
If mmc device [dev] = 1 for e•MMC device in U-Boot (default on STMicroelectronics board).
The command mmc
is used in U-Boot console for e•MMC device configuration.
mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>
Before the first boot, select the right e•MMC boot configuration (1 wire, 25 MHz) with the command:
STM32MP> mmc bootbus 1 0 0 0
2.2.1 Select boot partition[edit]
The targeted e•MMC HW partition is selected in U-Boot by the command mmc partconf
:
mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]
With:
- dev = 1 (e•MMC device on STMicroelectronics board)
- boot_ack=1 (the boot acknowledge bit in the e•MMC ext_csd register is needed by ROM code)
- boot_partition = 1 (boot partition 1 enabled for boot)
- partition_access = 0
- 0: user data partition (default)
- 1: boot partition 1
- 2: boot partition 2
Do not change the last parameter partition_access value if you do not manually access to the boot partition content with mmc read
or mmc write
.
The command to select the boot partition used by ROM code on e•MMC at next reboot is:
- for boot1:
STM32MP> mmc partconf 1 1 1 0
- for boot2 (not needed by default, only required for fail-safe update):
STM32MP> mmc partconf 1 1 2 0
2.2.2 With ums command[edit]
The e•MMC update is done with the ums
command, with the U-Boot's partition syntax U-Boot's partition syntax:
<command> <interface> [devnum][.hwpartnum][:partnum|#partname]
The exported e•MMC is mounted on the Linux® PC as a block device named sd<X> and the GPT partitions are exported by sd<X><n> where
- <X> is the ID of the device starting at a
- <n> the ID of the partition.
In the next examples, we assume <X> = a, so the block device e•MMC available in /dev/sda but this value need to be verified on your PC.
boot partitions
This boot partition by ROM code is selected in previous step #select boot partition, only the selected on needed to be updated.
To update FSBL=TF-A in the boot1 HW partition.
STM32MP> ums 0 mmc 1.1 UMS: LUN 0, dev 1, hwpart 1, sector 0x0, count 0x1000
On boot partitions, without GPT partitions, just copy TF-A binary on the block device /dev/sda exported by U-Boot.
dd if=tf-a-emmc.stm32 of=/dev/sda conv=fdatasync
To update boot2, change the mmc device to 1.2; but it not needed by default if boot1 is selected: mmc partconf 1 1 1 0
. It is only required for fail-safe update, when the boot partition is selected after update with mmc partconf
.
STM32MP> ums 0 mmc 1.2 UMS: LUN 0, dev 1, hwpart 2, sector 0x0, count 0x1000 dd if=tf-a-emmc.stm32 of=/dev/sda conv=fdatasync
And select boot2 partition after update:
STM32MP> mmc partconf 1 1 2 0
user data partition
To export all the e•MMC in /dev/sda, including all GPT partitions in /dev/sdaN:
STM32MP> ums 0 mmc 1
And copy each binary in the GPT partitions of this block device:
dd if=metadata.bin of=/dev/sda1 conv=fdatasync dd if=metadata.bin of=/dev/sda2 conv=fdatasync dd if=fip.bin of=/dev/sda3 conv=fdatasync
And clear the U-Boot environment with
dd if=/dev/zero of=/dev/mmcblk1p5 conv=fdatasync
2.2.3 With mmc command[edit]
The command mmc
can be use also to directly write file previously loaded in memory by an other U-Boot command.
For example, to check the GPT partition of e•MMC, on dev=1 for STMicroelectronics board:
STM32MP> mmc dev 1 STM32MP> mmc part
To write TF-A , loaded at 0xC000000 at blk# = 0 for boot1 for 256KB (0x200*512):
STM32MP> mmc partconf 1 1 1 1 STM32MP> mmc write 0xC0000000 0 200 STM32MP> mmc partconf 1 1 1 0
See in #select boot partition for details on boot_partition=1 and partition_access=1 and 0 of mmc partconf
.
To write metadata1, loaded at 0xC000000 at blk# = 0x00, size = 1KB (0x2*512)
STM32MP> mmc write 0xC0000000 00 2
With block address (blk#) and clock count (ctn), multiple of block size = LBA of 512 bytes.
3 References[edit]
Please refer to the following links for additional information:
<noinclude>{{ApplicableFor |MPUs list=STM32MP13x, STM32MP15x |MPUs checklist=STM32MP13x,STM32MP15x }}</noinclude> This page explains how to manually update the bootloaders binary (including [[U-Boot_overview|U-Boot]] and [[TF-A_overview|TF-A]]) on an SD card or on the ''e''•MMC. == Update of SD card == User has access to the SD card device partitions: * on a Linux<sup>®</sup>PC, with a card reader of this PC * on target, with Linux<sup>®</sup> console or U-Boot console. [[STM32_MPU_Flash_mapping#SD_card_memory_mapping|The 7 first GPT partitions on the SD card]] are by default in OpenSTLinux BSP: # '''fsbl1''' = TF-A BL2 # '''fbsl2''' = TF-A BL2: second copy (a manual update is not needed by default, only used for fail-safe update) # '''metadata1''' = TF-A firmware update data : select FIP-A # '''metadata2''' = TF-A firmware update data : select FIP-A, second copy of the same binary # '''fip-a''' = FIP, first slot # '''fip-b''' = FIP, second slot, not required as the first slot is selected in metadata # '''u-boot-env''' = U-Boot environment See [[Boot_chain_overview]] for the bootloader definitions. === On a Linux<sup>®</sup> console with the Linux<sup>®</sup> dd command === You can use the Linux<sup>®</sup> <code>dd</code> command to copy the bootloader files directly to the correct partition: {{PC$}} dd if={{HighlightParam|<file>}} of=/dev/{{HighlightParam|<dev>}} conv={{HighlightParam|fdatasync}} {{HighlightParam|<dev>}} is: * mmcblk{{Highlight|<X>}}p{{Highlight|<n>}}: PC-embedded card reader case or target Linux<sup>®</sup> console * sd{{Highlight|<X>}}{{Highlight|<n>}}: USB-connected SD card reader case where {{Highlight|<X>}} is the ID of the device, and {{Highlight|<n>}} the ID of the partition. The <code>dd</code> command needs to be repeated for each GPT partition to update. Note: the dd option {{HighlightParam|conv}}={{HighlightParam|fdatasync}} is used to force synchronous copying. The U-Boot environment is saved in the partition, named "u-boot-env": ID = {{HighlightParam|7}} in OpenSTLinux BSP. <br> You can erase this partition to clear this environment; for example, by using the <code>dd</code> command this input file: if={{HighlightParam|/dev/zero}}. When SD card device is {{Highlight|mmcblk0}}, the GPT partition {{HighlightParam|p<n>}} is '''/dev/{{Highlight|mmcblk0}}{{HighlightParam|p<n>}}''' (for example in OpenSTLinux target console or for a PC internal card reader), the update of the SD card is done with: {{PC$}} dd if={{HighlightParam|tf-a-sdcard.stm32}} of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p1}} conv=fdatasync {{PC$}} dd if={{HighlightParam|tf-a-sdcard.stm32}} of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p2}} conv=fdatasync {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p3}} conv=fdatasync {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p4}} conv=fdatasync {{PC$}} dd if={{HighlightParam|fip.bin}} of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p5}} conv=fdatasync {{PC$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk0}}{{HighlightParam|p7}} conv=fdatasync === On a U-Boot console === ==== With ums command ==== Alternatively, with U-Boot [[How to use USB mass storage in U-Boot|<code>ums</code> command]], on mmc dev = {{Highlight|0}},the SD card device on STMicroelectronics board: {{U-Boot$}} ums 0 mmc {{Highlight|0}} The exported SD card is mounted on the Linux<sup>®</sup> PC as a block device named sd{{Highlight|<X>}} and the GPT partitions are exported by '''sd{{Highlight|<X>}}{{Highlight|<n>}}''' where: * {{Highlight|<X>}} is the ID of the device starting at '''a''' * {{Highlight|<n>}} the ID of the partition. If the block device SD card is available in '''/dev/{{Highlight|sda}}''' (with {{Highlight|<X>}} = '''a''' but this value need to be verified on your PC), the partitions are updated with the dd command: {{PC$}} dd if={{HighlightParam|tf-a-sdcard.stm32}} of=/dev/{{Highlight|sda}}{{HighlightParam|1}} conv=fdatasync {{PC$}} dd if={{HighlightParam|tf-a-sdcard.stm32}} of=/dev/{{Highlight|sda}}{{HighlightParam|2}} conv=fdatasync {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|3}} conv=fdatasync {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|4}} conv=fdatasync {{PC$}} dd if={{HighlightParam|fip.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|5}} conv=fdatasync {{PC$}} dd if=/dev/zero of=/dev/{{Highlight|sda}}{{HighlightParam|7}} conv=fdatasync ==== With mmc command ==== {{DocSource | domain=U-Boot | path=usage/mmc.html|text=The command <code>mmc</code>}} can be use also to directly write file previously loaded in memory by other U-boot command. For example, to check partition offset on dev 0, SD Card on STMicroelectonics boards: {{U-Boot$}} mmc dev 0 {{U-Boot$}} mmc part Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 {{HighlightParam|0x00000022}} {{Highlight|0x00000221}} "fsbl1" .... To write TF-A, loaded at {{Highlight|0xC000000}} at blk# = {{HighlightParam|22}} for 256KB ({{Highlight|0x200}}*512) {{U-Boot$}} mmc write {{Highlight|0xC0000000}} {{HighlightParam|22}} {{Highlight|200}} With block address (blk#) and clock count (ctn), multiple of block size = LBA of 512 bytes. == Update of ''e''•MMC == User has access to the ''e''•MMC device partitions on target, with Linux<sup>®</sup> console or U-Boot console. [[STM32_MPU_Flash_mapping#eMMC_memory_mapping|The ''e''•MMC memory mapping]] are by default: * FSBL = TF-A is saved in the ''e''•MMC boot partitions (2 copy for fail-safe update) * Other binaries are in the GPT partitions of the ''e''•MMC user area # '''metadata1''' = TF-A firmware update data : select FIP-A # '''metadata2''' = TF-A firmware update data : select FIP-A, second copy of the same binary # '''fip-a''' = FIP, first slot # '''fip-b''' = FIP, second slot, not required as the first slot is selected in metadata # '''u-boot-env''' = U-Boot environment The user needs to select the ''e''•MMC hardware partition to update: user data, boot1, or boot2. === On a Linux<sup>®</sup> console === If dev = {{Highlight|mmcblk1}} for ''e''•MMC device (default on STMicroelectronics board). The boot partitions are available in /dev/{{Highlight|mmcblk1}}{{HighlightParam|boot0}} and /dev/{{Highlight|mmcblk1}}{{HighlightParam|boot1}} <ref>https://www.kernel.org/doc/Documentation/mmc/mmc-dev-parts.txt</ref>. The user could need to allow access, for example with: {{Board$}} echo 0 > /sys/class/block/{{Highlight|mmcblk1}}{{HighlightParam|boot0}}/force_ro The <code>mmc</code> tools allow the boot partition that can be selected <ref>https://manpages.debian.org/buster/mmc-utils/mmc.1.en.html</ref>. The ROM code requires: * <send_ack> =1[[STM32_MPU_ROM_code_overview|ROM code]] requires: * <send_ack> =1 to enable the boot acknowledge bit in the ''e''•MMC ''ext_csd'' register* the eMMC boot configuration is: 1 wire configuration and 25 MHz, it is done with the command: {{Board$}} mmc bootbus set single_backward x1 x1 dev/{{Highlight|mmcblk1}} To update TF-A in boot1 and select this boot partition (default): {{Board$}} dd if={{HighlightParam|tf-a-emmc.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|boot0}} conv=fdatasync {{Board$}} mmc bootpart enable {{HighlightParam|1}} 1 /dev/{{Highlight|mmcblk1}} To update TF-A in boot2 and select this boot partition (not needed by default, only required for fail-safe update): {{Board$}} dd if={{HighlightParam|tf-a-emmc.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|boot1}} conv=fdatasync {{Board$}} mmc bootpart enable {{HighlightParam|2}} 1 /dev/{{Highlight|mmcblk1}} To update the GPT partitions: {{Board$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync {{Board$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync {{Board$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p2}} conv=fdatasync {{Board$}} dd if={{HighlightParam|fip.bin}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p3}} conv=fdatasync The U-Boot environment is saved in the partition, named "u-boot-env": ID = {{HighlightParam|5}} in OpenSTLinux. <br> You can erase this partition to clear this environment; for example, by using the dd command this input file: if={{HighlightParam|/dev/zero}}. {{Board$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p5}} conv=fdatasync See also <ref>https://www.emcraft.com/som/stm32mp1/booting-linux-from-emmc</ref>. === On a U-Boot console === If mmc device [dev] = {{Highlight|1}} for ''e''•MMC device in U-Boot (default on STMicroelectronics board). {{DocSource | domain=U-Boot | path=usage/mmc.html|text=The command <code>mmc</code>}} is used in U-Boot console for ''e''•MMC device configuration. mmc {{Highlight|bootbus}} <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode> Before the first boot, select the right ''e''•MMC boot configuration (1 wire, 25 MHz) with the command: {{U-Boot$}} mmc bootbus {{Highlight|1}} 0 0 0 ==== Select boot partition ==== The targeted ''e''•MMC HW partition is selected in U-Boot by {{DocSource | domain=U-Boot | path=usage/mmc.html|text= the command <code>mmc partconf</code>}}: mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]] With: * dev = {{Highlight|1}} (''e''•MMC device on STMicroelectronics board) * boot_ack=1 (the boot acknowledge bit in the ''e''•MMC ''ext_csd'' register is needed by ROM code[[STM32_MPU_ROM_code_overview|ROM code]]) * boot_partition = {{HighlightParam|1}} (boot partition 1 enabled for boot) * partition_access = 0 ** {{HighlightParam|0}}: user data partition (default) ** {{HighlightParam|1}}: boot partition 1 ** {{HighlightParam|2}}: boot partition 2 Do not change the last parameter {{HighlightParam|partition_access}} value if you do not manually access to the boot partition content with <code>mmc read</code> or <code>mmc write</code>. The command to '''select the boot partition used by ROM code''' on ''e''•MMC at next reboot is: * for {{Highlight|boot1}}: {{U-Boot$}} mmc partconf {{Highlight|1}} 1 {{HighlightParam|1}} 0 * for {{Highlight|boot2}} (not needed by default, only required for fail-safe update): {{U-Boot$}} mmc partconf {{Highlight|1}} 1 {{HighlightParam|2}} 0 ==== With ums command ==== The ''e''•MMC update is done with the [[How to use USB mass storage in U-Boot|<code>ums</code> command]], with the U-Boot's partition syntax {{DocSource | domain=U-Boot | path=usage/partitions.html|text=U-Boot's partition syntax }}:<command> <interface> [devnum][.hwpartnum][:partnum|#partname] The exported ''e''•MMC is mounted on the Linux<sup>®</sup> PC as a block device named sd{{Highlight|<X>}} and the GPT partitions are exported by '''sd{{Highlight|<X>}}{{Highlight|<n>}}''' where * {{Highlight|<X>}} is the ID of the device starting at '''a''' * {{Highlight|<n>}} the ID of the partition. In the next examples, we assume {{Highlight|<X>}} = '''a''', so the block device ''e''•MMC available in '''/dev/{{Highlight|sda}}''' but this value need to be verified on your PC. '''boot partitions''' This boot partition by ROM code is selected in previous step [[#select boot partition]], only the selected on needed to be updated. To update FSBL=TF-A in the {{HighlightParam|boot1}} HW partition. {{U-Boot$}} ums 0 mmc {{Highlight|1}}.{{HighlightParam|1}} UMS: LUN 0, dev {{Highlight|1}}, hwpart {{HighlightParam|1}}, sector 0x0, count 0x1000 On boot partitions, without GPT partitions, just copy TF-A binary on the block device /dev/{{Highlight|sda}} exported by U-Boot. {{PC$}} dd if={{HighlightParam|tf-a-emmc.stm32}} of=/dev/{{Highlight|sda}} conv=fdatasync To update {{HighlightParam|boot2}}, change the mmc device to {{Highlight|1}}.{{HighlightParam|2}}; but it not needed by default if [[#select boot partition|'''boot1''' is selected]]: <code>mmc partconf 1 1 {{HighlightParam|1}} 0</code>. It is only required for fail-safe update, when the boot partition is selected after update with <code>mmc partconf</code>. {{U-Boot$}} ums 0 mmc {{Highlight|1}}.{{HighlightParam|2}} UMS: LUN 0, dev {{Highlight|1}}, hwpart {{HighlightParam|2}}, sector 0x0, count 0x1000 {{PC$}} dd if={{HighlightParam|tf-a-emmc.stm32}} of=/dev/{{Highlight|sda}} conv=fdatasync And select ''boot2'' partition after update: {{U-Boot$}} mmc partconf {{Highlight|1}} 1 {{HighlightParam|2}} 0 '''user data partition''' To export all the ''e''•MMC in {{HighlightParam|/dev/sda}}, including all GPT partitions in /dev/{{Highlight|sda}}{{HighlightParam|N}}: {{U-Boot$}} ums 0 mmc {{Highlight|1}} And copy each binary in the GPT partitions of this block device: {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|1}} conv=fdatasync {{PC$}} dd if={{HighlightParam|metadata.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|2}} conv=fdatasync {{PC$}} dd if={{HighlightParam|fip.bin}} of=/dev/{{Highlight|sda}}{{HighlightParam|3}} conv=fdatasync And clear the U-Boot environment with {{PC$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p5}} conv=fdatasync ==== With mmc command ==== {{DocSource | domain=U-Boot | path=usage/mmc.html|text=The command <code>mmc</code>}} can be use also to directly write file previously loaded in memory by an other U-Boot command. For example, to check the GPT partition of ''e''•MMC, on dev=1 for STMicroelectronics board: {{U-Boot$}} mmc dev 1 {{U-Boot$}} mmc part To write TF-A , loaded at 0xC000000 at blk# = {{HighlightParam|0}} for boot{{Highlight|1}} for 256KB ({{Highlight|0x200}}*512): {{U-Boot$}} mmc partconf 1 1 {{HighlightParam|1}} {{Highlight|1}} {{U-Boot$}} mmc write 0xC0000000 {{HighlightParam|0}} {{Highlight|200}} {{U-Boot$}} mmc partconf 1 1 {{HighlightParam|1}} {{Highlight|0}} See in [[#select boot partition]] for details on ''boot_partition''={{HighlightParam|1}} and ''partition_access''={{Highlight|1}} and {{Highlight|0}} of <code>mmc partconf</code>. To write metadata1, loaded at {{Highlight|0xC000000}} at blk# = {{HighlightParam|0x00}}, size = 1KB ({{Highlight|0x2}}*512) {{U-Boot$}} mmc write {{Highlight|0xC0000000}} {{HighlightParam|00}} {{Highlight|2}} With block address (blk#) and clock count (ctn), multiple of block size = LBA of 512 bytes. ==References== Please refer to the following links for additional information: <references /> <noinclude> [[Category:How to populate boards]] {{PublicationRequestId | 16075 | 2020-05-12}}</noinclude>
Line 111: | Line 111: | ||
The <code>mmc</code> tools allow the boot partition that can be selected <ref>https://manpages.debian.org/buster/mmc-utils/mmc.1.en.html</ref>. |
The <code>mmc</code> tools allow the boot partition that can be selected <ref>https://manpages.debian.org/buster/mmc-utils/mmc.1.en.html</ref>. |
||
− | The ROM code requires: |
+ | The [[STM32_MPU_ROM_code_overview|ROM code]] requires: |
− | * <send_ack> =1 |
+ | * <send_ack> =1 to enable the boot acknowledge bit in the ''e''•MMC ''ext_csd'' register
|
* the eMMC boot configuration is: 1 wire configuration and 25 MHz, it is done with the command: |
* the eMMC boot configuration is: 1 wire configuration and 25 MHz, it is done with the command: |
||
{{Board$}} mmc bootbus set single_backward x1 x1 dev/{{Highlight|mmcblk1}} |
{{Board$}} mmc bootbus set single_backward x1 x1 dev/{{Highlight|mmcblk1}} |
||
Line 154: | Line 154: | ||
With: |
With: |
||
* dev = {{Highlight|1}} (''e''•MMC device on STMicroelectronics board) |
* dev = {{Highlight|1}} (''e''•MMC device on STMicroelectronics board) |
||
− | * boot_ack=1 (the boot acknowledge bit in the ''e''•MMC ''ext_csd'' register is needed by ROM code) |
+ | * boot_ack=1 (the boot acknowledge bit in the ''e''•MMC ''ext_csd'' register is needed by [[STM32_MPU_ROM_code_overview|ROM code]]) |
* boot_partition = {{HighlightParam|1}} (boot partition 1 enabled for boot) |
* boot_partition = {{HighlightParam|1}} (boot partition 1 enabled for boot) |
||
* partition_access = 0 |
* partition_access = 0 |