Skip to content

arch/arm/stm32: fix undeclared page variable in flash write#18295

Closed
adwait-godbole wants to merge 8 commits intoapache:masterfrom
adwait-godbole:arch/stm32-fix-dualbank-flash-page
Closed

arch/arm/stm32: fix undeclared page variable in flash write#18295
adwait-godbole wants to merge 8 commits intoapache:masterfrom
adwait-godbole:arch/stm32-fix-dualbank-flash-page

Conversation

@adwait-godbole
Copy link
Copy Markdown
Contributor

This PR fixes a compilation error in stm32f10xxf30xx_flash.c where the variable page was used without being declared in up_progmem_write().

The issue is configuration-dependent and occurs when STM32_FLASH_DUAL_BANK is enabled.

The fix derives the page index from the write address using up_progmem_getpage() and uses it for flash bank selection.

Fixes #18172

Fix a compilation error in stm32f10xxf30xx_flash.c where the variable
`page` is used without being declared in up_progmem_write().

The issue appears when STM32_FLASH_DUAL_BANK is enabled.

The page index is now derived from the write address using
up_progmem_getpage() and used for bank selection.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small labels Jan 31, 2026
@adwait-godbole adwait-godbole changed the title arch: stm32: fix undeclared page variable in flash write arch/arm/stm32: fix undeclared page variable in flash write Jan 31, 2026
acassis
acassis previously approved these changes Jan 31, 2026
CV-Bowen and others added 4 commits January 31, 2026 13:09
Add empty line after `}`

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Replace all goto statements with structured control flow using while loops and
conditional blocks. Consolidate early returns into a single error-handling path
for better code structure and MISRA HIS standards compliance.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Extract the core waitid logic into a separate waittcb() helper function to reduce the
cyclomatic complexity of the main waitid() function. This improves code maintainability,
reduces nested conditions, and enhances code clarity while preserving all functionality.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
Fix a compilation error in stm32f10xxf30xx_flash.c where the variable
`page` is used without being declared in up_progmem_write().

The issue appears when STM32_FLASH_DUAL_BANK is enabled.

The page index is now derived from the write address using
up_progmem_getpage() and used for bank selection.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
…t-godbole/nuttx into arch/stm32-fix-dualbank-flash-page
…t-godbole/nuttx into arch/stm32-fix-dualbank-flash-page
@adwait-godbole adwait-godbole requested a review from yamt as a code owner January 31, 2026 17:04
@github-actions github-actions bot added Area: Drivers Drivers issues Area: OS Components OS Components issues Size: M The size of the change in this PR is medium labels Jan 31, 2026
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Jan 31, 2026

@adwait-godbole I missed a detail during the view: the generic flash code cannot depend on PROGMEM. Progmem is a featured used when you want to have write access to internal flash of the microcontroller

@adwait-godbole
Copy link
Copy Markdown
Contributor Author

@adwait-godbole I missed a detail during the view: the generic flash code cannot depend on PROGMEM. Progmem is a featured used when you want to have write access to internal flash of the microcontroller

@acassis I've re-opened the PR here. I will address your request over there. Thanks.

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

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Area: OS Components OS Components issues Size: M The size of the change in this PR is medium Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Compilation error in stm32f10xxf30xx_flash.c: 'page' variable used without definition

4 participants