Difference between revisions of "How to load U-Boot with dfu-util"

[quality revision] [quality revision]
m (Identify alternate)
m (STM32_MPU_resources)
 
Applicable for STM32MP13x lines, STM32MP15x lines

This page explains how to load and start U-Boot with the dfu-util[1] tool over a USB port.

This tool, available on Linux or Windows, supports the DFU standard [2] and can replace STM32CubeProgrammer for the U-Boot load use case.

1 Overview[edit]

To load and execute U-Boot in DDR with the DFU protocol, the dfu-util tools can be used instead of STM32CubeProgrammer.

As the GetPhase is an STMicroelectronics protocol for STM32CubeProgrammer and is not supported by dfu-util, you must follow the steps described in AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders and provide the binaries in the order expected by the bootloaders:

  1. Download phase 0x1 by ROM code is the FSBL (TF-A BL2)
  2. DFU detach to request an FSBL start - not required for STM32MP15x lines More info.png ROM code
  3. Download phase 0x3 by FSBL is the FIP file including the SSBL image (U-Boot)
  4. DFU detach to request an SSBL start

The FSBL, SSBL and FIP definitions can be found in the Boot chain overview.

The FIP includes the required SSBL = U-Boot, see How to configure TF-A FIP in order to update it with the U-Boot binary.

This feature can be used to debug U-Boot during board bring-up.

See also How to load U-Boot with STM32CubeProgrammer.

2 dfu-util[edit]

The help message of dfu-util is:

 
  dfu-util --help
 Usage: dfu-util [options] ...
   -h --help			Print this help message
   -V --version			Print the version number
   -v --verbose			Print verbose debug statements
   -l --list			List currently attached DFU capable devices
   -e --detach			Detach currently attached DFU capable devices
   -E --detach-delay seconds	Time to wait before reopening a device after detach
   -d --device <vendor>:<product>[,<vendor_dfu>:<product_dfu>]
 				Specify Vendor/Product ID(s) of DFU device
   -p --path <bus-port. ... .port>	Specify path to DFU device
   -c --cfg <config_nr>		Specify the Configuration of DFU device
   -i --intf <intf_nr>		Specify the DFU Interface number
   -S --serial <serial_string>[,<serial_string_dfu>]
 				Specify Serial String of DFU device
   -a --alt <alt>		Specify the Altsetting of the DFU Interface
 				by name or by number
   -t --transfer-size <size>	Specify the number of bytes per USB Transfer
   -U --upload <file>		Read firmware from device into <file>
   -Z --upload-size <bytes>	Specify the expected upload size in bytes
   -D --download <file>		Write firmware from <file> into device
   -R --reset			Issue USB Reset signalling once we're finished
   -s --dfuse-address <address>	ST DfuSe mode, specify target address for
 				raw file download or upload. Not applicable for
 				DfuSe file (.dfu) downloads

The minimal dfu-util option used to load U-Boot is:

  • -a/--alt select the alternate to load the requested phase
  • -D/--download Download the requested binary for the selected phase
  • -e/--detach request a DFU DETACH

2.1 Identify alternate[edit]

You can also use the -l/--list option to check the alternate associated to each phase (see AN5275 for the coding of the alternate name).

For example the result of this command on ROM code with a USB serial boot is:

  • on STM32MP15x lines More info.png: the first alternate is alt=1 for FSB alternate associate to phase 0x1 and the last one is alt = 5 for virtual associate to phase 0xF1
 
 dfu-util -l
 dfu-util 0.9
 
 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
 This program is Free Software and has ABSOLUTELY NO WARRANTY
 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
 
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=5, name="@virtual /0xF1/1*512Ba", 
 serial="004100323338511634383330"
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=4, name="@Partition4 /0x04/1*16Me", 
 serial="004100323338511634383330"
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=3, name="@Partition3 /0x03/1*16Me", 
 serial="004100323338511634383330"
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=2, name="@Partition2 /0x02/1*1Me", 
 serial="004100323338511634383330"
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=1, name="@FSBL /0x01/1*1Me", 
 serial="004100323338511634383330"
 Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=0, name="@Partition0 /0x00/1*256Ke", 
 serial="004100323338511634383330"
  • on STM32MP13x lines Warning.png: the first alternate is alt=0 for FSB alternate associate to phase 0x1 and the second is alt = 1 for virtual associate to phase 0xF1
 
 dfu-util -l
 dfu-util 0.9
 
 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
 This program is Free Software and has ABSOLUTELY NO WARRANTY
 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
 
 Found DFU: [0483:df11] ver=0200, devnum=6, cfg=1, intf=0, path="1-5.2", alt=1, name="@virtual /0xF1/1*512Ba", serial="801480113530510138343532"
 Found DFU: [0483:df11] ver=0200, devnum=6, cfg=1, intf=0, path="1-5.2", alt=0, name="@FSBL/0x01/1*128Ke", serial="801480113530510138343532"

2.2 Select device[edit]

In each dfu-util command, the command device can be identified by:

  • USB vendor and product identifiers (VID and PID)
  • USB serial number

In the previous STM32MP15 example, the device has VID:PID=0483:df11 and its serial number is 004100323338511634383330.

In the following sections, you can add the -d/--device and -S/--serial options to select this specific device:

 
 dfu-util -d 0483:df11 -S 004100323338511634383330 ....

It is required only when several devices are connected on the host.

3 The U-Boot load sequence[edit]

The load sequence is described in #Overview, depending of the alternate (phase = P for alternate A) and the corresponding commands are:

  1. Download phase P = dfu-util -a A -D [file]
  2. DFU detach = dfu-util -a 0 -e
Info white.png Information
After a DFU detach done with dfu-util -a 0 -e, you must wait that the next stage is ready, for example by adding some delay in script.

3.1 On STM32MP15x lines More info.png[edit]

 
 dfu-util -a 1 -D tf-a-usb.stm32
  dfu-util -a 3 -D fip.bin
  dfu-util -a 0 -e

3.2 On STM32MP13x lines Warning.png[edit]

 
 dfu-util -a 0 -D tf-a-usb.stm32
  dfu-util -a 0 -e
  dfu-util -a 0 -D fip.bin
  dfu-util -a 0 -e

4 U-Boot DFU support[edit]

After load sequence, U-Boot is running, the boot command is executed, the DFU stack is running and the stm32prog is waiting the FlashLayout file before to reenumerate. you can:

 
 dfu-util -a 0 -D flashlayout.tsv
  dfu-util -a 0 -e

  • interrupt the stm32progcommand by sending a Ctrl-C on the console or sending an empty flashlayout with 2 DFU detach:
 
 dfu-util -a 0 -e
  dfu-util -a 0 -e

  • request device reboot by a USB reset with option -R --reset:
 
 dfu-util -a 0 -e -R

4.1 Generate an flashlayout.stm32 file[edit]

You can generate the flashlayout.stm32 file from the tsv flashlayout file = flashlayout.tsv with the U-Boot mkimage tool by using the following Linux shell commands:

 mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d flashlayout.tsv flashlayout.stm32

4.2 Execute a U-Boot script[edit]

You can replace the flashlayout file with a U-Boot script containing a U-Boot image header. This is then executed automatically by U-Boot.

The following example is for a simple script to start U-Boot in dfu mode and then reset:

 dfu 0
 reset
 echo "dfu 0; reset" > script.cmd
 mkimage -C none -A arm -T script -d script.cmd script.uimg

Then the complete sequence is:

  • on STM32MP15x lines More info.png
 
 dfu-util -a 1 -D tf-a-usb.stm32
  dfu-util -a 3 -D fip.bin
  dfu-util -a 0 -e
  dfu-util -a 0 -D script.uimg
  dfu-util -a 0 -e

  • on STM32MP13x lines Warning.png
 
 dfu-util -a 0 -D tf-a-usb.stm32
  dfu-util -a 0 -e
  dfu-util -a 0 -D fip.bin
  dfu-util -a 0 -e
  dfu-util -a 0 -D script.uimg
  dfu-util -a 0 -e

5 GetPhase support with dfu-util[edit]

The GetPhase is an STMicroelectronics addition, on top of DFU, not supported by dfu-util, see AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders for details.

The expected Phase P and the expected DFU detach request are indicated by device in the Get Phase answer, read (= DFU_UPLOAD) in the last alternate, with alternate id = A, name = "virtual" with phase id = 0xF1 with the command:

 
 dfu-util -a A -U phase.bin

The format of the received data, the phase.bin file in this example, is:

Byte Name Description
1 Phase Phase P expected by device
2-5 Address 0xFFFFFFFF or load address in embedded RAM
6-9 Offset 0x0
10 NeedDFUDetach Present only if P = 01 : DFU detach is requested for a new USB enumeration

This information can be used to dynamically manage the load sequence in script using dfu-util as it is done in STM32CubeProgrammer.

Example of "Get Phase" answer done by STM32MP13x ROM code on alternate 1:

 
 dfu-util -a 1 -U phase.bin
 dfu-util 0.9
 
 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
 This program is Free Software and has ABSOLUTELY NO WARRANTY
 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
 
 Opening DFU capable USB device...
 ID 0483:df11
 Run-time device DFU version 0110
 Claiming USB DFU Interface...
 Setting Alternate Setting #0 ...
 Determining device status: state = dfuIDLE, status = 0
 dfuIDLE, continuing
 DFU mode device DFU version 0110
 Device returned transfer size 1024
 Copying data from DFU device to PC
 Upload	[=========================] 100%            9 bytes
 Upload done.
 
  hexdump phase.bin
 0000000 0001 fdfe 002f 0000 0000               
 0000009

6 References[edit]

  1. dfu-util - Device Firmware Upgrade Utilities - http://dfu-util.sourceforge.net
  2. USB DFU - Universal Serial Bus Device Class Specification for Device Firmware Upgrade Version 1.1 - https://usb.org/sites/default/files/DFU_1.1.pdf


<noinclude>{{ApplicableFor
|MPUs list=STM32MP13x, STM32MP15x
|MPUs checklist=STM32MP13x,STM32MP15x
}}</noinclude>

This page explains how to load and start U-Boot with the <code>dfu-util</code><ref>dfu-util - Device Firmware Upgrade Utilities - http://dfu-util.sourceforge.net</ref> tool over a USB port.

This tool, available on Linux or Windows, supports the DFU standard <ref>USB DFU - Universal Serial Bus Device Class Specification for Device Firmware Upgrade Version 1.1 - https://usb.org/sites/default/files/DFU_1.1.pdf</ref> and can replace [[STM32CubeProgrammer]] for the [[How_to_load_U-Boot_with_STM32CubeProgrammer|U-Boot load use case]]. 

== Overview ==

To load and execute U-Boot in DDR with the DFU protocol, the <code>dfu-util</code> tools can be used instead of [[STM32CubeProgrammer]].

As the [[#GetPhase support with dfu-util|GetPhase]] is an STMicroelectronics protocol for STM32CubeProgrammer and is not supported by <code>dfu-util</code>, you must follow the steps described in [[STM32MP15 STM32_MPU_resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] and provide the binaries in the order expected by the bootloaders:

# Download phase {{Highlight|0x1}} by ROM code is the FSBL ([[TF-A_overview|TF-A]] BL2)
# {{Highlight|DFU detach}} to request an FSBL start - not required for {{MicroprocessorDevice | device=15}} ROM code
# Download phase {{Highlight|0x3}} by FSBL is the FIP file including the SSBL image ([[U-Boot_overview|U-Boot]])
# {{Highlight|DFU detach}} to request an SSBL start

The FSBL, SSBL and FIP definitions can be found in the [[Boot chain overview]].

The FIP includes the required SSBL = U-Boot, see [[How to configure TF-A FIP]] in order to update it with the U-Boot binary.

This feature can be used to debug U-Boot during board bring-up.

See  also [[How to load U-Boot with STM32CubeProgrammer]].

== dfu-util ==

The help message of <code>dfu-util</code> is:
<div class="mw-collapsible  mw-collapsed">

  {{PC$}}  dfu-util --help<div div class="mw-collapsible-content">

  Usage: dfu-util [options] ...
    -h --help			Print this help message
    -V --version			Print the version number
    -v --verbose			Print verbose debug statements
    -l --list			List currently attached DFU capable devices
    -e --detach			Detach currently attached DFU capable devices
    -E --detach-delay seconds	Time to wait before reopening a device after detach
    -d --device <vendor>:<product>[,<vendor_dfu>:<product_dfu>]
  				Specify Vendor/Product ID(s) of DFU device
    -p --path <bus-port. ... .port>	Specify path to DFU device
    -c --cfg <config_nr>		Specify the Configuration of DFU device
    -i --intf <intf_nr>		Specify the DFU Interface number
    -S --serial <serial_string>[,<serial_string_dfu>]
  				Specify Serial String of DFU device
    -a --alt <alt>		Specify the Altsetting of the DFU Interface
  				by name or by number
    -t --transfer-size <size>	Specify the number of bytes per USB Transfer
    -U --upload <file>		Read firmware from device into <file>

    -Z --upload-size <bytes>	Specify the expected upload size in bytes
    -D --download <file>		Write firmware from <file> into device
    -R --reset			Issue USB Reset signalling once we're finished
    -s --dfuse-address <address>	ST DfuSe mode, specify target address for
  				raw file download or upload. Not applicable for
  				DfuSe file (.dfu) downloads</div></div>


The minimal <code>dfu-util</code> option used to load U-Boot is:
* '''-a'''/'''--alt''' select the alternate to load the requested phase
* '''-D'''/'''--download''' Download the requested binary for the selected phase
* '''-e'''/'''--detach''' request a DFU DETACH

=== Identify alternate ===

You can also use the '''-l'''/'''--list''' option to check the alternate associated to each phase (see [[STM32MP15 STM32_MPU_resources#AN5275|AN5275]] for the coding of the alternate name).

For example the result of this command on ROM code with a USB serial boot is:
<div class="mw-collapsible  mw-collapsed">

* on {{MicroprocessorDevice | device=15}}: the first alternate is alt={{HighlightParam|1}} for {{HighlightParam|FSB}} alternate associate to phase {{Highlight|0x1}} and the last one is alt = {{HighlightParam|5}} for {{HighlightParam|virtual}} associate to phase {{Highlight|0xF1}}<div div class="mw-collapsible-content">

  {{PC$}} dfu-util -l
  dfu-util 0.9

  Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
  Copyright 2010-2016 Tormod Volden and Stefan Schmidt
  This program is Free Software and has ABSOLUTELY NO WARRANTY
  Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt={{HighlightParam|5}}, name="@{{HighlightParam|virtual}} /{{Highlight|0xF1}}/1*512Ba", 
  serial="004100323338511634383330"
  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=4, name="@Partition4 /0x04/1*16Me", 
  serial="004100323338511634383330"
  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=3, name="@Partition3 /0x03/1*16Me", 
  serial="004100323338511634383330"
  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=2, name="@Partition2 /0x02/1*1Me", 
  serial="004100323338511634383330"
  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt={{HighlightParam|1}}, name="@{{HighlightParam|FSBL }}/{{Highlight|0x01}}/1*1Me", 
  serial="004100323338511634383330"
  Found DFU: [0483:df11] ver=0200, devnum=12, cfg=1, intf=0, path="1-5.2", alt=0, name="@Partition0 /0x00/1*256Ke", 
  serial="004100323338511634383330"</div></div>

<div class="mw-collapsible  mw-collapsed">

* on {{MicroprocessorDevice | device=13}}: the first alternate is alt={{HighlightParam|0}} for {{HighlightParam|FSB}} alternate associate to phase {{Highlight|0x1}} and the second is alt = {{HighlightParam|1}} for {{HighlightParam|virtual}} associate to phase {{Highlight|0xF1}}<div div class="mw-collapsible-content">

  {{PC$}} dfu-util -l
  dfu-util 0.9

  Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
  Copyright 2010-2016 Tormod Volden and Stefan Schmidt
  This program is Free Software and has ABSOLUTELY NO WARRANTY
  Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

  Found DFU: [0483:df11] ver=0200, devnum=6, cfg=1, intf=0, path="1-5.2", alt={{HighlightParam|1}}, name="@{{HighlightParam|virtual}} /{{Highlight|0xF1}}/1*512Ba", serial="801480113530510138343532"
  Found DFU: [0483:df11] ver=0200, devnum=6, cfg=1, intf=0, path="1-5.2", alt={{HighlightParam|0}}, name="@{{HighlightParam|FSBL}}/{{Highlight|0x01}}/1*128Ke", serial="801480113530510138343532"</div></div>


=== Select device ===

In each <code>dfu-util</code> command, the command device can be identified by:
* USB vendor and product identifiers (VID and PID)
* USB serial number 

In the previous STM32MP15 example, the device has VID:PID={{HighlightParam|0483:df11}} and its serial number is {{HighlightParam|004100323338511634383330}}.

In the following sections, you can add the {{Highlight|-d}}/'''--device''' and  {{Highlight|-S}}/'''--serial''' options to select this specific device:

  {{PC$}} dfu-util {{Highlight|-d}} {{HighlightParam|0483:df11}} {{Highlight|-S}} {{HighlightParam|004100323338511634383330}} ....

It is required only when several devices are connected on the host.

== The U-Boot load sequence ==

The load sequence is described in [[#Overview]], depending of the [[#Identify alternate|alternate]] (phase = {{Highlight|P}} for alternate {{Highlight|A}})  and the corresponding commands are:
# Download phase {{Highlight|P}} = <code>dfu-util -a {{Highlight|A}} -D [file]</code>

# {{Highlight|DFU detach}} = <code>dfu-util -a 0 -e</code>


{{Info | After a DFU detach done with <code>dfu-util -a 0 {{Highlight|-e}}</code>, you must wait that the next stage is ready, for example by adding some delay in script.}}

=== On {{MicroprocessorDevice | device=15}} ===

  {{PC$}} dfu-util -a {{Highlight|1}} -D tf-a-usb.stm32
  {{PC$}} dfu-util -a {{Highlight|3}} -D fip.bin
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

=== On {{MicroprocessorDevice | device=13}} ===

  {{PC$}} dfu-util -a {{Highlight|0}} -D tf-a-usb.stm32
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}
  {{PC$}} dfu-util -a {{Highlight|0}} -D fip.bin
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

== U-Boot DFU support ==

After [[#The U-Boot load sequence|load sequence]], U-Boot is running, the boot command is executed, the DFU stack is running and the <code>stm32prog</code> is waiting the FlashLayout file before to reenumerate. you can:

* provided the {{HighlightParam|flashlayout file}} in alternate 0: [[STM32CubeProgrammer_flashlayout|flashlayout.tsv]] or [[#Generate an flashlayout.stm32 file|flashlayout.stm32]], the same file with [[STM32 header for binary files|STM32 header]]:

  {{PC$}} dfu-util -a {{Highlight|0}} -D {{HighlightParam|flashlayout.tsv}}
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

* interrupt the <code>stm32prog</code>command by sending a Ctrl-C on the console or sending an empty flashlayout with 2 DFU detach:

  {{PC$}} dfu-util -a 0 {{Highlight|-e}}
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

* request device reboot by a USB reset with option -R --reset:

  {{PC$}} dfu-util -a 0 {{Highlight|-e}} {{Highlight|-R}}

* [[#Execute a U-Boot script]] as explained in the next chapter

=== Generate an flashlayout.stm32 file ===

You can generate the {{HighlightParam|flashlayout.stm32}} file from [[STM32CubeProgrammer_flashlayout|the tsv flashlayout file]] = {{HighlightParam|flashlayout.tsv}} with the U-Boot <code>mkimage</code> tool by using the following Linux shell commands:

 {{PC$}} mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d {{HighlightParam|flashlayout.tsv}} {{HighlightParam|flashlayout.stm32}}

=== Execute a U-Boot script ===

You can replace the flashlayout file with a U-Boot script containing a U-Boot image header. This is then executed automatically by U-Boot.

The following example is for a simple script to start U-Boot in dfu mode and then reset:

  dfu 0
  reset

 {{PC$}} echo "dfu 0; reset" > script.cmd
 {{PC$}} mkimage -C none -A arm -T script -d script.cmd {{HighlightParam|script.uimg}}

Then the complete sequence is:

* on {{MicroprocessorDevice | device=15}}

  {{PC$}} dfu-util -a {{Highlight|1}} -D tf-a-usb.stm32
  {{PC$}} dfu-util -a {{Highlight|3}} -D fip.bin
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}
  {{PC$}} dfu-util -a {{Highlight|0}} -D {{HighlightParam|script.uimg}}
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

* on {{MicroprocessorDevice | device=13}}

  {{PC$}} dfu-util -a {{Highlight|0}} -D tf-a-usb.stm32
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}
  {{PC$}} dfu-util -a {{Highlight|0}} -D fip.bin
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}
  {{PC$}} dfu-util -a {{Highlight|0}} -D {{HighlightParam|script.uimg}}
  {{PC$}} dfu-util -a 0 {{Highlight|-e}}

== GetPhase support with dfu-util ==

The GetPhase is an STMicroelectronics addition, on top of DFU, not supported by dfu-util, see [[STM32MP15 STM32_MPU_resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] for details.

The expected {{HighlightParam|Phase}} {{Highlight|P}} and the expected {{HighlightParam|DFU detach request}} are indicated by device in the '''Get Phase''' answer, read (= DFU_UPLOAD) in the last alternate, with alternate id = {{Highlight|A}}, name = "{{HighlightParam|virtual}}" with phase id = {{HighlightParam|0xF1}}  with the command:
  {{PC$}} dfu-util -a {{Highlight|A}} -U {{HighlightParam|phase.bin}}</code>


The format of the received data, the {{HighlightParam|phase.bin}} file in this example, is:

{| class="st-table"
|-
! Byte !! Name !! Description
|-
| 1 || {{HighlightParam|Phase}} || Phase {{Highlight|P}} expected by device
|-
| 2-5 || Address || 0xFFFFFFFF or load address in embedded RAM
|-
| 6-9 || Offset || 0x0
|-
| 10 || {{HighlightParam|NeedDFUDetach}} || Present only if {{Highlight|P}} = 0</br>1 :  DFU detach is requested for a new USB enumeration
|}
<div class="mw-collapsible  mw-collapsed">

This information can be used to dynamically manage the load sequence in script using <code>dfu-util</code> as it is done in STM32CubeProgrammer.
<div div class="mw-collapsible-content">

Example of "Get Phase" answer done by STM32MP13x ROM code on alternate {{Highlight|1}}:

  {{PC$}} dfu-util -a {{Highlight|1}} -U {{HighlightParam|phase.bin}}
  dfu-util 0.9

  Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
  Copyright 2010-2016 Tormod Volden and Stefan Schmidt
  This program is Free Software and has ABSOLUTELY NO WARRANTY
  Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

  Opening DFU capable USB device...
  ID 0483:df11
  Run-time device DFU version 0110
  Claiming USB DFU Interface...
  Setting Alternate Setting #0 ...
  Determining device status: state = dfuIDLE, status = 0
  dfuIDLE, continuing
  DFU mode device DFU version 0110
  Device returned transfer size 1024
  Copying data from DFU device to PC
  Upload	[=========================] 100%            9 bytes
  Upload done.

  {{PC$}} hexdump {{HighlightParam|phase.bin}}
  0000000 00{{HighlightParam|01}} fdfe 002f 0000 0000               
  0000009</div></div>


== References ==<references/>

<noinclude>


[[Category:U-Boot|U-Boot - 9]]
{{PublicationRequestId | 20382 | 2021-06-24}}</noinclude>
Line 11: Line 11:
 
To load and execute U-Boot in DDR with the DFU protocol, the <code>dfu-util</code> tools can be used instead of [[STM32CubeProgrammer]].
 
To load and execute U-Boot in DDR with the DFU protocol, the <code>dfu-util</code> tools can be used instead of [[STM32CubeProgrammer]].
   
As the [[#GetPhase support with dfu-util|GetPhase]] is an STMicroelectronics protocol for STM32CubeProgrammer and is not supported by <code>dfu-util</code>, you must follow the steps described in [[STM32MP15 resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] and provide the binaries in the order expected by the bootloaders:
+
As the [[#GetPhase support with dfu-util|GetPhase]] is an STMicroelectronics protocol for STM32CubeProgrammer and is not supported by <code>dfu-util</code>, you must follow the steps described in [[STM32_MPU_resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] and provide the binaries in the order expected by the bootloaders:
   
 
# Download phase {{Highlight|0x1}} by ROM code is the FSBL ([[TF-A_overview|TF-A]] BL2)
 
# Download phase {{Highlight|0x1}} by ROM code is the FSBL ([[TF-A_overview|TF-A]] BL2)
Line 66: Line 66:
 
=== Identify alternate ===
 
=== Identify alternate ===
   
You can also use the '''-l'''/'''--list''' option to check the alternate associated to each phase (see [[STM32MP15 resources#AN5275|AN5275]] for the coding of the alternate name).
+
You can also use the '''-l'''/'''--list''' option to check the alternate associated to each phase (see [[STM32_MPU_resources#AN5275|AN5275]] for the coding of the alternate name).
   
 
For example the result of this command on ROM code with a USB serial boot is:
 
For example the result of this command on ROM code with a USB serial boot is:
Line 204: Line 204:
 
== GetPhase support with dfu-util ==
 
== GetPhase support with dfu-util ==
   
The GetPhase is an STMicroelectronics addition, on top of DFU, not supported by dfu-util, see [[STM32MP15 resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] for details.
+
The GetPhase is an STMicroelectronics addition, on top of DFU, not supported by dfu-util, see [[STM32_MPU_resources#AN5275|AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders]] for details.
   
 
The expected {{HighlightParam|Phase}} {{Highlight|P}} and the expected {{HighlightParam|DFU detach request}} are indicated by device in the '''Get Phase''' answer, read (= DFU_UPLOAD) in the last alternate, with alternate id = {{Highlight|A}}, name = "{{HighlightParam|virtual}}" with phase id = {{HighlightParam|0xF1}}  with the command:
 
The expected {{HighlightParam|Phase}} {{Highlight|P}} and the expected {{HighlightParam|DFU detach request}} are indicated by device in the '''Get Phase''' answer, read (= DFU_UPLOAD) in the last alternate, with alternate id = {{Highlight|A}}, name = "{{HighlightParam|virtual}}" with phase id = {{HighlightParam|0xF1}}  with the command: