<?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 program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59645/how-to-program-the-code-in-software-to-enable-flash-read-protection</link><description>config flash read protection in code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Apr 2020 06:22:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59645/how-to-program-the-code-in-software-to-enable-flash-read-protection" /><item><title>RE: how to program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/thread/243300?ContentTypeID=1</link><pubDate>Fri, 03 Apr 2020 06:22:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01c7bd8f-b3e2-4438-b6fc-62944843ae0a</guid><dc:creator>chenwenbin</dc:creator><description>&lt;p&gt;thanks!&amp;nbsp;&amp;nbsp;const uint32_t approtect_set __attribute__((used,at(0x10001208))) = 0xFFFFFF00;&amp;nbsp; the code is OK,&amp;nbsp; &amp;nbsp;it means that my code is save ,&amp;nbsp; can not be readback&amp;nbsp; anyway&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/thread/242604?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 07:57:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d3b3451-158f-4b3f-98fc-c0add23d92de</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;I think this is because you need a system reset in order to &amp;quot;activate&amp;quot; the readback protection. Either, set the following const in outside any function in your main file (this won&amp;#39;t require a system reset for the readback protection to turn on:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const uint32_t approtect_set __attribute__((used,at(0x10001208))) = 0xFFFFFF00;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or, you can add this snippet at I.E. the start of your main() loop, which will set readback protection and trigger a system reset to enable the readback protection.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrf_nvmc_write_word(uint32_t address, uint32_t value)
{
    // Enable write.
    NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
    __ISB();
    __DSB();

    *(uint32_t*)address = value;
    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {;}

    NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
    __ISB();
    __DSB();
}

int main(void)
{
    nrf_delay_ms(1000);
    if (NRF_UICR-&amp;gt;APPROTECT == 0xFFFFFFFF)
    {
        nrf_nvmc_write_word((uint32_t)&amp;amp;(NRF_UICR-&amp;gt;APPROTECT), 0xFFFFFF00);
        
        NVIC_SystemReset();
    }    &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/thread/242502?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 15:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a8bbc33-e883-468a-bb98-a96d2acd5b3c</guid><dc:creator>chenwenbin</dc:creator><description>&lt;p&gt;&amp;nbsp;NRF_UICR-&amp;gt;APPROTECT=0xffffff00;&amp;nbsp; run the code , but still can readback FLASH DATA through J-FLASH , why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/thread/242400?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 12:10:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b02c3b08-aabd-4285-901b-33f9f4831803</guid><dc:creator>chenwenbin</dc:creator><description>&lt;p&gt;can you give me the sample code use&amp;nbsp;&lt;span&gt;APPROTECT register to do&amp;nbsp;&amp;nbsp;readback protection ,thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to program the code in software to enable flash read  protection</title><link>https://devzone.nordicsemi.com/thread/242357?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 10:30:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:add276aa-5c8b-4851-b0f7-ef4118acd3e6</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;There are two rather simple ways to enable readback protection using the APPROTECT register.&amp;nbsp;&lt;span&gt;Either, you can set it in your application code like my colleague explains in&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30517/enabling-access-port-protection-from-code"&gt;this thread&lt;/a&gt;&lt;span&gt;. Or, you can download&amp;nbsp;&lt;/span&gt;&lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools/Download"&gt;nrfjprog&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;on your computer and enable APPROTECT by calling the command&amp;nbsp;&lt;/span&gt;&lt;strong&gt;nrfjprog --rbp all&amp;nbsp;&lt;/strong&gt;&lt;span&gt;in a command window when your device is connected. In both cases, you will have to recover the chip/ do a full chip erase in order to access the memory of the chip.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When you set the APPROTECT register, JTAG will keep working until you reset the device, at which point the readback protection will kick in, and your JTAG and SWD will be disabled, and you won&amp;#39;t be able to use the RTT viewer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>