#pragma GCC optimize ("O0") #include "TeensyDebug.h" #include <NativeEthernet.h> #include <NativeEthernetUdp.h> //////////////////////////////////////////////////////////////////////////// // UN-COMMENT LINE BELOW TO REPRODUCE ISSUE WHEN COMPILING WITH DEBUG FLAG ON //EthernetUDP Udp; void setup() { delay(1); debug.begin(); } volatile int mark = 0; void loop() { Serial.print("mark=");Serial.println(mark++); delay(1000); } |
This sounds great. I used a software-based debugger for ATMega. A limitation was that interrupts needed to be running all the time in order for the debugger to work. Is it possible to set a breakpoint inside an ISR if the ISR disables interrupts for its duration?When trying to use TeensyDebug with NativeUDP after compiling and programming, the mid board LED flashes Yellow at about 4 Hz and the board becomes unreachable via USB until a valid program like Blink is compiled and loaded.
I have successfully debugged other Teensy 4.1 programs and this issue appears only (so far) when trying to open a UDP port when compiling with the DEBUG Flag on.
I've tried with and without #pragma and a bunch of other dial spinning and flailing attempts but to no avail.
Anyone have any idea how to solve this issue?
Also what does the rapidly flashing LED after a programming attempt mean? Boot loader Fail?
Platform Linux Debian
Arduino IDE 1.8.13
Board Teensy 4.1 with Ethernet
TeensyDebug version 0.0.1
NativeEthernet version 1.0.3
FNET version 0.1.3
Code:
#pragma GCC optimize ("O0")
#include "TeensyDebug.h"
#include <NativeEthernet.h>
#include <NativeEthernetUdp.h>
////////////////////////////////////////////////////////////////////////////
// UN-COMMENT LINE BELOW TO REPRODUCE ISSUE WHEN COMPILING WITH DEBUG FLAG ON
//EthernetUDP Udp;
void setup() {
delay(1);
debug.begin();
}
volatile int mark = 0;
void loop() {
Serial.print("mark=");Serial.println(mark++);
delay(1000);
}
kburden000 said:The actual code is here:
https://github.com/luni64/TeensyDebug
Then I guess you need to fix up the debugger code, take a fork and mend it.
Use a logic analyzer, Oscilloscope or console out to find out why it is not working.
Indeed, Thread was marked BETA - and a good amount of effort shows GDB generally usable - but has some limitations - for whatever reason the author hasn't updated in 10 months. Whether lack of interest when time was at hand or complexity of doing more given the process and parts that worked with this fixed external tool.
Ethernet is speedy and perhaps naughty to the ways of the debugger. Perhaps some things like building with Ethernet disabled or made active later would allow it to start and then maybe even trap where it dies?
Unless said bug is smack in the middle of a time sensitive IRQThat being said, with enough print statements and pin toggling, one can find a bug without a debugger.
#include "TeensyDebug.h"
#pragma GCC optimize ("O0")
// ~/arduino/arduino-*/hardware/tools/arm/bin/arm-none-eabi-gdb /tmp/arduino_build_xxx/jz-gdbstub-test.ino.elf -ex "target remote /dev/ttyACM1"
// gdb-multiarch /tmp/arduino_build_*/jz-gdbstub-test.ino.elf -ex "target remote /dev/ttyACM1"
// set USB Type to "Dual Serial"
#define ASSERT(expr) if (!(expr)) {asm volatile("svc #0x11");}
int mark1 = 3;
void test_function() {
mark1 += 1;
mark1 += three();;
}
int three() {
int i = 3;
//ASSERT(mark1 < 50);
return i;
}
void setup() {
Serial.begin(19200);
while (!Serial && millis() < 2000) {} // wait
// gdbstub debugger on second serial port
SerialUSB1.begin(19200);
do {
Serial.println("start debugger now...");
delay(1000);
} while (!SerialUSB1); // wait
debug.begin(SerialUSB1);
Serial.println("debugger connected, issue continue command\n");
halt();
debug.printf("teensy program running\n");
}
void loop() {
delay(500);
Serial.println(mark1);
debug.printf("%d\n", mark1); delay(1); // delay is needed with breakpoints
test_function();
}