Alright so i did some investigation and im running this small program
Code:
#include <Arduino.h>
#include <TeensyDebug.h>
#include <Adafruit_ADS1X15.h>
#pragma GCC optimize ("O0")
Adafruit_ADS1115 ads;
void setup(){
while (!SerialUSB1) {} // Wait for Debugger connect
debug.begin(SerialUSB1); // Start Debug Serial e.g. COM11
Serial.begin(115200); // Start User Serial e.g. COM10
}
int boop = 0;
void loop(){
boop++;
digitalWrite(LED_BUILTIN, HIGH); // <<<<< Add A Breakpoint on this line
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
With my platformio.ini looking like
Code:
[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
lib_deps =
SPI
Adafruit ADS1X15
TeensyDebug
;build_type = debug
; See https://github.com/platformio/platform-teensy/issues/65
build_unflags = -DUSB_SERIAL
build_flags = -DUSB_DUAL_SERIAL
debug_port = /dev/ttyACM1
debug_tool = custom
debug_load_mode = manual
debug_server =
debug_init_cmds =
target extended-remote $DEBUG_PORT
$INIT_BREAK
define pio_reset_run_target
interrupt
tbreak loop
continue
end
define pio_restart_target
echo Restart is undefined for now.
end
debug_init_break =
This works perfectly, i can debug it and put a watch on 'boop' and step through and see how it increases. However, if i change my setup() to include ads.begin() like so
Code:
void setup(){
while (!SerialUSB1) {} // Wait for Debugger connect
debug.begin(SerialUSB1); // Start Debug Serial e.g. COM11
Serial.begin(115200); // Start User Serial e.g. COM10
ads.begin();
}
All USB ports immediately disappear after programming and i have to do a hard reset. Interestingly enough, if i simply comment out "build_type = debug" in platformio.ini, the program works great - but then i cant debug it anymore so whats the point