hal: stm32u5: Fix FLASH_CR_PNB_MASK #632
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit update the PNB (Secure page number selection) mask according by reference manual to fix the compatible for devices with larger size flash.
According to latest RM0456 document (Rev.6), FLASH_SECCR register definitions shown below:

PNB bits in FLASH_SECCR has been updated from 7 bits to 8 bits for the support of 2MB in single bank.
Logically, devices which flash is lesser than 2MB will ignore bit 10 because of the definition (see below).
(Rev.3 definitions)

Without this commit, page calculation will be wrong because bit 10 is always 1 after flipping by:
wolfBoot/hal/stm32u5.c
Line 210 in a8afa74
Test on NUCLEO-U5A5ZJ-Q (2MB per bank) and NUCLEO-U575ZJ-Q (1MB per bank)