Works with the AI Agents you already use

    STM32 Unlock Planner: RDP, Write Protection & PCROP

    by Khaled, STM32 Engineer

    1

    "My STM32 is locked" has four causes, and STM32CubeProgrammer gives the same error for three of them.

    Free

    Security scanned
    STM32 Unlock Planner: RDP, Write Protection & PCROP

    STM32 Unlock Planner: RDP, Write Protection & PCROP

    Example session with this skill installed

    My STM32H750 board is giving me "failed to erase memory" errors when I try to flash. I need to unlock it. Can you help me diagnose and fix this?

    • Read your context and instructions
    • Compiled the stm32 unlock planner

    I read the option bytes from your STM32H750 (read-only) to find the exact cause of the erase failure.

    STM32 Option Byte Analysis & Recovery Plan

    Your device is at

    RDP Level 1. That is why flashing fails: at Level 1, once a debugger has been connected, every access to the flash is refused. Write protection is

    not active, so it is not part of the problem.

    AttributeValueMeaning
    Device0x450 STM32H7xx (STM32H750)Rules verified in RM0433
    RDP0xBB → Level 1Flash unreadable and unwritable by any debugger
    Write protectionnWRP0 = 1Not active
    PCROP / secure areasSTART 0xFF > END 0x0Disabled (factory default, RM0433 Sec. 4.4.6 p.181)
    Cost of unlockingFlash erasedFirmware cannot be recovered: no tool can read it at Level 1

    Recovery plan

    1. Regress RDP Level 1 → 0
      • Command: STM32_Programmer_CLI -c port=SWD mode=UR -rdu
      • Erases: the whole internal user flash (128 KB), backup SRAM and RTC backup registers. External QSPI flash is not touched.
      • Reversible: no (the data is gone; the protection itself can be set again)
      • Source: RM0433 Sec. 4.5.3 p.185 and p.188 · hardware-tested on an STM32H750B-DK
    2. Verify
      • Command: STM32_Programmer_CLI -c port=SWD mode=UR -ob displ
      • Expected: RDP : 0xAA (Level 0, no protection)

    Shall I run step 1? It erases the flash.


    After you said yes, the regression ran:

    Disabling memory Read Protection...
    Time elapsed during option Bytes configuration: 00:00:04.864
    Memory Read Protection disabled successfully
    

    Verified: RDP is 0xAA (Level 0) and the flash reads FFFFFFFF (erased). You can program your firmware again.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Reads your STM32 option bytes read-only, finds why flashing fails (RDP Level 1, write protection or PCROP) and plans the cheapest safe fix, with exact commands and the manual page behind each step.

    "My STM32 is locked" has four causes, and STM32CubeProgrammer gives the same error for three of them.

    • RDP Level 1: RDP regression. Cost: erases the flash.
    • Write protection: clear the WRP bits. Cost: nothing.
    • PCROP or secure areas: one exact combined command. Cost: erases the flash.
    • RDP Level 2: no fix. It's permanent.

    The usual advice ("just run a mass erase") destroys firmware that didn't need to die, and fails on PCROP-protected parts. This skill makes your agent diagnose first.

    What it does

    1. Reads the option bytes through STM32CubeProgrammer, read-only. This works even on a read-protected chip.
    2. Decodes RDP level, sector and area write protection, PCROP, H7 secure-only areas and boot settings, using the device database already installed with CubeProgrammer.
    3. Plans the fix: unlock, remove-wrp, lock-rdp1 (production protection) or explain. Every step shows the exact command, what it erases, whether it can be undone, and the reference-manual section and page it relies on.
    4. Asks before every write, runs one step at a time and re-reads after each.

    Traps it handles

    • F42x/43x: SPRMOD=1 inverts the meaning of the nWRP bits. PCROP can only be released inside the RDP 1 → 0 command.
    • F72x/73x: PCROP_RDP must already be set before the regression command.
    • H7: PCROP and secure areas need DMEP/DMES = 1 and START > END. The factory "START > END" default is disabled, not active PCROP.
    • G4: BOOT_LOCK. L4/G4: PCROP_RDP and partial mass erase.

    Safety

    • It never generates RDP Level 2 (0xCC).
    • It refuses TrustZone and product-state parts (H5, U5, L5, WBA, H7RS, N6, C5, U3) rather than guessing.
    • Steps that haven't been tested on hardware are marked VERIFY, with the manual citation.

    Where it stops

    • Covers STM32F4, F7, H7, L4 and G4. Rules come from RM0090, RM0410, RM0431, RM0433, RM0351 and RM0440.
    • Tested on hardware with an STM32H750: lock to Level 1, unlock with -rdu, set and remove sector write protection.
    • The PCROP paths follow the manuals but haven't been tested on hardware.

    Not affiliated with STMicroelectronics.

    No support for TrustZone/product-state parts (H5, U5, L5, etc.). Requires STM32_Programmer_CLI. Verified only for specific F4, F7, H7, L4, and G4 device IDs.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 14 days ago

    • Free with an Agensi account

    Software
    Python

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables
    Listed14 days ago

    What's inside

    Frequently Asked Questions

    No. Level 2 is permanent on every STM32. The skill says so and stops.

    Only the read-only option-byte read. Every write is printed with its cost and runs only after your yes.

    No. At Level 1 no debugger can read the flash, and unlocking erases it. Back up at Level 0.

    TrustZone and product-state devices use different regression procedures. Guessing could brick them, so they're out of scope for v1.

    H7 lock, unlock and write-protection removal. PCROP steps follow the cited manual pages and are marked VERIFY.

    New in Testing & Debugging

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.

    Free