Using SD 6.2 and sDK 15 I need to write to the UICR_Customer space while the BLE system is operating.
I tried pulling example code from https://devzone.nordicsemi.com/f/nordic-q-a/11781/writing-to-uicr-from-application-code and https://devzone.nordicsemi.com/f/nordic-q-a/13742/is-there-sample-code-for-writing-to-an-uicr-register but neither gets the value written to UICR, even after a reboot.
When running the write routine, I just get a reboot, Trying to isolate it, I get a reboot when I just call nrf_sdh_disable_request() followed by nrf_sdh_enable_request() with no intervening code.
My full routine as of now is:
bool FLSH_WriteData(uint32_t start_addr, const uint8_t *src, size_t len)
{
uint32_t *src32 = (uint32_t *)src;
uint8_t addr = (start_addr - (uint32_t )(&NRF_UICR->CUSTOMER[0])) / sizeof(uint32_t);
addr = 0;
nrf_sdh_disable_request();
/* MWU Disable -- This is workaround suggested by Aryan on the Nordic Developer Zone */
/* Turn on flash write enable and wait until the NVMC is ready: */
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
// while(len > 0)
{
/* write to the register */
NRF_UICR->CUSTOMER[addr] = 0x12345678; //*src32;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
len -= 4;
addr += 1;
src32 += 1;
}
/* Turn off flash write enable and wait until the NVMC is ready: */
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
nrf_sdh_enable_request();
return true;
}
I know about maybe needing to use the MWU enable as well, but that does not help at the moment and still just causes a reboot without writing to the flash.
I have verified that the UICR space I am writing it erased (all 0xFF).