How to debug Due?

What is the correct approach to do debugging for the Due? What hardware do I need and what IDE do I need in order to set breakpoints, look at registers etc?

I noticed the Due has a SWD interface, I have a cheap ST-Link V2 clone can this work? Has anyone used Jeff Probe?

Thanks

Welcome to the forum

The Arduino Due has a 10-pin ARM Cortex-M Debug connector (it is marked JTAG on the PCB). This allows debugging with all common ARM Cortex-M debug environments and debug probes from ARM/Keil, IAR, Segger, Lauterbach ...

I tested this with MDK-ARM with an ULINK Pro. Works like expected.

I noticed the Due has a SWD interface, I have a cheap ST-Link V2 clone can this work? Has anyone used Jeff Probe?

I have no idea who or what Jeff Probe is.

But the ST-Link clones work fine. The Due even has some 2.54mm SWD pins. So you don't need a tiny 5x2 JTAG adapter.

Obviously Microchip/Atmel will not support ST-Link in AS7.0
But non-partisan IDE like Keil, Rowley, ... do support it.

David.

Klaus_K:
Welcome to the forum

The Arduino Due has a 10-pin ARM Cortex-M Debug connector (it is marked JTAG on the PCB). This allows debugging with all common ARM Cortex-M debug environments and debug probes from ARM/Keil, IAR, Segger, Lauterbach ...

I tested this with MDK-ARM with an ULINK Pro. Works like expected.

david_prentice:
I have no idea who or what Jeff Probe is.

But the ST-Link clones work fine. The Due even has some 2.54mm SWD pins. So you don't need a tiny 5x2 JTAG adapter.

Obviously Microchip/Atmel will not support ST-Link in AS7.0
But non-partisan IDE like Keil, Rowley, ... do support it.

David.

Hi, I picked up a JLINK mini EDU, it seems to work with embedded studio but I can't make the breakpoints work with microchip studio. Any tips?
Secondly, if I wanted to continue to use the Arduino Libraries how would I do this? Can load them into a third party IDE?
Last, if I wanted to continue to use the Arduino IDE, how would I go about using GDB? Does the arduino IDE include the debug flags for using GDB? It doesn't look arduino uses the .C extension which makes me very confused.

gunky:
Hi, I picked up a JLINK mini EDU, it seems to work with embedded studio but I can't make the breakpoints work with microchip studio. Any tips?

Every IDE is different. I have not worked with Microchip tools for more than 10 years.

gunky:
Secondly, if I wanted to continue to use the Arduino Libraries how would I do this? Can load them into a third party IDE?

The software is open source. When you use another IDE, I would use the included standard libraries and take special libraries as needed.

gunky:
Last, if I wanted to continue to use the Arduino IDE, how would I go about using GDB? Does the arduino IDE include the debug flags for using GDB? It doesn't look arduino uses the .C extension which makes me very confused.

The Arduino IDE will create a folder in your temp directory. Check the output at the bottom. On my PC the folder is usually in

C:\Users\UserName\AppData\Local\Temp\arduino_build_xxxxx (some number)

In that folder you will find all files for debugging and analysis. e.g.

  • all precompiled object files *.o
  • the binaries *.bin and *.hex
  • the *.map file, which tells you the entire memory map where all code and data is and which files they come from
  • the *.elf file, this file contains the code with debug information.
    The files are deleted when the Arduino IDE closes. You need to copy the folder content if you want to use it with another tools.

Most IDE should allow you to use these files just for debugging. You need to figure out how because every IDE is a bit different.

You can even just connect a pre-programmed Arduino to most debuggers. This would allow you to start, stop, look at registers & memory and assembly instructions. If you figure out how to tell the debugger where the *.elf file is you can even look at variables and source code.

Klaus_K:
Every IDE is different. I have not worked with Microchip tools for more than 10 years.
The software is open source. When you use another IDE, I would use the included standard libraries and take special libraries as needed.
The Arduino IDE will create a folder in your temp directory. Check the output at the bottom. On my PC the folder is usually in

C:\Users\UserName\AppData\Local\Temp\arduino_build_xxxxx (some number)

In that folder you will find all files for debugging and analysis. e.g.

  • all precompiled object files *.o
  • the binaries *.bin and *.hex
  • the *.map file, which tells you the entire memory map where all code and data is and which files they come from
  • the *.elf file, this file contains the code with debug information.
    The files are deleted when the Arduino IDE closes. You need to copy the folder content if you want to use it with another tools.

Most IDE should allow you to use these files just for debugging. You need to figure out how because every IDE is a bit different.

You can even just connect a pre-programmed Arduino to most debuggers. This would allow you to start, stop, look at registers & memory and assembly instructions. If you figure out how to tell the debugger where the *.elf file is you can even look at variables and source code.

Thanks, I have the dissasembly working but I want to set breakpoints at specific points, my understanding is that gdb needs the C source file. But the arduino sketches are not saved as .C files. Can I just input the sketch name and line number?

gunky:
Thanks, I have the dissasembly working but I want to set breakpoints at specific points, my understanding is that gdb needs the C source file. But the arduino sketches are not saved as .C files. Can I just input the sketch name and line number?

Everything you need should be in the *.elf file. You should be able to use symbols e.g. function names.

In case you need to use the file name before using symbols, if you look into the folder I mentioned the ino file is converted and compiled into a *.ino.cpp file.

C:\Users\UserName\AppData\Local\Temp\arduino_build_xxxxx\sketch\

Hi!
I tried to use a cheap jlink with the 4 pins debug connector. First it's necessary to modify the jlink to have the reset and it is possible to upload at "light speed" but I didn't succeed to debug (with vsc and pio and right settings in pio.ini).
I made an other attempt with nucleo board stlink (on the same 4 pins) without success (no upload no debug).
Please, can you explain the detailed setting (hard and soft) who give "stlink clones work fine" and "you don't need a tiny 5x2 adapter"
Thanks