If you are troubleshooting an unexpected behavior in your code, it often beneficial to be able to see the values of variables while your code is running to speed up debugging. This tutorial shows how to use a Segger J-Link debugger probe, together with the Ozone standalone debugging software, to debug your code running on the RTL8722 EVB.
Step 1: Get a debugger probe.
You will need to get a Segger debug probe first if you have yet to get one. The various models and specifications can be found at J-Link Debug Probes - SEGGER - The Embedded Experts. It is fine to buy the EDU or EDU mini version of the debug probe, these are often the cheapest option.
Step 2: Install required software.
From this link: SEGGER - The Embedded Experts - Downloads - J-Link / J-Trace, download and install the “J-Link Software and Documentation Pack” and “Ozone – The J-Link Debugger software”. These are required to communicate with the debug probe and debug your code.
Step 3: Compile and upload your code.
Depending on which SDK/IDE you are using, follow the regular process to compile and upload your code. If you are using the Arduino IDE, do not close the IDE window after uploading, as doing so will delete the compiled application file from the temporary folder.
Step 4: Connect the debug probe.
The RTL8722 EVB has SWD debug pins located on the top left of the board, when the USB ports are pointed downwards, as seen here:
Connect the SWD debug pins to the J-Link debug probe following the SWD pinout: J-Link interface description JTAG/cJTAG/SWD/SWO - SEGGER - The Embedded Experts.
Step 5: Run and setup Ozone
Launch the Ozone application. The New Project Wizard should pop up. Choose the Cortex-M33 as the target device.
In the next window, you should be able to see and select the J-Link debug probe connected to the PC. Ensure that SWD is selected as the target interface.
In the next window, you will need to provide Ozone with the compiled application file.
- If you are using Arduino IDE, go to C:\Users\%USERNAME%\AppData\Local\Temp, and look for a folder that looks like “arduino_build_243508” with different numbers. The folder’s modified date and time should correspond to time of compilation. Provide Ozone with the path to the “application.axf’ file in the folder.
- If you are using the GCC SDK, provide the path to the “target_img2.axf” file in the “\project\realtek_amebaD_va0_example\GCC-RELEASE\project_hp\asdk\image” folder.
In the next window, provide Ozone with the path to the “AP2_KM4.JLinkScript” file, which can be found in “\project\realtek_amebaD_va0_example\GCC-RELEASE\project_hp\jlink_script” or downloaded from ambd_sdk/AP2_KM4.JLinkScript at master · ambiot/ambd_sdk · GitHub.
Step 6: Debug
You are now ready to debug. You should see your code opened in the central window, with the cursor at the main function of main.cpp or main.c file. Reset the RTL8722, ensure that your code is running on the EVB, and click on “Attach to running program” in the top left next to the green power icon to start debugging.