<?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>Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect</link><description>Hi, We&amp;#39;ve created an application for the nRF9160 non secure image with TF-M and are looking to add in ERASEPROTECT/APPROTECT/SECUREAPPROTECT functionality. From reading the Production Programming document I can see that when enabling ERASEPROTECT, APPROTECT</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jul 2023 23:48:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect" /><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/435582?ContentTypeID=1</link><pubDate>Mon, 10 Jul 2023 23:48:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c47d4529-7b32-493e-96ec-c870cbb66382</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/435391"]Additionally, there is a bug in the docs on &lt;a href="https://infocenter.nordicsemi.com/index.jsp"&gt;ERASEPROTECT.DISABLE&lt;/a&gt;: The register is not RW, but is R1.&lt;br /&gt;So you can not read out the value to verify that the data is set. (It will always read 0).[/quote]
&lt;p&gt;Thank you for letting me know!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/435391"]Definitely! Just create a ticket and reference this one.[/quote]
&lt;p&gt;I have just created a private ticket about this. Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/435391?ContentTypeID=1</link><pubDate>Mon, 10 Jul 2023 06:43:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbbc0580-6369-4928-a28e-65d8d3ebaf9b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="blasph"]My impression was that the ERASEPROTECT.disable key had to be set on each reboot. Does the ERASEPROTECT.disable key persist across reboots, and only need to be set once then?[/quote]
&lt;p&gt;Good catch! &lt;br /&gt;You are correct, so my suggestion is not really useful.&lt;/p&gt;
&lt;p&gt;Additionally, there is a bug in the docs on &lt;a href="https://infocenter.nordicsemi.com/index.jsp"&gt;ERASEPROTECT.DISABLE&lt;/a&gt;: The register is not RW, but is R1.&lt;br /&gt;So you can not read out the value to verify that the data is set. (It will always read 0).&lt;/p&gt;
[quote user="blasph"]&lt;p&gt;- I copied over the relevant CMakeLists.txt additions from the tfm_secure_peripheral sample and merged them into my main CMakeLists.txt file&lt;/p&gt;
&lt;p&gt;- Modified the&amp;nbsp;&lt;span&gt;secure_peripheral_partition.c file to no longer use the sample peripherals and only generate and set the key (and removed the&amp;nbsp;init and while loop from the&amp;nbsp;&lt;/span&gt;tfm_spp_main, as I only need this code to run once at boot up and not again)&lt;/p&gt;
&lt;p&gt;- copied over my modified secure_peripheral_partition directory&lt;/p&gt;
&lt;p&gt;- copied over the prj.conf symbols&amp;nbsp;CONFIG_TFM_IPC=y and&amp;nbsp;CONFIG_TFM_ISOLATION_LEVEL=1 from the sample. The TFM_PROFILE_NOT_SET=y makes my project not build, but I&amp;#39;ve also removed this symbol from the sample and the sample still works&lt;/p&gt;[/quote]
&lt;p&gt;From just reading the steps, they seem reasonable to me.&lt;/p&gt;
[quote user="blasph"]When running my application, I see the key now gets set properly, but my main application fails to run. Would it be possible for me to create a private ticket to see if I could get some help with this final integration step?&amp;nbsp;[/quote]
&lt;p&gt;Definitely! Just create a ticket and reference this one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/435314?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2023 16:14:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b0526e3-d9ac-4295-b43d-281a6ce40419</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for getting back to me!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/434258"]I would generally recommend writing your key to this register before enabling eraseprotect.&lt;br /&gt;This is so that you are sure that you never lock the device before a key is set.[/quote]
&lt;p&gt;My impression was that the ERASEPROTECT.disable key had to be set on each reboot. Does the ERASEPROTECT.disable key persist across reboots, and only need to be set once then?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/434258"]We will move from multi-image builds to &lt;a href="https://nrfconnect.github.io/vscode-nrf-connect/release_notes/connect/2023.6.345.html#sysbuild-support"&gt;sysbuild&lt;/a&gt; soon, and then I think it will be easier to do something like this.&lt;br /&gt;But we are not there yet, so for now, I agree, it is less portable.[/quote]
&lt;p&gt;Thank you for letting me know about this. I encountered a few examples in the 2.4.0 examples and wasn&amp;#39;t sure what it was about.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/434258"]If you want to write to secure registers when TF-M is enabled, you options are MCUboot or how it is done in the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/tfm/tfm_secure_peripheral/README.html"&gt;TF-M secure peripheral partition sample&lt;/a&gt;, by creating a Application RoT Service. See&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/an-introduction-to-trusted-firmware-m-t-m" data-contentid="62d8dd68478d426aae3aee38c2a843c8" data-contenttypeid="f7d226abd59f475c9d224a79e3f0ec07" class="ui-contentpeek internal-link"&gt;An Introduction to Trusted Firmware-M (TF-M)&lt;/a&gt;&amp;nbsp;for more information on TF-M.[/quote]
&lt;p&gt;I am currently trying on implementing this and have been working on it for the last couple of days without success. I have been able to successfully able to use the example to create and set the Eraseprotect key for my device. However, I am having difficulty integrating it into my main application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my attempt to integrate it into my main application:&lt;/p&gt;
&lt;p&gt;- I copied over the relevant CMakeLists.txt additions from the tfm_secure_peripheral sample and merged them into my main CMakeLists.txt file&lt;/p&gt;
&lt;p&gt;- Modified the&amp;nbsp;&lt;span&gt;secure_peripheral_partition.c file to no longer use the sample peripherals and only generate and set the key (and removed the&amp;nbsp;init and while loop from the&amp;nbsp;&lt;/span&gt;tfm_spp_main, as I only need this code to run once at boot up and not again)&lt;/p&gt;
&lt;p&gt;- copied over my modified secure_peripheral_partition directory&lt;/p&gt;
&lt;p&gt;- copied over the prj.conf symbols&amp;nbsp;CONFIG_TFM_IPC=y and&amp;nbsp;CONFIG_TFM_ISOLATION_LEVEL=1 from the sample. The TFM_PROFILE_NOT_SET=y makes my project not build, but I&amp;#39;ve also removed this symbol from the sample and the sample still works&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When running my application, I see the key now gets set properly, but my main application fails to run. Would it be possible for me to create a private ticket to see if I could get some help with this final integration step?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will continue doing some further testing and will get back to you as soon as I have new information.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/434258?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 14:28:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c12819d-7dfc-4cee-96a5-2b0976c10fde</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I will continue to help in this case.&lt;/p&gt;
[quote user="blasph"]My apologies in advance if I am incorrect about this, but I want to be able to write (or trigger a write for) a key to the ERASEPROTECT.disable register from my current application.[/quote]
&lt;p&gt;Yes, that is a good idea.&lt;br /&gt;I would generally recommend writing your key to this register before enabling eraseprotect.&lt;br /&gt;This is so that you are sure that you never lock the device before a key is set.&lt;/p&gt;
[quote user="blasph"] that my application is required to be built for ns (i.e. nrf_modem_lib&amp;nbsp;requires to be run from non-secure firmware)[/quote]
&lt;p&gt;Correct&lt;/p&gt;
[quote user="blasph"]believe the nrf asset tracker v2 has a similar set of requirements, so it could be a good reference for what solution would be needed.[/quote]
&lt;p&gt;Also yes.&lt;/p&gt;
[quote user="blasph"]&lt;p&gt;From Rory&amp;#39;s answer above, the best way we know of to set this consistently is through editing the MCUboot Bootloader main.c file to include the following write:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Doing this in MCUboot is a valid option.&lt;/p&gt;
[quote user="blasph"] The downside of directly editing the MCUboot file is that this change is less portable -- if I were to have a coworker build my application, I would need to have them edit the MCUboot file in-tree. [/quote]
&lt;p&gt;We will move from multi-image builds to &lt;a href="https://nrfconnect.github.io/vscode-nrf-connect/release_notes/connect/2023.6.345.html#sysbuild-support"&gt;sysbuild&lt;/a&gt; soon, and then I think it will be easier to do something like this.&lt;br /&gt;But we are not there yet, so for now, I agree, it is less portable.&lt;/p&gt;
[quote user="blasph"]Furthermore, modifying the MCUBoot Bootloader directly with anything more complex seems risky, as I don&amp;#39;t fully understand the MCUBoot Bootloader code. I have some additional logic I want to add for generating the key, but I am not sure if it is safe to add this logic to the Bootloader.&amp;nbsp;[/quote]
&lt;p&gt;I agree very much with this. It can be risky to do this inside MCUboot if you want to generate the &lt;/p&gt;
[quote user="blasph"]- Creating a script built for the nrf9160dk_nrf9160 (not ns) to set the register, however I didn&amp;#39;t have much luck integrating this into my current application, as my current application is built for nrf9160dk_nrf9160_ns. I attempted to build a child image with the goal of the secure child image to run and set the key before the main image boots, but was unsuccessful. I can attach a zip of this attempt if helpful.[/quote]
&lt;p&gt;I do not understand completely what you are trying to do here.&lt;br /&gt;If you want to write to secure registers when TF-M is enabled, you options are MCUboot or how it is done in the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/tfm/tfm_secure_peripheral/README.html"&gt;TF-M secure peripheral partition sample&lt;/a&gt;, by creating a Application RoT Service. See&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/an-introduction-to-trusted-firmware-m-t-m"&gt;An Introduction to Trusted Firmware-M (TF-M)&lt;/a&gt;&amp;nbsp;for more information on TF-M.&lt;/p&gt;
[quote user="blasph"]- Using the TF-M secure peripheral/partition examples to have the non secure partition send a request to execute some code on the secure environment. This doesn&amp;#39;t appear to work in my case since different TF-M build profiles beyond the default don&amp;#39;t seem to build with MCUboot. The TF-M secure peripheral/partition seems to require some customization to the TF-M profile settings.[/quote]
&lt;p&gt;TF-M will build as part of your application, and does not know about MCUboot.&lt;br /&gt;Either set ERASEPROTECT.DISABLE from MCUboot or from TF-M.&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/tfm/tfm_secure_peripheral/README.html"&gt;TF-M secure peripheral partition sample&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;Just want to add some nuance. While it is risky to do stuff in MCUboot, setting ERASEPROTECT.DISABLE later is also risky, as more things can go wrong before you can revert ERASEPROTECT.&lt;br /&gt;So in the end, I do not see any &amp;quot;perfect&amp;quot; place to do this operation. So you kindof need to decide if you want a more robust MCUboot, so you know you can DFU if anything fails. Or if you want a more robust ERASEPROTECT disable, so you can reprogram if anything fails.&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><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/434256?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 14:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4edc98ab-825d-4cec-9896-68177c30a5e5</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Dinesh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I just wanted to give you a bit of a recommendation while you do your testing for now. If you can&amp;#39;t afford to brick a couple of devices while developing,&amp;nbsp;I recommend doing the ERASEPROTECT development separately from using the APPROTECT and SECUREAPPROTECT for now. This way, if you are unable to get the ERASEPROTECT.disable to work, you can always use use&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfjprog --family nRF91 --recover&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to recover the device and erase all of the firmware. When APPROTECT and SECUREAPPROTECT are enabled, I haven&amp;#39;t been able to use the recover command.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Once you&amp;#39;ve finished with developing your solution and can consistently disable ERASEPROTECT by supplying the erase protect key, you could return to also using the APPROTECT and SECUREAPPROTECT functionalities.&lt;br /&gt;&lt;br /&gt;I recommend changing your second step to&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Enable ERASEPROTECT
nrfjprog --family nRF91 --memwr 0x00FF8030 --val 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;for the meantime until your ERASEPROTECT disable solution works smoothly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/434250?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 14:07:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0f575b4-e54b-4e9a-91e9-6caf01705052</guid><dc:creator>Dinesh Kumar K</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/rory.piper"&gt;Rory&lt;/a&gt;&amp;nbsp; for the reply, Understood your comments,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;since I am not afford to brick another device&lt;/p&gt;
&lt;p&gt;just need a reconfirmation for below steps.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;1. flash this sample code.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;pre class="ui-code" data-mode="text"&gt;void main(void)
{
	const uint32_t key = 0xDEADBEEF;

	NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;

	while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);

	NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = key;

	printk(&amp;quot;ERASEPROTECT         0x%X\n&amp;quot;, NRF_UICR-&amp;gt;ERASEPROTECT);
	printk(&amp;quot;ERASEPROTECT.LOCK    0x%X\n&amp;quot;, NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK);
	printk(&amp;quot;ERASEPROTECT.DISABLE 0x%X\n&amp;quot;, NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE);
}&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;2. cmd line values to set protections and reboot the device should enable erase protect with disabling&lt;br /&gt;key value of 0xDEADBEEF&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;# Enable APPROTECT
nrfjprog --family nRF91 --memwr 0x00FF8000 --val 0
# Enable SECUREAPPROTECT
nrfjprog --family nRF91 --memwr 0x00FF802C --val 0
# Enable ERASEPROTECT
nrfjprog --family nRF91 --memwr 0x00FF8030 --val 0&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. JLink script to unlock eraseprotect.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;USB 960093400
SWDSelect
SWDWriteDP 1 0x50000000
SWDWriteDP 2 0x04000010
SWDWriteAP 3 0xDEADBEEF

sleep 10000
SWDWriteDP 2 0x04000000
SWDWriteAP 1 0x00000001
SWDReadAP 1
SWDReadAP 1
sleep 5000
SWDWriteAP 1 0x00000000
SWDReadAP 1
SWDReadAP 1
sleep 1000

exit&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433968?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2023 14:22:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b63aba53-94fd-4d13-b322-89a4a89fde40</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Simon,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My apologies in advance if I am incorrect about this, but I want to be able to write (or trigger a write for) a key to the ERASEPROTECT.disable register from my current application.&lt;/p&gt;
&lt;p&gt;To my knowledge, the major constricting requirements are that my application is required to be built for ns (i.e. nrf_modem_lib&amp;nbsp;requires to be run from non-secure firmware),&amp;nbsp;it uses TF-M, and uses MCUboot (for FOTA). I believe the nrf asset tracker v2 has a similar set of requirements, so it could be a good reference for what solution would be needed.&lt;/p&gt;
&lt;p&gt;From Rory&amp;#39;s answer above, the best way we know of to set this consistently is through editing the MCUboot Bootloader main.c file to include the following write:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
{
    NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = (uint32_t)0xDEADF00D;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I would need a consistent way to be able to set this information either before my application boots or to be triggered to be written, so it can still be recovered when all three of the erase protect, approtect, and secureapprotect functionalities are enabled. The downside of directly editing the MCUboot file is that this change is less portable -- if I were to have a coworker build my application, I would need to have them edit the MCUboot file in-tree. Additionally, the Bootloader isn&amp;#39;t upgradable in this case, so the method for generating/setting the key cannot be changed over an OTA update.&amp;nbsp;Furthermore, modifying the MCUBoot Bootloader directly with anything more complex seems risky, as I don&amp;#39;t fully understand the MCUBoot Bootloader code. I have some additional logic I want to add for generating the key, but I am not sure if it is safe to add this logic to the Bootloader.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been able to replicate the ability to write this key in a couple of other ways, each with challenges to integrate into my application:&lt;br /&gt;&lt;br /&gt;- Creating a script built for the nrf9160dk_nrf9160 (not ns) to set the register, however I didn&amp;#39;t have much luck integrating this into my current application, as my current application is built for nrf9160dk_nrf9160_ns. I attempted to build a child image with the goal of the secure child image to run and set the key before the main image boots, but was unsuccessful. I can attach a zip of this attempt if helpful.&lt;/p&gt;
&lt;p&gt;- Using the TF-M secure peripheral/partition examples to have the non secure partition send a request to execute some code on the secure environment. This doesn&amp;#39;t appear to work in my case since different TF-M build profiles beyond the default don&amp;#39;t seem to build with MCUboot. The TF-M secure peripheral/partition seems to require some customization to the TF-M profile settings.&lt;br /&gt;&lt;br /&gt;Thank you in advance for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433920?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2023 11:39:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4727716c-c999-4b96-9f62-81a72eb3fe48</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Edward&lt;/p&gt;
&lt;p&gt;Why do you need to change UICR data from the bootloader? It is recommended to leave the UICR alone, as bootloader addresses are stored there for example, so it&amp;#39;s easy to tread wrong. If you have data that needs to be changed more often, I&amp;#39;d suggest using a dedicated flash page to store this instead of UICR.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why exactly do you need to make changes to UICR during runtime?&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: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433762?ContentTypeID=1</link><pubDate>Thu, 29 Jun 2023 16:27:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95b2f9d2-49eb-467f-9b8a-afde0efdb4b5</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Simon,&lt;br /&gt;&lt;br /&gt;Similar to what Rory mentioned in editing MCUboot, is there an easy way to create a bootloader with the code to set the UICR registers in the secure domain that occurs before or after the MCUboot bootloader?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Alternatively, is there a way have a complied hex of a script of your linked ticket included to be run with a non secure application with a&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/config_and_build/multi_image.html"&gt;multi-image build&lt;/a&gt;? I&amp;#39;ve tried to follow the multi-image build instructions and some examples from the nrf sdk, but unfortunately I haven&amp;#39;t had much luck in getting it to work. I can share a zip of what I am working on, if helpful.&lt;br /&gt;&lt;br /&gt;Another way I can think of this is to ask how one could add the ERASEPROTECT.disable key write into the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/asset_tracker_v2/doc/asset_tracker_v2_description.html"&gt;nRF Asset Tracker V2&lt;/a&gt;&amp;nbsp;application? Would the best way still be to edit MCUboot directly?&lt;/p&gt;
&lt;p&gt;Edit to add:&lt;br /&gt;Is there possibly a good way in TFM to create a function that can execute in the secure environment that is invoked from the non-secure side? E.g. The non secure side calls function in secure side to write a value into the UICR ERASEPROTECT.disable?&lt;/p&gt;
&lt;p&gt;Thank you for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433555?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 21:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67b06a5a-20b3-45b9-a376-5bdabc9d8e81</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Rory,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Apologies for the day delay in response, I&amp;#39;ve been pulled to a different project for the last bit and am just able to get back into this project.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve setup my device to use the MCUboot edit and am able to successfully replicate having the MCUboot file set a key and using the JLink Commander script to remove the ERASEPROTECT! Thank you for your help! I will continue with testing the JLink Commander script to flash the hex file and set the protections.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The only thing I&amp;#39;d hope for on, which may be a bit out of scope, is if there&amp;#39;s a better way to locate the code that sets the script to be closer to the application directory. This way my coworkers can replicate this without making a more-so in-tree change. I&amp;#39;ve been able to create a script based off of &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93169/how-to-remove-the-nrf9160-s-erase-protection"&gt;this response&lt;/a&gt;&amp;nbsp;to set the key when built for the nrf9160dk_nrf9160 (not ns) -- I&amp;#39;m curious if there&amp;#39;s a way to merge a compiled hex file built for the&amp;nbsp;&lt;span&gt;nrf9160dk_nrf9160 into a&amp;nbsp;separate&amp;nbsp;nrf9160dk_nrf9160_ns application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thank you again for the help, Rory!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433170?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 10:07:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c0eeb40-edc3-40b7-bbeb-27171281809d</guid><dc:creator>Rory</dc:creator><description>&lt;p&gt;The problem is likely with the code setting both&amp;nbsp;ERASEPROTECT.LOCK and&amp;nbsp;ERASEPROTECT.DISABLE. These can&amp;#39;t both be set. If you read the documentation on &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/chapters/dif/ctrl-ap.html?cp=2_0_0_8_7#register.ERASEPROTECT.LOCK"&gt;ERASEPROTECT.LOCK&lt;/a&gt;&lt;span&gt;, you will see that it prevents&amp;nbsp;ERASEPROTECT.DISABLE from being set until next boot. You cannot set them both in sequence like this. Notice how in the output&amp;nbsp;ERASEPROTECT.DISABLE never actually get set to 0xDEADBEEF, it just stays at 0x0 because it was previously locked.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
                NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001;
        }

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
            NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = key;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I stated in my original post that&amp;nbsp;&lt;span&gt;ERASEPROTECT.LOCK could optionally be set if&amp;nbsp;ERASEPROTECT.DISABLE is&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;not to be set on bootup.&lt;/span&gt;&lt;/p&gt;
[quote userid="82875" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/431351"]If serial recovery is not activated at boot, you can optionally prevent &lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; from being written to until next reboot by setting &lt;code&gt;NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001&lt;/code&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try just removing these lines and it should properly set ERASEPROTECT.DISABLE&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
                NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, the nRF9160 you flashed with your previous code cannot be recovered now, you&amp;#39;ll need to get a new board. Also, the command &lt;code&gt;nrfjprog --recover&lt;/code&gt; can&amp;#39;t be used to disable ERASEPROTECT since there is no way to supply it the key. Your script looks to be correct, and that is the only way to properly disable ERASEPROTECT and perform and ERASEALL.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/433165?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 09:50:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a5fe1e3-0685-4b26-ae25-35ae7576c050</guid><dc:creator>Dinesh Kumar K</dc:creator><description>&lt;p&gt;Hi everyone,&lt;br /&gt;&lt;br /&gt;I read through this Q&amp;amp;A and&amp;nbsp;also this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93169/how-to-remove-the-nrf9160-s-erase-protection"&gt;one&lt;/a&gt; and copied the same question from there, I wanted to test the working of ERASEPROTECT and disable it using the Jlink script&amp;nbsp;shared in the discussions, but I am&amp;nbsp;neither able to disable erase protection using the script nor&amp;nbsp;&lt;strong&gt;nrfjprog --recover&lt;/strong&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr.h&amp;gt;

void main(void)
{
        const uint32_t key = 0xDEADBEEF;

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        NRF_UICR-&amp;gt;APPROTECT = 0x00000000;

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        NRF_UICR-&amp;gt;ERASEPROTECT = 0x00000000;

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        NRF_UICR-&amp;gt;SECUREAPPROTECT = 0x00000000;

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
                NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001;
        }

        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy);
        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
            NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = key;
        }

        printk(&amp;quot;Before Write Key.\n&amp;quot;);
        printk(&amp;quot;ERASEPROTECT     Addr    0x%p\n&amp;quot;, &amp;amp;NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK);
        printk(&amp;quot;ERASEPROTECT          0x%X\n&amp;quot;,  NRF_UICR-&amp;gt;ERASEPROTECT);
        printk(&amp;quot;ERASEPROTECT.LOCK    0x%X\n&amp;quot;,   NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK);
        printk(&amp;quot;ERASEPROTECT.DISABLE 0x%X\n&amp;quot;,   NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE);
        uint32_t count = 0;

        k_msleep(1000);

        while (count &amp;lt; 10)
        {
                k_msleep(1000);
                printk(&amp;quot;Count:: %u\r\n&amp;quot;, count++);
        }

}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;output:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build zephyr-v2.3.0-22164-gb121d671c44c  ***                                                                     
Before Write Key.                                                                                                                      
ERASEPROTECT     Addr    0x0x50006500                                                                                                  
ERASEPROTECT          0x0                                                                                                              
ERASEPROTECT.LOCK    0x1                                                                                                               
ERASEPROTECT.DISABLE 0x0                                                                                                               
Count:: 0                                                                                                                              
Count:: 1                                                                                                                              
Count:: 2                                                                                                                              
Count:: 3                                                                                                                              
Count:: 4                                                                                                                              
Count:: 5                                                                                                                              
Count:: 6                                                                                                                              
Count:: 7                                                                                                                              
Count:: 8                                                                                                                              
Count:: 9&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;jlink script:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;USB 960093400
SWDSelect
SWDWriteDP 1 0x50000000  
SWDWriteDP 2 0x04000010
SWDWriteAP 3 0xDEADBEEF

sleep 10000
SWDWriteDP 1 0x50000000
SWDWriteDP 2 0x04000000
SWDWriteAP 0 0x00000001
SWDReadAP 0
SWDReadAP 0
sleep 5000
SWDWriteAP 0 0x00000000
SWDReadAP 0
SWDReadAP 0
sleep 1000

exit&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Help needed.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Dinesh Kumar K&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431432?ContentTypeID=1</link><pubDate>Fri, 16 Jun 2023 08:52:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be26b91a-184f-451d-a130-1568ef28df5b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;We have a GitHub script that should work for disabling eraseprotect that &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93169/how-to-remove-the-nrf9160-s-erase-protection"&gt;Sigurd links to in this ticket&lt;/a&gt;. Here he also links to the device protection Application note that can be usefult for additional information. Other than that we don&amp;#39;t have a specific sample that does this I&amp;#39;m afraid.&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: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431394?ContentTypeID=1</link><pubDate>Fri, 16 Jun 2023 03:04:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0eda3f4e-c709-4fdd-b4d0-6ac71f66ac15</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Rory,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much for replying and for the in depth write up!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for clarifying that those KCONFIGs don&amp;#39;t work for the nRF9160.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The information you provided about setting the protections via the JLink Commander scripts and modifying the mcuboot main.c is extremely helpful, thank you for sharing that! I&amp;#39;ll try implementing this over the next couple of days and will circle back with my findings.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431351?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 15:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc787fb8-6498-42bc-8ec9-4fe57e6a08db</guid><dc:creator>Rory</dc:creator><description>&lt;p&gt;Hi blasph,&lt;/p&gt;
&lt;p&gt;We&amp;nbsp;were&amp;nbsp;in a similar situation, and figured out how to enable/disable all three protections: APPROTECT, SECUREAPPROTECT, and ERASEPROTECT.&lt;/p&gt;
&lt;p&gt;First off, we found that CONFIG_NRF_APPROTECT_LOCK and&amp;nbsp;CONFIG_NRF_SECURE_APPROTECT_LOCK are only supported on the nRF52 and nRF53 series SoCs, and cannot be used with the nRF91 series. See documentation &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/ap_protect/index.html#configuration-overview-in-the-ncs"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Setting these protections on the nRF9160 seems to only be possible by writing to the UICR with a JLink during production.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h2vop5560"&gt;Mechanism to set ERASEPROTECT.DISABLE in MCUBoot&lt;/h3&gt;
&lt;p&gt;This is very important to implement first, as it is needed if you ever want to disable ERASEPROTECT. Without this mechanism, you will never be able to erase the chip again once&amp;nbsp;&lt;span&gt;ERASEPROTECT&amp;nbsp;is enabled, and it could become a brick.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We decided to trigger setting &lt;code&gt;NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE&lt;/code&gt; to our special 32-bit unlock key in MCUBoot only when serial recovery is forced via GPIO button press. Just before boot_serial_enter() is called in MCUBoot, we check if &lt;code&gt;NRF_UICR_S-&amp;gt;ERASEPROTECT&lt;/code&gt; is enabled, and if it is, set &lt;code&gt;NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = (uint32_t)0xDEADF00D.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;bootloader/mcuboot/boot/zephyr/main.c&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef CONFIG_BOOT_SERIAL_ENTRANCE_GPIO
    if (detect_pin() &amp;amp;&amp;amp;
            !boot_skip_serial_recovery()) {

        if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
        {
            // Disable ERASEPROTECT in serial recovery
            NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.DISABLE = (uint32_t)0xDEADF00D;
        }
        boot_serial_enter();
    }
#endif&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If serial recovery is not activated at boot, you can optionally prevent &lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; from being written to until next reboot by setting &lt;code&gt;NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ...
    if (NRF_UICR_S-&amp;gt;ERASEPROTECT != UICR_ERASEPROTECT_PALL_Unprotected)
    {
        // Lock ERASEPROTECT before booting image
        NRF_CTRL_AP_PERI_S-&amp;gt;ERASEPROTECT.LOCK = (uint32_t)0x00000001;
    }
    FIH_CALL(boot_go, fih_rc, &amp;amp;rsp);
    ...&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h2vp4cm61"&gt;Enabling APPROTECT, SECUREAPPROTECT, and ERASEPROTECT in Production&lt;/h3&gt;
&lt;p&gt;We learned that you can use a sequence of nrfjprog commands, or a JLink Commander script to program our factory_image.hex file, and then write to the UICR to set all three protections, followed by a pin reset.&lt;/p&gt;
&lt;p&gt;nrfjprog commands:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfjprog.exe --family NRF91 --program factory_image.hex --chiperase --verify factory_image.hex
nrfjprog.exe --family NRF91 --memwr 0x00FF8000 --val 0
nrfjprog.exe --family NRF91 --memwr 0x00FF802C --val 0
nrfjprog.exe --family NRF91 --memwr 0x00FF8030 --val 0
nrfjprog.exe --family NRF91 --pinreset&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;JLink Commander script:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;device NRF9160_XXAA
selectinterface SWD
speed 4000
connect
halt
erase
loadfile factory_image.hex
write4 0x00FF8000 0
write4 0x00FF802C 0
write4 0x00FF8030 0
RSetType 2
reset
exit&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;At this point, the nRF9160 should have all three protections set. The JLink debugger will no longer work at all if you try to even connect and detect the Chip ID. The nRF9160 is completely protected from any and all access over the SWD interface, including flash read, write, and erase, and is considered &amp;quot;sealed&amp;quot;. The only access that can be done over CTRL-AP is to set&amp;nbsp;&lt;span&gt;&lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; to hopefully disable&amp;nbsp;ERASEPROTECT and allow an ERASEALL.&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h2vpqp1d4"&gt;&lt;br /&gt;Disabling ERASEPROTECT and Performing ERASEALL&lt;/h3&gt;
&lt;p&gt;If you do need to erase a device that has been sealed, you must first boot the nRF9160 and trigger the mechanism to set&amp;nbsp;&lt;span&gt;&lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; to the known 32-bit key value.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For&amp;nbsp;this example, serial recovery must be forced via button press so that &lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; is set to our key&lt;code&gt; 0xDEADF00D&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then, the following JLink Commander script can be used to set the Ctrl-AP &lt;code&gt;ERASEPROTECT.DISABLE&lt;/code&gt; to the matching key, and then trigger an ERASEALL and RESET.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;JLink Commander script:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Setup SWD
SWDSelect               // Activate SWD
SWDWriteDP 1 0x50000000 // Enable debug power

// Set ERASEPROTECT.DISABLE
SWDWriteDP 2 0x04000010 // Select the 0x04XXXXXX Access Port and 0xXXXXX01X Register bank in the access port
SWDWriteAP 3 0xDEADF00D // CTRL-AP Bank 1, register offset 3 (ERASEPROTECT.DISABLE 0x01C)

// Perform ERASEALL
SWDWriteDP 2 0x04000000 // Select the 0x04XXXXXX Access Port and 0xXXXXX00X Register bank in the access port
SWDWriteAP 1 0x00000001 // CTRL-AP Bank 0, register offset 1 (ERASEALL 0x004)
SWDReadAP 2             // CTRL-AP Bank 0, register offset 2 (ERASEALLSTATUS 0x008)
SWDReadAP 2             // Second read returns the value: 0 = Ready, 1 = Busy
sleep 2000
SWDReadAP 2             // CTRL-AP Bank 0, register offset 2 (ERASEALLSTATUS 0x008)
SWDReadAP 2             // Second read returns the value: 0 = Ready, 1 = Busy

// Perform RESET
SWDWriteAP 0 0x00000001 // CTRL-AP Bank 0, register offset 0 (RESET 0x000)
SWDWriteAP 0 0x00000000 // CTRL-AP Bank 0, register offset 0 (RESET 0x000)
SWDReadAP 0             // CTRL-AP Bank 0, register offset 0 (RESET 0x000)
SWDReadAP 0             // Second read returns the value: 0 = NoReset, 1 = Reset
exit&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope this helps!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431296?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 13:51:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8021151-0e04-44d0-ad42-bddfb791de07</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for sharing this case. I was wondering, does Nordic publish some sort of guide/sample of how to add the write the ERASEPROTECT.DISABLE key to an existing application? If so, that would be very helpful.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431203?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 10:04:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1abc2381-2185-41b5-b169-99b4b7e878e3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Edward&lt;/p&gt;
&lt;p&gt;Raoul is currently out of office so I&amp;#39;ve been asked to take over this case in his absence.&lt;/p&gt;
&lt;p&gt;Please check ou&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/91586/how-to-disable-eraseprotect-for-nrf9160"&gt;t this case&lt;/a&gt; by Hung, and the one he links to, where there is a thorough discussion on how to use the ERASEPROTECT.DISABLE register. Let me know if something there is unclear, but I think most aspects are covered.&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: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431099?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2023 18:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:952c94f2-af5c-4096-9592-b5d910e01df4</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Hi Raoul,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for getting back to me and sharing that information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Thank you for clarifying the process for the ns and non-ns builds. In this case, if we needed to add a bit of additional code to the our application to write the 32-bit key into the ERASEPROTECT.DISABLE register, what would you recommend as the best way to go about that? Is there an easy way to add this to be executed by the secure partition while keeping TF-M?&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;In our case with the nRF9160, the APPROTECT and SECUREAPPROTECT are important to prevent someone else from reading back our firmware. Thank you for sharing the information about the KCONFIGs, that should come in handy in our case.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Our application uses the nRF9160&amp;#39;s CMNG to store certificates. &amp;nbsp;Since ERASEALL does not remove certificates stored in CMNG, our concern is to prevent the possibility of an attack that someone else may be able to load their own program onto our device and use the certificates for their own purposes. Although they shouldn&amp;#39;t be able to read out the certificate contents, they could possibly use the certificates in a similar manner as we use it in our application.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="117489" url="~/f/nordic-q-a/100614/request-for-guidance-and-documentation-on-eraseprotect-approtect-secureapprotect/431087"]Note that if you enable both ERASEPROTECT and APPROTECT and you haven&amp;#39;t added a robust way to unlock the device from the inside, you will have bricked the device.[/quote]
&lt;p&gt;I&amp;#39;m hoping to get a bit of guidance on how to properly add a robust way to unlock the device. Any help would be greatly appreciated, thank you!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3. Thank you for confirming that ERASEPROTECT does not affect FOTA.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you again for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/431087?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2023 16:49:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f42a74c1-02b8-455f-9578-232b7c8776ff</guid><dc:creator>Raoul</dc:creator><description>&lt;p&gt;Hi Edward,&lt;/p&gt;
&lt;p&gt;1. This might be based on a misunderstanding:&lt;/p&gt;
&lt;p&gt;When building an application for the &amp;quot;_ns&amp;quot; target, you tell NCS that you are building a non-secure application (read: one that shouldn&amp;#39;t be trusted), and then NCS will automatically include TF-M and a secure partition which exposes various &amp;quot;secure&amp;quot; functions and services such as cryptography functions.&lt;/p&gt;
&lt;p&gt;Please see this article by my colleague: &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/an-introduction-to-trusted-firmware-m-t-m"&gt; An Introduction to Trusted Firmware-M (TF-M)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So, it&amp;#39;s automatically included, but note that this secure partition is &lt;em&gt;not&lt;/em&gt; a child image, and in fact isn&amp;#39;t even built on Zephyr.&lt;/p&gt;
&lt;p&gt;If the provided secure services don&amp;#39;t cover your needs, you can create custom Root-of-Trust services that you can access from your non-secure code.&lt;/p&gt;
&lt;p&gt;2. regarding this point, I should again clarify some things:&lt;/p&gt;
&lt;p&gt;APPROTECT and ERASEPROTECT have very different use cases.&lt;/p&gt;
&lt;p&gt;APPROTECT, enables protection of the debug access port, which mainly serves to prevent people with a debugger from extracting the firmware from one of your devices. If this were disabled, someone could for instance copy your product by first copying the physical hardware and then just flashing firmware that they extracted from an original device.&lt;/p&gt;
&lt;p&gt;APPROTECT protects intellectual property.&lt;/p&gt;
&lt;p&gt;APPROTECT can usually be disabled by doing a &amp;quot;recover&amp;quot;, which in essence is an erase-all of the flash. This will unlock the access port, but there will be no firmware left to extract.&lt;/p&gt;
&lt;p&gt;ERASEPROTECT on the other hand, protects against someone with a debugger, doing exactly that, erasing the device. As far as I know, this is only useful if you&amp;#39;re selling some special device where it is absolutely critical that nobody is able to flash their own firmware to the device.&lt;/p&gt;
&lt;p&gt;ERASEPROTECT is rarely needed, and is not &amp;quot;supported&amp;quot; in NCS, it has to be done by setting the registers directly. Are you sure you need this?&lt;/p&gt;
&lt;p&gt;Note that if you enable both ERASEPROTECT and APPROTECT and you haven&amp;#39;t added a robust way to unlock the device from the inside, you will have bricked the device.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;APPROTECT is commonly used and can be set through NCS, by setting one or both of the following Kconfig options (you usually only do this for the release build that will be flashed to production devices):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_NRF_APPROTECT_LOCK"&gt;CONFIG_NRF_APPROTECT_LOCK&lt;/a&gt; - locks the Debug Access Port entirely&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_NRF_SECURE_APPROTECT_LOCK"&gt;CONFIG_NRF_SECURE_APPROTECT_LOCK&lt;/a&gt; - Locks the ability to debug code and peripherals under the &amp;quot;secure&amp;quot; environment.&lt;/p&gt;
&lt;p&gt;See here for a more in-depth description: &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/ap_protect/index.html#configuration-overview-in-the-ncs"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/ap_protect/index.html#configuration-overview-in-the-ncs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I think it&amp;#39;s likely that your needs are entirely covered by the default APPROTECT options.&lt;/p&gt;
&lt;p&gt;3. if you do use ERASEPROTECT; then this won&amp;#39;t affect your DFU/FOTA ability. ERASEPROTECT only protects against an &amp;quot;eraseall&amp;quot; operation, which isn&amp;#39;t used for FOTA.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding your supplemental question, I&amp;#39;m actually not sure. I&amp;#39;ll see if a colleague can answer that for you. I&amp;#39;ll be out-of-office for the next 14 days.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Raoul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/430576?ContentTypeID=1</link><pubDate>Mon, 12 Jun 2023 17:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:213839ca-5a32-4ab6-926a-073975b5ec44</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;Thank you Raoul, I&amp;#39;m looking forward to hearing back from you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/430327?ContentTypeID=1</link><pubDate>Sun, 11 Jun 2023 23:05:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f722dd3-c51e-4305-9f52-1bc1f7f8484c</guid><dc:creator>Raoul</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve received your questions and I&amp;#39;ll be looking into them this week, but it might take me some time to research some of it and write up an answer. I&amp;#39;ll get back to you soon!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Raoul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Request for Guidance and Documentation on ERASEPROTECT/APPROTECT/SECUREAPPROTECT</title><link>https://devzone.nordicsemi.com/thread/430068?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 18:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c07ba661-1e76-40cd-a240-a655592486ed</guid><dc:creator>blasph</dc:creator><description>&lt;p&gt;As a supplemental question, is there any protection against a brute force attack on trying all possible key combinations in the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf9160%2Fchapters%2Fdif%2Fctrl-ap.html"&gt;ERASEPROTECT.DISABLE&lt;/a&gt; register from the SWD? For example, is a rate limit for how fast keys can be tried?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>