我的STM32F072V8 工作电压 3.3V。产品内置 USB 接口,该接口仅用于通过 DFU 烧录单片机程序。
BOOT0 引脚通过电阻分压电路连接到 USB 的 VBUS:接入 USB 时,BOOT0 引脚电平为 3.3V;未接入 USB 时,BOOT0 引脚接地。
进入 DFU 模式的操作流程为,设备不上电时,将 USB 连接至主机。给设备上电
我本以为在上电之前 BOOT0 引脚已经是高电平,单片机会进入 DFU 模式。
但实际并未进入 DFU 模式,在 dmesg 中可以看到如下日志:
[28936069] usb 3-13: new full-speed USB device number 49 using xhci_hcd
[28064068] usb 3-13: device descriptor read/64, error -71
[28300075] usb 3-13: device descriptor read/64, error -71
[28536067] usb 3-13: new full-speed USB device number 50 using xhci_hcd
[28664084] usb 3-13: device descriptor read/64, error -71
[28900059] usb 3-13: device descriptor read/64, error -71
[28008079] usb usb3-port13: attempt power cycle
[28660084] usb 3-13: new full-speed USB device number 51 using xhci_hcd
[28660186] usb 3-13: Device not responding to setup address.
[28868143] usb 3-13: Device not responding to setup address.
[28076066] usb 3-13: device not accepting address 51, error -71
[28204078] usb 3-13: new full-speed USB device number 52 using xhci_hcd
[28204178] usb 3-13: Device not responding to setup address.
[28412188] usb 3-13: Device not responding to setup address.
[28620100] usb 3-13: device not accepting address 52, error -71
[28620142] usb usb3-port13: unable to enumerate USB device
此时如果手动拉低 NRST 引脚,单片机复位后 DFU 就能正常启动。
我在 NRST 引脚使用 1μF 电容替代常规的 100nF 电容,延长复位保持时间,但问题依旧存在。
我查到一些资料提到 USB 的 DP 引脚需要上拉电阻,但我的硬件设计中没有添加。不过数据手册和引导程序应用笔记都说明不需要外部上拉电阻。有意思的是,STM32F072-DISCO 评估板上却焊了上拉电阻,而这块评估板进入 DFU 模式完全正常。
|
|