<?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>APPROTECT FEATURE ON FIRMWARE WITH FREERTOS.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79678/approtect-feature-on-firmware-with-freertos</link><description>Hello Everyone, 
 I am working on NRF52840 and we had enabled the APPROTECT feature in our firmware. The code for implementing this is as follows:- 
 void init_mem(void) 
 { 
 if (NRF_UICR-&amp;gt;APPROTECT == 0xFFFFFFFF) { NRF_LOG_INFO(&amp;quot;PROTECTING FIRMWARE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Sep 2021 11:08:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79678/approtect-feature-on-firmware-with-freertos" /><item><title>RE: APPROTECT FEATURE ON FIRMWARE WITH FREERTOS.</title><link>https://devzone.nordicsemi.com/thread/329798?ContentTypeID=1</link><pubDate>Thu, 16 Sep 2021 11:08:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:045f9323-123b-4ddd-b174-6d029a0779b1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is not related to FreeRTOS specifically, not even APPROTECT. You get the invalid memory access error because you write directly to flash after the SoftDevice has been enabled.&amp;nbsp;The key point here is that you need to do this before you enable the SoftDevice. I suggest you do this also before starting the FreeRTOS scheduler.&lt;/p&gt;
&lt;p&gt;Note that enabling APPROTECT only needs to happen once, as it is a persistent field in the UICR. You can either do it in production programming, by making it included in the hex file or you check to see if it is enabled, if not write it and reset. The next time, and all subsequent times it will be enabled and no more writes to flash will be needed. See for instance &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30517/enabling-access-port-protection-from-code/120943#120943"&gt;this post&lt;/a&gt;, or check the implementation of nrf_bootloader_debug_port_disable() in &amp;lt;nRF5 SDK 17&amp;gt;\components\libraries\bootloader\nrf_bootloader_info.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>