Many microcontrollers allow you to lock them to prevent reading out the contents
of flash. On Silicon Labs EFM32
[a-zA-Z]+ Gecko devices, this is done by
disabling most of the SWD interface so that accessing memory through a debugger
You lock the device by writing to the Memory System Controller peripheral. Unlocking is a little more complicated: according to Application Note 0062 “Programming Internal Flash Over the Serial Wire Debug Interface”, you must write to registers on the SW-DP and AHB-AP which are some kind of esoteric ARM business.
OpenOCD can do both.
# Lock reset init mww 0x400c0008 1 mww 0x400c0010 0x0fe041fc mww 0x400c000c 1 mww 0x400c0018 0 mww 0x400c000c 8 reset_config srst_only ;# ??? reset run shutdown # Unlock dap apreg 0 0x4 0xcfacc118 dap apreg 0 0x0 1 dap apreg 0 0x8 ;# ??? sleep 1000 ;# ??? dap apreg 0 0x0 2 reset_config none ;# ??? reset init shutdown
I don’t remember why the commands marked with
;# ??? (a Tcl inline
comment) were necessary. It might work without them. It might set your
device on fire. Who knows?