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

Writing into UICR register by disabling SoftDevice

Hello,

 

I am using nRF52840, SDK_16.0.0, SoftDevice S140 V7.0.1 and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

1) I want to write Serial number into UICR register. Since SoftDevice is enabled, I am not able to update UICR register. If we can update UICR even with SoftDevice, please let me know the procedure.

 

2) I follower below approach. Write UICR register with 5 bytes of Serial number and then reset the chip. Is this approach fine.

a) Is waiting for busy state of NVMC is correct ?

         

void writeSerialNumber(uint8_t* p8SeralNumber)
{
    // Disable Soft Device
    sd_softdevice_disable();
    
    // Write Serial Number into UICR register
    nrf_nvmc_write_bytes((uint32_t)0x1000108C,  (const uint8_t *) p8SeralNumber, 5);

    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NVIC_SystemReset();
}

 

3) Whether NVIC_SystemReset() do a complete reset. To my understanding it’s a Soft reset. Correct me if I am working.

a) How about RAM during Soft reset. Will it be erased ?

 

4) Using nrfjprog, if I try to re-write I will get error. But I dont see such mechanism when I use nrf_nvmc_write_byte(). It is a void function. In this case, do I need check before writing.

 Thanks & Regards

Vishnu Beema

Parents
  • Hi,

    1. You wont be able to write to UICR while softdevice is enabled and we do not have any API exposed by softdevice to allow writing to UICR while SD is enabled.
    2. nrf_nvmc_write_bytes already waits for flash ready, so you do not need to wait again for it.'
    3. NVIC_SystemReset is a soft reset. You need to do a pin reset if you want a hard reset.
      1. It is not clear what you are trying to ask here. Softreset will NOT reset RAM
    4. You cannot write to already wriiten UICR address. You need to erase the UICR page (and this you can only do by erasing the whole chip). nrfjprog will not write to any address that has already some value in it.
Reply
  • Hi,

    1. You wont be able to write to UICR while softdevice is enabled and we do not have any API exposed by softdevice to allow writing to UICR while SD is enabled.
    2. nrf_nvmc_write_bytes already waits for flash ready, so you do not need to wait again for it.'
    3. NVIC_SystemReset is a soft reset. You need to do a pin reset if you want a hard reset.
      1. It is not clear what you are trying to ask here. Softreset will NOT reset RAM
    4. You cannot write to already wriiten UICR address. You need to erase the UICR page (and this you can only do by erasing the whole chip). nrfjprog will not write to any address that has already some value in it.
Children
No Data
Related