<?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>MPU on nRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111498/mpu-on-nrf52832</link><description>Hi, 
 We are developing on a nRF52832 MCU and we tried to enable MPU on the whole RAM region (addr: 0x20000000, size : 0x10000) But when we create a new MPU region around the RAM with the function nrf_mpu_lib_region_create() , it triggers an Hard Fault</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 May 2024 12:49:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111498/mpu-on-nrf52832" /><item><title>RE: MPU on nRF52832</title><link>https://devzone.nordicsemi.com/thread/486028?ContentTypeID=1</link><pubDate>Mon, 27 May 2024 12:49:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b130b9dc-6f10-4a47-9d8e-bebed81708fd</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thomas, Thanks for letting us know the reason for this behavior. Very helpful :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPU on nRF52832</title><link>https://devzone.nordicsemi.com/thread/486025?ContentTypeID=1</link><pubDate>Mon, 27 May 2024 12:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:728339c8-c941-4083-9429-0fd2c9d95dcd</guid><dc:creator>Thomas Chapelle</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thanks for you reply,&lt;/p&gt;
&lt;p&gt;The problem came from the attributes we put on the creation of the region : we only put&amp;nbsp;&lt;em&gt;(1 &amp;lt;&amp;lt; MPU_RASR_XN_Pos)&amp;nbsp;&lt;/em&gt;as attribute, and it misses the others attributes to work as it should be.&lt;br /&gt;&lt;br /&gt;We succeeded to protect the whole RAM by creating 2 different regions (RAM can be accessed by 2 different ranges of addresses : 0x2000 0000 and 0x0080 0000).&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;I close this ticket (resolved)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPU on nRF52832</title><link>https://devzone.nordicsemi.com/thread/485996?ContentTypeID=1</link><pubDate>Mon, 27 May 2024 10:11:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53fe20de-a265-4e6c-b1b1-947e8cbf5a24</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;I am not sure which SDK version you are using and which tools you use to build your project.&lt;/p&gt;
&lt;p&gt;I am giving you a generic reply and few steps how to do this., it is possible to activate the Memory Protection Unit (MPU) on the whole RAM. Here are the steps to do it using the `nrf_mpu_lib_region_create()` function:&lt;/p&gt;
&lt;p&gt;1. First, you need to initialize the MPU and its driver using the `nrf_mpu_lib_init()` function. This function returns `NRF_SUCCESS` on success, otherwise, it returns an error code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t status = nrf_mpu_lib_init();&lt;/pre&gt;&lt;br /&gt; ```&lt;/p&gt;
&lt;p&gt;2. After initializing the MPU, you can create a new MPU region using the `nrf_mpu_lib_region_create()` function. This function takes four parameters: a pointer to an `nrf_mpu_lib_region_t` variable, a pointer to the base address of the region, the size of the region, and the attributes of the region.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrf_mpu_lib_region_t region;
uint32_t attributes = (0x05 &amp;lt;&amp;lt; MPU_RASR_TEX_Pos) | (1 &amp;lt;&amp;lt; MPU_RASR_B_Pos) | (0x07 &amp;lt;&amp;lt; MPU_RASR_AP_Pos) | (1 &amp;lt;&amp;lt; MPU_RASR_XN_Pos);
ret_code_t status = nrf_mpu_lib_region_create(&amp;amp;region, (void *)0x20000000, 0x10000, attributes);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3. If you want to remove the protection and release the region, you can destroy the MPU region using the `nrf_mpu_lib_region_destroy()` function.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t status = nrf_mpu_lib_region_destroy(region);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please note that the `nrf_mpu_lib_region_create()` function returns `NRF_SUCCESS` on success, otherwise, it returns an error code. If you are getting a Hard Fault error, it might be due to incorrect parameters or conflicts with other parts of your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>