0
\$\begingroup\$

So I was testing the boot option bytes of my Nucleo32 STM32G431KB board and somehow my Nucleo board is in Read Out Protection level 1. STLink Utility is unable to revert it, I get the error "Read/Write protected zone for bank 1 can't be reduced".

enter image description here

These are the only lines of code I had in main():

//STCubeIDE autogenerated code...
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
FLASH->OPTR|=(1<<27);
SET_BIT(FLASH->CR, FLASH_CR_OPTSTRT);
HAL_FLASH_OB_Launch(); 
HAL_FLASH_Lock();
while(1)
{
}
//STCubeIDE autogenerated code...

I also tried to bypass the STLink and try if I could communicate directly to IC's bootloader using a FTDI driver and writing raw bytes to UART, because there is a command to revert the ROP, but I had no reply from the chip.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ The readout protection feature would be pretty pointless if you could just reduce it like that in the ST-LINK utility. You'll probably have to erase the chip to clear the protection. \$\endgroup\$ – brhans Feb 18 at 13:32
4
\$\begingroup\$

I think I've managed to recover the board, using STM32CubeProgrammer (not CubeIDE, this is a different program).

The only thing I had to do was changing RDP to 0xAA (no protection) and now I can reprogram the IC.

First install the program and click Connect to STLink, then:

enter image description here

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Just a warning for readers of this answer: Do not choose CC. Doing so places uC in Level 2 protection, permanently disables debug and bricks the uC. You can not recover from Level 2 protection . \$\endgroup\$ – Tagli Feb 18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.