Debugging - Using the Debug Interface

Preparation

Example

Using the debugging feature available in the Arduino 2.0 IDE to debug your board. In this example, we will use SEGGER’s debug probe with Arduino IDE’s debug interface. Begin by installing the SEGGER debugging software. This can be found on SEGGER’s official website: https://www.segger.com/downloads/jlink/.

Before debugging, ensure that the code is optimized for debugging. Enable it by navigating to Sketch -> Optimize for Debugging.

1

Open the Debug example, “File” -> “Examples” -> “Debugging” -> “ExampleDebug”

1

Two files will open in the IDE; ExampleDebug.ino and debug_custom.json. Click on debug_custom.json. Under “serverArgs”, insert the directory path to Arduino15 folder, as well as the current version number of the tools folder.

1

Connect the JLink Debug Probe and AmebaD board to the computer. Refer to the table below for the wiring connection between JLink Debug Probe and AmebaD board. For more information, please refer to here.

JLink Debug ProbeAmebaD Board
VTref3.3V
GNDGND
SWDIOSWDIO
SWCLKSWCLK

1

1

AmebaD boards only have 2 hardware breakpoints. Setting more than that will cause debugging to fail. Hardware breakpoints can be set at the left of the code and are indicated by a red dot shown in line 42. You will need to stop debugging and reset if this happens.

If 2 hardware breakpoint is not enough, software breakpoint can be used. Either of the instructions (__BKPT() or __asm__(“BKPT”)) can be used to add a software breakpoint in the program execution.

1

Upload the code and press the reset button on Ameba once the upload is finished.
Once uploading is completed, reset the board. Start debugging by selecting the Debug button. This is located to the right of the upload button. Arduino will proceed with opening a gdb-server tab in the same window as the output window if all connections were connected correctly between JLink and board. This can sometimes take up to 10 seconds to set up.

1

The line highlighted in yellow indicates which line of code the program is currently halted at. Debug console will appear to show the debugging information.

1

To continue running the code after the breakpoint, use any of the single-stepping functions highlighted in the red box above (continue, step over, step into, step out, restart, stop)
Note: For AmebaD boards, using any of the single-stepping functionality requires both hardware breakpoint resources to be free. You should remove or disable all existing breakpoints before using them.

1

Please confirm that QQ communication software is installed