AnsweredAssumed Answered

Check under debug mode for ARM semihosting

Question asked by ctc.ctc on Jun 15, 2017
Latest reply on Jun 15, 2017 by Clive One

I'm study cortex-m4 for semihost and use stm32f429-discovery board. I have a trouble with that semihost can not work when board is standalone(without in debug mode), So, I hope to use judge debug status before printf(), like

if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \         ==CoreDebug_DHCSR_C_DEBUGEN_Msk) {     printf("THIS IS SEMIHOST\n"); }

In normal situation, it will be like my expect, in debug mode, I can see semihiost log, in standalone, nothing pending. But in one situation, when I just burn the code into flash (using openocd or texane stlink with stlink hardware in linux). The first time it run, the bit of debug mode(CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) keep being 1. I thought it should not be in debug mode, even I press reset hardware button on the board, it still keep 1, and the program will pending in printf().

After I plug out the power and then plug again, the debug mode bit will back to 0, and it work correctly now, Is this trouble can be solved? or I use wrong openocd command? Thanks.

openocd command I use:

openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg \ -c "init" \  -c "reset init" \ -c "flash write_image erase XXX.bin 0x8000000" \ -c "reset run" \ -c "shutdown"

Outcomes