<?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>5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96577/5340-protect-programs-from-theft</link><description>Hello 
 NCS2.0.2, nRF5340, VScode 
 when download hex to 5340. 
 how to read out it? 
 and how to prohibit read out? 
 protect programs from theft. 
 
 Best regards</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Feb 2023 01:36:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96577/5340-protect-programs-from-theft" /><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410984?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 01:36:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ce18f6f-f30b-4a1d-ba79-31a819dd8845</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;test it on nRF5340-DK&lt;/p&gt;
&lt;p&gt;when no call&amp;nbsp;&amp;nbsp;nrf_debug_port_disable()&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:94px;max-width:528px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1056x188/__key/communityserver-discussions-components-files/4/pastedimage1676942686631v28.png" /&gt;&lt;/p&gt;
&lt;p&gt;when call&amp;nbsp; &amp;nbsp;nrf_debug_port_disable()&amp;nbsp; (even no&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_APPROTECT_LOCK=y in prj.conf&amp;nbsp; and&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;ENABLE_APPROTECT&amp;nbsp;&amp;nbsp;&lt;/span&gt;in CMakeLists.txt&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:185px;max-width:529px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1058x370/__key/communityserver-discussions-components-files/4/pastedimage1676942644961v27.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410937?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2023 14:34:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cd8b366-7b6a-4d16-9f4f-2ecfc8b43e8d</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you tried it and does this solve your issue?&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410734?ContentTypeID=1</link><pubDate>Sat, 18 Feb 2023 00:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5a6bb6f-8d22-4457-8ba6-7174830cea1d</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;ok, now&lt;/p&gt;
&lt;p&gt;nrf5340dk_nrf5340_cpuapp&lt;/p&gt;
&lt;p&gt;i only add tow line to prj.conf&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_APPROTECT_LOCK&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_SECURE_APPROTECT_LOCK&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410680?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 14:32:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd00d0b-6000-4099-b035-d347c837ec6a</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We recently added this information to the documentation, and it might be helpful:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/ap_protect/index.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/ap_protect/index.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410549?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 09:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d6c7471-527b-46d9-abbc-5a3fe80f0394</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in CmakeLists.txt&amp;nbsp; add:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;zephyr_compile_definitions_ifdef(CONFIG_NRF_APPROTECT_LOCK&lt;br /&gt; ENABLE_APPROTECT)&lt;br /&gt;zephyr_compile_definitions_ifdef(CONFIG_NRF_APPROTECT_USER_HANDLING&lt;br /&gt; ENABLE_APPROTECT_USER_HANDLING)&lt;br /&gt;zephyr_compile_definitions_ifdef(CONFIG_NRF_SECURE_APPROTECT_LOCK&lt;br /&gt; ENABLE_SECURE_APPROTECT)&lt;br /&gt;zephyr_compile_definitions_ifdef(CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING&lt;br /&gt; ENABLE_SECURE_APPROTECT_USER_HANDLING)&lt;br /&gt;zephyr_library_compile_definitions_ifdef(CONFIG_NRF_TRACE_PORT&lt;br /&gt; ENABLE_TRACE)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;int prj.conf add:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_APPROTECT_LOCK&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;in main top call&amp;nbsp; nrf_debug_port_disable()&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrf_nvmc_write_word(uint32_t address, uint32_t value)
{
	// Enable flash write access and wait until the NVMC is ready
    NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);
    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {;}

    // Write to the register and wait until the NVMC is ready
    *(uint32_t*)address = value;
    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {;}

	// Disable flash write access and wait until the NVMC is ready
    NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);
    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {;}
}
void nrf_debug_port_disable(void)
{
	if(NRF_UICR-&amp;gt;APPROTECT&amp;amp;0x000000ff)
    {
		printk(&amp;quot;\nAccess Port Protection is not enabled --&amp;gt; Enable Access Port Protection now\n&amp;quot;);
		/* Enable Access Port Protection
		 * Access through debugger to CPU registers, mapped-memory and RAM will be disabled
		 * To disable protection ERASEALL command must be applied. */
		nrf_nvmc_write_word((uint32_t)&amp;amp;NRF_UICR-&amp;gt;APPROTECT, NRF_UICR-&amp;gt;APPROTECT&amp;amp;0xffffff00);
		printk(&amp;quot;Access Port Protection is now enabled --&amp;gt; Reboot to apply the config...\n&amp;quot;);

		// Sleep is only necessary to show the logs before reboot for debug purposes
		k_msleep(2000);

		//NVIC_SystemReset();
		sys_reboot(SYS_REBOOT_COLD);
    }
	else
	{
		printk(&amp;quot;\nAccess Port Protection is already enabled\n&amp;quot;);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could&amp;nbsp;you please confirm my understanding?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410514?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 06:50:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cee5374-fce4-4d76-af00-67dac6a80096</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Sorry, I had shared the wrong link. Fat fingers! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61b.svg" title="Stuck out tongue"&gt;&amp;#x1f61b;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the link:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/allowing-debugger-access-to-an-nrf5340"&gt;Allowing debugger access to nRF5340&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410501?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 02:54:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:decae20a-b039-4e96-983b-f1b589238dfc</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;thanks for reply.&lt;/p&gt;
&lt;p&gt;i have a look it,&lt;/p&gt;
&lt;p&gt;the follow code is for nRF SDK,&amp;nbsp; but i&amp;#39;m using NCS2.0&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifdef ENABLE_APPROTECT
	if ((NRF_UICR-&amp;gt;APPROTECT &amp;amp; UICR_APPROTECT_PALL_Msk) !=
		(UICR_APPROTECT_PALL_Enabled &amp;lt;&amp;lt; UICR_APPROTECT_PALL_Pos)) {

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}

        NRF_UICR-&amp;gt;APPROTECT = ((NRF_UICR-&amp;gt;APPROTECT &amp;amp; ~((uint32_t)UICR_APPROTECT_PALL_Msk)) |
		    (UICR_APPROTECT_PALL_Enabled &amp;lt;&amp;lt; UICR_APPROTECT_PALL_Pos));

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
   	}
#else
	if ((NRF_UICR-&amp;gt;APPROTECT &amp;amp; UICR_APPROTECT_PALL_Msk) !=
		(UICR_APPROTECT_PALL_HwDisabled &amp;lt;&amp;lt; UICR_APPROTECT_PALL_Pos)) {

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}

        NRF_UICR-&amp;gt;APPROTECT = ((NRF_UICR-&amp;gt;APPROTECT &amp;amp; ~((uint32_t)UICR_APPROTECT_PALL_Msk)) |
		    (UICR_APPROTECT_PALL_HwDisabled &amp;lt;&amp;lt; UICR_APPROTECT_PALL_Pos));

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
	}
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410218?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 06:26:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2355259c-91e5-49d0-86a1-24355b554c59</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can refer &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect"&gt;this guide&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/410208?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 02:20:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:653294d8-d8ad-423b-8dcf-11c348138e93</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;thanks for reply&lt;/p&gt;
&lt;p&gt;about&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fdif.html&amp;amp;cp=4_0_0_3_7_1&amp;amp;anchor=concept_udr_mns_1s"&gt;APPROTECT&lt;/a&gt;&lt;span&gt;.&amp;nbsp; i do&amp;#39;t know how to write code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 5340 protect programs from theft</title><link>https://devzone.nordicsemi.com/thread/409772?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 09:04:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2164b9b-b032-4639-9241-5e8d19681a55</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can read the hex files using the nRF Connect for Desktop -&lt;span&gt;&lt;span dir="ltr"&gt;&amp;gt; Programmer App, or using &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf_cltools/UG/cltools/nrf_nrfjprogexe_reference.html?cp=11_1_3_0"&gt;nrfjprog&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span dir="ltr"&gt;nrfjprog --readcode app_flash_dump.hex --coprocessor CP_NETWORK&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;In order to prevent readout, you can enable the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fdif.html&amp;amp;cp=4_0_0_3_7_1&amp;amp;anchor=concept_udr_mns_1s"&gt;APPROTECT&lt;/a&gt;. It is disabled in most of our samples.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Best Regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Priyanka&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>