JLink V8 Upload problem

Uploading and debugging is working fine with ST-Link/V2 using standard PIO configuration:

upload_protocol = stlink
debug_tool = stlink

I would like use the Segger J-Link/V8 I have so I could hopefully use RTT (Getting printf Output from Target to Debugger - SEGGER Blog). However, I am not able to get upload/debug working with standard config:

; J-Link SWD interface
upload_protocol = jlink
debug_tool = jlink

I read everything related with J-Link on both this Community forum and platformio/platformio-core GitHub Issues:

Issues · platformio/platformio-core · GitHub
Issues · platformio/platformio-core · GitHub

I know for fact that others have it working fine with standard config. These are the findings I am suspecting being related to the problem:

  • J-Link/V8 does not support USB CDC serial port (virtual COM port).
  • The J-Link driver appears fine in my device drivers-Universal Serial Bus controllers.
  • Running latest version of VSCode 1.29.1 w/ PlatformIO: Home 1.0.6, Core 3.6.2a2
  • Win7 x64
  • home_dir/packages/tool-jlink’ mentioned in J-LINK — PlatformIO latest documentation
    is missing from my HD but ‘tool-stlink’ is there.

This is the error I get when uploading:

Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, mbed, stlink
CURRENT: upload_protocol = jlink
Uploading .pioenvs\bluepill_f103c8\firmware.elf
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-15:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Error: No J-Link device found.
Error: No Valid JTAG Interface Configured.
*** [upload] Error -1

And this is the Error I get when I choose ‘Start Debugging F5’:

error

I managed to get the upload working by adding the following to platformio.ini:

upload_protocol = jlink
extra_scripts = extra_script.py

However, I have to ‘Build’ first then ‘Upload’ next. The ‘firmware.bin’ doesn’t get generated when I click ‘Upload’ alone after ‘Clean’.

I don’t like the ‘extra_script’ method because it shows ‘SUCCESS’ at the end even though it couldn’t find/open ‘firmware.bin’.

Note: ‘JLink.exe’ used in the ‘extra_script‘ below doesn’t read ‘firmware.elf’; that’s why the script was modified not to use ‘SOURCE’.

Here is my ‘extra_script’:

# https://docs.platformio.org/en/latest/plus/debug-tools/custom.html?highlight=j-link#j-link-as-debugger-and-uploader

from os import makedirs
from os.path import isdir, join
Import('env')

def _jlink_cmd_script(env, source):
    build_dir = env.subst("$BUILD_DIR")
    if not isdir(build_dir):
        makedirs(build_dir)
    script_path = join(build_dir, "upload.jlink")
#     commands = ["h", "loadbin %s, 0x0" % source, "r", "q"]
    commands = ["h", "loadbin %s/firmware.bin, 0x0" % build_dir, "r", "q"]
    with open(script_path, "w") as fp:
        fp.write("\n".join(commands))
    return script_path

env.Replace(
    __jlink_cmd_script=_jlink_cmd_script,
    UPLOADER="C:/Program Files (x86)/SEGGER/JLink_V640/JLink.exe",
    UPLOADERFLAGS=[
        "-device", "STM32F103C8",
        "-speed", "4000",
        "-if", "swd",
        "-autoconnect", "1"
    ],
    UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -CommanderScript ${__jlink_cmd_script(__env__, SOURCE)}'
)

I also managed to get debug working by adding the following to platformio.ini:

debug_tool   = custom
debug_server = C:\Program Files (x86)\SEGGER\JLink_V640\JLinkGDBServerCL.exe
                -singlerun
                -if
                 SWD
                -select
                 USB
                -port
                 2331
                -device
                 STM32F103C8

However, it’s very slow to start the debugger (> 30 secs after compiling) compared to ST-Link (< 10 secs) and it’s almost impractical.

Correction: I exited VSCode and repeated the test and now they’re both fast enough (< 5 secs). So apparently memory is leaking seriously and tasks are probably left behind and new ones are spawned. What prompted me to exit is that the OS warned about running out of memory.

Bottom line, what do I have to do in order to ‘use official JLink GDB default without these extra scripts and hooks’ ?

Would someone please help me learn how to keep code formatting/indentation intact when posting on this forum?

I used <code> pasted my code in between </code>
I can see the indentation on the left in the editor but it’s lost on the right previewer and after posting!

Thanks

Best to just use standard Markdown code formatting using three backticks (cheat sheet).

Thanks a lot Maximillian @maxgerhardt.

I see that you already edited/fixed the formatting of my OP :slight_smile:.

Can anyone edit my posts or just admins and you happen to be one?

Just mods and admins, not everyone, that would be chaos :slight_smile:

We used openOCD for J-Link probe previously. Now, we have switched to official J-Link tool for uploading and debugging. Please re-test with the latest upstream version of dev/platform => ST STM32 — PlatformIO latest documentation

P.S: Please remove any extra scripts and settings from platformio.ini. You need just 2 lines J-LINK — PlatformIO latest documentation

[env:myenv]
platform = ...
board = ...
debug_tool = jlink
upload_protocol = jlink

@ivankravets,

Thanks for your reply.

It downloaded from GitHub the upstream platform-ststm32 and the tool-jlink, and this what I see when I start debug:

> Executing task: C:\Users\Samir\.platformio\penv\Scripts\platformio.exe debug <

PIO Plus (https://pioplus.com) v1.5.3
Processing genericSTM32F103CB (framework: arduino; platform: https://github.com/platformio/platform-ststm32.git; board: genericSTM32F103CB)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103CB.html
PLATFORM: ST STM32 > STM32F103CB (20k RAM. 128k Flash)
HARDWARE: STM32F103CBT6 72MHz 20KB RAM (128KB Flash)
DEBUG: CURRENT(jlink) EXTERNAL(blackmagic, jlink, stlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit Unified Sensor> 1.0.2
|-- <DHT sensor library> 1.3.0
|   |-- <Adafruit Unified Sensor> 1.0.2
|-- <Adafruit DHT Unified> 1.0.0
|   |-- <Adafruit Unified Sensor> 1.0.2
|   |-- <DHT sensor library> 1.3.0
|   |   |-- <Adafruit Unified Sensor> 1.0.2
|-- <RTT>
Checking size .pioenvs\genericSTM32F103CB\firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [==        ]  21.3% (used 4368 bytes from 20480 bytes)
PROGRAM: [==        ]  23.8% (used 31212 bytes from 131072 bytes)
=================================================================== [SUCCESS] Took 2.38 seconds ===================================================================

Terminal will be reused by tasks, press any key to close it.

and then this pops up:

Update:

Upload is working fine:

> Executing task: C:\Users\Samir\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing genericSTM32F103CB (framework: arduino; platform: https://github.com/platformio/platform-ststm32.git; board: genericSTM32F103CB)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103CB.html
PLATFORM: ST STM32 > STM32F103CB (20k RAM. 128k Flash)
HARDWARE: STM32F103CBT6 72MHz 20KB RAM (128KB Flash)
DEBUG: CURRENT(jlink) EXTERNAL(blackmagic, jlink, stlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit Unified Sensor> 1.0.2
|-- <DHT sensor library> 1.3.0
|   |-- <Adafruit Unified Sensor> 1.0.2
|-- <Adafruit DHT Unified> 1.0.0
|   |-- <DHT sensor library> 1.3.0
|   |   |-- <Adafruit Unified Sensor> 1.0.2
|   |-- <Adafruit Unified Sensor> 1.0.2
|-- <RTT>
Compiling .pioenvs\genericSTM32F103CB\src\main.cpp.o
Archiving .pioenvs\genericSTM32F103CB\lib04e\libAdafruit Unified Sensor_ID31.a
Compiling .pioenvs\genericSTM32F103CB\libc7d\DHT sensor library_ID19\DHT.cpp.o
Compiling .pioenvs\genericSTM32F103CB\libc7d\DHT sensor library_ID19\DHT_U.cpp.o
Compiling .pioenvs\genericSTM32F103CB\lib25a\Adafruit DHT Unified_ID18\DHT_U.cpp.o
Compiling .pioenvs\genericSTM32F103CB\lib1a7\RTT\RTT.c.o
Compiling .pioenvs\genericSTM32F103CB\lib1a7\RTT\RTT_printf.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\board.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\wirish\boards.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\wirish\boards_setup.cpp.o
Archiving .pioenvs\genericSTM32F103CB\lib25a\libAdafruit DHT Unified_ID18.a
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\wirish\start.S.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\wirish\start_c.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduinoVariant\wirish\syscalls.c.o
Archiving .pioenvs\genericSTM32F103CB\libc7d\libDHT sensor library_ID19.a
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\HardwareTimer.cpp.o
Archiving .pioenvs\genericSTM32F103CB\lib1a7\libRTT.a
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\IPAddress.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\Print.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\Stream.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\WString.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\avr\dtostrf.c.o
Archiving .pioenvs\genericSTM32F103CB\libFrameworkArduinoVariant.a
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\cxxabi-compat.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\ext_interrupts.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\hooks.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\itoa.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\adc.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\adc_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\bkp_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\dac.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\dma.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\dma_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\exc.S.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\exti.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\exti_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\flash.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\fsmc_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\gpio.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\gpio_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\i2c.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\i2c_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\iwdg.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\nvic.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\pwr.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\rcc.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\rcc_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\spi.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\spi_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\stm32f1\performance\isrs.S.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\stm32f1\performance\vector_table.S.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\systick.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\timer.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\timer_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usart.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usart_f1.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usart_private.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\stm32f1\usb.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\stm32f1\usb_cdcacm.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\stm32f1\usb_reg_map.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\usb_lib\usb_core.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\usb_lib\usb_init.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\usb_lib\usb_mem.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\usb\usb_lib\usb_regs.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\libmaple\util.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\main.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\new.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\pwm.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\sdio.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\stm32f1\util_hooks.c.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\stm32f1\wiring_pulse_f1.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\stm32f1\wirish_debug.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\stm32f1\wirish_digital_f1.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\tone.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\usb_serial.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\wirish_analog.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\wirish_digital.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\wirish_math.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\wirish_shift.cpp.o
Compiling .pioenvs\genericSTM32F103CB\FrameworkArduino\wirish_time.cpp.o
Archiving .pioenvs\genericSTM32F103CB\libFrameworkArduino.a
Linking .pioenvs\genericSTM32F103CB\firmware.elf
Checking size .pioenvs\genericSTM32F103CB\firmware.elf
Building .pioenvs\genericSTM32F103CB\firmware.bin
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [==        ]  21.3% (used 4360 bytes from 20480 bytes)
PROGRAM: [==        ]  22.1% (used 28948 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = jlink
Uploading .pioenvs\genericSTM32F103CB\firmware.bin
SEGGER J-Link Commander V6.32h (Compiled Jul  5 2018 18:11:36)
DLL version V6.32h, compiled Jul  5 2018 18:11:19

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 ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: -1
License(s): RDI,FlashDL,FlashBP,JFlash,GDBF
VTref=3.293V
Target connection not established yet but required for command.
Device "STM32F103CB" selected.

Connecting to target via SWD
Found SW-DP with ID 0x1BA01477
Found SW-DP with ID 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
Cortex-M3 identified.
PC = 0800523E, CycleCnt = 0017DF98
R0 = 20000CAF, R1 = 080074CA, R2 = 00000000, R3 = 28007CEF
R4 = 00000000, R5 = 000003FF, R6 = 20001014, R7 = 00000003
R8 = 080074CA, R9 = 0000000A, R10= 080074BC, R11= 080074B0
R12= 20000CAF
SP(R13)= 20004F58, MSP= 20004F58, PSP= 283FA33C, R14(LR) = 08000AC3
XPSR = 81000000: APSR = Nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00002000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 20, PRIMASK = 00
FPU regs: FPU not enabled / not implemented on connected CPU.

Downloading file [.pioenvs\genericSTM32F103CB\firmware.bin]...
J-Link: Flash download: Bank 0 @ 0x08000000: 1 range affected (29696 bytes)
J-Link: Flash download: Total time needed: 1.505s (Prepare: 0.051s, Compare: 0.018s, Erase: 0.639s, Program: 0.790s, Verify: 0.000s, Restore: 0.004s)
O.K.

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.20 seconds ===================================================================

Terminal will be reused by tasks, press any key to close it.

However if I turn off the power to my target board and connection cannot be established I still see success at the end but when you read the details there is an indication that it wasn’t successful:

> Executing task: C:\Users\Samir\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing genericSTM32F103CB (framework: arduino; platform: https://github.com/platformio/platform-ststm32.git; board: genericSTM32F103CB)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103CB.html
PLATFORM: ST STM32 > STM32F103CB (20k RAM. 128k Flash)
HARDWARE: STM32F103CBT6 72MHz 20KB RAM (128KB Flash)
DEBUG: CURRENT(jlink) EXTERNAL(blackmagic, jlink, stlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit Unified Sensor> 1.0.2
|-- <DHT sensor library> 1.3.0
|   |-- <Adafruit Unified Sensor> 1.0.2
|-- <Adafruit DHT Unified> 1.0.0
|   |-- <DHT sensor library> 1.3.0
|   |   |-- <Adafruit Unified Sensor> 1.0.2
|   |-- <Adafruit Unified Sensor> 1.0.2
|-- <RTT>
Checking size .pioenvs\genericSTM32F103CB\firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [==        ]  21.3% (used 4360 bytes from 20480 bytes)
PROGRAM: [==        ]  22.1% (used 28948 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = jlink
Uploading .pioenvs\genericSTM32F103CB\firmware.bin
SEGGER J-Link Commander V6.32h (Compiled Jul  5 2018 18:11:36)
DLL version V6.32h, compiled Jul  5 2018 18:11:19

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 ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: -1
License(s): RDI,FlashDL,FlashBP,JFlash,GDBF
VTref=0.000V
Target connection not established yet but required for command.
Device "STM32F103CB" selected.


Connecting to target via SWD
Cannot connect to target.

Target connection not established yet but required for command.
Device "STM32F103CB" selected.

Connecting to target via SWD
Cannot connect to target.

Target connection not established yet but required for command.
Device "STM32F103CB" selected.


Connecting to target via SWD
Cannot connect to target.


Script processing completed.

=================================================================== [SUCCESS] Took 2.55 seconds ===================================================================

Terminal will be reused by tasks, press any key to close it.

So we still need to fix debug.

Update #2:

Debug is working now! I have no idea how! I didn’t change anything; I just tried again:

However, I do remember now that I couldn’t access the ‘.pioenvs’ folder. It gave me some access error in File Explorer. I closed File Explorer then I went back and I was able to access it again. So I am not sure if this was the cause of the above shown error when I started debug.

Update #3:
I just figured it out. It works only if I did a regular upload first the debug without cleanup. I turned out Debug after cleanup is the ‘upload.jlink’ is not generated. So when I placed it back into ‘.pioenvs’ folder from backup. It worked! So you need to fix your debug scrip to have it generated.

We’re getting close. Awaiting one more update…

Thanks a lot Ivan @ivankravets for the great support.

Cheers…

It seems like an issue with folder permission.

  1. Please close VSCode
  2. Remove .pioenvs and .vscode folders from a project
  3. Start VSCode.

Does it work now?

P.S: There is a bug in the latest version of VSCode. It does not show DEBUG CONSOLE output in real-time. You will it only when debugging session is established. This issue was already fixed by Microsoft team in Insider build.

You are right.

It works now and ‘upload.jlink’ is not needed when debugging.

Thanks again…

Quick question:

Is there a way to scan and detect the pre-installed J-Link software and use it, as many IDEs do, rather than installing a duplicate/outdated in ~.platformio\packages\tool-jlink?

Just navigate to ~.platformio\packages\tool-jlink and remove everything excluding package.json. PlatformIO will use binaries from your system PATH.

Getting close to running out of System Path Space. Is there a way to do it in ‘User Settings’, as in here?

Sorry for asking many questions.

Thanks…

System path method didn’t work:

image

Yes! I restarted VSCode and double-checked the system path within it:

When I leave ‘platform = GitHub - platformio/platform-ststm32: ST STM32: development platform for PlatformIO’, tool-jlink gets downloaded again?

Please use our built-in J-Link GDB Server. Do you have a problem with it?

No, I don’t have a problem with it; and I’ll continue to use it.