Is my STT32F0 Dead after this code? - Page 1
Forum section: electronics / general

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 13, 2020, 01:18:39 pm
content: Hi,This is the first time, I'm trying to use low power mode for STM32F030KT6 part,The MCU was fine and everything was worked as expected, Now I have modified the code to put the MCU in low power mode.this is the code,Code:while (1){HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);}This code is put after the Cube generated code, and it was for testing, Now my j-link can not erase or flash the partIt would say something like thisQuoteSo, my guess is that when the MCU boots, it would go into sleep very soon, so the Debugger can not continue!What's your Ideas? is there a way to recover the MCU?

author: Skashkash
author_rank: Regular Contributor
timestamp: August 13, 2020, 01:42:56 pm
content: I noticed this on an L072 project. Debugger can not access part once it's in sleep mode.You need the reset pin to wake it up.Change your reset connect strategy under your IDE debug settings.Plus, make sure you have the reset pin connected to the target in addition to the usual 2 SWD pins. Or else use JTAG if possible.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 13, 2020, 01:57:06 pm
content: QuoteThanks, I'm using keil and J-link,this part has only SWD and I have connected RST pin too what should I do?

author: Skashkash
author_rank: Regular Contributor
timestamp: August 13, 2020, 02:36:09 pm
content: I don't use Keil.But there should be a setting in the debug configuration somewhere to enable the reset line. (if it's not already enabled)You could also maybe use the Segger J-flash utility to just erase the chip.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 13, 2020, 02:46:34 pm
content: I have changed all the different RST connection types, still no luck

author: Mecanix
author_rank: Frequent Contributor
timestamp: August 13, 2020, 02:51:22 pm
content: Shorting the rst pin with a 10k right after you press upload is often enough, if lucky.Properly done would require software assist though, CubeProgrammer got me out of trouble more than once...

author: Skashkash
author_rank: Regular Contributor
timestamp: August 13, 2020, 03:55:05 pm
content: Quote from: Mecanix on August 13, 2020, 02:51:22 pmI've manually shorted the rst line too when the programmer I had at hand did not bring out a reset drive line. Tricky to the the timing right.Was unaware of cube programmer. Will have to look at that for future reference.Also, for the OP.In extreme cases, you can try asserting the boot pins to force the target into bootloader mode. Then try to erase it using a ST utility.

author: hans
author_rank: Super Contributor
timestamp: August 13, 2020, 06:03:19 pm
content: If you have the dedicated JLink binaries installed, I think there is also a STM32 FLASH eraser tool that can be used to wipe the device clean of this kind of 'bricking' code (e.g. entering shutdown/sleep briefly after reset, without enough delay for the debugger to catch the target via SWD)On Linux I can use it with the command JLinkSTM32, then select my device. On Windows it's probably in the program files of JLink I think (it's a command line tool, no GUI, but very simple to use)I use it quite often as I've similar 'bricking issues' on STM32L4 running at a minimum clock (100kHz), with and without sleep usage.

author: ataradov
author_rank: Super Contributor
timestamp: August 13, 2020, 08:06:07 pm
content: This is annoying but certainly not going to kill the device.For the future to avoid the hassle of recovering the device - put a small delay before going to sleep (200 ms or so). This will give enough time for the debugger to connect and stop the core before your sleep code executes.

author: dgtl
author_rank: Regular Contributor
timestamp: August 14, 2020, 07:23:17 am
content: Another possibility to recover is to pull the BOOT0 pin to boot from internal bootloader. Then use the swd to re-program the chip. Once re-programmed, release the BOOT0.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 15, 2020, 11:17:46 am
content: Thanks for the hints, I is just pulled the boot leg up!now I can recover the deviceSad poor little thing