This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UICR registers protection from erase/write operations

Dear Nordic developers,

I want to write 24 bytes constant in Non-volatile Memory. Additionally, I want that this data can only be read by MCU and not being rewritten or erased.

I'm not using softdevice.

I'm thinkng to use UICR registers starting from 0x10001080 address. But I'm not sure how to protect the data not to be rewritten and read by other peripherals than MCU. Can you please tell is this possible or no?

I know that I can use code memory by deviding it in CR0 and CR1 regions and save my data in CR0. In this case I don't know how exactly should I write my data into CR0?

I'd highly appreciate any advice.

Best regards, Harut

Parents Reply Children
  • Hi Vidar Berg, Thanks a lot for your ansewer. No I don't need to update my 24 bytes. It's a constant.

    If I understand you correctly. I have 3 options.

    1. I can use UICR registers. Only CPU has access to those registers. But CPU can change the value by clearing '1's with '0's. This is not satisfing to my requiremnents. I should protect the value from changing.

    2. To use NVM protection blocks. As I understand with PROTENSET registers I can only protect code memory addresses from 0x00000000 to 0x00000040 (first 64 blockes from code memory). For implementation I think I should first write my 24 bytes to those addresses using NVMC and then set the PROTENSET register.

    3. Code region 0 protection. Which seems to me the most suitable for my application.To devide code memory in 2 parts by setting UICR_CLENR0 register to some small value (32 for example). Write my 24 bytes from 0x00000000 to 0x00000018 code memory addresses and my firmware code will be stored in region1.

    Can you please tell me how can I store my 24 bytes data into code memory without using NVMC? Because I want to do it not in a run time.

    Thanks again, Harut

  • Hi, the NVM blocks are actually 4KB and range from address 0x0 to 0x40000 (0x20000 on 128K parts) and are enabled at runtime. I think this might be the best option unless you are short on flash space. If you choose to store your data in CR0 you would to implement forwarding of interrupts and program execution to your application. Thus, making it a bit more complicated.

    Const data can be linked to a specific location in flash by using the at attribute if you're using Keil. You can then use the .map file (see build output) to verify the placement.

Related