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

nRF51822 : enable protection against readback in app doesn't work

Dear Nordic Developer Zone,

I am trying to enable the readback protection in the main function just before the "wait for interrupt" sd_app_event_wait function using the command

NRF_UICR->RBPCONF = (UICR_RBPCONF_PALL_Enabled << UICR_RBPCONF_PALL_Pos);

but it doesn't work. When I check the register value in the Keil Vision IDE in debug mode, I can see that the register PALL is always 0xFF and not 0x00 as specify in the nRF51822 documentation chapter 8 (MPU) p25.

Is it the right place to enable the readback? Is it the right syntax to enable this feature? Is it possible to activate the readback protection in the main function?

Works using nRFgo Studio, but I would like enable this feature in the app code.

Berst regards

  • The UICR is a flash-backed register, and as such, it cannot be written like you have done here, you have to enable flash writing in the NVMC first. Flash writing also halts the CPU, so if this happens to be at the same time as a radio event, the softdevice will assert. You should therefore always use the radio notification feature when doing flash writes.

    However, a much simpler option is to set this with nrfjprog, and not on run-time. This can be done with the --rbp option:

    
    nrfjprog --help
    ...
         --rbp <protection_level>                     Sets the desired protection
                                 level. Only CR0 or ALL can be used as valid
                                 levels. Can be combined with erase operations,
                                 reset operations and programming operations.
    ...
    
    

    (It is also possible to do a special trick to include such setting in the hex file itself, in which case this will be done automatically on programming. See the uicr_config_example in SDK 4.4.0)

    PS: I saw you had problems with the code-tag. We're working on solving that, and the fix will hopefully come tomorrow!

  • Thanks for your quick answer. I have looked on the nrfjprog software and it fits my needs.

    P.S. About the Developer Zone editor, it would be great if you could add a live preview of the final render when a question or an anwer is writing.

Related