Skip to main content
DVars.1
Associate II
June 29, 2021
Question

Flash corrupted, showing ? (Question mark)

  • June 29, 2021
  • 3 replies
  • 2076 views

I am working with STM32CubeIDE on device STM32H743

I am working with the flash and sometimes the data inside them being corrupted, showing ?.

What may be the reason causing some of the memory to show ?.

How can i identify that without getting hardfault?

Why after using HAL_FLASHEx_Erase_IT, the data is '0' instead of '1'?

This topic has been closed for replies.

3 replies

TDK
Super User
June 29, 2021

Probably the memory shows as ??? while a flash erase is ongoing. Bits should be 1 after an erase, perhaps you're not erasing what you intend to erase. Show some code or screenshots to better explain your situation.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DVars.1
DVars.1Author
Associate II
June 30, 2021

I erase the the correct sector, i checked that and it usually works so it is the correct place. I do the regular flaw as i so in many examples:

FLASH_EraseInitTypeDef pEraseInit=

{

.Banks = FLASH_BANK_2,

.NbSectors = 2,

.Sector = Sector_0,

.TypeErase = FLASH_TYPEERASE_SECTORS,

.VoltageRange = FLASH_VOLTAGE_RANGE_3

};

uint32_t error_sector;

status = HAL_FLASH_Unlock();

if (status != HAL_OK) return status;

status = HAL_FLASHEx_Erase(&pEraseInit, &error_sector);

if (status != HAL_OK) return status;

status = HAL_FLASH_Lock();

if (status != HAL_OK) return status;

-------------------------------------------------------------------------

All off that after initializing the HAL and system clock.

Today i saw that sometimes the erase function returns error. Don't know why yet.

TDK
Super User
June 30, 2021

> Today i saw that sometimes the erase function returns error. Don't know why yet.

That would explain why some bits are 0.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Guru
June 29, 2021

Unwritten or fails ECC, or beyond scope​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
DVars.1
DVars.1Author
Associate II
June 30, 2021

Why sometimes the erase fail? Why ECC fail?

alister
Senior III
June 30, 2021

Reads of PCROP enabled areas return 0. A read would not cause a bus error, but would set the FLASH_SR1/2.RDPERR1/2 flag. Could also check for it by seeing if PCROP is enabled in PROT_AREA_START1/2 and PROT_AREA_END1/2 in FLASH_PRAR_CUR1/2 with STM32CubeProgrammer or similar. An area is enabled if PROT_AREA_END1/2 > PROT_AREA_START1/2. A full bank is enabled if PROT_AREA_END1/2 = PROT_AREA_START1/2.

DVars.1
DVars.1Author
Associate II
June 30, 2021

The PCROP is not active, the START is 0xff and END is 0x00. i think it is not functional on the sectors i am using.

I am using the 2 first sectors of the second bank.