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

how to enable readback protection

Hi, Guys,

I am trying to enable the readback protection for the code region 0 and code region 1, I know that the NRF_UICR->RBPCONF register is flash_backed, so I have to include uicr_config.h file and uncomment the line
const uint32_t UICR_RBPCONF attribute((at(0x10001004))) attribute((used)) = 0xFFFF0000;

However, I use eclipse and gcc, so it seems the "at" keyword doesn't apply in eclipse gcc, so is there any equivalence in gcc or how should I enable this readback protection in the application but not using nrfgo, I know that the nrfgo can definitely do that. Thank you:)

Parents
  • Hi,

    You can either write UICR->RBPCONF from within the application by something like this:

    #if LOCK_UICR
        // Check if read-back mechanism is turned ON.
        if((uint32_t)((NRF_UICR->RBPCONF & UICR_RBPCONF_PALL_Msk) >> UICR_RBPCONF_PALL_Pos) != UICR_RBPCONF_PALL_Enabled) {
            ble_flash_word_write((uint32_t *)&NRF_UICR->RBPCONF, (NRF_UICR->RBPCONF & ~UICR_RBPCONF_PALL_Msk));
        }
    #endif
    

    or you can put something like this to the end of your HEX file:

    :020000041000EA
    :10100000FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFEF
    :00000001FF
    
  • Is there a possibility to write to flash from the firmware (without using the .hex file) without using the the flash manager library ? 

    Why is the flash manager necessary here and why doesn't sd_flash_write() work for me?

    Thanks!

Reply Children
Related