blob: 92a7695be22094d1f85d76c100e75dff5203d444 [file] [log] [blame]
Patrick Delaunay321179e2019-10-14 09:27:59 +02001# SPDX-License-Identifier: GPL-2.0+
2
3Device Firmware Upgrade (DFU)
4
5Overview:
6
7 The Device Firmware Upgrade (DFU) allows to download and upload firmware
8 to/from U-Boot connected over USB.
9
10 U-boot follows the Universal Serial Bus Device Class Specification for
11 Device Firmware Upgrade Version 1.1 the USB forum (DFU v1.1 in www.usb.org).
12
13 U-Boot implements this DFU capability (CONFIG_DFU) with the command dfu
14 (cmd/dfu.c / CONFIG_CMD_DFU) based on:
15 - the DFU stack (common/dfu.c and common/spl/spl_dfu.c), based on the
16 USB DFU download gadget (drivers/usb/gadget/f_dfu.c)
17 - The access to mediums is done in DFU backends (driver/dfu)
18
19 Today the supported DFU backends are:
20 - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system)
21 - NAND
22 - RAM
23 - SF (serial flash)
Patrick Delaunay6015af22019-10-14 09:28:04 +020024 - MTD (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
Patrick Delaunay321179e2019-10-14 09:27:59 +020025
26 These DFU backends are also used by
27 - the dfutftp (see README.dfutftp)
28 - the thordown command (cmd/thordown.c and gadget/f_thor.c)
29
30Configuration Options:
31 CONFIG_DFU
32 CONFIG_DFU_OVER_USB
33 CONFIG_DFU_MMC
Patrick Delaunay6015af22019-10-14 09:28:04 +020034 CONFIG_DFU_MTD
Patrick Delaunay321179e2019-10-14 09:27:59 +020035 CONFIG_DFU_NAND
36 CONFIG_DFU_RAM
37 CONFIG_DFU_SF
Patrick Delaunaycb986ba2019-10-14 09:28:00 +020038 CONFIG_DFU_SF_PART
Patrick Delaunay321179e2019-10-14 09:27:59 +020039 CONFIG_CMD_DFU
40
41Environment variables:
42 the dfu command use 3 environments variables:
43 "dfu_alt_info" : the DFU setting for the USB download gadget with a comma
44 separated string of information on each alternate:
45 dfu_alt_info="<alt1>;<alt2>;....;<altN>"
46
Patrick Delaunayfebabe32019-10-14 09:28:02 +020047 when only several device are used, the format is:
48 - <interface> <dev>'='alternate list (';' separated)
49 - each interface is separated by '&'
50 dfu_alt_info=\
51 "<interface1> <dev1>=<alt1>;....;<altN>&"\
52 "<interface2> <dev2>=<altN+1>;....;<altM>&"\
53 ...\
54 "<interfaceI> <devI>=<altY+1>;....;<altZ>&"
55
Patrick Delaunay321179e2019-10-14 09:27:59 +020056 "dfu_bufsiz" : size of the DFU buffer, when absent, use
57 CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
58
59 "dfu_hash_algo" : name of the hash algorithm to use
60
61Commands:
Patrick Delaunayfebabe32019-10-14 09:28:02 +020062 dfu <USB_controller> [<interface> <dev>] list
Patrick Delaunay321179e2019-10-14 09:27:59 +020063 list the alternate device defined in "dfu_alt_info"
64
Patrick Delaunayfebabe32019-10-14 09:28:02 +020065 dfu <USB_controller> [<interface> <dev>]
Patrick Delaunay321179e2019-10-14 09:27:59 +020066 start the dfu stack on the USB instance with the selected medium
67 backend and use the "dfu_alt_info" variable to configure the
68 alternate setting and link each one with the medium
69 The dfu command continue until receive a ^C in console or
70 a DFU detach transaction from HOST.
71
72 The possible values of <interface> are :
73 (with <USB controller> = 0 in the dfu command example)
74
75 "mmc" (for eMMC and SD card)
76 cmd: dfu 0 mmc <dev>
77 each element in "dfu_alt_info" =
78 <name> raw <offset> <size> raw access to mmc device
79 <name> part <dev> <part_id> raw acces to partition
80 <name> fat <dev> <part_id> file in FAT partition
81 <name> ext4 <dev> <part_id> file in EXT4 partition
82
83 with <partid> is the GPT or DOS partition index
84
85 "nand" (raw slc nand device)
86 cmd: dfu 0 nand <dev>
87 each element in "dfu_alt_info" =
88 <name> raw <offset> <size> raw access to mmc device
89 <name> part <dev> <part_id> raw acces to partition
90 <name> partubi <dev> <part_id> raw acces to ubi partition
91
92 with <partid> is the MTD partition index
93
94 "ram"
95 cmd: dfu 0 ram <dev>
96 (<dev> is not used for RAM target)
97 each element in "dfu_alt_info" =
98 <name> ram <offset> <size> raw access to ram
99
100 "sf" (serial flash : NOR)
101 cmd: dfu 0 sf <dev>
102 each element in "dfu_alt_info" =
103 <name> ram <offset> <size> raw access to sf device
Patrick Delaunaycb986ba2019-10-14 09:28:00 +0200104 <name> part <dev> <part_id> raw acces to partition
105 <name> partubi <dev> <part_id> raw acces to ubi partition
106
107 with <partid> is the MTD partition index
Patrick Delaunay321179e2019-10-14 09:27:59 +0200108
Patrick Delaunay6015af22019-10-14 09:28:04 +0200109 "mtd" (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
110 cmd: dfu 0 mtd <dev>
111 with <dev> the mtd identifier as defined in mtd command
112 (nand0, nor0, spi-nand0,...)
113 each element in "dfu_alt_info" =
114 <name> raw <offset> <size> raw access to mtd device
Patrick Delaunayd5640f72019-10-14 09:28:05 +0200115 <name> part <dev> <part_id> raw acces to partition
116 <name> partubi <dev> <part_id> raw acces to ubi partition
117
118 with <partid> is the MTD partition index
Patrick Delaunay6015af22019-10-14 09:28:04 +0200119
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200120 <interface> and <dev> are absent:
121 the dfu command to use multiple devices
122 cmd: dfu 0 list
123 cmd: dfu 0
124 "dfu_alt_info" variable provides the list of <interface> <dev> with
125 alternate list separated by '&' with the same format for each <alt>
126 mmc <dev>=<alt1>;....;<altN>
127 nand <dev>=<alt1>;....;<altN>
128 ram <dev>=<alt1>;....;<altN>
129 sf <dev>=<alt1>;....;<altN>
Patrick Delaunay6015af22019-10-14 09:28:04 +0200130 mtd <dev>=<alt1>;....;<altN>
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200131
132
Patrick Delaunay321179e2019-10-14 09:27:59 +0200133Host tools:
134 When U-Boot runs the dfu stack, the DFU host tools can be used
135 to send/receive firmwares on each configurated alternate.
136
137 For example dfu-util is a host side implementation of the DFU 1.1
138 specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
139
140Usage:
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200141 Example 1: firmware located in eMMC or SD card, with:
Patrick Delaunay321179e2019-10-14 09:27:59 +0200142 - alternate 1 (alt=1) for SPL partition (GPT partition 1)
143 - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
144
145 The U-Boot configuration is:
146
147 U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2"
148
149 U-Boot> dfu 0 mmc 0 list
150 DFU alt settings list:
151 dev: eMMC alt: 0 name: spl layout: RAW_ADDR
152 dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR
153
154 Boot> dfu 0 mmc 0
155
156 On the Host side:
157
158 list the available alternate setting:
159
160 $> dfu-util -l
161 dfu-util 0.9
162
163 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
164 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
165 This program is Free Software and has ABSOLUTELY NO WARRANTY
166 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
167
168 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
169 alt=1, name="u-boot", serial="003A00203438510D36383238"
170 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
171 alt=0, name="spl", serial="003A00203438510D36383238"
172
173 To download to U-Boot, use -D option
174
175 $> dfu-util -a 0 -D u-boot-spl.bin
176 $> dfu-util -a 1 -D u-boot.bin
177
178 To upload from U-Boot, use -U option
179
180 $> dfu-util -a 0 -U u-boot-spl.bin
181 $> dfu-util -a 1 -U u-boot.bin
182
183 To request a DFU detach and reset the USB connection:
184 $> dfu-util -a 0 -e -R
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200185
186
187 Example 2: firmware located in NOR (sf) and NAND, with:
188 - alternate 1 (alt=1) for SPL partition (NOR GPT partition 1)
189 - alternate 2 (alt=2) for U-Boot partition (NOR GPT partition 2)
190 - alternate 3 (alt=3) for U-Boot-env partition (NOR GPT partition 3)
191 - alternate 4 (alt=4) for UBI partition (NAND GPT partition 1)
192
193 U-Boot> env set dfu_alt_info \
194 "sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \
195 u-boot-env part 0 3&nand 0=UBI partubi 0,1"
196
197 U-Boot> dfu 0 list
198
199 DFU alt settings list:
200 dev: SF alt: 0 name: spl layout: RAW_ADDR
201 dev: SF alt: 1 name: ssbl layout: RAW_ADDR
202 dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
203 dev: NAND alt: 3 name: UBI layout: RAW_ADDR
204
205 U-Boot> dfu 0
206
207 $> dfu-util -l
208 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
209 intf=0, alt=3, name="UBI", serial="002700333338511934383330"
210 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
211 intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330"
212 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
213 intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
214 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
215 intf=0, alt=0, name="spl", serial="002700333338511934383330"
Patrick Delaunayd5640f72019-10-14 09:28:05 +0200216
217 Same example with MTD backend
218
219 U-Boot> env set dfu_alt_info \
220 "mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
221 "mtd nand0=UBI partubi 1"
222
223 U-Boot> dfu 0 list
224 using id 'nor0,0'
225 using id 'nor0,1'
226 using id 'nor0,2'
227 using id 'nand0,0'
228 DFU alt settings list:
229 dev: MTD alt: 0 name: spl layout: RAW_ADDR
230 dev: MTD alt: 1 name: u-boot layout: RAW_ADDR
231 dev: MTD alt: 2 name: u-boot-env layout: RAW_ADDR
232 dev: MTD alt: 3 name: UBI layout: RAW_ADDR