cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575VGT HAL_FLASHEx_Erase() not working (page is not erased)

Adriano Melis
Associate III

Hello all,

this code snippet is not working: the page is not erased, although the HAL does not report errors.

No RTOS is running.

 

if (HAL_ICACHE_Disable() != HAL_OK) {

Error_Handler();

}

 

status = HAL_FLASH_Unlock();

if (status != HAL_OK) {

Error_Handler();

}

 

erase_init_struct.TypeErase = FLASH_TYPEERASE_PAGES;

erase_init_struct.Banks = FLASH_BANK_1;

erase_init_struct.Page = 127;

erase_init_struct.NbPages = 1;

 

status = HAL_FLASHEx_Erase(&erase_init_struct, &page_error);

if (status != HAL_OK) {

Error_Handler();

}

 

Any suggestion?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Adriano Melis
Associate III

Hello all,

I found the source of the problem: the DUALBANK bit in FLASH_OPTR was set to 1.

On this device this arranges the FLASH page access in two banks of 64 pages each.

 

View solution in original post

12 REPLIES 12
TDK
Guru

How are you verifying the page is not erased? What tool and memory addresses are you looking at?

If you feel a post has answered your question, please click "Accept as Solution".

I am monitoring the page content using the Memory renderer of STM32Cube Ide, there are values different from the erased value 0xFFFFFFFF

Adriano Melis
Associate III

AdrianoMelis_0-1708528531593.png

 

Sarra.S
ST Employee

Hello @Adriano Melis 

The page 127 in bank1 is in 0x080F E000 - 0x080F FFFF 

the screenshot you showed, does not show page 127 

SarraS_0-1708530176754.png

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

AdrianoMelis_0-1708530610222.png

 

Adriano Melis
Associate III

my bad. this is an actual screenshot: Flash erase has been executed, FLASH content is unchanged.

(status value is HAL_OK)

 

Sarra.S
ST Employee

Hello @Adriano Melis

I tried to reproduce your issue using the FLASH_EraseProgram example in STM32U5CubeFW, however, page 127 was erased successfully and I couldn't reproduce it 

Maybe share a minor project to reproduce it on my side. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

hello, these are additional info:

  • the MCU is STM32U575VGT6 on a proprietary board clocked at 100 MHz: are there known problems on this particular device? The same code is OK on the Nucleo STM32U575ZI-Q
  • FLASH erase on a single page works fine from Cube Programmer
  • when the page is pre-erased with Cube Programmer writing data is successful

Hello @Adriano Melis 

I suppose you're setting Flash latency to 3WS? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.