Skip to content

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

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

davidlattimore
Copy link
Contributor

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.

@newAM newAM added the stm32g0 label Feb 2, 2022
@github-actions
Copy link

github-actions bot commented Feb 2, 2022

Memory map comparison

@richardeoin
Copy link
Member

Thanks for the PR! This looks good, couple of comments:

  • Looks like the PCROP1??R registers are also erroneously read-only
  • The resetValue for these registers are very wrong in the SVD, perhaps safer to at least make them zero. Alternatively use the ST production value listed in the RM.
  • This patch doesn't apply to a few parts (g050, g051, g061, g0b0) as they don't have flash blocks in the SVD. 👀 That can be out of scope for this PR, but should be fixed eventually.
  • Could you rebase after G0 #687 was merged? The rebase should be simple (choose both)

Also fixed the reset values for these registers to match RM
@github-actions
Copy link

github-actions bot commented Apr 4, 2022

Memory map comparison

@davidlattimore
Copy link
Contributor Author

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.

@burrbull
Copy link
Member

burrbull commented Apr 4, 2022

The value I've observed for WRP1AR on an stm32g071 is 0x3f, not 0xff as the datasheet says.

If something is really different from RM, it is better to add detailed comment to prevent somebody "fixing" your fix.

@davidlattimore
Copy link
Contributor Author

The value I've observed for WRP1AR on an stm32g071 is 0x3f, not 0xff as the datasheet says.

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.

Copy link
Member

@richardeoin richardeoin left a 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+

@bors
Copy link
Contributor

bors bot commented Apr 4, 2022

Build succeeded:

@bors bors bot merged commit c3833a8 into stm32-rs:master Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy