DFU Mode设备实例
2026-10-23
本文链接为:http://www.usbzh.com/article/detail-1818.html ,欢迎转载,转载请附上本文链接。
描述符
------------------ Configuration Descriptor -------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0024 (36 bytes)
bNumInterfaces : 0x01 (1 Interface)
bConfigurationValue : 0x01 (Configuration 1)
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0x32 (100 mA)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00 (Interface 0)
bAlternateSetting : 0x00
bNumEndpoints : 0x00 (Default Control Pipe only)
bInterfaceClass : 0xFE (Application Specific)
bInterfaceSubClass : 0x01 (Device Firmware Upgrade)
bInterfaceProtocol : 0x02 (DFU mode)
iInterface : 0x04 (String Descriptor 4)
Language 0x0409 : "FLASH"
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00 (Interface 0)
bAlternateSetting : 0x01
bNumEndpoints : 0x00 (Default Control Pipe only)
bInterfaceClass : 0xFE (Application Specific)
bInterfaceSubClass : 0x01 (Device Firmware Upgrade)
bInterfaceProtocol : 0x02 (DFU mode)
iInterface : 0x05 (String Descriptor 5)
Language 0x0409 : "EEPROM"
----- Device Firmware Update Functional Descriptor ----
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (DFU Functional Descriptor)
bmAttributes : 0x07
Bit 7..4: reserved : 0x00
Bit 3: WillDetach : 0x00
Bit 2: ManifestTolerant : 0x01
Bit 1: CanUpload : 0x01
Bit 0: CanDownload : 0x01
wDetachTimeOut : 0x03E8 (1000 ms)
wTransferSize : 0x0040 (max 64 bytes)
bcdDFUVersion : 0x0101 (Version 1.1)
-------------------- String Descriptors -------------------
------ String Descriptor 0 ------
bLength : 0x04 (4 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language ID[0] : 0x0409 (English - United States)
------ String Descriptor 1 ------
bLength : 0x10 (16 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "TinyUSB"
------ String Descriptor 2 ------
bLength : 0x1E (30 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "TinyUSB Device"
------ String Descriptor 4 ------
bLength : 0x0C (12 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "FLASH"
------ String Descriptor 5 ------
bLength : 0x0E (14 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "EEPROM"
可以看到,有2个分区,分别为FLASH和EEPROM
C:\dfu\win64>dfu-util.exe -l
dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 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: [2717:50ed] ver=0110, devnum=52, cfg=1, intf=0, path="1-1.2.1", alt=1, name="EEPROM", serial=""
Found DFU: [2717:50ed] ver=0110, devnum=52, cfg=1, intf=0, path="1-1.2.1", alt=0, name="FLASH", serial=""
分区描述符信息是通过接口描述符索引不同的USB字符串而实现的。
测试
假如我们进行文件下载:
C:\dfu\win64>dfu-util -a 0 -D d:/a.txt
dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 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/
Warning: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release
Opening DFU capable USB device...
Device ID 2717:50ed
Device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 0101
Device returned transfer size 64
Copying data from PC to DFU device
Download [=========================] 100% 72 bytes
Download done.
DFU state(7) = dfuMANIFEST, status(0) = No error condition is present
DFU state(2) = dfuIDLE, status(0) = No error condition is present
Done!
bushouund抓包如下:
以下仅为测试,并没有执行真正的FLASH操作,所以状态都是错误的
Length Phase Data
-------- ----- --------------------------------------------- --------------------------------
CTL 80 06 0300 0000 00ff GET DESCRIPTOR
4 IN 04 03 09 04 ....
CTL 80 06 0304 0409 00ff GET DESCRIPTOR
12 IN 0c 03 46 00 4c 00 41 00 53 00 48 00 ..F.L.A.S.H.
CTL 80 06 0300 0000 00ff GET DESCRIPTOR
4 IN 04 03 09 04 ....
CTL 80 06 0303 0409 00ff GET DESCRIPTOR
6 IN 06 03 a8 00 14 00 ......
CTL a1 03 0000 0000 0006 get status
6 IN 00 00 00 00 02 00 ......
CTL 21 01 0000 0000 0040 download firmwar
64 OUT 31 32 33 34 35 36 37 38 39 41 42 43 44 45 123456789ABCDEFGHIJKLMNOPQRSTUVW
58 59 5a 61 62 63 64 65 66 67 68 69 6a 6b XYZabcdefghijklmnopqrstuvwxyz012
CTL a1 03 0000 0000 0006 get status
6 IN 00 01 00 00 04 00 ......
CTL a1 03 0000 0000 0006 get status
6 IN 00 00 00 00 05 00 ......
CTL 21 01 0001 0000 0008 download firmwar
8 OUT 33 34 35 36 37 38 39 30 34567890
CTL a1 03 0000 0000 0006 get status
6 IN 00 01 00 00 04 00 ......
CTL a1 03 0000 0000 0006 get status
6 IN 00 00 00 00 05 00 ......
CTL 21 01 0002 0000 0000 download firmwar
CTL a1 03 0000 0000 0006 get status
6 IN 00 00 00 00 07 00 ......
CTL a1 03 0000 0000 0006 get status
6 IN 00 00 00 00 02 00 ......
本文链接为:http://www.usbzh.com/article/detail-1818.html ,欢迎转载,转载请附上本文链接。
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936 USB技术交流3:1031974172
DFU





