cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030C8T6 readout protection doesn't work

NiTr0man
Associate III

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!
5 REPLIES 5
TDK
Super User

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

Use STM32CubeProgrammer. It also has a CLI.

STM32CubeProg | Software - STMicroelectronics

If you feel a post has answered your question, please click "Accept as Solution".

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?

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

first method (with json) affects only defined bits, and doesn't affect factory (reserved) bits of option bytes.trouble is in reserved bits - it seems like STM32G0x0 are similar to STM32G0x1, but undocumented hardware features aren't tested and may not work (or may be removed in future revisions)

about second method ('factory reset' menu item) - I've got 'Device 0x466 not supported for factory reset operation'.

NiTr0man
Associate III

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...