blob: 96bced39d837d9c01182c164b78da21d98092b8a [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
115
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200116 <interface> and <dev> are absent:
117 the dfu command to use multiple devices
118 cmd: dfu 0 list
119 cmd: dfu 0
120 "dfu_alt_info" variable provides the list of <interface> <dev> with
121 alternate list separated by '&' with the same format for each <alt>
122 mmc <dev>=<alt1>;....;<altN>
123 nand <dev>=<alt1>;....;<altN>
124 ram <dev>=<alt1>;....;<altN>
125 sf <dev>=<alt1>;....;<altN>
Patrick Delaunay6015af22019-10-14 09:28:04 +0200126 mtd <dev>=<alt1>;....;<altN>
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200127
128
Patrick Delaunay321179e2019-10-14 09:27:59 +0200129Host tools:
130 When U-Boot runs the dfu stack, the DFU host tools can be used
131 to send/receive firmwares on each configurated alternate.
132
133 For example dfu-util is a host side implementation of the DFU 1.1
134 specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
135
136Usage:
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200137 Example 1: firmware located in eMMC or SD card, with:
Patrick Delaunay321179e2019-10-14 09:27:59 +0200138 - alternate 1 (alt=1) for SPL partition (GPT partition 1)
139 - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
140
141 The U-Boot configuration is:
142
143 U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2"
144
145 U-Boot> dfu 0 mmc 0 list
146 DFU alt settings list:
147 dev: eMMC alt: 0 name: spl layout: RAW_ADDR
148 dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR
149
150 Boot> dfu 0 mmc 0
151
152 On the Host side:
153
154 list the available alternate setting:
155
156 $> dfu-util -l
157 dfu-util 0.9
158
159 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
160 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
161 This program is Free Software and has ABSOLUTELY NO WARRANTY
162 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
163
164 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
165 alt=1, name="u-boot", serial="003A00203438510D36383238"
166 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
167 alt=0, name="spl", serial="003A00203438510D36383238"
168
169 To download to U-Boot, use -D option
170
171 $> dfu-util -a 0 -D u-boot-spl.bin
172 $> dfu-util -a 1 -D u-boot.bin
173
174 To upload from U-Boot, use -U option
175
176 $> dfu-util -a 0 -U u-boot-spl.bin
177 $> dfu-util -a 1 -U u-boot.bin
178
179 To request a DFU detach and reset the USB connection:
180 $> dfu-util -a 0 -e -R
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200181
182
183 Example 2: firmware located in NOR (sf) and NAND, with:
184 - alternate 1 (alt=1) for SPL partition (NOR GPT partition 1)
185 - alternate 2 (alt=2) for U-Boot partition (NOR GPT partition 2)
186 - alternate 3 (alt=3) for U-Boot-env partition (NOR GPT partition 3)
187 - alternate 4 (alt=4) for UBI partition (NAND GPT partition 1)
188
189 U-Boot> env set dfu_alt_info \
190 "sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \
191 u-boot-env part 0 3&nand 0=UBI partubi 0,1"
192
193 U-Boot> dfu 0 list
194
195 DFU alt settings list:
196 dev: SF alt: 0 name: spl layout: RAW_ADDR
197 dev: SF alt: 1 name: ssbl layout: RAW_ADDR
198 dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
199 dev: NAND alt: 3 name: UBI layout: RAW_ADDR
200
201 U-Boot> dfu 0
202
203 $> dfu-util -l
204 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
205 intf=0, alt=3, name="UBI", serial="002700333338511934383330"
206 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
207 intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330"
208 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
209 intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
210 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
211 intf=0, alt=0, name="spl", serial="002700333338511934383330"