cancel
Showing results for 
Search instead for 
Did you mean: 

How to unlock SWD on STM32F0?

mmensch
Associate II
Posted on August 09, 2013 at 10:15

Hi,

I accidentally configured USART2 to pins PA14 and PA15 with PA14 being also SWCLK. Now I can't upload code anymore. I read about putting the MCU into bootloader mode by setting BOOT0 to Vdd. But this doesn't work either. When reseting in this state, PA14 is also high which means the port is configured as USART by the bootloader. I found a note in AN2606:

         

Note: After the STM32F051x6 and STM32F051x8 devices have booted in bootloader mode, the serial wire debug (SWD) communication is no more possible until the system is reset, because SWD uses PA14 pin (SWCLK) which is already used by the bootloader

(USART2_RX).

Is there any way to rescue my board (except of setting up a complete bootloader programming environment - or is there a simple tool doing it?)

Thank you very much for any help

Martin

4 REPLIES 4
crt2
Associate II
Posted on August 09, 2013 at 10:53

And why is a problem is PA14 is configured as USART on bootloader? That means you can program your board via USART (aka send mass erase command) which will make your SWD work afterwards.

frankmeyer9
Associate II
Posted on August 09, 2013 at 11:49

And why is a problem is PA14 is configured as USART on bootloader? That means you can program your board via USART (aka send mass erase command) which will make your SWD work afterwards.

 

That's correct.

To be more detailed: do the BOOT0/BOOT1 trick with a working UART connection to a PC (level shifter ?), then run the Flash Loader Demonstrator software (available from the ST site) to erase the Flash.

That should get your MCU accessible again.

mmensch
Associate II
Posted on August 09, 2013 at 16:43

Hi,

and thanks for the answers.

I didn't know about the flash loader tool and I first thought to get along faster, just put it into bootloader mode and reprogram it. Well now I learned how to work with the flash loader tool and my STM32F0 discovery kit is working again.

Thanks again

Martin

frankmeyer9
Associate II
Posted on August 09, 2013 at 18:46

This  UART access in bootloader mode is supported by all STM32 MCUs, and (with differents protocols), by other Cortex M variants, too.

Therefore I suggest to keep this kind of UART hardware in a drawer for the next of those events ...