Hello Everyone,
I am working on NRF52840 and we had enabled the APPROTECT feature in our firmware. The code for implementing this is as follows:-
void init_mem(void)
{
if (NRF_UICR->APPROTECT == 0xFFFFFFFF)
{
NRF_LOG_INFO("PROTECTING FIRMWARE...SETTING APPROTECT");
nrf_nvmc_write_word((uint32_t)&(NRF_UICR->APPROTECT), 0xFFFFFF00);
NVIC_SystemReset();
}
}
static void nrf_nvmc_write_word(uint32_t address, uint32_t value)
{
// Enable write.
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
__ISB();
__DSB();
*(uint32_t*)address = value;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {;}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
__ISB();
__DSB();
}
This code was working fine in our device. Recently we had updated the code and introduced FREERTOS in it. Now this particular APPROTECT feature is implemented in a particular device_init() task. After introducing FREERTOS, this feature of APPRTOTECT is not working anymore. Moreover, when I try to write the APPROTECT register in firmware, the device hangs totally and nothing works. Also in the logs, i get a message "SOFTDEVICE: INVALID MEMORY ACCES" after I try to write the register. Please help me what might be the issue??