Broken device through optoin bytes
Hello,
I am currently fiddling around with a STM32G491 in bare metal. I wanted to test the write protection. So I executed following code
FLASH->KEYR = FLASH_KEY1;
FLASH->KEYR = FLASH_KEY2;
while(FLASH->CR&bit31); // wait for unlock
FLASH->OPTKEYR = FLASH_OPTKEY1;
FLASH->OPTKEYR = FLASH_OPTKEY2;
while(FLASH->CR&bit30); // wait for option unlock
//#define PROTECT(start, end) FLASH->WRP1AR = (((start>>11)&0xFF)|(((end>>11)&0xFF)<<16))
PROTECT(0x5000, 0x6000);
FLASH->CR |= bit17; // option start
while(FLASH->CR&bit17); // wait for option done
FLASH->CR |= bit27; // option load
while(FLASH->CR&bit27); // wait for option reload done
FLASH->CR |= bit30; // lock option
FLASH->CR |= bit31; // lock
Just to note my code worked fine (except the locking) until I added line 12. It seems the OB_LAUNCH bit is never reset to 0.
The problem is now that I can not reach my device any more. I am connected through SWD via STlinkV2 with a hardware reset connectd. But none of the connection methods works any more using STProg or STCubeIDE. Not even connect under reset works. How can that be? Is there anything I can do to erase it?
Edit: the error I get is
Target no device found
Error in initializing ST-LINK device.
Reason: No device found on target.
