cancel
Showing results for 
Search instead for 
Did you mean: 

ST-Link Utility : Mass flash erase fails, however erase bank 1 and 2 works

Ali Mousavi
Associate
Posted on December 01, 2017 at 16:13

I can connect to my MCU with the ST-Link Utility and ST-Link V2.  I can perform an erase of Bank 1 and Bank 2

(Target -> Erase Bank1).  I can perform an erase of all flash pages (Target -> Erase Sectors...).  

However, the st-link utility fails to perform a 'flash erase' (Target -> Erase Chip), I get the message 'Error occured during flash mass erase!'

I tried to perform a full flash erase with Keil UV5 with the same result: I get an error, however I am able to erase individual sectors or banks.

My setup:

MCU (STM32L476RGT6)

ST-Link Utility (v4.1.0.0)

ST-Link V2 (V2.J28.S7)

#stm32l476 #stm32l476-flash #st-link-utility #stm32-st-link-utility #flash-erase #st-link-utility
3 REPLIES 3
Scott Löhr
Senior II
Posted on December 12, 2017 at 00:37

ST please help, this seems to be not trivial error with ST-Link Utility, I have also latest v4.1.0.0, trying to work with Nucleo L496ZG-P dev board:

sometimes same as above, sometimes after erase 1 then erase 2, 'full chip erase' does work.

But very much bigger problem: the utility bombs out programming a .bin file for the full 1-MB. So I broke it into half, and even bombs on trying to program a .bin file for lower half:

15:11:44 : The elf loader Program function fails.

15:11:49 : The elf loader Program function fails.

15:11:49 : Memory-Loader error

15:11:49 : Error occured during program operation!

15:11:59 : Programming error @: 0x0807FFFC

And fail for .bin file for upper half:

15:15:12 : The elf loader Program function fails.

15:15:17 : The elf loader Program function fails.

15:15:17 : Memory-Loader error

15:15:17 : Error occured during program operation!

15:15:27 : Programming error @: 0x0807FFF0

I think that a big clue for you is the difference of where it fails. In lower half, last line of 16 bytes has last 4 bytes as non-0xFFFFFFFF after a huge block of all erased values (just pad fill 0xFFFFFFFF). In upper half, last line of 16 bytes has all 16 bytes as non-0xFFFFFFFF after a huge block of all erased values (just pad fill 0xFFFFFFFF).

Makes me think that the ST-Link Utility is doing some form of 'fast flash program' like HAL API, programming blocks of 32 x 8-byte word size (or blocks of 256 bytes), but then gets tripped up by this last page with non-erased at end?

Anyway, this identical binary file (whether entire 1-MB, or half by half) will program just fine into a dev board with STM32F476RG.

So again, ST, please help with programming of Nucleo L496ZG-P dev board.

Posted on December 12, 2017 at 00:57

WRT the bank 1/2 succeeding but full flash erase failing, after I changed Target-->Settings-->SWD Frequency from the default 4.0 MHz down ot 1.8 MHz, full flash erase seems to always work now. But inability to program an entire flash bank still fails, as well as program entire 1-MB continues to fail.

Posted on December 13, 2017 at 04:27

So finally, in desperation, I tried uninstalling the ST-Link Utility v4.1.0.0 and then installing the v4.0.0.0 and magically, all issues disappeared  :\