Flash write protected

The target flash region is write-protected.

CORTEX_M_FLASH_WRITE_PROTECTED

Symptoms

  • Flashing fails on specific sectors while others program fine.
  • The error mentions write protection (WRPERR on STM32).
  • A bootloader region refuses to be overwritten.

Likely causes

  • WRP option bytes protect one or more sectors — often set deliberately to shield a bootloader.
  • PCROP / secure areas (on parts that support them) block programming of configured regions.
  • Previous tooling or production programming enabled protection and it was never cleared.

How to fix it

  1. Inspect option bytes

    Open STM32CubeProgrammer → Option Bytes and check the WRP (and PCROP, if present) configuration to see exactly which sectors are protected.

  2. Decide whether the protection is intentional

    If a bootloader lives in the protected sectors, you may want to keep WRP and instead link your application to start above the protected region.

  3. Clear write protection

    Disable WRP for the target sectors in the option bytes and apply. On some families this requires an option-byte launch (brief reset).

  4. Flash again

    Retry the flash in MCUHex — with WRP cleared, programming should complete.