Difference between revisions of "How to load U-Boot with dfu-util"
[unchecked revision] | [quality revision] |
Philip Sage (talk | contribs)
m
|
Philip Sage (talk | contribs)
m
|
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.
Contents
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:
- Download phase 0x1 by ROM code is the FSBL (TF-A BL2)
- Download phase 0x0 by FSBL is the flashlayout (mandatory on STM32MP15x)
- Download phase 0x3 by FSBL is the FIP file including the SSBL image (U-Boot)
- 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
3 Identify alternate[edit]
You can also use the -l/--list option to check the alternate associated to each phase.
For example , the command result on the STM32MP15x , the ROM code is in with a USB serial boot is:
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"
The alternate is alt=1 for FSB alternate associate to phase 0x1 (see AN5275 for the coding of the alternate name).
4 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 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 ....
5 Generate an empty flashlayout[edit]
You can generate this empty flashlayout.stm32 file, which is required by the STM32MP15x TF-A, with a U-Boot mkimage by using the following Linux shell commands:
echo "" > flashlayout.tsv
mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d flashlayout.tsv flashlayout.stm32
6 The U-Boot load sequence[edit]
dfu-util -a 1 -D tf-a.bin dfu-util -a 0 -D flashlayout.stm32 dfu-util -a 3 -D fip.bin dfu-util -a 0 -e
7 Generate 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
mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d script.uimg script.stm32
Then the sequence is:
dfu-util -a 1 -D tf-a.bin dfu-util -a 0 -D script.stm32 dfu-util -a 3 -D fip.bin dfu-util -a 0 -e
8 References[edit]
- ↑ dfu-util - Device Firmware Upgrade Utilities - http://dfu-util.sourceforge.net
- ↑ 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
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 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: # Download phase {{Highlight|0x1}} by ROM code is the FSBL ([[TF-A_overview|TF-A]] BL2) # Download phase {{Highlight|0x0}} by FSBL is the flashlayout (mandatory on STM32MP15x) # 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: {{PC$}} 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 <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. For example, the command result on the STM32MP15x, the ROM code is in USB serial boot with a USB serial boot is: {{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=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={{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" The alternate is alt={{HighlightParam|1}} for {{HighlightParam|FSB}} alternate associate to phase {{Highlight|0x1}} (see [[STM32MP15 resources#AN5275|AN5275]] for the coding of the alternate name). == 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 example, the device has VID:PID={{HighlightParam|0483:df11}} and its serial number is {{HighlightParam|004100323338511634383330}}. In the following sections, you can add the '''-d"''/'''--device''' and '''-S'''/'''--serial''' options to select this specific device: {{PC$}} dfu-util {{Highlight|-d}} {{HighlightParam|0483:df11}} {{Highlight|-S}} {{HighlightParam|004100323338511634383330}} .... == Generate an empty flashlayout == You can generate this empty flashlayout.stm32 file, which is required by the STM32MP15x TF-A, with a U-Boot mkimage by using the following Linux shell commands: {{PC$}} echo "" > flashlayout.tsv {{PC$}} mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d flashlayout.tsv {{HighlightParam|flashlayout.stm32}} == The U-Boot load sequence == {{PC$}} dfu-util -a {{Highlight|1}} -D tf-a.bin {{PC$}} dfu-util -a {{Highlight|0}} -D {{HighlightParam|flashlayout.stm32}} {{PC$}} dfu-util -a {{Highlight|3}} -D fip.bin {{PC$}} dfu-util -a 0 {{Highlight|-e}} == Generate 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 script.uimg {{PC$}} mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d script.uimg {{HighlightParam|script.stm32}} Then the sequence is: {{PC$}} dfu-util -a {{Highlight|1}} -D tf-a.bin {{PC$}} dfu-util -a {{Highlight|0}} -D {{HighlightParam|script.stm32}} {{PC$}} dfu-util -a {{Highlight|3}} -D fip.bin {{PC$}} dfu-util -a 0 {{Highlight|-e}} == References ==<references/> <noinclude> [[Category:U-Boot]] {{PublicationRequestId | 20382 | 2021-06-24}}</noinclude>
Line 61: | Line 61: | ||
You can also use the '''-l'''/'''--list''' option to check the alternate associated to each phase. |
You can also use the '''-l'''/'''--list''' option to check the alternate associated to each phase. |
||
− | For example |
+ | For example the command result on the STM32MP15x with a USB serial boot is: |
{{PC$}} dfu-util -l |
{{PC$}} dfu-util -l |