This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF51 how to enable readback protection

Hi,

I want to activate readback protection on nRF51822, in a simple project without bootloader without softdevice. My compiler is GCC and the const uint32_t UICR_RBPCONF __attribute__((at(0x10001004))) __attribute__((used)) = 0xFFFF0000; isn't compatible.

Like this post (here), I have added in the .hex file

:020000041000EA
:10100000FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFEF
:00000001FF

At the end of the file.

The result is partially good: I can't readback the flash memory, it's OK... but now, I can't eraze the chip and I can't write again to the flash !!!!

What's the good hex injection to have only a single read protection, but possiblity to rewrite the flash ?

Regards Gaétan

  • I believe both methods suggested by me in that old Q&A are 100% working. What do you mean by incompatibility? I use GCC as well, zero problems with that code sample. When it comes to erasing how exactly do you see that you "cannot erase"? Are you using Nordic tools such as nRFgo studio or NRFJPROG? They have "recover" option which will also erase the entire chip as side effect. Note that read-back protection also disables debugger so that's the reason why certain JTAG/SWD commands stop working... There is a way how to recover the chip without using Nordic tools, there are some hints how to do it in SEGGER J-Flash/J-Link or OpenOCD on this forum, however using Nordic tools it's so smooth that it's almost wasting of time to bother with something else...

  • Oh and btw. note that there is quite trivial SWD hack published on the internet showing how to break read-back protection of nRF51 so it's question what hope you put into this mechanism;) Justs another reason to move to nRF52 if you have that option...

  • Using nrfjprog command line tools type 'nrfjprog -f nrf51 --recover' to erase the user flash memory and lift the read back protection.

Related