[Tutorial] Debugging RTL8722 with the new Arduino IDE 2.0

此教程的中文版:
使用新的 Arduino IDE 2.0 调试 RTL8722


Requirements


Hardware:
RTL8720/RTL8721/RTL8722 DN/DM/DF development board
SEGGER JLink debug probe (https://www.segger.com/products/debug-probes/j-link/)
Software:
Arduino IDE 2.0 (https://www.arduino.cc/en/software)
SEGGER JLink Software Pack (SEGGER - The Embedded Experts - Downloads - J-Link / J-Trace)

Setup


  1. Install Arduino IDE 2.0. Instructions on installing Arduino IDE 2.0 can be found at https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing.

Note: Arduino IDE 2.0 can coexist with the old Arduino IDE. Any changes made to boards or libraries will affect both IDE versions.

  1. Install SEGGER JLink Software Pack.

For Windows users: this process assumes that the 64-bit version of JLink software is installed in the default directory of C:\Program Files\SEGGER.

  1. In Tools → Board → Boards Manager , find and install the board support package.

  2. In the menu near the toolbar, select the board and COM port corresponding to your evaluation board.

  3. Open the example code in File → Examples → AmebaDebugExample → ExampleDebug.

  4. Follow the comments to add in the correct folder path into the serverArgs field of the debug_custom.json file.

  5. Connect the evaluation board and JLink debug probe to your computer. Using jumper wires, connect the debug probe to the SWD pins on the evaluation board. SWD pins on the JLink debug probe can be found at J-Link Interface Description.

    JLink Debug Probe RTL8722 Evaluation Board
    VTref 3.3V
    GND GND
    SWDIO SWDIO
    SWCLK SWCLK



SWD

Debug


Refer to https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger for instructions on how to use the Arduino IDE debug interface.

  1. Before debugging, make sure to enable Sketch → Optimize for Debugging.

  2. Compile and upload the sketch in the same way as before, using the USB to UART COM port. Program download using the debug probe is not supported yet.
    4

  3. After uploading is complete, reset the board and you can start debugging by clicking on the debug icon near the upload icon. You should see program execution stop, and a yellow highlight on the first line of code in the setup function, this indicates the next line of code to be executed by the processor.

Note: The RTL872xD chip only has 2 hardware breakpoint registers. These will be used up when you set breakpoints. Trying to set too many breakpoints will cause debugging to fail, the output tab will show “WARNING: No more breakpoint resources left”. You may need to stop debugging and reset when this happens.

Note: Using any of the single-stepping functionality (step over, step into, step out) requires that both hardware breakpoint resources are free. You should remove or disable all existing breakpoints before using them.

2 Likes

Hi. To help others.

This is my debugger:

Firmware: J-Link EDU Mini V1 compiled Jun 24 2021 14:29:39
Hardware: V1.00

This is my debug_custom.json

{
 "servertype": "jlink",
 "interface": "swd",
 "device": "RTL872xCS",
 "serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe"
}

This is my launch.json (Generated)

{
  "version": "0.2.0",
  "configurations": [
    {
      "cwd": "${workspaceRoot}",
      "name": "Arduino",
      "request": "launch",
      "type": "cortex-debug",
      "executable": "C:\\Users\\ajsb85\\AppData\\Local\\Temp\\arduino-sketch-468C564005883B4DF820103161969518/application.axf",
      "servertype": "jlink",
      "serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe",
      "armToolchainPath": "C:\\Users\\ajsb85\\AppData\\Local\\Arduino15\\packages\\realtek\\tools\\ameba_d_asdk_toolchain\\1.0.1/bin/",
      "configFiles": [
        null
      ],
      "interface": "swd",
      "device": "RTL872xCS"
    }
  ]
}


image

2 Likes

Great! THanks for sharing!

I have a JLINK mini too, was wondering how to get started debugging with it just a while ago~:laughing::+1:

1 Like

Can you please share " AmebaDebugExample"? I don’t have it, and I cannot find it anywhere on google or github.

it is still only in the dev branch on GitHub, and will be available from Arduino package manager after it passes QC.
If you need to use it you will have to download and install it manually.

I am trying IAR + JLINK/SWD for program download . Is this had been supported ?
Thank you !

@Vic

This topic refers to Arduino IDE 2.0 only, for IAR features, you should refer to the application note.

Thank you, WYY!
Yes, I am working on this :

Wish me luck today… :slight_smile: