<?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>Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46323/writing-data-to-uicr-region-and-flashing-device</link><description>I&amp;#39;m trying to accomplish two things: 1. Write 2 values to the UICR (2 arrays actually - a serial number and encryption keys). 2. Flash the device in such a way that the information in UICR is preserved. My questions: 1. Whats the UICR address range? </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Apr 2019 13:04:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46323/writing-data-to-uicr-region-and-flashing-device" /><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/184088?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 13:04:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e75b805f-00ee-48dc-b9f3-cdaeb371a410</guid><dc:creator>Tim Adu</dc:creator><description>&lt;p&gt;Thanks Vidar! Both approaches work just fine.&lt;/p&gt;
&lt;p&gt;I definitely see your point where the fstorage can be overhead, but it&amp;#39;s overhead I can afford because I also plan to write other kinds of data, and fstorage provides a fairly more &amp;quot;controlled&amp;quot; way of writing/reading.&lt;/p&gt;
&lt;p&gt;Thanks again. I have enough to keep me going &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/184067?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 12:25:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d30eda58-0493-4216-869f-5e0d0c0b0426</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1. The module is intended for managing NV memory storage in the FLASH region (0x0 - 0x80000). You can probably use fstorage to write data to the UICR if you don&amp;#39;t use the softdevice backend (ie. can only be used while the softdevice is disabled). Since the UICR is intended for one-time configurations like serial numbers,etc., I don&amp;#39;t think fstorage is worth the overhead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. UICR can be read it like any other register. E.g.,&lt;/p&gt;
&lt;p&gt;uint32_t serial_number;&lt;/p&gt;
&lt;p&gt;serial_number = NRF_UICR-&amp;gt;CUSTOMER[x];&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/184061?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 12:12:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed94b366-c091-4c44-a072-ef93197c073d</guid><dc:creator>Tim Adu</dc:creator><description>&lt;p&gt;Thanks so much for the reply.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Why is fstorage not suitable?&lt;/li&gt;
&lt;li&gt;Using a similar approach like you described above, how would you read from the UICR?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/183977?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 08:15:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23daa576-4f92-4134-a7cf-3d2b89cf09c0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;fstorage is not suitable for writing data to the UICR. I&amp;#39;d recommend you to copy the approach used to enable the reset pin in system_nrf52840 if you&amp;nbsp;need the app to set the serial number and encryption keys at runtime.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        if (((NRF_UICR-&amp;gt;PSELRESET[0] &amp;amp; UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected &amp;lt;&amp;lt; UICR_PSELRESET_CONNECT_Pos)) ||
            ((NRF_UICR-&amp;gt;PSELRESET[1] &amp;amp; UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected &amp;lt;&amp;lt; UICR_PSELRESET_CONNECT_Pos))){
            NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos; //&amp;lt;-- Enable flash write
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NRF_UICR-&amp;gt;PSELRESET[0] = 21; //&amp;lt;-- write value to UICR register
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){} &amp;lt;-- wait until write is complete
            NRF_UICR-&amp;gt;PSELRESET[1] = 21; //&amp;lt;-- write value to UICR register
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos; // &amp;lt;-- disable write access
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NVIC_SystemReset(); // &amp;lt;-- Pinreset functionality is enabled after reset
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that it&amp;#39;s not possible to erase UICR from the app, so you cannot update an existing value in UICR. Also, it&amp;#39;s not possible to write to UICR while the softdevice is enabled.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/183964?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 07:40:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa129753-8477-4c51-b372-3e6d1394046d</guid><dc:creator>Tim Adu</dc:creator><description>&lt;p&gt;Okay. Would it therefore make sense to reserve the UICR customer adresses? The fstorage driver instance requires you to reserve an area of flash that you want to use. So, would this make sense: &lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage_instance) =
{
    .evt_handler = fstorage_evt_handler,

    .start_addr = 0x10001080UL, //CUSTOMER[0]
    .end_addr   = 0x100010FCUL, //CUSTOMER[31]
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/183308?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 06:45:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1167442c-2646-4bcb-8011-5f669b840b80</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1. UICR contains registers that are reserved for other uses as well, UICR.PSELRESET[] that enables the reset pin for instance. But you can use the &amp;quot;CUSTOMER&amp;quot; registers. A description of the different registers can be found in the PS here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uicr.html?cp=3_0_0_3_4"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/uicr.html?cp=3_0_0_3_4&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp; When writing to flash you need to specify the exact address you want to write to. E.g., if you want to write to UICR.CUSTOMER[0]:&lt;/p&gt;
&lt;p&gt;nrfjprog --memwr 0x10001080 --val &amp;lt;32-bit value&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing data to UICR region and flashing device</title><link>https://devzone.nordicsemi.com/thread/182635?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2019 13:29:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e31f780d-3b88-4112-99c6-d23df00d2638</guid><dc:creator>Tim Adu</dc:creator><description>&lt;p&gt;Been looking a little deeper into the SDK and found (in nrf52840.h) that there is a struct called NRF_UICR_Type, which contains&lt;/p&gt;
&lt;pre&gt;uint32_t  CUSTOMER[32];  &lt;/pre&gt;
&lt;p&gt;Could I just write my data here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>