Question about debugging Due w/ J-link ARM

Hi,

I’m not sure if this is the correct area for this post, so please let me know if not.

I am currently debugging a large Arduino Due sketch which has many interrupts. I am using a Segger J-Link w/ the JTAG protocol.

There is a point where I am detaching interrupts from several pins, and using a serial print immediately after to update an external application. While debugging, the serial print breaks after these interrupt detaches only sending a portion of the serial print message. In normal operation the serial print sends the entire message.

It looks something like this:

detach interrupt 1
detach interrupt 2
detach interrupt 3

serial print message

Under normal operation “message” is received. Under debug operation it varies, but includes just portions of “message,” sometimes the beginning, or the middle, or the end.

Any insight or advice would be appreciated.

When debugging, a debug-optimized (-Og) is uploaded to the device, otherwise an optimized (-Os) version. The debug version is generally slower and it’s my guess that it doesn’t send the string fast enough. Try calling Serial.flush(); after sending your serial message to make absolutely sure it has sent everything, only after that detach the interrupt.

Hi Max,

Sorry, I should have mentioned that I did try Serial.flush() and that it did not change the behavior.

Thank you though!

Is the behavior the same when you set

build_type = debug

in the platformio.ini and just upload the (now debug) firmware normally, without starting debugging?