当前位置:网站首页>STM32G0 USB DFU 升级校验出错-2
STM32G0 USB DFU 升级校验出错-2
2022-07-02 17:23:00 【gdut_llkkyy】
一、我遇到的问题
1.1 概述
需要用stm32g0 系列单片机实现固件升级功能,选择的升级方案是STM32 USB DFU 方案。由于我们需要做产品和固件匹配,还有一些其他功能,所以没有选择内置的boot,而是自己写boot,里面实现 usb dfu 功能。pc 客户端使用 st 官方提供的DfuSeDemo 。
1.2 遇到的问题
按照网上的流程,利用官方的cubemx 生产了boot 工程 ,配置了flash 的读写api,boot 就完成了。测试的时候发现,在某些电脑上升级固件时,随机出现校验出错。提示: matching not good . first difference at address ... 。 有些电脑出现得很频繁,有些电脑,出现的概率很低。
二、硬件连接
2.1 D+ D- 连接

2.2 pin 供电
USB USB-PD, USB-MD 连接的 IO 需要通过VDDIO2 供电,VDDIO2 需要提供一个1.6 ->3.6v的电压
2.3 VDDUSB IO
在AN2606 文档中,提到VDDUSB IO 必须接到3.3v,但是我没找到VDDUSB IO。
三、利用出厂boot 验证
boot 工程是根据官方的工具生成加轻微修改的,电路连接也比较简单,但是还是随机出错校验出错,会不会是这个单片机的usb 本身性能有问题呢?为了验证这款mcu 的usb 性能,我决定用官方的usb dfu boot 验证。
这里选择的pc 上位机是官网最新版的 STM32CubeProgrammer ,如果它都出问题,估计大概率是mcu 本身的问题了。
3.1 mcu 如何进入内置usb dfu boot ?
文档AN2606 提到 The STM32G0B1xx/0C1xx bootloader is activated by applying Pattern 11 , STM32G0B1 系列单片机,使用Pattern 11 进入内置 Boot模式。Pattern 11 定义如下:
如上图所示,Pattern11 也有几种方式,可以选择,我选择了第二个方式:先通过 STM32CubeProgrammer 将mcu 中的nBoot1(bit) 设置为1,nBOOT0_SEL(bit) 设置为0 ,然后将mcu 的 Boot0(pin) 接3.3v。上电重启,接入usb线,进入boot模式;
3.2 升级验证
以 STM32CubeProgrammer 为上位机,在不同pc 上升级验证了,都没出现校验出错。
3.3 本轮总结
内置boot 升级没异常,说明mcu 本身的usb 电路是没问题。还是要找自己的原因。原因可能是下面两个:
- 自己搭建的boot 有问题。
- 选择的升级客户端
DfuSeDemo有问题。
四、小插曲,客户端无法识别
4.1 遇到的问题
安装使用了 STM32CubeProgrammer 之后,再使用DfuSeDemo ,发现DfuSeDemo 不能识别出设备( STM Device in DFU Mode ) 。
4.2 问题查找
打开我的电脑-> 设备管理器,发现在通用串行总线设备下面出现: STM32 Download Firmware Update 这个设备。
4.3 解决
右键点击 STM32 Download Firmware Update , 选择卸载设备,并删除设备驱动程序。

将usb线拔出设备,然后再插入设备,DfuSeDemo 重新能识别出设备。
五、问题解决
检查了boot 工程的各个模块代码,都没发现异常。后面发现STM32G0 最新的驱动库是V1.5.1 ,而我用的是V1.5.0 。更新了最新的驱动库,问题解决了。比对了两个版本的代码,发现在stm32g0xx_ll_usb.c 这个文件作了大量的修改,这个刚好是usb的驱动函数库。暂时没时间,知识储备也不够,有机会再详细分析一下这个文件的差异。
边栏推荐
- 呆错图床系统源码图片CDN加速与破J防盗链功能
- Singapore summer tourism strategy: play Singapore Sentosa Island in one day
- 新加坡暑假旅遊攻略:一天玩轉新加坡聖淘沙島
- StretchDIBits函数
- Implementation shadow introduction
- 问题包含哪些环节
- Crypto usage in nodejs
- Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
- AI开发调试系列第二弹:多机分布式调测探索之旅
- Matlab中弧度转角度、角度转弧度
猜你喜欢

Thoroughly understand the point cloud processing tutorial based on open3d!

How to clean up discarded PVs and their corresponding folders

【每日一题】第一天
![[Northwestern Polytechnic University] information sharing of the first and second postgraduate examinations](/img/15/298ea6f7367741e1e085007c498e51.jpg)
[Northwestern Polytechnic University] information sharing of the first and second postgraduate examinations

任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过

工业软件讲堂-三维CAD设计软件的核心技术解析----讲坛第二次讲座

揭秘得物客服IM全链路通信过程

Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey

Singapore summer tourism strategy: play Singapore Sentosa Island in one day

科技公司不同人对Bug的反应 | 每日趣闻
随机推荐
Use MNIST in tensorflow 2_ 784 data set for handwritten digit recognition
Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
[Yugong series] July 2022 go teaching course 001 introduction to go language premise
Web version 3D visualization tool, 97 things programmers should know, AI frontier paper | information daily # 2022.07.01
300+ documents! This article explains the latest progress of multimodal learning based on transformer
Rte11 interrupt decoupling function
Websocket of Web real-time communication technology
Detailed explanation of cjson usage
Competence of product manager
How to clean up discarded PVs and their corresponding folders
Singapore summer tourism strategy: play Singapore Sentosa Island in one day
Installation of thingsboard, an open source IOT platform
options should NOT have additional properties
问题包含哪些环节
The second bullet of AI development and debugging series: the exploration journey of multi machine distributed debugging
27: Chapter 3: develop Passport Service: 10: [registration / login] interface: after the registration / login is OK, save the user session information (uid, utoken) to redis and cookies; (one main poi
The official docker image running container in version 1.5.1 can be set to use MySQL 8 driver?
开源物联网平台ThingsBoard的安装
科技公司不同人对Bug的反应 | 每日趣闻