blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.22k stars 768 forks source link

STM32L1 stuck in WFI after flash error #955

Open tomasvr opened 2 years ago

tomasvr commented 2 years ago

Dear community, I have been using a BMP to program and debug the stm32l162 processor with GDB. Most of the time this works without problems, but now I have ran into a problem during flashing which has left the mcu unresponsive.

I was trying to flash new firmware and during the load phase the following error occured:

Error writing data to flash

This has happened before, but usually I would just try to flash again and that would work. This time however, when I retry to flash firmware onto the mcu I keep getting the following response:

Target voltage: 1.79V
Timeout during scan. Is target stuck in WFI?
Timeout during scan. Is target stuck in WFI?
SW-DP scan failed!
gdb/gdb.gdb:3: Error in sourced command file:
.gdb/target:4: Error in sourced command file:
Attaching to Remote target failed

It seems to me like the MCU is stuck in a faulty state in which it is unresponsive to the SWD lines, possibly because of the error during writing to flash in the load phase.

what I've tried so far:

None of these seem to help. Since I currently don't have access to another set of cables/probe/target I cannot verify whether this problem is exclusive to this single board.

Any help is welcome. Thank you in advance!

UweBonnes commented 2 years ago

Please compile hosted. First run "blackmagic -t", If it fails, run, post the output. If it syucceeds, try to flash "blackmagic . Also state if WFI/WFE or deep sleep is involved, or a remap of the SWJ pins.

tomasvr commented 2 years ago

Sorry, I accidentally pressed enter while my post was still incomplete and you had already responded.

I do make use of deep sleep and WFI. My first thought was also that the MCU might immediately enter WFI after boot which means it would be unreachable for the probe. Thus I tried to enable the connect_srst option but that had no effect. Furthermore I do not see any output on my serial debug line so I suspect the application is not being run at all. Lastly, I am not aware of any SWJ pin remapping.

I will try your suggestion, thank you!

UweBonnes commented 2 years ago

Just a remainder: connect_srst needs NRST connected. What BMP platforms do you use?