Skip to main content
Graduate II
March 3, 2025
Question

Removing FLASH write protection dynamically

  • March 3, 2025
  • 2 replies
  • 890 views

Is it possible to change the FLASH write protection at run time without reprogramming the option bytes?

The write protection registers are writeable after unlocking, but it appears as if changing the value has no effect on the actual write protection; it looks as if the new values have to be written back to the option bytes, but the new values are only activated after a system reset.

Does that mean it is not possible to update a page when the system is operational if that page is write protected (to stop stray writes from corrupting it)?

Using an ST32G484, if that makes a difference.

    This topic has been closed for replies.

    2 replies

    Super User
    March 3, 2025

    @CTapp.1 wrote:

    Does that mean it is not possible to update a page when the system is operational if that page is write protected (to stop stray writes from corrupting it)?


    (my emphasis)

    If it were possible, that would compromise the protection!

    CTapp.1Author
    Graduate II
    March 3, 2025

    Possibly very slightly if there is a command sequence needed to remove it temporarily.

    The block is used to store parameters that only change infrequently but which are critical to normal operation. Other memory devices support "protect all", but allow that protection to be temporarily disabled (by guarded commands) to allow data like this to be updated.

    My only option here is to never write protect the region, which does compromise its protection ;)

     

    Super User
    March 3, 2025

    Option bytes need loaded before they take effect. See the "Option bytes programming" section in the reference manual for the procedure. In particular, setting OPTSTART and OBL_LAUNCH.

    The registers you are interfacing with are not the option bytes themselves, only the registers for accessing them.

    CTapp.1Author
    Graduate II
    March 3, 2025

    Thanks, I get that.

    However, the documentation does not make it clear that modifying the WRP registers allows the option bytes to be updated, but it does not immediately change the protection that is enforced.

    Super User
    March 3, 2025

    It says in order for the option bytes to take effect, they need to be loaded. How else would you interpret that? WRP is an option byte.