-
Notifications
You must be signed in to change notification settings - Fork 243
Make FLASH_WRP??R and FLASH_SECR writable #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR! This looks good, couple of comments:
|
Also fixed the reset values for these registers to match RM
d310d28
to
e27fe0f
Compare
I rebased, updated to include PCROP* and fixed the reset values. I went with the reset values from the datasheet, since for write protection and ROP, the end address is inclusive. So setting WRP to 0 would mean to write protect the first page of flash - something that might be surprising. The value I've observed for WRP1AR on an stm32g071 is 0x3f, not 0xff as the datasheet says. The g071 has 128KB of flash, so 0x3f is the last page of flash. i.e. start=0x3f, end=0 (don't write protect anything). I tried setting it to 0xff and the value (after applying option bytes and reloading) ended up as 0x3f anyway. I think it probably makes sense that the reset value is 0xff, since that would presumably accommodate all devices in the g0 series. |
If something is really different from RM, it is better to add detailed comment to prevent somebody "fixing" your fix. |
To clarify, the value I put in the patch is the value from the RM, not the value that I read from the device - but I think either value would likely be fine - in fact any value where start > end should be fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great investigation into the behaviour of those reset values. Agreed that anything setting start > end is reasonable.
With that I think everything needed for this PR is resolved, so let's merge.
bors r+
Build succeeded: |
See reference manual for STM32G0x0 and STM32G0x1. Both define FLASH_WRP1AR etc as read-write (but read-only in the SVD). STM32G0x1 defines FLASH_SECR as read-write (but read-only in the SVD). The STM32G0x0 doesn't have a FLASH_SECR register.