Skip to content

chore(spiflash): improve the efficiency of "is block erased" detection - #7582

Open
richardclli wants to merge 1 commit into
mainfrom
richardclli/fix-spiflash-efficiency
Open

chore(spiflash): improve the efficiency of "is block erased" detection#7582
richardclli wants to merge 1 commit into
mainfrom
richardclli/fix-spiflash-efficiency

Conversation

@richardclli

@richardclli richardclli commented Jul 24, 2026

Copy link
Copy Markdown
Member

The spi_flash.cpp flashSpiIsErased function is not efficient, it only use byte by byte read and it is slow.
New strategy:

  1. Read the first 4 bytes using byte by byte method
  2. If the first 4 bytes shows it is erased, use DMA to ensure the whole block is erased

This can guarantee the efficiency of is erase detection for both used and erased blocks.

2.11 fix combines in #7472, no need to merge to 2.11 branch

Summary by CodeRabbit

  • Performance Improvements
    • Improved flash erase verification speed by using bulk, DMA-friendly reads rather than checking every byte individually.
    • Added a two-phase sector verification approach to robustly confirm erased flash contents.
  • Maintenance
    • Updated a bundled third-party dependency to a newer revision for ongoing compatibility and fixes.

@richardclli richardclli added this to the 2.12.3 milestone Jul 24, 2026
@richardclli richardclli self-assigned this Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

flashSpiIsErased now uses staged DMA validation with a static sector buffer. The commented-out FTL garbage-collection call is removed, and the stb submodule pointer is updated.

Changes

Flash and FTL updates

Layer / File(s) Summary
DMA-backed sector validation
radio/src/targets/common/arm/stm32/spi_flash.cpp
Adds a DMA-capable sector buffer and replaces the full byte-by-byte scan with initial four-byte checks followed by DMA validation of the remaining bytes.
FTL read cleanup
radio/src/drivers/frftl.cpp
Removes the commented-out doGC call from ftlRead; the existing bounds check and read path remain unchanged.
stb submodule update
radio/src/thirdparty/stb
Updates the submodule pointer to a different upstream commit.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it omits required template sections such as 'Summary of changes:' and an optional 'Fixes #' reference. Add the template headings, especially 'Summary of changes:', and include a 'Fixes #' reference if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: improving flashSpiIsErased erase-detection efficiency.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pfeerick pfeerick added backport/2.12 To be backported to a 2.12 release also. house keeping 🧹 Cleanup of code and house keeping labels Jul 24, 2026
@pfeerick pfeerick changed the title chores: Improve the efficiency of is block erased detection chore(spiflash): improve the efficiency of "is block erased" detection Jul 24, 2026
@richardclli
richardclli force-pushed the richardclli/fix-spiflash-efficiency branch from 3cf27f5 to f18c6f1 Compare July 24, 2026 06:32
@richardclli
richardclli marked this pull request as draft July 27, 2026 04:33
@richardclli
richardclli marked this pull request as ready for review July 27, 2026 05:00
@richardclli

Copy link
Copy Markdown
Member Author

Tested, this change is already in my daily use radio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. house keeping 🧹 Cleanup of code and house keeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants