cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030 PCROP bit missing. Clearing RDP does not perform mass erase

DDeba.1
Associate III

Hi, 

I'm using the STM32G030 MCU and I want to perform programming using the CLI commands. When using the STM32 ST-LINK utility and opening the option bytes window, I can see the PCROP bit which if I set, the MCU performs a mass erase when RDP bit changes from 1 to zero, which is the expected behaviour. 

The issue is that this bit is not found in the datasheet. Also, when I use STM32CubeProgrammer, the PCROP bit is not shown as part of the option bytes ( I only see RDP setting). Moreover, when using the STM32CubeProgrammer CLI command to clear RDP bit, the subsequent mass erase command does not work. At this stage, a strange thing is seen. If I try to clear RDP bit using the STM32CubeProgrammer CLI command, a warning is returned that RDP is already set to zero so no action is taken. BUT, if than I connect to the MCU using the STM32 ST-LINK utility and open the option bytes window, the RDP bit is still read as level 1 !?!?!?

Can anyone put some light on this? Why two application shows different setting for RDP? Also, how can I set/reset the PCROP for this MCU (does it even officially have this bit and if not, how can I perform mass erase when clearing RDP bit)?

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Andreas Bolsch
Lead II

First: There is *NO* "PCROP bit" at all in STM32G0. There are two (or four) PCROP areas, whose start and end are defined by "PCROP start address register"and "PCROP end address register", respectively. PCROP is activated when start address <= end address, disabled otherwise.

Second: ST-Link Utility is rather outdated, so I don't think all features of G0 family had ever been implemented. Simply forget ST-Link Utility altogether.

Third: G030 is supposed *NOT* to have PCROP funtionality at all, only G0x1 do have this *officially*. However, G030 and G031 share the very same die, but only the G030 "subset" is tested and guaranteed for devices marked G030. The functionalities of G031 beyond that of G030 are still present and might be partially usable (use at your own risk), but of course the official tools supplied by ST do not allow their use (for a good reason).

Fourth: There is no "RDP bit" but a "RDP byte" (or even two bytes to be precise).

What do you mean by "the subsequent mass erase command does not work"? The decrease of RDP level 1 to level 0 actually triggers the mass erase, so in a sense it *IS* the mass erase command, and there is no "subsequent mass erase" required. However, if you used ST Link Utility to fiddle around with the option bytes, chances are that they're left in an invalid state, maybe even PCROP activated inadvertedly. To recover from this, you need a tool which allows (almost) anything, e.g. OpenOCD. Check all flash register settings against RM0444 (yes, G0x1 !!!) and follow the instructions there to reset PCROP/RDP "manually". Or, if this seems to complicated, discard the device.

 

View solution in original post

2 REPLIES 2
Andreas Bolsch
Lead II

First: There is *NO* "PCROP bit" at all in STM32G0. There are two (or four) PCROP areas, whose start and end are defined by "PCROP start address register"and "PCROP end address register", respectively. PCROP is activated when start address <= end address, disabled otherwise.

Second: ST-Link Utility is rather outdated, so I don't think all features of G0 family had ever been implemented. Simply forget ST-Link Utility altogether.

Third: G030 is supposed *NOT* to have PCROP funtionality at all, only G0x1 do have this *officially*. However, G030 and G031 share the very same die, but only the G030 "subset" is tested and guaranteed for devices marked G030. The functionalities of G031 beyond that of G030 are still present and might be partially usable (use at your own risk), but of course the official tools supplied by ST do not allow their use (for a good reason).

Fourth: There is no "RDP bit" but a "RDP byte" (or even two bytes to be precise).

What do you mean by "the subsequent mass erase command does not work"? The decrease of RDP level 1 to level 0 actually triggers the mass erase, so in a sense it *IS* the mass erase command, and there is no "subsequent mass erase" required. However, if you used ST Link Utility to fiddle around with the option bytes, chances are that they're left in an invalid state, maybe even PCROP activated inadvertedly. To recover from this, you need a tool which allows (almost) anything, e.g. OpenOCD. Check all flash register settings against RM0444 (yes, G0x1 !!!) and follow the instructions there to reset PCROP/RDP "manually". Or, if this seems to complicated, discard the device.

 

Hi,

Thank you for your detailed reply. I understood what you are saying. In order to avoid possible issues, I discarded the device and using a new one out of the box. Making me realize that the RDP is a byte not a bit solved the issue. When using the ST-Link utility CLI, the RDP was set by indicating the level (so for level 1, use "RDP=1"). I kept this syntax also for the STM32CubeProgrammer CLI and to try and revert back to RDP level 0, I was using the wrong line "RDP=0". Using "RDP=0xAA" as indicated in the data sheet solved the issue. 

Thanks.