flash download failed 之STLINK

STLINK_1

使用STLINK无法下载程序,提示如上图所示。

解决方案:如下图所示配置

stlink-1

其它需要配置的地方,和JLINK一样。

使用STLINK时,需要注意一下上图中的圆圈部分。

这个地方有四个选项,分别是Auto detect、HW RESET、SYSRESETREQ、VECTRESET。默认是Auto detcet,用STLINK需要改成HW RESET。

这四个选项的定义:

Reset — HW RESET performs a hardware reset by asserting the hardware reset (HW RESET) signal.

Reset — SYSRESETREQ performs a software reset by setting the SYSRESETREQ bit. The Cortex-M core and on-chip peripherals are reset.

Reset — VECTRESET performs a software reset by setting the VECTRESET bit. Only the Cortex-M core is reset. The on-chip peripherals are not affected. For some Cortex-M devices, VECTRESET is the only way to reset the core. VECTRESET is not supported on Cortex-M0 and Cortex-M1 cores.

Reset — Autodetect selects one of the above reset methods based on the target device. The SYSRESETREQ method is used if an unknown device is detected.

HW RESET意思就是硬件复位,SYSRESETREQ就是只给M内核和片上外设复位,VECTRSET就是只给M核复位。Auto detect就是自动选择上面的三个中的一个复位。(这段话无法理解,不要紧,以后会理解的)