Skip to main content
Visitor II
July 31, 2020
Solved

STM32F429 and Erase Sector time

  • July 31, 2020
  • 3 replies
  • 1637 views

Hello,

MCU: STM32F429ZI

I am building a bootloader for my project to upgrade the application firmware from SD card.

Everything works fine but the total time for a ~2MBytes .bin file is almost 45 seconds. So, i am trying to check each step and try to reduce its time.

  • Sector Erase Time

Sectors erasing takes up to 25 seconds, is there a way to reduce it? I am using the below function:

EraseStruct.NbSectors = (uint32_t)(NbOfSectors); 
if(HAL_FLASHEx_Erase(&EraseStruct, &SectorError) != HAL_OK) {
.
.
}
  •   Flash Writing Time

Writing to Flash (+ time to read from file) takes about 20 seconds. Is there a way to write more than doubleword to reduce the time?

if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, FileData) == HAL_OK) {
.
.
.
}

 Thank you.

    This topic has been closed for replies.
    Best answer by TDK

    Can't do anything about the erase time.

    You can improve write time by writing your own driver for it. It's not very complicated. HAL does a lot of extra stuff and calling one function per byte isn't efficient. I imagine this would speed things up quite a bit.

    Programming double words has a voltage requirement of 7-9V which you probably don't satisfy.

    3 replies

    Graduate II
    July 31, 2020

    Pretty sure the Data Sheet lists expected write/erase times

    2 seconds per 128KB sector erase as I recall

    TDKAnswer
    Super User
    July 31, 2020

    Can't do anything about the erase time.

    You can improve write time by writing your own driver for it. It's not very complicated. HAL does a lot of extra stuff and calling one function per byte isn't efficient. I imagine this would speed things up quite a bit.

    Programming double words has a voltage requirement of 7-9V which you probably don't satisfy.

    SKokk.1Author
    Visitor II
    August 1, 2020

    It's single WORD, my bad.

    if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, FileData) == HAL_OK) {
    	if(*(uint32_t*)Address != FileData) {
    				 /* De-initialization of SD-FileSystem */
    				 SimpleSD_DeInit();
    				 /* Locks the FLASH control register access. */
    				 HAL_FLASH_Lock();
    				 /* Flash Data Compare error */
    			 return SIMPLESD_FLASH_WRITE_COMPARE_ERROR;
    	 }
    	Address += sizeof(FileData);
    }

    SKokk.1Author
    Visitor II
    August 1, 2020

    You can improve write time by writing your own driver for it. It's not very complicated. HAL does a lot of extra stuff and calling one function per byte isn't efficient. I imagine this would speed things up quite a bit.

    I will try it, thank you.