How can I read the UICR register of 9160?

The current project needs to save the ID in the programmable register and use the ID in the application image.

So I save the ID number in the URCI->OTP[0] register. When I read the ID in URCI->OTP[0] in the main function of the application image, a fatal error occurred.

uint32_t get_id_from_uicr(){
        uint32_t id;
        id = (NRF_UICR_S->OTP[0]);
        return id;
}

As far as I know, UICR can only be read in secure code.

So I execute this code in the main function of spm and get the ID normally. How can I pass the ID to the application image(not via flash)?

Or is there any other better way to store this ID?

spm.c:

uint32_t get_id_from_uicr(){
        uint32_t id;
        id = (NRF_UICR_S->OTP[0]);
        return id;
}

void main(void)
{
    uint32_t id;
    id = get_imei_from_uicr();
	spm_config();
	spm_jump();
}

Parents Reply
  • I did not find secure_services.c under the secure_services demo. According to the macro configuration, the file should be imported, but the actual situation is the opposite.

    secure_services demo:

    nrf/subsys/spm/Kconfig:

    nrf/subsys/spm/CMakeLists.txt:

    When I tried to add CONFIG_SPM to spm, a fatal error occurred: CONFIG_SPM and CONFIG_IS_SPM conflict. Do I modify secure_services.c in spm image or modify it in app image?

Children
Related