<?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>Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107620/enabling-ap-protect-not-consistent</link><description>Hi! We are trying to enable AP-PROTECT using the zephyr config values. We noticed that for: CONFIG_NRF_APPROTECT_LOCK=y it works for only the NRF5340 and not the NRF52840. 
 CONFIG_NRF_APPROTECT_USE_UICR=y it works for both t he NRF5340 and not the NRF52840</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Feb 2024 16:27:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107620/enabling-ap-protect-not-consistent" /><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/468462?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2024 16:27:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5e3b48a-ff86-44f5-bc1f-9d5a1eedc114</guid><dc:creator>ernieforzano</dc:creator><description>&lt;p&gt;You must also include the following configuration otherwise there will be a linker issue:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRFX_NVMC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/468346?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2024 09:12:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87f27a6b-3e00-443d-9d0b-2bd389736b06</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Based on some feedback from a colleague, here is an improved version:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;nrfx_nvmc.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;

int main(void)
{
  k_sleep(K_MSEC(10));

  uint32_t approtect_status = nrfx_nvmc_uicr_word_read((uint32_t)&amp;amp;NRF_UICR-&amp;gt;APPROTECT) &amp;amp; UICR_APPROTECT_PALL_Msk;
  if(approtect_status == UICR_APPROTECT_PALL_Disabled) {
    while (!nrfx_nvmc_write_done_check()) 
      ;
    nrfx_nvmc_word_write((uint32_t)&amp;amp;NRF_UICR-&amp;gt;APPROTECT, UICR_APPROTECT_PALL_Enabled);
    while (!nrfx_nvmc_write_done_check()) 
      ;
        NVIC_SystemReset();
  }
    printk(&amp;quot;Hello World! %x\n&amp;quot;, approtect_status);
    return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/468263?ContentTypeID=1</link><pubDate>Fri, 09 Feb 2024 16:23:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f84242e6-2031-45b8-8308-f4bf4e54897c</guid><dc:creator>ernieforzano</dc:creator><description>&lt;p&gt;Thank you so much for following up Sigurd!! This was much appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/468111?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2024 15:43:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25d60565-cc73-4585-83f1-611912c816c2</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="ernieforzano"]In the future if you check revision, that would be awesome to prevent extra step for production.[/quote]
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/ernieforzano"&gt;ernieforzano&lt;/a&gt;&amp;nbsp;I must correct myself. I learned now that you can indeed enable APPROTECT for old nRF52 revisions from the code. You just have to do it manually.&lt;/p&gt;
&lt;p&gt;I hope that this is not too late.&lt;/p&gt;
&lt;p&gt;Try this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;nrfx_nvmc.h&amp;gt;

static void config_nvmc(uint32_t val)
{
  while (!NRF_NVMC-&amp;gt;READY);
  NRF_NVMC-&amp;gt;CONFIG = val;
  while (!NRF_NVMC-&amp;gt;READY);
}

void main(void)
{
  config_nvmc(1);
  NRF_UICR-&amp;gt;APPROTECT = 1;
  config_nvmc(0);
  printk(&amp;quot;Hello World! %x\n&amp;quot;, NRF_UICR-&amp;gt;APPROTECT);
  /* k_sleep(K_SECONDS(2)); */
  /* printk(&amp;quot;erasing\n&amp;quot;); */
  /* nrfx_nvmc_all_erase(); */
  /* printk(&amp;quot;after erase\n&amp;quot;); */
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/466081?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 15:48:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff845b41-cedf-4083-96fd-75df5688f51b</guid><dc:creator>ernieforzano</dc:creator><description>&lt;p&gt;Awesome thanks for the update.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;In the future if you check revision, that would be awesome to prevent extra step for production.&lt;br /&gt;&lt;br /&gt;Thanks for the support.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/465952?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 10:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44d2d1c9-7c03-4130-b8a6-22b5879cf4ed</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Sigurd Hellesvik"]Still, setting CONFIG_NRF_APPROTECT_LOCK should lock the device by default, no matter which chip you have I think. If not, the setting should let you know if it does not work.[/quote]
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/8780.pastedimage1706179705646v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;From the docs, Open is the only option for &amp;quot;Hardware Approtect&amp;quot; only devices. &lt;br /&gt;For the nRF52840DK, there is no way to detect which revision you have for the build system, so we can unfortunally not give a warning on this.&lt;/p&gt;
&lt;p&gt;EDIT: added DK, cause I think zephyr technically has knowledge about chip revisions. So it is not &amp;quot;no way to detect it&amp;quot;.&lt;/p&gt;
&lt;p&gt;Second EDIT: Zephyr does not know about revisions, it knows about package types, which is not the same&lt;/p&gt;
&lt;p&gt;So yea, you can not use the LOCK option on old revision.&lt;/p&gt;
[quote user="ernieforzano"]&lt;p&gt;&lt;br /&gt;It does not seem to give any feedback when flashing. When I read the firmware after flashing it in NRFConnect, I can see that:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Readback protection status: NRFDL_PROTECTION_STATUS_NONE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Whenever I program the&amp;nbsp;&lt;span&gt;nRF52840&amp;nbsp;with the UICR&amp;nbsp;CONFIG_NRF_APPROTECT_USE_UICR=y it works after you run the command&amp;nbsp; nrfjprog --rbp ALL. I can see that status change.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Let me know if I am missing something.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Looks right to me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/465676?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 18:28:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60694dd0-6862-4a95-bd56-8b27c05655ed</guid><dc:creator>ernieforzano</dc:creator><description>&lt;p&gt;Hi Sigurd!&lt;br /&gt;&lt;br /&gt;Ah! That makes sense. My revision is Dx0. So that would explain why it might not work.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;It does not seem to give any feedback when flashing. When I read the firmware after flashing it in NRFConnect, I can see that:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Readback protection status: NRFDL_PROTECTION_STATUS_NONE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Whenever I program the&amp;nbsp;&lt;span&gt;nRF52840&amp;nbsp;with the UICR&amp;nbsp;CONFIG_NRF_APPROTECT_USE_UICR=y it works after you run the command&amp;nbsp; nrfjprog --rbp ALL. I can see that status change.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Let me know if I am missing something.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/465503?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 09:17:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d525c28-c3d8-4e49-86fd-079652c1f505</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user=""]CONFIG_NRF_APPROTECT_LOCK=y it works for only the NRF5340 and not the NRF52840.&amp;nbsp;[/quote]
&lt;p&gt;I missed the &amp;quot;not&amp;quot; part for the nRF52840 here.&lt;br /&gt;We have two different versions of approtect on the nRF52840, and this depends on which revision you have. From&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect"&gt;Working with the nRF52 Series&amp;#39; improved APPROTECT&lt;/a&gt;&amp;nbsp;:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;br /&gt; New revisions of &lt;a href="https://infocenter.nordicsemi.com/pdf/in_153_v1.0.pdf?cp=18_4" rel="noopener noreferrer" target="_blank"&gt;nRF52805 (revision 2, build codes Bx0)&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/pdf/in_152_v1.0.pdf?cp=18_5" rel="noopener noreferrer" target="_blank"&gt;nRF52810 (revision 3, build codes Ex0)&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/pdf/in_151_v1.0.1.pdf?cp=18_6" rel="noopener noreferrer" target="_blank"&gt;nrf52811 (revision 2, build codes Bx0)&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/pdf/in_150_v1.0.pdf?cp=18_7" rel="noopener noreferrer" target="_blank"&gt;nRF52820 (revision 3, build codes Dx0)&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/pdf/in_149_v1.1.pdf?cp=18_8" rel="noopener noreferrer" target="_blank"&gt;nRF52833 (revision 2, build codes Bx0)&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/pdf/in_142_v1.1.pdf?cp=18_15" rel="noopener noreferrer" target="_blank"&gt;nRF52832 (revision 3, build codes Gx0)&lt;/a&gt;, and &lt;a href="https://infocenter.nordicsemi.com/pdf/in_141_v1.1.pdf?cp=18_16" rel="noopener noreferrer" target="_blank"&gt;nRF52840 (revision 3, build codes Fx0)&lt;/a&gt; include an improved implementation of the 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" rel="noopener noreferrer" target="_blank"&gt;access port protection mechanism&lt;/a&gt;.&lt;br /&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;From &lt;span&gt;&lt;span dir="ltr"&gt;&lt;a title="https://developer.nordicsemi.com/nrf_connect_sdk/doc/latest/nrf/security/ap_protect.html#implementation-overview" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/security/ap_protect.html#implementation-overview" rel="noopener noreferrer" target="_blank"&gt;Approtect: Implementation overview&lt;/a&gt;: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706001254894v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Here, 1 is the devices without the improved implementation, and 2 is the devices with the improved implementation.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;And nRF5340 is 2. So my guess is that you see different behaviour between the nRF52840 and nRF5340 because the nRF52 revision you have does 1 and nRF53 does 2.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Still, setting CONFIG_NRF_APPROTECT_LOCK should lock the device by default, no matter which chip you have I think. If not, the setting should let you know if it does not work.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="ernieforzano"]&lt;span&gt;&lt;/span&gt;This worked with the nRF53 but not the nRF52. Let me know if I am missing something.&amp;nbsp;[/quote]
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;I will do some testing and see if I can reproduce this.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Which revision is your nRF52? You can read that from the top of the SoC.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/465386?ContentTypeID=1</link><pubDate>Mon, 22 Jan 2024 15:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95986031-0597-4b05-b266-3329c70ea1ce</guid><dc:creator>ernieforzano</dc:creator><description>&lt;p&gt;Hi Sigurd!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I read that documentation and I believe for the CONFIG_NRF_APPROTECT_LOCK all you need to do is include this Kconfig and compile it.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Setting the&amp;nbsp;&lt;/span&gt;&lt;a class="reference external" title="(in Kconfig reference v&amp;amp;nbsp;)" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_NRF_APPROTECT_LOCK"&gt;&lt;code class="xref kconfig kconfig-option docutils literal notranslate"&gt;&lt;span class="pre"&gt;CONFIG_NRF_APPROTECT_LOCK&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;strong&gt;Kconfig option to&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;y&lt;/span&gt;&lt;/code&gt;&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;&amp;nbsp;and compiling the firmware is enough to enable the access port protection mechanism for SoCs of the nRF53 Series and those SoCs of the nRF52 Series&lt;/strong&gt; that feature the hardware and software type of AP-Protect. The access port protection configured in this way cannot be disabled without erasing the flash.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This worked with the nRF53 but not the nRF52. Let me know if I am missing something.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling AP-PROTECT not consistent</title><link>https://devzone.nordicsemi.com/thread/465252?ContentTypeID=1</link><pubDate>Mon, 22 Jan 2024 10:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36994d31-b39c-4757-b488-193ee419596a</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/security/ap_protect.html"&gt;Enabling access port protection mechanism docs&lt;/a&gt;.Then let me know if you still have questions.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>