JLink debug. Breakpoint in main

Hi All,
According AN after starting two JLink servers next is uploading images and start debugging.
But after make flash and make debug. Then I should enter “monitor reset” and set one bit by “x/1wx 0x480003f8” and “set {unsigned}0x480003f8=0x02000201”…

But how to reset from gdb to catch breakpoint in main function? Is it possible?

Is it mandatory to upload firmware via make flash or using flashing tool also possible?

Is it possible to debug by Eclipse? There is JLink plug in but I dont have any ideas how download image using eclipse.

Hi @Tuxford,

For the same question regarding GDB, please add your further questions in your previous post GDB server for KM4 .
You NEED NOT create a new topic for the same question.

  1. Please specify the requirement you would like to fulfill. Debug or upload an image (flash) to your RTL8720DN.
    make debug: is to enter the debug mode
    make flash: is to download all 3 necessary images to your flash chip

According to AN0400 Chapter 1.4.2 Setting Debugger - JLink, there is nowhere indicating that you need to start two JLink servers. Besides, there is not necessary to enter “monitor reset” and any other commands as you described. PLEASE STRICTLY FOLLOW THE APPLICATION NOTE STEP BY STEP!

  1. Steps to reset KM0 and KM4 are different.
  • For KM0, you need to use the “monitor reset” instruction in the corresponding rtl_gdb_debug.txt to reset it under debug. The default path of this file is under \project\realtek_amebaD_va0_example\GCC-RELEASE\project_lp\asdk\gnu_utility\gnu_script\rtl_gdb_debug.txt.

  • For KM4, you need to use the “monitor reset” instruction in the corresponding rtl_gdb_debug.txt first. Then, set the bit[25] of memory address 0x4800_03f8 to 1 because the boot process of KM4 is controlled by KM0. Without this operation, the KM4 can’t jump out of the boot function. Details of this operation are as follows:

    • After executing “make debug” instruction, a debug window pops up.

    • In this window. Set bit[25] to 1, then type “c”, the KM4 is reset.


    Note: Only resetting KM0 may cause KM4 to work in an abnormal way because KM0 reboot will change some settings of KM4.

Please refer to AN0400 Chapter 1 for full details.

You are allowed to upload via both make flash and Image Tool. We recommend open source users to use Image Tool to upload the firmware.

Please refer to AN0400 Chapter 8 Image Tool

For anything that is not covered in the AN0400, you may proceed to ask for the NDA version of SDK and require further support from a dedicated FAE (Field Application Engineer).

Thank you.

HI @dakamaster

Thank you for the quick answer.

  1. I understand how to upload image. But I haven’t catch yet all steps and sequences for debugging.

  2. Current I debug only KM4 only. But is Now I see that one JLink server is enough if I don’t use ‘make flash’.

  3. I debug only KM4, I follow this chapter.

For KM4, you need to use the “monitor reset” instruction in the corresponding rtl_gdb_debug.txt first.
But there is

#monitor reset 1
#monitor sleep 20
#monitor clrbp #Ameba_todo

And when I run make debug and reset chip by EN pin I can’t debug it until monitor reset and so on.

  1. My college @Muecke has already send request about NDA there is no answer for week or two.


Hi @Tuxford,

Thanks for your information. actually, for the open-source team, all the information about “make debug” is from the Application Note AN0400. Since there is not a clear guide yet. I am afraid we can only go through the NDA method to find an FAE dedicated to this issue.

As I mentioned previously, make flash and make debug are different. make flash allows you to upload an image using Jlink SWD. if you are using Windows OS, we suggest that you can just use the Image Tool.exe to upload an image. However, for make flash, you might need to do it in lp followed by hp due to some of the make rules for copying files from lp folders. But all of these are not linked with make debug.

I have informed my colleague to chase the NDA case from your college.

Thanks again.

1 Like

Hi @dakamaster
Thank you.
We use Linux (Ubuntu) for development. Tool amebad_image_tool. It works fine,
I haven’t got only how to catch breakpoint in main() function. After reset it starts immediately,

Hi @Tuxford,

Maybe you can take a look at this arduino example with a software breakpoint code __asm__(null); added, to confirm whether it can stop at the line you would like to further debug?

For more information, you can refer to another guide [Tutorial] Debugging RTL8722 with the new Arduino IDE 2.0 in this forum.

Thank you.