Difference between revisions of "How to update U-Boot"

[quality revision] [quality revision]
m (<code>ums</code>,)
m (Reverted edits by Patrick Delaunay (talk) to last revision by Jean-Christophe Trotin)
(Tag: Rollback)
 

This page explains how to manually update the U-Boot binaries on an SD card or on the e•MMC.

1 Copying a binary to

1 To update an SD card with the Linux dd command[edit]

When you have a Linux console has access to the device (with the SD card device partitions:

  • on a Linux PC
    • with a card reader of
a PC, or the
    • this PC
    • through a USB connection to the target and the ums command executed on a U-Boot console
  • on target
), the
  • , with Linux console.

The 3 first GPT partitions on the SD card are:

  1. FSBL1
  2. FSBL2
  3. SSBL

See Boot_chainschain_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> mmcblk<X>p<n>: PC-embedded card reader case sd<X><N> 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.

2 Trusted boot chain

1.1 U-Boot environment[edit]

The U-Boot environment 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, by writing 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]

The internal card reader is /dev/mmcblk0 or for a target Linux console, GPT partition <n> is /dev/mmcblk0p<n>mmcblk0p<n>:

 
 dd if=tf-a.stm32 of=/dev/mmcblk0p1mmcblk0p1 conv=fdatasync
  dd if=tf-a.stm32 of=/dev/mmcblk0p2mmcblk0p2 conv=fdatasync
  dd if=/dev/zero of=/dev/mmcblk0p3 conv=fdatasync
  dd if=u-boot.stm32 of=/dev/mmcblk0p3mmcblk0p3 conv=fdatasync
3 Basic boot chain udpate example

Alternatively, with U-Boot console, dev = 0 (SD card device on ST Microelectronics board), GPT partition <n> is /dev/sda<n>:

  mmc dev 0 
  ums 0 mmc 0
 
  dd if=tf-a.stm32 of=/dev/sda1 conv=fdatasync
  dd if=tf-a.stm32 of=/dev/sda2 conv=fdatasync
  dd if=/dev/zero of=/dev/sda3 conv=fdatasync
  dd if=u-boot.stm32 of=/dev/sda3 conv=fdatasync

1.3 SD card update example with SPL as FSBL[edit]

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

4 update of eMMC2 Update of e•MMC with the Linux dd command[edit]

The same command, dd, can be used to update eMMC with ums command, but the SSBL e•MMC memory mapping:

  • SSBL U-Boot is the first GPT partition in the e•MMC user area
  • FSBL = TF-A (or SPL)
can't be saved directly in the cached boot partitions, and the indexes of other partitions need to be adapted.

For the user area, we use GPT partitioning. SSBL is the first user partition in eMMC memory mapping :

ums 0 mmc 1 dd if=
  • is saved at the beginning of the e•MMC boot partition

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 ST Microelectronics board)

The boot partitions are available in /dev/mmcblk1boot0 and /dev/mmcblk1boot1 [1].

The user perhaps needs to allow access, for example with:

   echo 0 > /sys/class/block/mmcblk1boot0/force_ro

The mmc tools allow the boot partition to be selected [2].

The STM32MP15x ROM code requires:

  • <send_ack> =1
  • 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:

  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/sdb1mmcblk1p1 conv=fdatasync

For the boot partition, the user needs to select the targeted partition with See also [3].

2.2 On a U-Boot console[edit]

The e•MMC update is done with the ums command and 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 (
eMMC
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) 

To copy FSBL with a ums command And on a PC, the mass storage is mounted as /dev/sda

To update FSBL=TF-A, select the boot1 HW partition and come back to the user area , we have: at the end.

 
 mmc dev 1
  mmc partconf 1 1 1 1 
  ums 0 mmc 1
 
  dd if=tf-a.stm32 of=/dev/mmcblk0p1sda  conv=fdatasync
  
  mmc partconf 1 1 1 0

To update SSBL = U-Boot in the first GPT partition in the user partition

  mmc dev 1
  ums 0 mmc 1
 
  dd if=u-boot.stm32 of=/dev/sda1 conv=fdatasync

Before the first boot, select the e•MMC correct boot configuration (1 wire, 25 MHz) with the command:

  mmc bootbus 1 0 0 0

3 References[edit]

Please refer to the following links for additional information:


This page explains how to manually update the [[U-Boot_overview|U-Boot]] binaries on an SD card.

== Copying a binary to  or on the ''e''•MMC.

== To update an SD card with the Linux dd command ==

When you have a Linux console has access to the SD card device (with the card reader of a PC, or the partitions:
* on a Linux PC
** with a card reader of this PC
** through a USB connection to the target and the  [[How to use USB mass storage in U-Boot|<code>ums</code> command]] executed on a target), U-Boot console
* on target, with Linux console.
[[STM32MP15_Flash_mapping#SD_card_memory_mapping|theThe 3 first GPT partitions on the SD card]] are:
# FSBL1
# FSBL2
# SSBL

See [[Boot_chainschain_overview]] for the bootloader definitions.

You can use the Linux <code>dd</code> command to copy the FSBL and SSBL directly to the correct partition: {{PC$}}  dd if={{HighlightParam|<file>}} of=/dev/{{HighlightParam|<dev>}} conv={{HighlightParam|fdatasync

<dev> is:
* mmcblk<X>p<n> }}

{{HighlightParam|<dev>}} is:
* mmcblk{{Highlight|<X>}}p{{Highlight|<n>}}: PC-embedded card reader case * sd<X><N> or target Linux 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.

Note: the dd option {{HighlightParam|conv=fdatasync}}={{HighlightParam|fdatasync}} is used to force synchronous copying.

== Trusted boot chain update example === U-Boot environment ===

The U-Boot environment is saved at the end of the U-Boot partition, named "ssbl":  ID  = {{HighlightParam|3}}.

To clear this environment, erase the U-Boot partition before any update; for example, by writing 0 to this partition:
  {{PC$}}  dd if=/dev/zero of=/dev/mmcblk{{Highlight|<X>}}p{{HighlightParam|3}} conv=fdatasync

  {{PC$}}  dd if=/dev/zero of=sd{{Highlight|<X>}}{{HighlightParam|3}} conv=fdatasync

=== SD card update example ===The internal card reader is /dev/mmcblk0, partition <n> is /dev/mmcblk0p<n>:

  {{PC$}} dd if=tf-a.stm32 of=/dev/mmcblk0p1 or for a target Linux console, GPT partition <n> is {{HighlightParam|/dev/mmcblk0}}p<n>:
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/mmcblk0}}p1 conv=fdatasync
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/mmcblk0p2mmcblk0}}p2 conv=fdatasync
  {{PC$}} dd if=u-boot.stm32 of=/dev/mmcblk0p3 conv=fdatasync

== Basic boot chain udpate example ==/dev/zero of={{HighlightParam|/dev/mmcblk0}}p3 conv=fdatasync
  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/mmcblk0}}p3 conv=fdatasync

Alternatively, with U-Boot console, dev = {{Highlight|0}} (SD card device on ST Microelectronics board), GPT partition <n> is {{HighlightParam|/dev/sda}}<n>:
  {{Board$}} mmc dev {{Highlight|0}} 
  {{Board$}} ums 0 mmc {{Highlight|0}}

  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/sda}}1 conv=fdatasync
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/sda}}2 conv=fdatasync
  {{PC$}} dd if=/dev/zero of={{HighlightParam|/dev/sda}}3 conv=fdatasync
  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/sda}}3 conv=fdatasync

=== SD card update example with SPL as FSBL ===

The USB card reader is /dev/sdb, GPT partition <n> is {{HighlightParam|/dev/sdb<n>

}}:{{PC$}} dd if={{HighlightParam|u-boot-spl.stm32}} of={{HighlightParam|/dev/sdb1}} conv=fdatasync
  {{PC$}} dd if={{HighlightParam|u-boot-spl.stm32}} of={{HighlightParam|/dev/sdb2}} conv=fdatasync
  {{PC$}} dd if=u-boot.img of=/dev/sdb3 conv=fdatasync

== update of eMMC /dev/zero of={{HighlightParam|/dev/sdb3}} conv=fdatasync
  {{PC$}} dd if={{HighlightParam|u-boot.img}} of={{HighlightParam|/dev/sdb3}} conv=fdatasync

== Update of ''e''•MMC with the Linux dd command ==

The same command, <code>dd</code>, can be used to update eMMC with [[How to use USB mass storage in U-Boot|<code>ums</code> command]], but the SSBL [[STM32MP15_Flash_mapping#eMMC_memory_mapping|''e''•MMC memory mapping]]:
* SSBL U-Boot is the first GPT partition in the ''e''•MMC user area
* FSBL = TF-A (or SPL) can't be saved directly in the cached boot partitions, and the indexes of other partitions need to be adapted.

For the user area, we use GPT partitioning. SSBL is the first user partition in [[STM32MP15_Flash_mapping#eMMC_memory_mapping|eMMC memory mapping]] :

  {{Board$}} ums 0 mmc 1
  {{PC$}} dd if=u-boot.stm32 of=/dev/sdb1 conv=fdatasync

For the boot partition, the user needs to select the targeted partition with is saved at the beginning of the ''e''•MMC boot partition

The user needs to select the ''e''•MMC hardware partition to update: user data, boot1, or boot2.

=== On a Linux console ===

If dev = {{Highlight|mmcblk1}}  for ''e''•MMC device (default on ST Microelectronics 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 perhaps needs to allow access, for example with:
  {{Board$}}  echo 0 > /sys/class/block/{{Highlight|mmcblk1}}{{HighlightParam|boot0}}/force_ro

The mmc tools allow the boot partition to be selected <ref>https://manpages.debian.org/buster/mmc-utils/mmc.1.en.html</ref>.

The STM32MP15x ROM code requires:
* <send_ack> =1
* 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:   
  {{Board$}} dd if={{HighlightParam|tf-a.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:  
  {{Board$}} dd if={{HighlightParam|tf-a.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|boot1}} conv=fdatasync
  {{Board$}} mmc bootpart enable {{HighlightParam|2}} 1 /dev/{{Highlight|mmcblk1}}

To update U-Boot in the first GPT partition:
  {{Board$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync
  {{Board$}} dd if={{HighlightParam|u-boot.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync

See also <ref>https://www.emcraft.com/som/stm32mp1/booting-linux-from-emmc</ref>.

=== On a U-Boot console ===

The ''e''•MMC update is done with the [[How to use USB mass storage in U-Boot|<code>ums</code> command]] and
the targeted ''e''•MMC HW partition is selected in U-Boot by the third parameter {{HighlightParam|partition_access}} of command <code>{{Highlight|mmc partconf}}</code> :
* {{HighlightParam|0}}: user data partition
* {{HighlightParam|1}}: boot partition 1
* {{HighlightParam|2}}: boot partition 2

  {{Board$}}  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 {{HighlightParam|partition_access}}]
 - Show or change the bits of the PARTITION_CONFIG field of the specified device
 ..

For example, 
* dev = 1 (eMMCFor example:
 * dev = {{Highlight|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) * {{HighlightParam|partition_access}} =  {{HighlightParam|0}} (No access to boot partition - default)  * or {{HighlightParam|partition_access}} =  {{HighlightParam|1}} (R/W boot partition 1) 
To copy FSBL with a <code>ums</code> command And on a PC, the mass storage is mounted as {{HighlightParam|/dev/sda}} 

To update FSBL=TF-A, select the boot1 HW partition and come back to the user area, we have: at the end.{{Board$}} mmc dev {{Highlight|1}}

  {{Board$}} mmc partconf {{Highlight|1}} 1 1 {{HighlightParam|1}}  {{Board$}} ums 0 mmc {{Highlight|1
}}
{{PC$}} dd if=tf-a.stm32 of={{HighlightParam|/dev/mmcblk0p1 sda}}  conv=fdatasync 
{{Board$}} mmc partconf {{Highlight|1}} 1 1 {{HighlightParam|0}}
To update SSBL = U-Boot in the first GPT partition in the user partition
  {{Board$}} mmc dev {{Highlight|1}}
  {{Board$}} ums 0 mmc {{Highlight|1}}

  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/sda}}1 conv=fdatasync

Before the first boot, select the ''e''•MMC correct boot configuration (1 wire, 25 MHz) with the command:
  {{Board$}} mmc bootbus {{HighlightParam|1}} 0 0 0

==References==
Please refer to the following links for additional information:
<references />

<noinclude>

[[Category:How to populate boards]]
{{PublicationRequestId | 13227 | 2019-09-1116075 | 2020-05-12}}</noinclude>
(26 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This page explains how to manually update the [[U-Boot_overview|U-Boot]] binaries on an SD card.
+
This page explains how to manually update the [[U-Boot_overview|U-Boot]] binaries on an SD card or on the ''e''•MMC.
   
== Copying a binary to an SD card with the Linux dd command ==
+
== To update an SD card with the Linux dd command ==
   
When you have access to the device (with the card reader of a PC, or the [[How to use USB mass storage in U-Boot|<code>ums</code> command]] on a target), [[STM32MP15_Flash_mapping#SD_card_memory_mapping|the 3 first partitions on the SD card]] are:
+
When a Linux console has access to the SD card device partitions:
  +
* on a Linux PC
  +
** with a card reader of this PC
  +
** through a USB connection to the target and the [[How to use USB mass storage in U-Boot|<code>ums</code> command]] executed on a U-Boot console
  +
* on target, with Linux console.
  +
 
  +
[[STM32MP15_Flash_mapping#SD_card_memory_mapping|The 3 first GPT partitions on the SD card]] are:
 
# FSBL1
 
# FSBL1
 
# FSBL2
 
# FSBL2
 
# SSBL
 
# SSBL
   
See [[Boot_chains_overview]] for the bootloader definitions.
+
See [[Boot_chain_overview]] for the bootloader definitions.
   
 
You can use the Linux <code>dd</code> command to copy the FSBL and SSBL directly to the correct partition:
 
You can use the Linux <code>dd</code> command to copy the FSBL and SSBL 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 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.
  +
  +
Note: the dd option {{HighlightParam|conv}}={{HighlightParam|fdatasync}} is used to force synchronous copying.
  +
  +
=== U-Boot environment ===
  +
  +
The U-Boot environment is saved at the end of the U-Boot partition, named "ssbl":  ID  = {{HighlightParam|3}}.
  +
  +
To clear this environment, erase the U-Boot partition before any update; for example, by writing 0 to this partition:
  +
  {{PC$}}  dd if=/dev/zero of=/dev/mmcblk{{Highlight|<X>}}p{{HighlightParam|3}} conv=fdatasync
  +
  +
  {{PC$}}  dd if=/dev/zero of=sd{{Highlight|<X>}}{{HighlightParam|3}} conv=fdatasync
  +
  +
=== SD card update example ===
  +
The internal card reader is /dev/mmcblk0 or for a target Linux console, GPT partition <n> is {{HighlightParam|/dev/mmcblk0}}p<n>:
  +
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/mmcblk0}}p1 conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/mmcblk0}}p2 conv=fdatasync
  +
  {{PC$}} dd if=/dev/zero of={{HighlightParam|/dev/mmcblk0}}p3 conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/mmcblk0}}p3 conv=fdatasync
  +
  +
Alternatively, with U-Boot console, dev = {{Highlight|0}} (SD card device on ST Microelectronics board), GPT partition <n> is {{HighlightParam|/dev/sda}}<n>:
  +
  {{Board$}} mmc dev {{Highlight|0}}
  +
  {{Board$}} ums 0 mmc {{Highlight|0}}
  +
 
  +
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/sda}}1 conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|tf-a.stm32}} of={{HighlightParam|/dev/sda}}2 conv=fdatasync
  +
  {{PC$}} dd if=/dev/zero of={{HighlightParam|/dev/sda}}3 conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/sda}}3 conv=fdatasync
  +
  +
=== SD card update example with SPL as FSBL ===
  +
The USB card reader is /dev/sdb, GPT partition <n> is {{HighlightParam|/dev/sdb<n>}}:
  +
  {{PC$}} dd if={{HighlightParam|u-boot-spl.stm32}} of={{HighlightParam|/dev/sdb1}} conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|u-boot-spl.stm32}} of={{HighlightParam|/dev/sdb2}} conv=fdatasync
  +
  {{PC$}} dd if=/dev/zero of={{HighlightParam|/dev/sdb3}} conv=fdatasync
  +
  {{PC$}} dd if={{HighlightParam|u-boot.img}} of={{HighlightParam|/dev/sdb3}} conv=fdatasync
  +
  +
== Update of ''e''•MMC with the Linux dd command ==
  +
  +
The same command, <code>dd</code>, can be used to update [[STM32MP15_Flash_mapping#eMMC_memory_mapping|''e''•MMC memory mapping]]:
  +
* SSBL U-Boot is the first GPT partition in the ''e''•MMC user area
  +
* FSBL = TF-A (or SPL) is saved at the beginning of the ''e''•MMC boot partition
  +
  +
The user needs to select the ''e''•MMC hardware partition to update: user data, boot1, or boot2.
  +
  +
=== On a Linux console ===
   
  {{PC$}}  dd if=<file> of=/dev/<dev> conv=fdatasync
+
If dev = {{Highlight|mmcblk1}}  for ''e''•MMC device (default on ST Microelectronics board)
   
<dev> is:
+
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>.
* mmcblk<X>p<n> : PC-embedded card reader case
 
* 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.
+
The user perhaps needs to allow access, for example with:
  +
  {{Board$}}  echo 0 > /sys/class/block/{{Highlight|mmcblk1}}{{HighlightParam|boot0}}/force_ro
   
== Trusted boot chain update example ==
+
The mmc tools allow the boot partition to be selected <ref>https://manpages.debian.org/buster/mmc-utils/mmc.1.en.html</ref>.
The internal card reader is /dev/mmcblk0, partition <n> is /dev/mmcblk0p<n>:
 
   
  {{PC$}} dd if=tf-a.stm32 of=/dev/mmcblk0p1 conv=fdatasync
+
The STM32MP15x ROM code requires:
   {{PC$}} dd if=tf-a.stm32 of=/dev/mmcblk0p2 conv=fdatasync
+
* <send_ack> =1
  {{PC$}} dd if=u-boot.stm32 of=/dev/mmcblk0p3 conv=fdatasync
+
* 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}}
   
== Basic boot chain udpate example ==
+
To update TF-A in boot1 and select this boot partition: 
The USB card reader is /dev/sdb, partition <n> is /dev/sdb<n>
+
  {{Board$}} dd if={{HighlightParam|tf-a.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|boot0}} conv=fdatasync
  +
  {{Board$}} mmc bootpart enable {{HighlightParam|1}} 1 /dev/{{Highlight|mmcblk1}}
   
   {{PC$}} dd if=u-boot-spl.stm32 of=/dev/sdb1 conv=fdatasync
+
To update TF-A in boot2 and select this boot partition: 
   {{PC$}} dd if=u-boot-spl.stm32 of=/dev/sdb2 conv=fdatasync
+
   {{Board$}} dd if={{HighlightParam|tf-a.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|boot1}} conv=fdatasync
  {{PC$}} dd if=u-boot.img of=/dev/sdb3 conv=fdatasync
+
   {{Board$}} mmc bootpart enable {{HighlightParam|2}} 1 /dev/{{Highlight|mmcblk1}}
   
== update of eMMC ==
+
To update U-Boot in the first GPT partition:
  +
  {{Board$}} dd if=/dev/zero of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync
  +
  {{Board$}} dd if={{HighlightParam|u-boot.stm32}} of=/dev/{{Highlight|mmcblk1}}{{HighlightParam|p1}} conv=fdatasync
   
The same command, <code>dd</code>, can be used to update eMMC with [[How to use USB mass storage in U-Boot|<code>ums</code> command]], but the SSBL = TF-A (or SPL) can't be saved directly in the cached boot partitions, and the indexes of other partitions need to be adapted.
+
See also <ref>https://www.emcraft.com/som/stm32mp1/booting-linux-from-emmc</ref>.
 
For the user area, we use GPT partitioning. SSBL is the first user partition in [[STM32MP15_Flash_mapping#eMMC_memory_mapping|eMMC memory mapping]] :
 
   
  {{Board$}} ums 0 mmc 1
+
=== On a U-Boot console ===
  {{PC$}} dd if=u-boot.stm32 of=/dev/sdb1 conv=fdatasync
 
   
For the boot partition, the user needs to select the targeted partition with the third parameter {{HighlightParam|partition_access}} of command <code>{{Highlight|mmc partconf}}</code> :
+
The ''e''•MMC update is done with the [[How to use USB mass storage in U-Boot|<code>ums</code> command]] and
  +
the targeted ''e''•MMC HW partition is selected in U-Boot by the third parameter {{HighlightParam|partition_access}} of command <code>{{Highlight|mmc partconf}}</code>:
 
* {{HighlightParam|0}}: user data partition
 
* {{HighlightParam|0}}: user data partition
 
* {{HighlightParam|1}}: boot partition 1
 
* {{HighlightParam|1}}: boot partition 1
Line 57: Line 112:
 
   mmc partconf dev [boot_ack boot_partition {{HighlightParam|partition_access}}]
 
   mmc partconf dev [boot_ack boot_partition {{HighlightParam|partition_access}}]
 
  - Show or change the bits of the PARTITION_CONFIG field of the specified device
 
  - Show or change the bits of the PARTITION_CONFIG field of the specified device
   ..
+
 
  +
For example:
  +
* dev = {{Highlight|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)
  +
* {{HighlightParam|partition_access}} =  {{HighlightParam|0}} (No access to boot partition - default)
  +
* or {{HighlightParam|partition_access}} =  {{HighlightParam|1}} (R/W boot partition 1)
  +
 
  +
And on a PC, the mass storage is mounted as {{HighlightParam|/dev/sda}}
  +
 
  +
To update FSBL=TF-A, select the boot1 HW partition and come back to the user area at the end.
  +
   {{Board$}} mmc dev {{Highlight|1}}
  +
  {{Board$}} mmc partconf {{Highlight|1}} 1 1 {{HighlightParam|1}}
  +
  {{Board$}} ums 0 mmc {{Highlight|1}}
 
    
 
    
For example,
+
  {{PC$}} dd if=tf-a.stm32 of={{HighlightParam|/dev/sda}}  conv=fdatasync
* dev = 1 (eMMC device on ST Microelectronics board)
+
 
* boot_ack=1 (Boot Acknowledge is needed by ROM code)
+
  {{Board$}} mmc partconf {{Highlight|1}} 1 1 {{HighlightParam|0}}
* boot_partition = 1 (Boot partition 1 enabled for boot)
+
 
* {{HighlightParam|partition_access}} = {{HighlightParam|0}} (No access to boot partition - default)  
+
To update SSBL = U-Boot in the first GPT partition in the user partition
* or {{HighlightParam|partition_access}} {{HighlightParam|1}} (R/W boot partition 1)
+
  {{Board$}} mmc dev {{Highlight|1}}
  +
  {{Board$}} ums 0 mmc {{Highlight|1}}
  +
 
  +
  {{PC$}} dd if={{HighlightParam|u-boot.stm32}} of={{HighlightParam|/dev/sda}}1 conv=fdatasync
  +
 
  +
Before the first boot, select the ''e''•MMC correct boot configuration (1 wire, 25 MHz) with the command:
  +
  {{Board$}} mmc bootbus {{HighlightParam|1}} 0 0 0
  +
 
  +
==References==
  +
Please refer to the following links for additional information:
   
To copy FSBL with a <code>ums</code> command and come back to the user area, we have:
+
<references />
  {{Board$}} mmc dev 1
 
  {{Board$}} mmc partconf 1 1 1 {{HighlightParam|1}}
 
  {{Board$}} ums 0 mmc 1
 
  {{PC$}} dd if=tf-a.stm32 of=/dev/mmcblk0p1 conv=fdatasync
 
  {{Board$}} mmc partconf 1 1 1 {{HighlightParam|0}}
 
   
 
<noinclude>
 
<noinclude>
 
[[Category:How to populate boards]]
 
[[Category:How to populate boards]]
{{PublicationRequestId | 13227 | 2019-09-11}}
+
{{PublicationRequestId | 16075 | 2020-05-12}}
 
</noinclude>
 
</noinclude>