Skip to main content
SKokk.1
Associate III
Jul 31, 2020 4:18 PM UTC
Solved

STM32F429 and Erase Sector time

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.
TDK
TDKBest answer
Jul 31, 2020 10:23 PM UTC

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""."

4 replies

Tesla DeLorean
Guru
Jul 31, 2020 4:40 PM UTC

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
TDK
TDKBest answer
Jul 31, 2020 10:23 PM UTC

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""."
SKokk.1
SKokk.1Author
Associate III
Aug 1, 2020 8:54 AM UTC

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
SKokk.1Author
Associate III
Aug 1, 2020 8:56 AM UTC

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.