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

Best method for writing to UICR during production

Please note that I am a new developer.

I am currently testing on a nRF52 DK on Windows.

I want to flash my application (which has a SoftDevice) and also write manufacturing information such as serial number to the UICR (customer reserved) registers.

I have tried using the method described in the UICR Config Example where Keil uVision is modified to write to UICR. This method works, but is not desirable. I want to use a Flasher ATE (JLink flash programmer) to flash each of my devices during production.

I have seen in some threads that it is possible to write to the UICR using nrfjprog as such:

nrfjprog --memwr 0x10001304 --val 0x00000000

Is the best method to use nrfjprog and write to each individual UICR address and then to flash the application and SoftDevice? Or perhaps it is more efficient to produce a single .hex file (using mergehex) where UICR registers are already written.

My question is: what is the most efficient way to write to the UICR registers during production?

Thanks for any help!

Parents
  • Creating separate .hex file containing UICR data:

    I initially also wanted to find out how to create .hex files which contain UICR data. This .hex file can then be merged with the application .hex file (using Nordic`s mergehex executable) before flashing. As Terje has stated (in a comment below), this is not the most efficient method for writing to the UICR registers.

    To make a separate HEX file containing the UICR data, we can use a HEX editor such as FlexHEX. Then simply write the desired data (such as serial number) into the editor. Note that when we read from the chip, the order of bytes will be reversed. The example below will for example be displayed as 0xEFBEADDE (and not 0xDEADBEEF).

    When saving the file, FlexHEX will export it as a binary file. Then we can use a program like SRecord to convert the binary file to a HEX file. Here we determine the offset of the data. The offset of the CUSTOMER[0] register is 0x1080 (hex) which is 4224 in decimal.

    srec_cat uicr.bin -binary -offset=4224 -o uicr.hex -intel -obs=16

    After this, Nordic`s mergehex executable can be used to merge the uicr.hex file with the application .hex file. The mergehex executable is part og the nRF Command Line Tools.

    mergehex -m application.hex uicr.hex -o output.hex

    It is (as stated in other threads) important to erase the flash stored on the device before flashing UICR:

    nrfjprog --family nRF52 --eraseall
    nrfjprog --program output.hex -f NRF52

    After flashing we can verify that there is data in the CUSTOMER[0] register using nrfjprog:

    nrfjprog -f NRF52 --memrd 0x10001080 --n 4

Reply
  • Creating separate .hex file containing UICR data:

    I initially also wanted to find out how to create .hex files which contain UICR data. This .hex file can then be merged with the application .hex file (using Nordic`s mergehex executable) before flashing. As Terje has stated (in a comment below), this is not the most efficient method for writing to the UICR registers.

    To make a separate HEX file containing the UICR data, we can use a HEX editor such as FlexHEX. Then simply write the desired data (such as serial number) into the editor. Note that when we read from the chip, the order of bytes will be reversed. The example below will for example be displayed as 0xEFBEADDE (and not 0xDEADBEEF).

    When saving the file, FlexHEX will export it as a binary file. Then we can use a program like SRecord to convert the binary file to a HEX file. Here we determine the offset of the data. The offset of the CUSTOMER[0] register is 0x1080 (hex) which is 4224 in decimal.

    srec_cat uicr.bin -binary -offset=4224 -o uicr.hex -intel -obs=16

    After this, Nordic`s mergehex executable can be used to merge the uicr.hex file with the application .hex file. The mergehex executable is part og the nRF Command Line Tools.

    mergehex -m application.hex uicr.hex -o output.hex

    It is (as stated in other threads) important to erase the flash stored on the device before flashing UICR:

    nrfjprog --family nRF52 --eraseall
    nrfjprog --program output.hex -f NRF52

    After flashing we can verify that there is data in the CUSTOMER[0] register using nrfjprog:

    nrfjprog -f NRF52 --memrd 0x10001080 --n 4

Children
No Data
Related