<?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>how to enable readback protection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6134/how-to-enable-readback-protection</link><description>Hi, Guys, 
 I am trying to enable the readback protection for the code region 0 and code region 1, I know that the NRF_UICR-&amp;gt;RBPCONF register is flash_backed, so I have to include uicr_config.h file and uncomment the line 
const uint32_t UICR_RBPCONF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Jul 2019 11:21:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6134/how-to-enable-readback-protection" /><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/198134?ContentTypeID=1</link><pubDate>Fri, 12 Jul 2019 11:21:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c19b7e5b-58ec-4aa4-bfe6-b24cb802b874</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Eran: please create a devzone case for new question. Note that you can freely use sd_flash_write() to access flash. The fstorage flash library is just to help you with the operation queue and retry if the operation&amp;#39;s failed.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/196446?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 09:06:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b86426d6-4b3c-4a32-9df2-47a35cf9363f</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Is there a possibility to write to flash from the firmware (without using the .hex file) without using the the flash manager library ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why is the flash manager necessary here and why doesn&amp;#39;t&amp;nbsp;sd_flash_write() work for me?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21482?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 10:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b585f97-6faf-4f54-9263-04387a4add6e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;As far as I understand, &lt;a href="https://sourceware.org/binutils/docs/ld/Input-Section-Keep.html"&gt;using KEEP&lt;/a&gt; tells the linker to keep the section even if it&amp;#39;s not referenced. In this case there is a chance that the garbage colletion things that you don&amp;#39;t use UICR_ADDR_0x04 anywhere so it might eliminate the area.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21487?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 09:58:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cd797e8-a51c-40dc-bb6b-2c09054e411b</guid><dc:creator>David Garc&amp;#237;a Polo</dc:creator><description>&lt;p&gt;You could have just done the following:&lt;/p&gt;
&lt;p&gt;In some code of yours, start of main for example, in seudocode:&lt;/p&gt;
&lt;p&gt;If UICR-RBPCONF equal not protected:
set NVMC.CONFIG to Write Enable
wait for NVMC.READY
write RBPCONF to desired value
wait for NVMC.READY
set NVMC.CONFIG to Read Enable
system reset request&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21486?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 09:56:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51d5f4f3-ecbb-4530-afd4-399ad5941cc2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Clem: user supposed to use only 128 bytes UICR from 0x10001080 to 0x100010FF to store user data. Accessing UICR outside of that area is not recommended. Please have a look at chapter 8 in the nRF51 Reference Manual.
I would suggest you to use a normal flash page to store your key and info.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21485?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 09:08:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:010fb0f9-c82d-46e8-8060-be44c2c97bd4</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;Nope, I didn&amp;#39;t get a reply and I never bother to ask support or my sales rep. I really should ask. I suspect the answer will be something like &amp;#39;yes it is 1K but we don&amp;#39;t test the full 1K in production&amp;#39;.&lt;/p&gt;
&lt;p&gt;I still have some time to move the key data out of UICR and stick it someplace else, but UICR seemed like a good place for manufacturing time data.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d be willing to bet that FICR is also a full flash page as well. I need to take one of the bits of broken hardware I have lying around and see if I can stomp on bits in FICR just by setting NVMC_CONFIG = 2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21484?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 05:31:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68fe761c-f3e7-451e-9b80-789f4a2a9970</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Did you ever get proper confirmation that the UICR really is and is guaranteed to stay a full 1024 bytes of FLASH which can be used and not just the documented 160 bytes with 32 reserved for customer use?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21483?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2015 05:20:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b379d7d0-9bec-429e-adda-2c3a8ebc75b0</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;I ended up putting quite a bit of stuff in UICR (128 bytes of user data and 512 bytes of crypto keys).&lt;/p&gt;
&lt;p&gt;I have 2 sections, .infoUICR and .keysUICR, each contains a single structure (otherwise ld might swap the order)&lt;/p&gt;
&lt;p&gt;xxxUICR.c:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;xxxInfoUICR_t xxxInfoUICR __attribute__((section(&amp;quot;.infoUICR&amp;quot;), used));
xxxKeysUICR_t xxxKeysUICR __attribute__((section(&amp;quot;.keysUICR&amp;quot;), used));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;xxx.ld:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MEMORY
{
        /* manufacturing time data (customer UICR region) */
        UICR (r)          : ORIGIN = 0x10001000, LENGTH = 0x080 /* 128 bytes */
        INFO_UICR (r)     : ORIGIN = 0x10001080, LENGTH = 0x180 /* 384 bytes */
        KEYS_UICR (r)     : ORIGIN = 0x10001200, LENGTH = 0x200 /* 512 bytes */
}
...
SECTIONS
{
        /* UICR info data (manufacturing time data) */
        .infoUICR (NOLOAD) :
        {
                KEEP(*(.infoUICR))
        } &amp;gt; INFO_UICR
 
        /* UICR key data (manufacturing time data) */
        .keysUICR (NOLOAD) :
        {
                KEEP(*(.keysUICR))
        } &amp;gt; KEYS_UICR
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I ended up writing a host C program to build up the UICR data because I have several CRC values in the various data blocks. I also did not want the UICR data embedded in the bootloader hex file so the bootloader image for the factor and the bootloader image for DFU are exactly the same.&lt;/p&gt;
&lt;p&gt;The host tool builds up the 1024 byte UICR page writes it to stdout as binary data which is converted to a hex file with bin2hex.py. The hex file I send the factory is a hexmerge.py of the softdevice, application, bootloader and uicr hex files.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21479?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2015 15:52:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22934c6a-ce52-491b-be63-2f997d54e489</guid><dc:creator>nimalhuang</dc:creator><description>&lt;p&gt;Hi, Hung,
Thank you for your reply. I have figure out the problem. But without this line of code: KEEP((.uicrrbpconf)
so is there any difference between have and havn&amp;#39;t this line of code? Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21478?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2015 08:55:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c5573f3-93d3-4b9f-b7fd-2ce2529f2a7d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@nimalhuang: Could you send me a sample hex file that you added section(&amp;quot;.uicrrbpconf&amp;quot;) the same way as I suggested ?
And also another sample hex file that you use your configuration ?&lt;/p&gt;
&lt;p&gt;I tested here and seeing no problem. Attached in the answer above is the project and hex file I compiled with address 0x10001004 is set = 0xffff0000.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21481?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2015 16:06:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26baf528-9de3-431d-847d-df730108c45f</guid><dc:creator>nimalhuang</dc:creator><description>&lt;p&gt;Hi, Hung,&lt;/p&gt;
&lt;p&gt;I use jlink to debug the board, so it should be J flash I think. After I add the following code to the ld file. it works.&lt;br /&gt;
UICR (rw) : ORIGIN = 0x10001000, LENGTH = 0x0fd	/* 0x10001000 ~ 0x100010fd-1 &lt;em&gt;/
.uicrrbpconf 0x10001004 :
{
KEEP(&lt;/em&gt;(.uicrrbpconf))
} &amp;gt; UICR
However, this takes much more time to compile. Do you have any crew what&amp;#39;s going on?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21480?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2015 14:30:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:442e17a2-af06-4be9-9137-26d62b7039c6</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;There should be no different between on the way to write to UICR. Could you try the example on github and check if the uicrBootStartAddress is written ? Which program you used to flash the chip ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21477?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 22:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c5f3854-0f85-4811-a26a-5f5682b04433</guid><dc:creator>nimalhuang</dc:creator><description>&lt;p&gt;Hi, Huang&lt;/p&gt;
&lt;p&gt;I add code as you said, but it doesn&amp;#39;t work. I add the following code in the main.c:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;attribute&lt;/strong&gt;((section(&amp;quot;.uicrrbpconf&amp;quot;))) uint32_t UICR_ADDR_0x04 = 0xffff0000;&lt;/p&gt;
&lt;p&gt;and define the &amp;quot;.uicrrbpconf&amp;quot; section in ld file:&lt;/p&gt;
&lt;p&gt;.uicrrbpconf 0x10001004 :
{&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Is there anything that I have missed? Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21475?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 22:17:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23685093-f554-4f05-82cd-0822266316da</guid><dc:creator>nimalhuang</dc:creator><description>&lt;p&gt;Hi, Thank you for your reply. Because I enable softdevice s130, using function ble_flash while softdevice running will halt the cpu and hence cause hard fault, so this is not gonna work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21476?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 13:00:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a32f57d8-c7c1-4629-ac5d-344084d251a2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I think you can follow what we did &lt;a href="https://github.com/NordicSemiconductor/nrf51-dfu-bootloader-for-gcc-compiler/blob/master/nrf51822_v6.0.0%20-%20GCC_Bootloader/Board/nrf6310/device_firmware_updates/bootloader%20-%20gcc%20-%20BLE/bootloader_util_gcc.c"&gt;here&lt;/a&gt; to write the bootloader address to UICR:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__attribute__ ((section(&amp;quot;.uicrBootStartAddress&amp;quot;))) uint32_t m_uicr_bootloader_start_address = BOOTLOADER_REGION_START;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note: You would need to define the uicrBootStartAddress section in the .ld file as in &lt;a href="https://github.com/NordicSemiconductor/nrf51-dfu-bootloader-for-gcc-compiler/blob/master/nrf51822_v6.0.0%20-%20GCC_Bootloader/Board/nrf6310/device_firmware_updates/bootloader%20-%20gcc%20-%20BLE/gcc/gcc_nrf51_bootloader_xxaa.ld"&gt;gcc_nrf51_bootloader_xxaa.ld&lt;/a&gt; file.&lt;/p&gt;
&lt;p&gt;Example project: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/bootloader-_2D00_-gcc-_2D00_-BLE-_2D00_-TestRBP.zip"&gt;bootloader - gcc - BLE - TestRBP.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21474?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 10:50:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd1f0c11-a7f8-47d3-a67f-20893a6e24e7</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can either write UICR-&amp;gt;RBPCONF from within the application by something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if LOCK_UICR
    // Check if read-back mechanism is turned ON.
    if((uint32_t)((NRF_UICR-&amp;gt;RBPCONF &amp;amp; UICR_RBPCONF_PALL_Msk) &amp;gt;&amp;gt; UICR_RBPCONF_PALL_Pos) != UICR_RBPCONF_PALL_Enabled) {
        ble_flash_word_write((uint32_t *)&amp;amp;NRF_UICR-&amp;gt;RBPCONF, (NRF_UICR-&amp;gt;RBPCONF &amp;amp; ~UICR_RBPCONF_PALL_Msk));
    }
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or you can put something like this to the end of your HEX file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:020000041000EA
:10100000FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFEF
:00000001FF
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to enable readback protection</title><link>https://devzone.nordicsemi.com/thread/21473?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 00:37:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ba14a18-9472-457a-95de-ba3f54e6d07e</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;A search in the forums shows this answer&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/4381/nrf51822-bootloader-with-gcc/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which says it&amp;#39;s not trivial and probably involves reading the ld manual. I assume you want to embed the data in your application so that when it&amp;#39;s flashed the UICR is written. If I were going to do that I&amp;#39;d probably write a small .bin/.hex file with the values I want flashed in and add a step to merge it in with my code .hex file at the end using objcopy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>