cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 and Erase Sector time

SKokk.1
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

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

View solution in original post

4 REPLIES 4

Pretty sure the Data Sheet lists expected write/erase times

2 seconds per 128KB sector erase as I recall

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

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.

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

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.1
Associate II

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.