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

Disable SoftDevice Protection for DFU

Hi guys,

I am trying to create a Dual bank DFU bootloader (BL) program for nRF51822 which will be able to update the SoftDevice and bootloader no matter if the "Enable SoftDevice protection" is checked in the first place. I am not sure how it is possible.

First, I manage to disable the SoftDevice Protection by a code as below in the BL:

NRF_UICR->CLENR0 = 0xFFFFFFFF;

Sort of strange things happen when I try to switch between SD110+BL110 and SD120+BL120. The DFU process does not fail (and the Firmware Ids are good) but when I load my application, which is based on SD110, it does not work! If I uncheck the "Enable SoftDevice Protection" in nRFgo studio by JLink in the first place, the application works well even after several SD+BL switches.

In another test, I load the SD120 and BL120 (with NRF_UICR->CLENR0 = 0xFFFFFFFF line and Enable SD protection unchecked) and switch on SD110+BL110 via DFU and try to load the Application Jlink which gives me an error like "the device has two different CLeR0 values written. Try programming a new SoftDevice first".

I can see that the Firmware in Region 0 is a correct one as S110_nRF51822_7.1.0 (Id: 0x005a) but I have to erase all and program the SD110 to make things working.

Thanks,

Ehsan

Parents
  • Hi Ehsan,

    It's not possible to re-write the CLENR0 when it's written. It's the same with any other place in the flash. You write to it once and you can't modify it after that (only change the bin from 1 to 0 , can't do write to change bit from 0 to 1). If you want to re-write you need to erase the page first.

    And with UICR page, it's a little bit difference that you need to erase the whole chip if you want to erase that page.

    So in short, it's not possible to modify a UICR register after it's written, erasing the whole chip is the only solution.

    The reason you may still able to switch between softdevice was that turn on "Enable SoftDevice Protection" only protect the softdevice from being modified by the application but not if the modification is executed from inside the softdevice. So we have the MBR located inside the softdevice region and taking care of the task of replacing the softdevice.

    The only thing the "Enable SoftDevice Protection" does is to limit the size of the new softdevice (which is written in CLENR0). Basically you can switch softdevice if the size are equal, or the new softdevice has smaller size to the current softdevice.

    Anyway, I would not suggest to enable the option "Enable SoftDevice Protection" if you plan to update softdevice.

  • Thanks Hung Bui,

    Now I understand better. So, is it possible to have an application to keep a copy of the region where CLENR0 is in RAM, erase that region and modify the value of the CLENR0 to 0xFFFFFFFF and copy back from RAM? It is not a solution?

Reply Children
No Data
Related