PlatformIO Community

How to use local library member and J-Link Upload


A very green PlatformIO user here. So far I am amazed with this!

I have a Teensy 3.2 (MK20DX256VLH7) bare metal board which I finally figured out how to get it compiled without errors. However, I want to make a modification to one of the Teensy core files and make that modification only for the current project.

I tried copying that file into the lib “folder” in the project explorer pane, but compilations do not seem to recognize that file and use the original core file by default.

What am I doing wrong?

Also, I am using a J-Link to download the compiled/linked code, but I only see options for debugging in the Run menu. Pressing the —> button on the bottom bar of VSCode calls up the TeensyLoader application, but I want to upload via SWD through the J-Link. Can I specify that somehow?

If you put a modified version of one of the core files (I assume from framework-arduinoteensy), putting that file in to lib/ won’t do what you want, because the original file still exists and would also be compiled in (-> double definition). Also you probably didn’t have the right folder structure if you put it directly in lib/ (but doesn’t matter).

See related topic How to modify Teensy core files? and especially Custom framework? or platform? (mentally replace framework-arduino-nrf52-mbedos with framework-arduinoteens, same procedure).

Further see documentation.

See documentation and documentation.

Thank you!

I seem to have some issues with J-Link. I did this in my environment:

platform = teensy
board = teensy31
framework = arduino
debug_tool = jlink
upload_protocol = jlink

and when I hit the —> button after compiling I got this:

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 Apr 23 2020 16:49:14
Hardware version: V10.10
S/N: 260106418
License(s): FlashBP, GDB
Target connection not established yet but required for command.
Device "MK20DX256XXX10" selected.

Connecting to target via SWD
Cannot connect to target.

Now the device is an MK20DX256VLH7, not XXX10. How did that change?

I unplugged the J-Link and plugged it back in and it seems to work now. My bad, I guess.

The board definition says

The MCU on the Teensy 3.1/2 is a MK20DX256VLH7, and the assigned JLink target by PlatformIO is MK20DX256xxx10… which seems actually wrong, should be MK20DX256xxx7


If it works by coincidence they are probably very similiar :sweat_smile:

You can manually fix it in the project by adding

board_debug.jlink_device = MK20DX256xxx7

in the platformio.ini. Also @valeros can fix it uplink.

1 Like

Thanks. That helps when I want to change processors to something like the MK20DX128.

1 Like