2020-07-31 09:18 AM
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.
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) {
.
.
}
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.
Solved! Go to Solution.
2020-07-31 03:23 PM
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.
2020-07-31 09:40 AM
Pretty sure the Data Sheet lists expected write/erase times
2 seconds per 128KB sector erase as I recall
2020-07-31 03:23 PM
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.
2020-08-01 01:54 AM
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);
}
2020-08-01 01:56 AM
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.