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

Add configuration via additional hex

Hi

I would like to prepare a provisioning hex file for my firmware. Can somebody supply an example how this could be made?

I'm using gcc toolchain, Eclipse and SDK 12.3 for development.

Example: I would like to add specific data like e.g. DeviceType, HW-Revision , Manufacturing Date to be accessible from the firmware.

Same procedure would also be interesting for dfu bootloader configuration.

Thanks in advance

Martin

Parents
  • Hi Martin,

    Do you plan to update these data after the device is deployed ? If the data is unchange, you can store it in UICR. If it can be updated at some point, you should use a normal flash page.

    There are many way to get the hex file with the data, but easiest from my point of view is to use nrfjprog -memwr to write directly to the flash. After you have it, you can read the flash out to a hex file. Then you can edit the hex file to reduce it to only the data you need. You would need to understand intel hex syntax.

    Another option is to convert the data to binary and use Jlink loadbin to flash it, please have a look here.

  • Hi Martin, surprisingly beginners as well as veterans actually use "write it once and then dump back" procedure as Hang Bui describes. This is how most of embedded products (like Smart Cards) are produced. So if you want to store some data simply add them to the code as constants, put them somewhere to the flash (use some fixed address in space where you are sure that no other code access them - typically at the end of flash memory range but be sure that you don't use fstorage or other module from SDK, then you would need to align it togeahter). In UICR it works the same: find the UICR->CUSTOMER register address and write data there. Then you dump it with nrfjprog and you have your hex file. Note that UICR has only 32 words (32x4B = 128B) available, if you need more (or you need to change it later) you need to allocate one or more flash pages.

Reply
  • Hi Martin, surprisingly beginners as well as veterans actually use "write it once and then dump back" procedure as Hang Bui describes. This is how most of embedded products (like Smart Cards) are produced. So if you want to store some data simply add them to the code as constants, put them somewhere to the flash (use some fixed address in space where you are sure that no other code access them - typically at the end of flash memory range but be sure that you don't use fstorage or other module from SDK, then you would need to align it togeahter). In UICR it works the same: find the UICR->CUSTOMER register address and write data there. Then you dump it with nrfjprog and you have your hex file. Note that UICR has only 32 words (32x4B = 128B) available, if you need more (or you need to change it later) you need to allocate one or more flash pages.

Children
No Data
Related