Skip to content

Commit f077616

Browse files
committed
hal: stm32u5: Fix FLASH_CR_PNB_MASK
This commit update the PNB (Secure page number selection) mask according to reference manual update. In RM0456 document update (Rev.3 -> Rev.4), PNB bits in FLASH_SECCR (Section 7.9.10) 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 (Reserved). However, for other devices, NUCLEO-U5A5ZJ-Q for example, page calculation will be wrong because bit 10 is __always 1__ after flipping by: reg = *cr & (~((FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT) | FLASH_CR_BKER)); Without this commit, some devices will be failed to erase pages of flash, and lead to update failure. Signed-off-by: Elwin Huang <[email protected]>
1 parent a8afa74 commit f077616

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hal/stm32u5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
#define FLASH_CR_PER (1 << 1)
211211
#define FLASH_CR_MER1 (1 << 2)
212212
#define FLASH_CR_PNB_SHIFT 3
213-
#define FLASH_CR_PNB_MASK 0x7F
213+
#define FLASH_CR_PNB_MASK 0xFF /* RM0456 - Table 79 */
214214
#define FLASH_CR_BKER (1 << 11)
215215
#define FLASH_CR_MER2 (1 << 15)
216216
#define FLASH_CR_STRT (1 << 16)

0 commit comments

Comments
 (0)