Debugging the Cortex-M0 Core with openocd
Posted: 2025-07-24 20:08
Hi,
On the Milk-V Duo I can develop bare metal software on the small core using a JTAG debugger.
I would like to do the same on the rk3506 (Luckfox Lyra Plus). So using openocd and a SWD debugger I would like to contact to the Cortex-M0 core, upload the software from the ide, and debug from the IDE. So the development cycle is about 5 seconds or less.
Now as the RK3506 reference manual is available, there is much more information about the chip.
I switched the UART0 to SWD port M1 with these commands:
I could connect this way with the openocd to the A7 core (using some rk3308 based configuration):
So I think my debug probe and hw setup works.
But If I routed the M1 port to the Cortex-M0 core with this:
I got no response from the chip using the openocd:
I tried to enable the HCLK_M0 and STCLK_M0 clocks with these
Still no success ("Error: Error connecting DP: cannot read IDR)").
Remark: I did not load any code into the Cortex-M0 memory (at 0xFFF80000).
There is a note in the rk3506 TRM (reference manual):
grf_con_mcu_dbgen: SerialWire Debug Enable, 0 = disable, 1=enable, default=0.
But in the TRM I did not find any register with this name or any register containig containing this switch.
Can someone help me to connect to the Cortex-M0 core with openocd?
I like this board, the rk3506 seems to be an excellent device, but this must also work for me.
Best Regards,
nvitya
On the Milk-V Duo I can develop bare metal software on the small core using a JTAG debugger.
I would like to do the same on the rk3506 (Luckfox Lyra Plus). So using openocd and a SWD debugger I would like to contact to the Cortex-M0 core, upload the software from the ide, and debug from the IDE. So the development cycle is about 5 seconds or less.
Now as the RK3506 reference manual is available, there is much more information about the chip.
I switched the UART0 to SWD port M1 with these commands:
Code: Select all
iomux 0 22 2
iomux 0 23 2
Code: Select all
Info : SWD DPIDR 0x2ba01477
Info : [rk3308.ahb] Examination succeed
Info : rk3308.core0: hardware has 1 breakpoints, 1 watchpoints
But If I routed the M1 port to the Cortex-M0 core with this:
Code: Select all
devmem 0xFF288000 w 0x00300020
Code: Select all
Error: Error connecting DP: cannot read IDR
Code: Select all
devmem 0xFF9A0814 w 0x04000000
devmem 0xFF9A0820 w 0x00040000
Remark: I did not load any code into the Cortex-M0 memory (at 0xFFF80000).
There is a note in the rk3506 TRM (reference manual):
grf_con_mcu_dbgen: SerialWire Debug Enable, 0 = disable, 1=enable, default=0.
But in the TRM I did not find any register with this name or any register containig containing this switch.
Can someone help me to connect to the Cortex-M0 core with openocd?
I like this board, the rk3506 seems to be an excellent device, but this must also work for me.
Best Regards,
nvitya
