This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I configure my project to write to UICR in IAR

Hello,

I'm trying to create my own bootloader application that uses softdevice in IAR. I would like to know how to configure my project so that it writes 0x0003A000 to the UICR at 0x10001014.

I am using IAR workbench, but when I use

#pragma location = 0x10001014
__root uint32_t uicr = 0x0003A000;

the value is not present at this specific address after i flash the device.

Is there an example available how to do this in IAR?

Thanks in advance

  • Try:

    #pragma location="MySection"
    const uint32_t uicr = 0x0003A000;
    

    In icf file add line:

    place at address mem: 0x10001014 { readonly section MySection};
    

    But compiler may not allocate it in memory if you don't use it. So you have to add line anywhere in your code where you assign that constant to dummy variable; Other method is to create small hex file with 0x0003A000@0x10001014 value and do post-build merge of final hex and small hex.

    :020000041000EA
    :0410140000A0030035
    
  • Thank you for your answer. you are correct that it fills the entire bin file with padding if i add it to the icf file.

    I have solved the problem by having my application write the UICR boot address register if it is not found like so:

    uicrTemp = *(reinterpret_cast<volatile uint32_t *>(0x10001014));
    if (uicrTemp != 0x0003A000){
    	nrf_nvmc_write_word(0x10001014, 0x0003A000);	
    }
    
Related