# \[Tutorial\] Debugging RTL8722 with the new Arduino IDE 2.0

**URL:** <https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656>\
**Category:** Arduino\
**Created:** [July 13, 2021, 7:37am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656 "2021-07-13T07:37:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [July 13, 2021, 7:37am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/1 "2021-07-13T07:37:13Z")

</div>

## 此教程的中文版：

> [@使用新的 Arduino IDE 2.0 调试 RTL8722](https://forum.amebaiot.com/t/arduino-ide-2-0-rtl8722/657):
>
> English version of this guide: [https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656)硬件和软件要求 硬件: RTL8720/RTL8721/RTL8722 DN/DM/DF 开发板 SEGGER JLink 调试器( [https://www.segger.com/products/debug-probes/j-link/](https://www.segger.com/products/debug-probes/j-link/) ) 软件: Arduino IDE 2.0 ([https://www.arduino.cc/en/software](https://www.arduino.cc/en/software)) SEGGER JLink 软件包 ( [https://www.segger.com/downloads/jlink/](https://www.segger.com/downloads/jlink/) ) 安装步骤 安装 Arduino IDE 2.0。 安装 Arduino IDE 2.0 的说明可以在以下网站找到 [https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2…](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing)

* * *

# Requirements

* * *

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

# 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](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](https://www.segger.com/products/debug-probes/j-link/technology/interface-description/) .

 ![AmebaD](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/0a2475920f4f8456c03709ad5a038c714b34613c.png)  
 ![AmebaD_mini](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/02c67e2a257a72594e35dc7a4e9275afd73dcf36.png)  
 ![SWD](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/ef69f51fea550c63192c86552359e477ea1a283f.png)

# Debug

* * *

Refer to [https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger](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.  

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.
> 
> ![6](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/7/7e6479f04917bca079cf51212111b386cccfd8c1.png)

> 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.
> 
> ![7](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/6/6ea328fbe2dc0b8921a1b4245b73edb65906cabc.png)

---

<div class="post-metadata">

**Author:** ![ajsb85](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/ajsb85/32/414_2.png) [@ajsb85](https://forum.amebaiot.com/u/ajsb85)\
**Post date:** [July 30, 2021, 3:34pm UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/2 "2021-07-30T15:34:11Z")

</div>

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**

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

```

This is my **launch.json** (Generated)

```json
{
  "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](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/de1cc787858559301ed666da5e1335f0d8ccd336.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/36ab549e06b62bc03aa1b8b7791735112e5afef5.png)

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [August 2, 2021, 6:39am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/3 "2021-08-02T06:39:58Z")

</div>

Great! THanks for sharing!

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

---

<div class="post-metadata">

**Author:** ![jdt1](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jdt1/32/1203_2.png) [@jdt1](https://forum.amebaiot.com/u/jdt1)\
**Post date:** [November 9, 2022, 8:55pm UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/4 "2022-11-09T20:55:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [November 10, 2022, 1:30am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/5 "2022-11-10T01:30:27Z")

</div>

it is still only in the dev branch on [GitHub](https://github.com/ambiot/ambd_arduino/tree/dev/Arduino_package/hardware/libraries/Debugging), 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.

---

<div class="post-metadata">

**Author:** ![Vic](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/vic/32/1217_2.png) [@Vic](https://forum.amebaiot.com/u/Vic)\
**Post date:** [December 29, 2022, 3:11am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/6 "2022-12-29T03:11:14Z")

</div>

> [@wyy](#):
>
> 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.**

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

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 29, 2022, 3:33am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/7 "2022-12-29T03:33:46Z")

</div>

@Vic

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

---

<div class="post-metadata">

**Author:** ![Vic](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/vic/32/1217_2.png) [@Vic](https://forum.amebaiot.com/u/Vic)\
**Post date:** [December 29, 2022, 3:40am UTC](https://forum.amebaiot.com/t/tutorial-debugging-rtl8722-with-the-new-arduino-ide-2-0/656/8 "2022-12-29T03:40:02Z")

</div>

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

 ![sdk](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/8/8de5590d95e04c80a876da083e5a1850b121dd68.png)

Wish me luck today… 🙂
