Step-through debugging via a UART on ARM Cortex-M MCUs | Interrupt

Debugging an MCU requires attaching a debugger via JTAG and halting the core. Or does it?

There are many situations where this debug strategy is not feasible such as on


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/cortex-m-debug-monitor

Hi, chris coleman:
I’m interested in this topic, but when I disable Halting Debug from GDB, the result is different from what you said. I use stm32F769I_Discovery platform with on board stlink debugger.
when gdb set: set (uint32_t)0xE000EDF0=(0xA05F<<16), DHCSR register result is not 0xA05F0000, then I step, the debugger crash.


Do you have some idea, the stlink do not support Monitor Mode Debugging?
Is there some other way to write DHCSR register with the current platform, waiting for your reply, thank you.

Hi, it is normal because once you clear the enable bit on DHCSR, it will disable the halt mode right now. So the stlink cann’t work before next reset. You can only do monitor debug on shell the next step. I port it to my stm32f103rc chip and it work.

Another tip is that you should enable the AFIO_MAPR register for stm32 chip to enable the memory remap fro debugger. At first I disable it which cause a “cann’t access memory” error when I try to do set (uint32_t )0xE000EDF0=(0xA05F<<16), on gdb

Hi, Jack3100:
Thank you for your reply and your working. I will try as your reply.
Could you tell AFIO_MAPR register address and the value, and could you shared stm32f103rc porting code or github website?

Hi, the AFIO_MAPR can be found at the stm reference “RM0008” section 9.4.2. I give you a screen shot here:

I still need some time to organize my port code. I will tell you when I’m ready.

enen,thanks very much, looking forward to your porting code~

Hi yingbin,

I’m glad to tell you my demo code is ready at https://github.com/cheng3100/armdbg. I wish you can give me some feed back like give me a star or issue on it if you like it.

:slight_smile:

Thanks