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

How to set nrf51 Read Back Protection using OpenOCD?

Looking for the OpenOCD equivalent of ""nrfjprog --rbp all"

Looking at the commands for OpenOCD they have a "flash protect" command, but it doesn't appear that's quite the same thing (requests regions of flash).

Any assistance for a OpenOCD newbie would be appreciated!

Parents
  • Hi Jerod,

    Simply write 0xFFFF00FF to UICR->RBCONF register which resides on address 0x100010004. To be precise you should read it out and mask with that value (to preserve PR0 register part on the least significant byte of the register in case it is used). Also make sure what endian OpenOCD use to code raw 32-bit hexadecimal values when writing to the memory. In the end reset the target and memory should be protected.

    Btw. you can easily do this from within the FW code to be sure that you don't forget this in production and also note that nRF51 has major security hole in read-back protection and debugging interface so doing RBALL is rather cosmetic thing which saves you against people who cannot use Google search.

    Cheers Jan

    Edit 10-Feb-2017

    Here is HEX file which writes RBALL to UICR->RBCONF on any nRF51 variant. It can be flashed by any tool including OpenOCD. Can be stripped down to single register write (with little bit of work with GCC tools or similar) but normally it isn't needed.

    Cheers Jan

    nrf51822_UICR_lock.hex

  • Hello Jerod,

    Indeed you cannot program that HEX file separately, programmer will complain that chip isn't erased. You need to do the same as with SoftDevice and Application: concatenate the thing into one blob and program it at once. I'm using PyOCD on Windows, will try to get some example tomorrow... but honestly, this is rather question to OpenOCD community (= how to flash three binaries at once or how to write particular flash byte/word after chip is programmed). You can also seak help at @hnhoan 's blog, he seems to be using ST-Link and OpenOCD on nRF5x chips routinely.

    Cheers Jan

Reply
  • Hello Jerod,

    Indeed you cannot program that HEX file separately, programmer will complain that chip isn't erased. You need to do the same as with SoftDevice and Application: concatenate the thing into one blob and program it at once. I'm using PyOCD on Windows, will try to get some example tomorrow... but honestly, this is rather question to OpenOCD community (= how to flash three binaries at once or how to write particular flash byte/word after chip is programmed). You can also seak help at @hnhoan 's blog, he seems to be using ST-Link and OpenOCD on nRF5x chips routinely.

    Cheers Jan

Children
No Data
Related