Skip to content

[platform] H7 Flash now uses interrupts - #9

Open
jgmess-dlr wants to merge 1 commit into
developfrom
platform/h7-flash-uses-interrupts
Open

[platform] H7 Flash now uses interrupts#9
jgmess-dlr wants to merge 1 commit into
developfrom
platform/h7-flash-uses-interrupts

Conversation

@jgmess-dlr

Copy link
Copy Markdown

No description provided.

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from f48364b to 1f9a569 Compare September 3, 2026 12:40

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an off-by-one write here: bank is 1 or 2, while bankStatus has indices 0 and 1. Bank 1 updates the wrong slot and bank 2 writes past the array. This should use bankStatus[bank - 1].

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, one API-flow issue I noticed: unlock() used to call Flash::enable(), but that call is removed just as enable() gains the important NVIC_EnableIRQ(FLASH_IRQn) behaviour. Existing callers that only unlock before erase/program will therefore never enable the interrupt and can leave the new async status stuck. Could the IRQ enable stay in the existing initialization path?

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from 1f9a569 to 753a863 Compare September 3, 2026 21:16

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the new failure state looks unreachable for flash errors that do not also generate EOP. initiateErase/Program() only enables EOPIE, while H7 exposes separate error interrupt enables such as WRPERRIE, PGSERRIE, STRBERRIE, INCERRIE, and OPERRIE. A failed operation can therefore leave bankStatus stuck at operationOngoing; could the error interrupts be enabled and handled independently of EOP?

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch 2 times, most recently from 332fec9 to d2c58f8 Compare September 9, 2026 19:55
@jgmess-dlr

Copy link
Copy Markdown
Author

Hi, the new failure state looks unreachable for flash errors that do not also generate EOP. initiateErase/Program() only enables EOPIE, while H7 exposes separate error interrupt enables such as WRPERRIE, PGSERRIE, STRBERRIE, INCERRIE, and OPERRIE. A failed operation can therefore leave bankStatus stuck at operationOngoing; could the error interrupts be enabled and handled independently of EOP?

Good catch, should be done in the new revision.

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from d2c58f8 to 19b9cd8 Compare September 9, 2026 20:02
@jgmess-dlr

Copy link
Copy Markdown
Author

There is an off-by-one write here: bank is 1 or 2, while bankStatus has indices 0 and 1. Bank 1 updates the wrong slot and bank 2 writes past the array. This should use bankStatus[bank - 1].

Done.

@jgmess-dlr

Copy link
Copy Markdown
Author

There is an off-by-one write here: bank is 1 or 2, while bankStatus has indices 0 and 1. Bank 1 updates the wrong slot and bank 2 writes past the array. This should use bankStatus[bank - 1].

Fixed.

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from 19b9cd8 to ed3d097 Compare September 10, 2026 09:32
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp Outdated
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp Outdated
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp Outdated
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp
Comment thread src/modm/platform/flash/stm32/flash_h7.cpp
Comment thread src/modm/platform/flash/stm32/flash_h7.cpp Outdated
Comment thread src/modm/platform/flash/stm32/flash_h7.cpp Outdated
Comment thread src/modm/platform/flash/stm32/flash_h7.cpp
Comment thread src/modm/platform/flash/stm32/flash_h7.hpp
@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from ed3d097 to d918a13 Compare September 10, 2026 10:13

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked the current head. Two compile blockers remain in the new helpers: initErase(uint32_t volatile& CR) references index although it has no index parameter, and initiateProgram() uses sizeof(uin32_t). Please fix both before merge.

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from d918a13 to 4c36dd8 Compare September 10, 2026 21:22

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two compile blockers from my previous review are fixed. One correctness issue remains in the new program bounds check: using addr + FlashWord * sizeof(uint32_t) >= OriginAddr + Size rejects the final valid flash word, whose end is exactly OriginAddr + Size. Please use > (or an equivalent subtraction-based check) so the last flash word remains writable.

@jgmess-dlr
jgmess-dlr force-pushed the platform/h7-flash-uses-interrupts branch from 4c36dd8 to f66af53 Compare September 11, 2026 13:27
@jgmess-dlr

Copy link
Copy Markdown
Author

The two compile blockers from my previous review are fixed. One correctness issue remains in the new program bounds check: using addr + FlashWord * sizeof(uint32_t) >= OriginAddr + Size rejects the final valid flash word, whose end is exactly OriginAddr + Size. Please use > (or an equivalent subtraction-based check) so the last flash word remains writable.

Fixed!

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked current f66af534. The final flash word is now accepted by the bounds check, and the earlier compile, bank-index and error-interrupt issues from my reviews are addressed. No remaining blocker from me.

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.

3 participants