cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to erase flash sector in STM32F765VI

Mike Hooper
Senior
Posted on September 18, 2017 at 17:48

STM32F765VI on custom board.

Atollic TrueStudio

SEGGER JLink SWD

I am unable to erase a sector of flash in my custom board using an STM32F765VI chip. I am using the HAL function HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError). I can step through the program and watch the registers get set properly:

LOCK=0

SER=1

SNB=7

PSIZE=2

I can watch the STRT bit get set, followed by the BSY bit being set. But PG does not get set and the sector is not erased. I see no error flags being set.

Can anyone offer some guidance into what may be happening?

Thanks,

MikeH

5 REPLIES 5
Posted on September 18, 2017 at 18:42

>>But PG does not get set and the sector is not erased. I see no error flags being set.

Excuse my ignorance with the F7, but why would PG get set during an Erase?

Make sure you're looking at the right memory, the addresses can change based on mapping/banking options.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 18, 2017 at 19:41

Excuse my ignorance with the F7, 

but why would PG get set during an Erase?

Hmm... not your ignorance, but mine.

Make sure you're looking at the right memory, the addresses can change based on mapping/banking options.

I am sure that I am looking at the correct memory space. I can see my op code in the lower sectors. I can also see my config variables stored in the sector I am attempting to erase.

I did actually see the sector get erased once. But I cannot replicate the erasure. I have tried erasing several different sectors to no avail. I have also tried different prarllelism. 

Curt Black
Associate II
Posted on October 28, 2017 at 06:25

I am having the same issue.  PNB & PER are set correctly, and there is no error.  Flash memory remains unaffected..

UPDATE:

It appears that while debugging (jlink), I cannot erase any part of MCU flash.  If I remove the JTAG and let the same program execute, the print messages now show erased flash.

Why is this??  Does the STM32 have some sort of flash lockout while debugging?

Note.. it is not cache related, all cache/prefetch, etc is disabled

Posted on November 02, 2017 at 12:14

 ,

 ,

Curt,

Although I am still working on a solution, I believe that there is some issue with the JLink and the STM32F7xx. The folks at Segger provided a firmware update (V6.20b) that did not fix the problem. The JLink was also not able to accommodate dual-bank mode. But they have now provided a Wiki and a firmware update that is supposed to have fixed the problem (

https://wiki.segger.com/STM32F7 ♯ Flash_Dual_Bank_Mode

). I have not yet had a chance to try it. Let me know if you do.
Posted on November 02, 2017 at 15:42

I forgot to mention that my setup is STM32L431RC (single flash bank).

Also, the issue isn't that the Jlink flash/programmer does not work (which the above article addresses), it's that erasing from the -code- does not work while debugging.  Hopefully I worded that distinction correctly.