cancel
Showing results for 
Search instead for 
Did you mean: 

How to erase stm32f429 flash sector in dual bank mode?

ray
Associate II
Posted on March 27, 2015 at 06:38

429 has 1M flash and I divide it into two banks using dual bank mode. Each has 512MB. 

I want to erase sector 15 (0x0808 C000 - 0x0808 FFFF) , but it fails. But if I use single bank mode and erase sector 8 (0x0808 0000 - 0x0809 FFFF), it operate correct. As below, I use the standard function in Cube.

Who can give me a tips on how to solve it?

uint32_t FLASH_EraseSector(uint32_t sectorAdd)

{

FLASH_EraseInitTypeDef EraseInitStruct;

uint32_t errSector = RET_OK;

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

/* Fill EraseInit structure*/

EraseInitStruct.TypeErase = TYPEERASE_SECTORS;

EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3;

EraseInitStruct.Sector = FLASH_GetSector(sectorAdd);

EraseInitStruct.NbSectors = 1;

HAL_FLASHEx_Erase(&EraseInitStruct, &errSector);

HAL_FLASH_OB_Lock();

HAL_FLASH_Lock();

return errSector;

}

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
3 REPLIES 3
Posted on March 27, 2015 at 11:14

Are you sure it's not a 2MB part, or the software thinks it is? What's the exact part number?

What's value is returned in EraseInitStruct.Sector in these two cases?

I think also the OB Lock/Unlock are unnecessary, they would be in SPL code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ray
Associate II
Posted on March 28, 2015 at 17:06

Part number is STM32F429IGT6. It a 1 M part.

EraseInitStruct.Sector = 15, which is the right sector number in bank 2 [0x0808 C000 - 0x0808 FFFF].

I know sector+4 in HAL_FLASHEx_Erase() funtion then SNB is 19.

I don't know why it can't work. 

Any solution or insight here? Also facing the same issue