hal: stm32u5: Fix FLASH_CR_PNB_MASK#632
Closed
s09289728096 wants to merge 1 commit intowolfSSL:masterfrom
s09289728096:master
Closed
hal: stm32u5: Fix FLASH_CR_PNB_MASK#632s09289728096 wants to merge 1 commit intowolfSSL:masterfrom s09289728096:master
s09289728096 wants to merge 1 commit intowolfSSL:masterfrom
s09289728096:master
Conversation
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 <s09289728096@gmail.com>
Contributor
|
Thank you @s09289728096 for pointing this out! Its been fixed in PR #633 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)