Problems with large uploads on Teensy 5.1
I am trying to get TeensyDebug working stably on a Teensy 4.1 using vscode and platformio on Linux. Using the latest version of TeensyDebug it works fine on small sketches, but fails on large ones. The 4.1 accomodates much larger sketches (*10) than any previous teensy. This exacerbates the usb enumeration problem of the teensy upload process returning success before the host OS has recognised the existence of the dual usb serial ports.
I have tried numerous ways of fixing this, but with limited success. The problem is that platformio launches gdb before Linux has created the usb serial device nodes in the file system. This means that gdb exits as soon it tries to open the remote debug target.
This is the recommend platformio.ini section.
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
I have tried inserting a gdb shell command before the target command i.e.
shell sleep 5
or
shell while ! [ -c $DEBUG_PORT ]; do echo $DEBUG_PORT not found; sleep 2; done
Neither of these stop my test sketch failing. I am beginning to think that something in the sketch might be causing this. I have this at the beginning of the setup() function.
while (!Serial) {} // wait for Serial Monitor to be ready
#ifdef GDB_DEBUGGING
Serial.printf("Waiting for debugger to attach\n");
while (!SerialUSB1) {
Serial.printf(".");
delay(1000);
} // wait for Serial Debugger to be ready
Serial.printf("\nSerial debugger ready\n");
Serial.flush();
debug.begin(SerialUSB1);
halt_cpu(); // stop on startup; if not, Teensy keeps running and you
// have to set a breakpoint or use Ctrl-C.
#endif
Has anyone got any ideas?
I can supply much more information if required.
Thanks
Roger