Skip to content

fix(extflash): keep page program commands inside one NOR page - #7950

Open
inskr wants to merge 2 commits into
EdgeTX:mainfrom
inskr:extflash-page-boundary
Open

inskr wants to merge 2 commits into
EdgeTX:mainfrom
inskr:extflash-page-boundary

Conversation

@inskr

@inskr inskr commented Oct 27, 2026

Copy link
Copy Markdown

Fixes #7576

Summary of changes:

  • stm32_qspi_nor_program() and stm32_xspi_nor_program() now stop at the page boundary instead of handing the whole length to one page program command.
  • The 256-byte page constant sits next to each driver.

I put the fix in the shared driver instead of in each board's extflash_program(): nine extflash_driver.cpp copies call into these two functions (the issue lists five), and the lower layer is where the page size is known.

The per-board loops still slice by length. That is harmless now, the lower layer re-slices on the page boundary.

How it was checked

Host harness: the patched function body compiled against a fake HAL that wraps like real NOR flash. HAL_QSPI_Command() / HAL_QSPI_Transmit() are stubbed, and every page program command is checked for offset + len > 256.

Current master:

addr=0x100 len=300 -> cmds=1 cross_page=1 CORRUPT (44 bytes wrong, first +256)
addr=0x180 len=300 -> cmds=1 cross_page=1 CORRUPT (171 bytes wrong, first +128)
addr=0x1F0 len=32  -> cmds=1 cross_page=1 CORRUPT (16 bytes wrong, first +16)

With this patch:

addr=0x100 len=300 -> cmds=2 cross_page=0 ok
addr=0x180 len=300 -> cmds=2 cross_page=0 ok
addr=0x1F0 len=32  -> cmds=2 cross_page=0 ok

Both changed functions are STM32 HAL only, so this is as far as it goes without a radio. The normal update path writes page aligned from a sector start, so a hardware test would not show a difference either way.

inskr and others added 2 commits October 27, 2026 15:37
extflash_program() sized each write with min(len, QSPI_NOR_PAGE_SIZE), which
is only correct when the address is page aligned. A page program command that
starts mid-page wraps at the page boundary and overwrites the start of the
same page.

The limit now lives in stm32_qspi_nor_program() and stm32_xspi_nor_program(),
the two functions every board's extflash_driver.cpp calls into, so the fix
covers all nine copies at once.

Fixes EdgeTX#7576
Don't split MEMORY_READY_MATCH_VALUE and MEMORY_READY_MASK_VALUE

This branch has not been deployed

No deployments
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.

extflash_program: page-alignment not handled in NOR flash write loop

2 participants