Skip to content

Optimise erase time for stm32f410/413/423#1493

Closed
jameswalmsley wants to merge 1 commit into
stlink-org:testingfrom
jameswalmsley:jw/f4-fast-erase
Closed

Optimise erase time for stm32f410/413/423#1493
jameswalmsley wants to merge 1 commit into
stlink-org:testingfrom
jameswalmsley:jw/f4-fast-erase

Conversation

@jameswalmsley

Copy link
Copy Markdown

Repeated flashing f413 with st-link is very very slow compared to j-link / stm32 cube.
This ensures full sector erases are used when possible.

STM32F410 and STM32F413/F423 were missing from the F4 sector-size list in
stlink_calculate_pagesize(), so they fell back to the uniform flash_pagesize
(16 KB) from the chip config. The erase loop advances by that page size, but
calculate_F4_sectornum() maps every address within a sector to the same
sector number -- so a 64 KB sector was erased 4 times and a 128 KB sector 8
times.

Add both chip ids to the list so the erase advances by the real sector size
(16/64/128 KB) and erases each sector once. Measured on a Nucleo-F413ZH: a
512 KiB write dropped from ~44 s to ~16 s (32 -> 4 sector erases). Small
16 KB sectors are unchanged (page size already matched the sector).

Signed-off-by: James Walmsley <james@fullfat-fs.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant