DFU
+ -

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

0 篇笔记 写笔记

USB-C/TYPE-C的角色分类及定义
USB总线是一个主从总线,在一条USB总线中,只能有一个USB主机,其余设备都是从机。USB总线中两个设备通过USB总线连接之前,其主从关系是一般是确定的(OGT除外)。如USB的下行端口(DownStreaming Face Port,DFP)一般为主机,而而USB的上行端口(UpStreami......
DFU 术语
缩写英文中文DFUDevice Firmware Upgrade设备固件更新FirmwareExecutable software stored in a write-able, nonvolatile memory on a USB device存储在USB设备上......
DFU 介绍
购买了 USB 设备的用户需要能够在制造商提供的改进版本中升级这些设备的固件。DFU就是完成该任务的机制。任何类型的 USB 设备都可以通过支持本文档中指定的要求来利用此功能。本文档重点介绍为已在现场部署的设备安装产品增强功能和补丁。固件升级功能的其他潜在用途超出了本文档的范围。由于设备同时......
DFU 固件更新过程
完成实现固件升级可以分为4个不同阶段。1.枚举:设备把自身的一些特性告知主机,嵌入在设备正常运行描述符中的一个DFU类接口描述符和相关的函数符能够完成这个目的,并且能够为通过控制管道的类专用的请求提供目标。2.DFU枚举:主机和设备同意开始固件升级,主机向设备发出USB复位,设备发出第二个描述符......
DFU 类特定请求
DFU类特定请求用于完成升级操作。 下表总结了 DFU 类特定的请求。RequestRequest codeRequest descriptionDFU_DETACH0X00请求设备离开DFU模式,进入应用程序DFU_DNLOAD0x01请求Host主机端数据发送......
DFU 运行时接口描述符
因为DFU仅使用控制端点故不存在端点描述符。 这样主机提供了足够的信息来识别设备能够执行固件升级操作。 它还提供了通过默认控制管道启动此类操作的方法。DFU 类接口通常是为每个运行时配置枚举的最后一个接口。但是,并不要求此接口占据任何特定位置。DFU 接口描述符格式偏移字段长度值描......
DFU 运行时功能描述符(Device Firmware Update Functional Descriptor)
运行时DFU功能描述符全称Run-Time DFU Functional Descriptor或 Device Firmware Update Functional Descriptor。描述符对于运行时和 DFU 模式描述符集是相同的运行时DFU 功能描述符格式偏移字段长度值描述......
DFU 模式配置描述符
DFU模式配置描述符与USB规范描述的标准配置描述符相同,但bNumInterfaces字段必须包值01h。偏移量名称大小说明0bLength1描述符长度(9字节)1bDescriptorType1描述符类型(配置描述符为0x02)2wTotalLe......
DFU 运行时
在正常运行时操作期间,设备会公开其正常的描述符集。但是,在每个支持DFU的运行时配置中插入了以下附加描述符:运行时DFU特定类接口描述符运行时功能描述符运行时描述符集公开设备的正常运行时设备描述符和配置描述符。支持DFU的每个配置的配置描述符的bNumInterfaces字段增加1,以适应运行......
UVC彩色摄像头与红外(IR)摄像头相机
常见的UVC摄像头叫彩色相机,是通过摄像头镜头将捕捉的彩色画面进行感光,数据压缩,再通过USB线缆传递给我们的主机,通过我们普通的相机应用软件打开该彩色相机,就可以实时的查看它的彩色画面了。我们经常见到的UVC摄像头基本上全是这类相机。不过,现实中还有一种特殊的相机,它不是捕捉彩色画面的,而是通过......
USB PD3.1进入与退出EPR Mode的程序
从USB PD3.1开始,支持EPR模式,故在进行协商时:第一步:明确PD连接此阶段,Source/Sink会确认双方是否都有宣告支持EPR Mode:Source/Sink,需要先建立Explicit PD Contract。在Source Capabilities与Request Mess......
Android手机USB Accessory Mode模式
一、模式定义与特点==‌USB Accessory Mode‌== 是 Android 系统的一种特殊 USB 通信模式,其核心特性包括:==‌角色分配‌== 外部配件(如读卡器、传感器)作为 ==‌USB Host‌==(主机),......
NCM GetCrcMode
GET_CRC_MODE 请求格式字段值描述bmRequestType10100001B请求类型:• 位7:1 = 设备到主机• 位6-5:00 = 标准请求• 位4:0 = 主机到设备• 位3-0:0001 = 接口bRequestGET_CRC_MODE请求代码......
NCM SetCrcMode
SET_CRC_MODE 请求格式字段值描述bmRequestType00100001B请求类型:• 位7:0 = 主机到设备• 位6-5:00 = 标准请求• 位4:0 = 主机到设备• 位3-0:0001 = 接口bRequestSET_CRC_MODE请求代码......
进入Compliance Mode(合规模式)的三个必要条件
条件内容含义条件1360ms 定时器超时Polling.LFPS 握手阶段耗尽了规定等待时间,没有得到期望的响应条件2不满足转入 Polling.RxEQ 的条件比如没有检测到对方发送的 LFPS 信号,或信号质量不足以进入下一阶段条件3是本次上电复位后的首......
关注公众号
  • HID人机交互
  • Linux&USB
  • UAC音频
  • CDC
  • TYPE-C
  • USB规范
  • USB大容量存储
  • USB百科
  • USB周边
  • UVC摄像头
  • Windows系统USB
  • USB资源
  • 音视频博客
  • 取消
    感谢您的支持,我会继续努力的!
    扫码支持
    扫码打赏,你说多少就多少

    打开支付宝扫一扫,即可进行扫码打赏哦

    您的支持,是我们前进的动力!