当前位置: 首页 > 技术文章 > 正文

近期使用了ST公司的STM32单片机,遇到了奇怪的现象:每个单片机只能下载一次程序,之后的每次操作都会出现Flash写入错误,更换4,5次单片机也是如此,如下图。

Download-Error

窗口中的打印信息为

JLink info:
------------
DLL: V4.40c, compiled Jan 24 2012 09:30:33
Firmware: J-Link ARM V8 compiled Dec 6 2011 18:57:44
Hardware: V8.00
S/N : 20100214
Feature(s) : RDI,FlashDL,FlashBP,JFlash,GDBFull

* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: TPIU fitted.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: Found Cortex-M3 r1p1, Little endian.
ROMTableAddr = 0xE00FF003
* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: TPIU fitted.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: Found Cortex-M3 r1p1, Little endian.

Target info:
------------
Device: STM32F103T8
VTarget = 3.028V
State of Pins:
TCK: 0, TDI: 0, TDO: 0, TMS: 0, TRES: 1, TRST: 1
Hardware-Breakpoints: 6
Software-Breakpoints: 8192
Watchpoints: 4
JTAG speed: 2000 kHz

Erase Done.
Programming Failed!

笔者使用的下载方式是SWD,从打印信息中可以看到,JLink成功地擦除了单片机的Flash,但写入失败。然而,在这款产品的第一版中,并没有出现这样的问题。较大的区别是,第一版所用型号为STM32F103C8T6,第二版为了缩小尺寸选用了STM32F103T8U6。查看Datasheet,认为这里两款芯片除了封装尺寸,IO数目不同以外,在配置上并没有什么差异。

尝试诊断问题,发现Flash下载配置选项似乎不正常,如下图:

Target-Driver-Setup

根据已有的产品开发经验,如果Flash擦除不完整,很容易出现问题。于是勾选“Erase Full Chip”选项,如下图。

Erase-Full-Chip

再次下载程序,终于成功了,窗口中出现了正确的打印信息

JLink info:
------------
DLL: V4.40c, compiled Jan 24 2012 09:30:33
Firmware: J-Link ARM V8 compiled Dec 6 2011 18:57:44
Hardware: V8.00
S/N : 20100214
Feature(s) : RDI,FlashDL,FlashBP,JFlash,GDBFull

* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: TPIU fitted.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: Found Cortex-M3 r1p1, Little endian.
ROMTableAddr = 0xE00FF003
* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: TPIU fitted.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: Found Cortex-M3 r1p1, Little endian.

Target info:
------------
Device: STM32F103T8
VTarget = 3.028V
State of Pins:
TCK: 0, TDI: 0, TDO: 0, TMS: 0, TRES: 1, TRST: 1
Hardware-Breakpoints: 6
Software-Breakpoints: 8192
Watchpoints: 4
JTAG speed: 2000 kHz

Full Chip Erase Done.
Programming Done.
Verify OK.

STM32单片机只能下载一次程序的问题:目前有2 条评论

  1. 沙发
    wisepragma

    下载之后禁用了SWD接口,第二次就下载不了了

    2017-06-17 04:33
    • lics

      跟我的情况不太一样

      2017-06-17 04:34