It works just fine with PlatformIO.
platformio.ini
[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
build_type = debug
lib_deps =
https://github.com/ftrias/TeensyDebug/archive/refs/heads/master.zip
; activate Dual USB just as README says
build_flags =
-D USB_DUAL_SERIAL
src\main.cpp
#include <Arduino.h>
#include "TeensyDebug.h"
#pragma GCC optimize ("O0")
int mark = 0;
void test_function() {
mark++;
}
void setup() {
// Use the first serial port as you usually would
Serial.begin(19200);
// Debugger will use second USB Serial; this line is not need if using menu option
debug.begin(SerialUSB1);
// debug.begin(Serial1); // or use physical serial port
halt(); // stop on startup; if not, Teensy keeps running and you
// have to set a breakpoint or use Ctrl-C.
}
void loop() {
test_function();
Serial.println(mark);
delay(1000);
}
.vscode/launch.json
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "C:/Users/Max/Documents/PlatformIO/Projects/teensy-gdb-stub/.pio/build/teensy40/firmware.elf",
"projectEnvName": "teensy40",
"toolchainBinDir": "C:/Users/Max/.platformio/packages/toolchain-gccarmnoneeabi@1.50401.190816/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "C:/Users/Max/Documents/PlatformIO/Projects/teensy-gdb-stub/.pio/build/teensy40/firmware.elf",
"projectEnvName": "teensy40",
"toolchainBinDir": "C:/Users/Max/.platformio/packages/toolchain-gccarmnoneeabi@1.50401.190816/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Launch",
"type": "cppdbg",
"request": "launch",
"miDebuggerPath": "C:/Users/Max/.platformio/packages/toolchain-gccarmnoneeabi@1.50401.190816/bin/arm-none-eabi-gdb.exe",
"miDebuggerArgs": "--baud=115200",
"MIMode": "gdb",
"targetArchitecture": "arm",
"program": "C:/Users/Max/Documents/PlatformIO/Projects/teensy-gdb-stub/.pio/build/teensy40/firmware.elf",
"launchCompleteCommand": "None",
"filterStderr": false,
"filterStdout": false,
"externalConsole": false,
"cwd": "${workspaceRoot}",
"setupCommands": [
{"text": "set target-async off"},
{"text": "target extended-remote \\\\.\\COM9"},
]
}
]
}
You have to adapt the all the paths for your local machine though.