Is it possible to write to the UICR to set APPROTECT from non-secure code?
The description in section 4.4.8.10 of the nRF9160_PS_v2.1 claims to "Allow non-secure code to set APPROTECT" and defines a key value that must be set along with the Set bit.
Section 4.4.4 of the nRF9160 PS v2.1 defines a procedure for setting APPROTECT by writing to WRITEUICRNS after first setting SECUREAPPROTECT. I'm not sure how to execute this procedure, and not example is given.
I've tried writing to WRITEUICRNS with the code below, and APPROTECT never actually gets enabled.
// Write UICR from non-secure code NRF_NVMC->WRITEUICRNS = (uint32_t)((NVMC_WRITEUICRNS_KEY_Keyvalid << NVMC_WRITEUICRNS_KEY_Pos) | (NVMC_WRITEUICRNS_SET_Set << NVMC_WRITEUICRNS_SET_Pos));