blob: d1ef7e406455a98b86f6f330b33f71fafbf80507 [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)
24
25 These DFU backends are also used by
26 - the dfutftp (see README.dfutftp)
27 - the thordown command (cmd/thordown.c and gadget/f_thor.c)
28
29Configuration Options:
30 CONFIG_DFU
31 CONFIG_DFU_OVER_USB
32 CONFIG_DFU_MMC
33 CONFIG_DFU_NAND
34 CONFIG_DFU_RAM
35 CONFIG_DFU_SF
Patrick Delaunaycb986ba2019-10-14 09:28:00 +020036 CONFIG_DFU_SF_PART
Patrick Delaunay321179e2019-10-14 09:27:59 +020037 CONFIG_CMD_DFU
38
39Environment variables:
40 the dfu command use 3 environments variables:
41 "dfu_alt_info" : the DFU setting for the USB download gadget with a comma
42 separated string of information on each alternate:
43 dfu_alt_info="<alt1>;<alt2>;....;<altN>"
44
Patrick Delaunayfebabe32019-10-14 09:28:02 +020045 when only several device are used, the format is:
46 - <interface> <dev>'='alternate list (';' separated)
47 - each interface is separated by '&'
48 dfu_alt_info=\
49 "<interface1> <dev1>=<alt1>;....;<altN>&"\
50 "<interface2> <dev2>=<altN+1>;....;<altM>&"\
51 ...\
52 "<interfaceI> <devI>=<altY+1>;....;<altZ>&"
53
Patrick Delaunay321179e2019-10-14 09:27:59 +020054 "dfu_bufsiz" : size of the DFU buffer, when absent, use
55 CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
56
57 "dfu_hash_algo" : name of the hash algorithm to use
58
59Commands:
Patrick Delaunayfebabe32019-10-14 09:28:02 +020060 dfu <USB_controller> [<interface> <dev>] list
Patrick Delaunay321179e2019-10-14 09:27:59 +020061 list the alternate device defined in "dfu_alt_info"
62
Patrick Delaunayfebabe32019-10-14 09:28:02 +020063 dfu <USB_controller> [<interface> <dev>]
Patrick Delaunay321179e2019-10-14 09:27:59 +020064 start the dfu stack on the USB instance with the selected medium
65 backend and use the "dfu_alt_info" variable to configure the
66 alternate setting and link each one with the medium
67 The dfu command continue until receive a ^C in console or
68 a DFU detach transaction from HOST.
69
70 The possible values of <interface> are :
71 (with <USB controller> = 0 in the dfu command example)
72
73 "mmc" (for eMMC and SD card)
74 cmd: dfu 0 mmc <dev>
75 each element in "dfu_alt_info" =
76 <name> raw <offset> <size> raw access to mmc device
77 <name> part <dev> <part_id> raw acces to partition
78 <name> fat <dev> <part_id> file in FAT partition
79 <name> ext4 <dev> <part_id> file in EXT4 partition
80
81 with <partid> is the GPT or DOS partition index
82
83 "nand" (raw slc nand device)
84 cmd: dfu 0 nand <dev>
85 each element in "dfu_alt_info" =
86 <name> raw <offset> <size> raw access to mmc device
87 <name> part <dev> <part_id> raw acces to partition
88 <name> partubi <dev> <part_id> raw acces to ubi partition
89
90 with <partid> is the MTD partition index
91
92 "ram"
93 cmd: dfu 0 ram <dev>
94 (<dev> is not used for RAM target)
95 each element in "dfu_alt_info" =
96 <name> ram <offset> <size> raw access to ram
97
98 "sf" (serial flash : NOR)
99 cmd: dfu 0 sf <dev>
100 each element in "dfu_alt_info" =
101 <name> ram <offset> <size> raw access to sf device
Patrick Delaunaycb986ba2019-10-14 09:28:00 +0200102 <name> part <dev> <part_id> raw acces to partition
103 <name> partubi <dev> <part_id> raw acces to ubi partition
104
105 with <partid> is the MTD partition index
Patrick Delaunay321179e2019-10-14 09:27:59 +0200106
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200107 <interface> and <dev> are absent:
108 the dfu command to use multiple devices
109 cmd: dfu 0 list
110 cmd: dfu 0
111 "dfu_alt_info" variable provides the list of <interface> <dev> with
112 alternate list separated by '&' with the same format for each <alt>
113 mmc <dev>=<alt1>;....;<altN>
114 nand <dev>=<alt1>;....;<altN>
115 ram <dev>=<alt1>;....;<altN>
116 sf <dev>=<alt1>;....;<altN>
117
118
Patrick Delaunay321179e2019-10-14 09:27:59 +0200119Host tools:
120 When U-Boot runs the dfu stack, the DFU host tools can be used
121 to send/receive firmwares on each configurated alternate.
122
123 For example dfu-util is a host side implementation of the DFU 1.1
124 specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
125
126Usage:
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200127 Example 1: firmware located in eMMC or SD card, with:
Patrick Delaunay321179e2019-10-14 09:27:59 +0200128 - alternate 1 (alt=1) for SPL partition (GPT partition 1)
129 - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
130
131 The U-Boot configuration is:
132
133 U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2"
134
135 U-Boot> dfu 0 mmc 0 list
136 DFU alt settings list:
137 dev: eMMC alt: 0 name: spl layout: RAW_ADDR
138 dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR
139
140 Boot> dfu 0 mmc 0
141
142 On the Host side:
143
144 list the available alternate setting:
145
146 $> dfu-util -l
147 dfu-util 0.9
148
149 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
150 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
151 This program is Free Software and has ABSOLUTELY NO WARRANTY
152 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
153
154 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
155 alt=1, name="u-boot", serial="003A00203438510D36383238"
156 Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
157 alt=0, name="spl", serial="003A00203438510D36383238"
158
159 To download to U-Boot, use -D option
160
161 $> dfu-util -a 0 -D u-boot-spl.bin
162 $> dfu-util -a 1 -D u-boot.bin
163
164 To upload from U-Boot, use -U option
165
166 $> dfu-util -a 0 -U u-boot-spl.bin
167 $> dfu-util -a 1 -U u-boot.bin
168
169 To request a DFU detach and reset the USB connection:
170 $> dfu-util -a 0 -e -R
Patrick Delaunayfebabe32019-10-14 09:28:02 +0200171
172
173 Example 2: firmware located in NOR (sf) and NAND, with:
174 - alternate 1 (alt=1) for SPL partition (NOR GPT partition 1)
175 - alternate 2 (alt=2) for U-Boot partition (NOR GPT partition 2)
176 - alternate 3 (alt=3) for U-Boot-env partition (NOR GPT partition 3)
177 - alternate 4 (alt=4) for UBI partition (NAND GPT partition 1)
178
179 U-Boot> env set dfu_alt_info \
180 "sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \
181 u-boot-env part 0 3&nand 0=UBI partubi 0,1"
182
183 U-Boot> dfu 0 list
184
185 DFU alt settings list:
186 dev: SF alt: 0 name: spl layout: RAW_ADDR
187 dev: SF alt: 1 name: ssbl layout: RAW_ADDR
188 dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
189 dev: NAND alt: 3 name: UBI layout: RAW_ADDR
190
191 U-Boot> dfu 0
192
193 $> dfu-util -l
194 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
195 intf=0, alt=3, name="UBI", serial="002700333338511934383330"
196 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
197 intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330"
198 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
199 intf=0, alt=1, name="u-boot", serial="002700333338511934383330"
200 Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\
201 intf=0, alt=0, name="spl", serial="002700333338511934383330"