Skip to main content
Visitor II
September 16, 2025
Question

STM32G030C8T6 readout protection doesn't work

  • September 16, 2025
  • 2 replies
  • 442 views

I tried to set readout protection via ST-LINK CLI - it's enabled and disabled correctly, but after RDP=0 I can't erase/write chip - I've got an error on write operation. Tested on 2 boards and both boards have same behavior.

 

e:\STM32 projects>"%PROGRAMFILES%\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c SWD SWCLK=9 -OB RDP=1
STM32 ST-LINK CLI v3.6.0.0
STM32 ST-LINK Command Line Interface

[SWCLK=9]: SWCLK is obsolete. Use SWJCLK instead.
ST-LINK SN: 55FF6B067087534936162567
ST-LINK Firmware version: V2J37S7
Connected via SWD.
SWD Frequency = 950K.
Target voltage = 3.1 V
Connection mode: Normal
Reset mode: Software reset
Device ID: 0x466
Device flash Size: 64 Kbytes
Device family: STM32G0

Updating option bytes...
Option bytes updated successfully.


e:\STM32 projects>"%PROGRAMFILES%\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c SWD SWCLK=9 -OB RDP=0 -ME
STM32 ST-LINK CLI v3.6.0.0
STM32 ST-LINK Command Line Interface

[SWCLK=9]: SWCLK is obsolete. Use SWJCLK instead.
ST-LINK SN: 55FF6B067087534936162567
ST-LINK Firmware version: V2J37S7
Connected via SWD.
SWD Frequency = 950K.
Target voltage = 3.1 V
Connection mode: Normal
Reset mode: Software reset
Device ID: 0x466
Device flash Size: 64 Kbytes
Device family: STM32G0

Updating option bytes...
Option bytes updated successfully.

Full chip erase...
The elf loader Mass Erase function fails.
Error occurred during flash mass erase!
    This topic has been closed for replies.

    2 replies

    Super User
    September 16, 2025

    ST-LINK Utility was deprecated long before the STM32G0 came out.

    Use STM32CubeProgrammer. It also has a CLI.

    STM32CubeProg | Software - STMicroelectronics

    NiTr0manAuthor
    Visitor II
    September 17, 2025

    in STM32CubeProgrammer locked chips have same behavior

    e:\>"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=SWD -ob displ -e all
     -------------------------------------------------------------------
     STM32CubeProgrammer v2.20.0
     -------------------------------------------------------------------
    
    ST-LINK SN : 55FF6B067087534936162567
    ST-LINK FW : V2J46S7
    Board : --
    Voltage : 3.13V
    SWD freq : 4000 KHz
    Connect mode: Normal
    Reset mode : Software reset
    Device ID : 0x466
    Revision ID : Rev 1.1
    Device name : STM32G03x/STM32G04x
    Flash size : 64 KBytes
    Device type : MCU
    Device CPU : Cortex-M0+
    BL Version : 0x53
    
    
    UPLOADING OPTION BYTES DATA ...
    
     Bank : 0x00
     Address : 0x40022020
     Size : 108 Bytes
    
    ██████████████████████████████████████████████████ 100%
    
     Bank : 0x01
     Address : 0x40022080
     Size : 4 Bytes
    
    ██████████████████████████████████████████████████ 100%
    
    
    OPTION BYTES BANK: 0
    
     Read Out Protection:
    
     RDP : 0xAA (Level 0, no protection)
    
     User Configuration:
    
     nRST_STOP : 0x1 (No reset generated when entering Stop mode)
     nRST_STDBY : 0x1 (No reset generated when entering Standby mode)
     IWDG_SW : 0x1 (Software independent watchdog)
     IWDG_STOP : 0x1 (IWDG counter active in stop mode)
     IWDG_STDBY : 0x1 (IWDG counter active in standby mode)
     WWDG_SW : 0x1 (Software window watchdog)
     RAM_PARITY_CHECK: 0x1 (SRAM parity check disable)
     nBOOT_SEL : 0x1 (BOOT0 signal is defined by nBOOT0 option bit)
     nBOOT1 : 0x1 (Boot from Flash if BOOT0 = 1, otherwise system memory)
     nBOOT0 : 0x1 (nBOOT0=1)
    
     Write Protection:
    
     WRP1A_STRT : 0x1F (0x800F800)
     WRP1A_END : 0x0 (0x8000000)
     WRP1B_STRT : 0x1F (0x800F800)
     WRP1B_END : 0x0 (0x8000000)
     WRP2A_STRT : 0x0 (0x8000000)
     WRP2A_END : 0x0 (0x8000000)
     WRP2B_STRT : 0x0 (0x8000000)
     WRP2B_END : 0x0 (0x8000000)
    
    Mass erase ...
    
    Error: Mass erase operation failed.Please verify flash protection

    I've checked option bytes content - it seems like it differs between locked and non-locked device, but I can't change their values
    good one:

    0x1FFF7800 : DFFFE1AA 20001E55 FFFFFFFF 00000000
    0x1FFF7810 : 00FF0000 FF00FFFF FF00FF3F 00FF00C0
    0x1FFF7820 : FF00FF3F 00FF00C0 FFFFFFFF 00000000
    0x1FFF7830 : FFFF0000 0000FFFF FFFFFFFF FFFFFFFF
    0x1FFF7840 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
    0x1FFF7850 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
    0x1FFF7860 : FFFFFFFF FFFFFFFF FFFFFFFF

    locked one:

    0x1FFF7800 : DFFFE1AA 20001E55 0000007F FFFFFF80
    0x1FFF7810 : 80000000 7FFFFFFF 0000001F FFFFFFE0
    0x1FFF7820 : 0000001F FFFFFFE0 00000000 FFFFFFFF
    0x1FFF7830 : 00000000 FFFFFFFF FFFFFFFF FFFFFFFF
    0x1FFF7840 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
    0x1FFF7850 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
    0x1FFF7860 : FFFFFFFF FFFFFFFF FFFFFFFF

    is it possible to write dump of opt region (or reset it to default)? or I need to replace CPU?

    Technical Moderator
    September 17, 2025

    is it possible to write dump of opt region (or reset it to default)? or I need to replace CPU?


    You need to have a new device (not a programmed one), then you can apply steps described in this article: Restoring the STM32 option bytes to their factory settings using STM32CubeProgrammer.

    -Amel

    NiTr0manAuthor
    Visitor II
    September 17, 2025

    I tried to change device type in xmls (to force STM32CubeProgrammer think that it's STM32G031) - but it still can't change wrong values (like one on place of PCROP1B_STRT in G0x1, which is zero in bricked chips and 0x7F in good ones). looks like they can't be unbricked...