解决方案:
1、查看魔术棒 “Debug”里面是否选择了JLINK
2、确认JLINK连接正常(√),但是找不到设备(❌).
选择JTAG端口的时候,报错:
JLink info:
------------
DLL: V6.30h, compiled Mar 16 2018 18:02:51
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N : 66663203
Feature(s) : GDB, RDI, FlashBP, FlashDL, JFlash, RDDI
* JLink Info: TotalIRLen = ?, IRPrint = 0x..000000000000000000000000
* JLink Info: STM32 (connect): Can not attach to CPU. Trying connect under reset.
* JLink Info: TotalIRLen = ?, IRPrint = 0x..000000000000000000000000
* JLink Info: TotalIRLen = ?, IRPrint = 0x..000000000000000000000000
* JLink Info: STM32 (connect): Can not attach to CPU. Trying connect under reset.
* JLink Info: TotalIRLen = ?, IRPrint = 0x..000000000000000000000000
***JLink Error: STM32: Connecting to CPU via connect under reset failed.
Error: Flash Download failed - Target DLL has been cancelled
Flash Load finished at 17:41:07
选择SWD端口的时候报错:
JLink info:
------------
DLL: V6.30h, compiled Mar 16 2018 18:02:51
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N : 66663203
Feature(s) : GDB, RDI, FlashBP, FlashDL, JFlash, RDDI
* JLink Info: STM32 (connect): Can not attach to CPU. Trying connect under reset.
* JLink Info: STM32 (connect): Can not attach to CPU. Trying connect under reset.
***JLink Error: STM32: Connecting to CPU via connect under reset failed.
Error: Flash Download failed - Target DLL has been cancelled
Flash Load finished at 17:42:33
问题原因:
1、确定接线,我用的是JLINK v9仿真器
自己可以选择接线的方式,我自己用SWD,只用接四根线
1:3.3v
7:swdio
9:swclk
20:GND
然后端口确定选择正确,设备就可以被找到。
下载正常。
JLink info:
------------
DLL: V6.30h, compiled Mar 16 2018 18:02:51
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N : 66663203
Feature(s) : GDB, RDI, FlashBP, FlashDL, JFlash, RDDI
* JLink Info: Found SW-DP with ID 0x2BA01477
* JLink Info: Found SW-DP with ID 0x2BA01477
* JLink Info: Scanning AP map to find all available APs
* JLink Info: AP[1]: Stopped AP scan as end of AP map has been reached
* JLink Info: AP[0]: AHB-AP (IDR: 0x24770011)
* JLink Info: Iterating through AP map to find AHB-AP to use
* JLink Info: AP[0]: Core found
* JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
* JLink Info: CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
* JLink Info: Found Cortex-M4 r0p1, Little endian.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: CoreSight components:
* JLink Info: ROMTbl[0] @ E00FF000
* JLink Info: ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
* JLink Info: ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
* JLink Info: ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
* JLink Info: ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
* JLink Info: ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
* JLink Info: ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
ROMTableAddr = 0xE00FF000
* JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
* JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
Target info:
------------
Device: STM32F401RETx
VTarget = 3.235V
State of Pins:
TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 0
Hardware-Breakpoints: 6
Software-Breakpoints: 8192
Watchpoints: 4
JTAG speed: 4000 kHz
Erase Done.
Programming Done.
Verify OK.
Flash Load finished at 17:55:06