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

Creating Flash Space that is only ever programmed once during production

I would like space in flash that can be written to during production and then never changes or is overwritten.  I have explored adding a section in the linker.

SECTIONS
{
  __RAM_segment_start__ = 0x20000000;
  __RAM_segment_end__ = 0x20040000;
  __RAM_segment_size__ = 0x00040000;
  __FLASH_segment_start__ = 0x00000000;
  __FLASH_segment_end__ = 0xFFEFF;
  __FLASH_segment_size__ = 0xFFEFF;
  __DEVICE_VALUES_segment_start = 0xFFF00;
  __DEVICE_VALUES_segment_end = 0x00100000;
  __DEVICE_VALUES_segment_size = 0x100;

Are these values relative offsets or actual and how do I test this new segment.  What are my options for programming this space on a production line.

Parents
  • Hello,

    How much data do you need to store? I set you set aside 0x100 as the size. 

    The reason I ask is that there is something called UICR, which has 32 registers (each 32bit) that are intended for such cases where you set them during production. 

    The issue with using partial pages like you do here is that if you use 0x0FFF00 -> 0x100000, it means that you can never erase the page 0x0FF000 -> 0x100000, so it means that you can't use 0x0FF000 -> 0x0FFEFF for anything else either (it can at least not be updated). 

    As I see it you have a couple of options here. Either you can use the UICR->CUSTOMER[n], n = 0..31, if that is sufficient space. If not, then you need to set aside a flash page for this purpose. E.g. 0x0FF000 -> 0x100000.

    When you select what page you want to use for this, please consider whether or not you intend to use a bootloader at any point in time. If you do, you need to reserve the top pages (how many depends on what kind of bootloader you use). 

    As of how to write the content that you want to the flash, you can either do this using a programmer directly, you can include it in your hex file, or you can have the application do it (check if written, if not, write) on startup. 

    Check out nRF Command Line Tools, and the command "nrfjprog --memwr <addr> --val <value>", such as:

    nrfjprog --memwr 0x0FF000 --val 0xDEADBEEF

    nrfjprog --memrd 0x0FF000

    It looks like you are using Segger Embedded Studio. What chip are you using? nRF52840 or nRF52832, or something else?

    How much data do you need to store?

    Best regards,

    Edvin

  • Edvin thank you for your response,

    I am saving 64 bits of data at the time of programming and would like them to be protected for the life of the device.  I will give the UICRs a shot.  I am using the nRF52840.  Do these registers work the same as flash, do they have to be erased before written to and can they be read protected?

    Thanks again, Bloq

  • Bloq said:
    Do these registers work the same as flash, do they have to be erased before written to and can they be read protected?

     Yes. The UICR is part of the flash. You can read about the UICR here:

    https://infocenter.nordicsemi.com/topic/ps_nrf52840/uicr.html?cp=4_0_0_3_4

    If you enable readback protection, then the UICR is not available via a debugger, if that is what you mean. 

    Please note that it is physically possible to write to it several times, but it will only change the bits that are 1 to 0, just like the rest of the flash.

Reply Children
No Data
Related