<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22472/add-configuration-via-additional-hex</link><description>Hi 
 I would like to prepare a provisioning hex file for my firmware.
Can somebody supply an example how this could be made? 
 I&amp;#39;m using gcc toolchain, Eclipse and SDK 12.3 for development. 
 Example:
I would like to add specific data like e.g. DeviceType</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Jun 2017 12:23:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22472/add-configuration-via-additional-hex" /><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88345?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 12:23:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5fc80da-98d4-4337-8fa2-da76a7e93b34</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Martin Peters: To write to any address on the chip , you can use the programmer program to write, it could be nrfjprog or Jlink commander.
On nrfjprog you use this syntax &lt;code&gt;nrfjprog --memwr &amp;lt;addr&amp;gt; --val &amp;lt;val&amp;gt;&lt;/code&gt; , type nrfjprog &amp;amp; enter to know how to use it.&lt;/p&gt;
&lt;p&gt;I would suggest you to have a look at the nRF51 reference manual to understand the flash layout and UICR. Bootloader setting doesn&amp;#39;t use UICR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88344?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 10:39:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ee76b44-a312-4f57-b5a6-2441331d36c0</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Martin, surprisingly beginners as well as veterans actually use &amp;quot;write it once and then dump back&amp;quot; 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&amp;#39;t use fstorage or other module from SDK, then you would need to align it togeahter). In UICR it works the same: find the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uicr.html?cp=2_2_0_13_0_27#register.CUSTOMER-0"&gt;UICR-&amp;gt;CUSTOMER&lt;/a&gt; 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.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88343?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 10:33:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c603a91-d57f-4998-9ef0-45326c9c16f9</guid><dc:creator>Martin</dc:creator><description>&lt;p&gt;@endnode : Are there any source examples somewhere or a tutorial covering this for &amp;quot;beginners&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88342?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 10:32:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd0b129a-4dc5-4207-a361-514e715146aa</guid><dc:creator>Martin</dc:creator><description>&lt;p&gt;Hi Hung Bui
can you supply a link to the suggested &amp;quot;writing to UICR&amp;quot; procedure? I read alot about it, but it is not clear to me how this works and from my understanding this clashes when using the bootloader.
Is my understand correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88341?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 10:29:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d435b14e-5eb3-41c0-a089-ae2e1c5fa296</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;You can also easily convert HEX to BIN and vice versa in GCC by using &lt;code&gt;arm-none-eabi-objcopy&lt;/code&gt; ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add configuration via additional hex</title><link>https://devzone.nordicsemi.com/thread/88340?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 10:26:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99343793-374c-4362-bf16-44e6a8ccfd90</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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 &lt;a href="https://en.wikipedia.org/wiki/Intel_HEX"&gt;intel hex syntax&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Another option is to convert the data to binary and use Jlink loadbin to flash it, please have a look &lt;a href="https://devzone.nordicsemi.com/question/134565/preparing-a-hex-file-to-program-in-flash/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>