I cannot debug with J-Link

I am using PlatformIO in vs Code.
I want to do digging using J-link.

My platformio.ini looks like this:

src_dir = Src
lib_dir = Middlewares/ST
include_dir = Inc/

;platform = https://github.com/platformio/platform-ststm32.git
platform = ststm32
board = genericSTM32F103VE
framework = stm32cube
build_type = debug
;debug_tool = custom
debug_tool = jlink
; SWD interface
upload_protocol = jlink

And the TERMINAL output is:

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.1% (used 44 bytes from 65536 bytes)
Flash: [ ] 0.6% (used 3144 bytes from 524288 bytes)
Building .pio\build\genericSTM32F103VE\firmware.bin
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = jlink
Uploading .pio\build\genericSTM32F103VE\firmware.bin
SEGGER J-Link Commander V7.20 (Compiled Apr 28 2021 17:35:36)
DLL version V7.20, compiled Apr 28 2021 17:34:08

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link V10 compiled Jun 17 2021 16:40:36
Hardware version: V10.10
S/N: 260118458
License(s): FlashBP, GDB
Target connection not established yet but required for command.
Device "STM32F103VE" selected.

Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x1BA01477
DPIDR: 0x1BA01477
Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x14770011)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x411FC231. Implementer code: 0x41 (ARM)
Found Cortex-M3 r1p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 001BB000 SCS
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 001BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 000BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 001BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 001BB923 TPIU-Lite
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 101BB924 ETM-M3
Cortex-M3 identified.
PC = 080002D2, CycleCnt = C377463C
R0 = 0000B1EA, R1 = 00800000, R2 = 00000080, R3 = 20000028
R4 = 0000012D, R5 = 0000B18B, R6 = 20000704, R7 = A5A5A5A5
R8 = A5A5A5A5, R9 = A5A5A5A5, R10 = A5A5A5A5, R11 = A5A5A5A5
R12= 40011400
SP(R13)= 2000FFE8, MSP= 2000FFE8, PSP= 200006A0, R14(LR) = 080002D3
XPSR = 81000000: APSR = Nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
FPU regs: FPU not enabled / not implemented on connected CPU.

Downloading file [.pio\build\genericSTM32F103VE\firmware.bin]...
Comparing flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x08000000: Skipped. Contents already match

Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.

Script processing completed.

============================ [SUCCESS] Took 8.22 seconds ================= ===========

And I was running SEGGER J-LINK GDB Server V7.22b.
I added the path where the JLinkGDBServer.exe file is located in the environment variable.

The log in SEGGER SERVER is as follows.

SEGGER J-Link GDB Server V7.22b GUI Version

JLinkARM.dll V7.22b (DLL compiled Jun 17 2021 17:22:49)

-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 5000 ms

------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none

------Target related settings------
Target device: Unspecified
Target interface: JTAG
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Jun 17 2021 16:40:36
Hardware: V10.10
S/N: 260118458
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.32V
Listening on TCP/IP port 2331
Connecting to target...


Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.1% (used 44 bytes from 65536 bytes)
Flash: [          ]   0.6% (used 3152 bytes from 524288 bytes)
========================= [SUCCESS] Took 1.77 seconds =========================
undefinedError: Traceback (most recent call last):
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\platformio\__main__.py", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\platformio\commands\__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\platformio\commands\debug\command.py", line 167, in cli
    from platformio.commands.debug.process.client import GDBClient, reactor
  File "c:\users\ilk48\.platformio\penv\lib\site-packages\platformio\commands\debug\process\client.py", line 26, in <module>
    from twisted.internet import stdio  # pylint: disable=import-error
  File "C:\Users\ilk48\.platformio\packages\contrib-pysite\twisted\internet\stdio.py", line 30, in <module>
    from twisted.internet import _win32stdio
  File "C:\Users\ilk48\.platformio\packages\contrib-pysite\twisted\internet\_win32stdio.py", line 9, in <module>
    import win32api
ImportError: DLL load failed: ������ ���ν����� ã�� �� �����ϴ�.


An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section

* Report this problem to the developers


But debugging is not running.
Help me


Googling this error leads to e.g. this talking about Anaconda / Conda. Did you ever install this? There’s also this.

You should also try to update everything first. Open a CLI and execute

pio upgrade --dev
pio platform update
1 Like

Thank you.
I have installed anaconda before.
And it’s perfectly solved in your way.