2014-12-02 10:30 AM
Hello ST gurus!
May I inquire on the right sequence of steps to unlock a device (level 1 lock) to unlocked (level 0)? The STM library reveals the following sequence is required to lock: FLASH_OB_Unlock(); // Take the STM32F4xx from unlocked (level 0) to reversible lock (level 1) FLASH_OB_RDPConfig(OB_RDP_Level_1); FLASH_OB_Launch(); I assume the following code would unlock but it doesn't work! FLASH_OB_Unlock(); // Take the STM32F4xx from reversible lock (level 1) to unlocked (level 0) -> Does not work! FLASH_OB_RDPConfig(OB_RDP_Level_0); FLASH_OB_Launch(); When I run the unlock code below, the chip crashes (understandable as its Flash & memory is wiped) and the chip becomes invisible via JTAG. The only way to revert the STM32 back to level 0 is by booting the device in DFU mode by shorting boot pins and lanuching the DFUSE utility to unprotect the device. Can unlocking be done in code? If DFUSE can do it I assume there is a magic sequence that can unlock a device by code running in Flash? Thank you!! Jean-Pierre #locking-unlocking-protection2014-12-02 05:01 PM
Really tricky stuff! Is there a sample app that shows how to correctly lock & unlock.
Yes, unfortunately such things tend not to fall out of trees, people have either invested a lot of resources to build/understand them, or wear darker hats and move in different circles. I suspect it would take several hours to knock out something serviceable. sourcer32@gmail.com2014-12-03 02:01 AM
Your Q1: Will it run differently in Flash or RAM?
Pay attention at the back there! Flash gets erased during the process. So if you try to run it from FLASH then most-likely it will never complete cleanly e.g. it might miss off the FLASH_OB_Lock() and instead head off into the hills leaving your stm32 in an unknown state.Q2: Is my code similar to Clives?Yes largely. I log some diagnostic information but that's mainly so I know how far it's completed.And also between the Unlock and the RDPConfig I do:FLASH_OB_WRPConfig(OB_WRP_Sector_All, DISABLE);
Hope this helps,Danish