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

[NRF81522] Can't enable Read Protection ALL (RBPCONF)

Hello,

I am trying to enable the read protection on the NRF51822 on a custom board. By looking through the forums, I found different ways to try and enable the read protection.

According to the reference manual, bits 8 to 15 from RBPCONF must be set to 1 in order to enable the read protection for all the chip. RBPCONF is a RW register, so we should be able to write to the register directly.

So using sd_flash_write, I have this function.

void UTILS_EnableReadProtection (void)
{
#ifdef RELEASE
uint32_t RegisterValue;

RegisterValue = ~(0x0000FF00);
// 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) {
sd_flash_write((uint32_t *)&NRF_UICR->RBPCONF, &RegisterValue,1);
}
//nrf_nvmc_write_word(0x10001004, 0x0000FF00);
#endif
}

I tried both the method with sd_flash_write, or with nrf_nvmc_write_word to no avail. I tried with and without power cycle and still the same.

What am i missing here?

Thanks,

Jean-Francois

Parents
  • Hi,

    I tested this out, and using nrf_nvmc_write_word(0x10001004, 0x0000FF00); worked on my board (nRF51 DK/PCA10028). Note that the sd_flash_write will report an error if the destination is outside of the flash area, this function cannot be used for writing to UICR. You must write this register before enabling the softdevice, or disable the softdevice before doing the write.

    To be exact, I added this code and called the function from start of main():

    #define RELEASE
    
    void UTILS_EnableReadProtection (void)
    {
    #ifdef RELEASE
    // 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) {
    	nrf_nvmc_write_word(0x10001004, 0xFFFF0000);
    }
    #endif
    }

    Best regards,
    Jørgen

  • So maybe my method of testing is wrong. When the protection is enabled, I shouldn't be able to use the SWD right? Because when I run this piece of code (the initial one), I can still JTAG in.

    If it makes a difference, I am using IAR 8.40.1

    How do you confirm that the read protection is correctly applied? Also, I see that you've put PR0 protection as well. It is not clear in the documentation, but I thought that only PALL was needed for a full protection.

    I will try your code in the meantime.

    Thanks,

    Jean-Francois

Reply
  • So maybe my method of testing is wrong. When the protection is enabled, I shouldn't be able to use the SWD right? Because when I run this piece of code (the initial one), I can still JTAG in.

    If it makes a difference, I am using IAR 8.40.1

    How do you confirm that the read protection is correctly applied? Also, I see that you've put PR0 protection as well. It is not clear in the documentation, but I thought that only PALL was needed for a full protection.

    I will try your code in the meantime.

    Thanks,

    Jean-Francois

Children
No Data
Related