<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: S32K3xx RTD default MPU implementation causes problems/seems wrong in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1876061#M35869</link>
    <description>&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;thanks for the reply.&lt;/P&gt;&lt;P&gt;I'm getting it now, however, it is very implicitly done.&lt;/P&gt;&lt;P&gt;Due to the regions being at minimum 32 bytes, if you align the addresses accordingly, the lower 5 bits 0:4 will always be zero, as 2^5 = 32.&lt;BR /&gt;Going further, if you increase the region size, for each doubling, the needed bits shift by two, thus the N comes into place.&lt;/P&gt;&lt;P&gt;So I guess you don't need to test it, the code now makes implicitly sense.&lt;/P&gt;&lt;P&gt;Thank you&lt;BR /&gt;Andreas&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 07:45:36 GMT</pubDate>
    <dc:creator>AndreasStolze</dc:creator>
    <dc:date>2024-05-28T07:45:36Z</dc:date>
    <item>
      <title>S32K3xx RTD default MPU implementation causes problems/seems wrong</title>
      <link>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1871986#M35729</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;we're having problems with MemManage faults being generated on startup. This is either a IACCVIOL or a DACCVIOL error.&lt;BR /&gt;This happens not in our own code, but already in RTD or NXP IPCF code.&lt;/P&gt;&lt;P&gt;I'm currently suspecting the MPU setup that's at fault, as when I am not defining MPU_ENABLED it works.&lt;/P&gt;&lt;P&gt;On further investigation, I am very puzzled about the MPU code provided by NXP in this file: "Platform_TS_T40D34M40I0R0\startup\src\system.c"&lt;BR /&gt;I am looking at the linker file from the Dio_Example_S32K358 of RTD 4.0.&lt;/P&gt;&lt;P&gt;Before we head into the file itself, I was also confused by this post:&lt;BR /&gt;&lt;A href="https://community.nxp.com/t5/S32K/S32K312-W-R-FULL-access-MPU-address-leads-to-MemManage-exception/m-p/1773906" target="_blank" rel="noopener"&gt;https://community.nxp.com/t5/S32K/S32K312-W-R-FULL-access-MPU-address-leads-to-MemManage-exception/m-p/1773906&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It seems to me that for the S32K3xx the wrong document was shown, as Cortex M7 is afaik ARMv7E-M architecture, thus not the Arm v7-M manual but this document must be used: &lt;A href="https://developer.arm.com/documentation/ddi0489/latest/" target="_blank"&gt;https://developer.arm.com/documentation/ddi0489/latest/&lt;/A&gt;&lt;BR /&gt;This is quite important, as the MPU RBAR are different between those two architectures!&lt;/P&gt;&lt;P&gt;Here are the relevant snippets for Cortex M7:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndreasStolze_0-1716464543626.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/280472iE5BF1E5FC296124A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndreasStolze_0-1716464543626.png" alt="AndreasStolze_0-1716464543626.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndreasStolze_1-1716464560176.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/280473i34C843D7CCE94E4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndreasStolze_1-1716464560176.png" alt="AndreasStolze_1-1716464560176.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndreasStolze_2-1716464576025.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/280474i0683349C4584E914/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndreasStolze_2-1716464576025.png" alt="AndreasStolze_2-1716464576025.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndreasStolze_3-1716464597506.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/280475i2ECE280DDB43A05C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndreasStolze_3-1716464597506.png" alt="AndreasStolze_3-1716464597506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndreasStolze_4-1716464656660.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/280476iF31CDDA704431BB0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndreasStolze_4-1716464656660.png" alt="AndreasStolze_4-1716464656660.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Coming back to the start.c file:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The MPU is configured via the rbar and rasr arrays, for example region 6:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /*Ram unified section*/
#if defined(S32K396) || defined(S32K394) || defined(S32K344) || defined(S32K324) || defined(S32K314) || defined(S32K374)|| defined(S32K376)
    rbar[6]=(uint32)__INT_SRAM_START;
    /* Size: import information from linker symbol, Type: Normal, Inner Cache Policy: Inner write-back, write and read allocate, Outer Cache Policy: Outer write-back, write and read allocate, Shareable: No, Privileged Access:RW, Unprivileged Access:RW */
    /* Disable subregion 7 &amp;amp; 8*/
    rasr[6]=((uint32)0x030B0001UL)|(((uint32)__RAM_CACHEABLE_SIZE - 1) &amp;lt;&amp;lt; 1)|(1&amp;lt;&amp;lt;15)|(1&amp;lt;&amp;lt;14);
#else
    rbar[6]=(uint32)__INT_SRAM_START;
    /* Size: import information from linker symbol, Type: Normal, Inner Cache Policy: Inner write-back, write and read allocate, Outer Cache Policy: Outer write-back, write and read allocate, Shareable: No, Privileged Access:RW, Unprivileged Access:RW */
    rasr[6]=((uint32)0x030B0001UL)|(((uint32)__RAM_CACHEABLE_SIZE - 1) &amp;lt;&amp;lt; 1);
#endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 1&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Why are the addresses of the linker are directly written into RBAR? The ADDR field is high withing the 32-bit word, and must be shifted. Furthermore, the shift is dependent on "N", which itself results of the "SIZE" field of RASR.&lt;/P&gt;&lt;P&gt;Also impacts of course currently the VALID and REGION field.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 2 (special case S32K344)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;RAM section is 256 KB, thus subregions are 32 KB big. Top 2 regions 7 and 6 are disabled via "SRD" field. However, shouldn't region 5 also be disabled to get 160 KB size?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;256 KB / 8 * 6 = 192 KB&lt;/LI&gt;&lt;LI&gt;256 KB / 8 * 5 = 160 KB&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Further remark:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This table is not correct, at least because the code uses "__INT_SRAM_START" rather than "__RAM_CACHEABLE_START" as stated in the table. However, this is fine and should be even better, as this also includes the sram BSS section which should be fine to enable cache on as well.&lt;BR /&gt;Also the "ADDR" must somewhat be aligned based on the SIZE field. In the example __INT_SRAM_START is set to "ORIGIN(int_sram)" (so kind of aligned), but "__RAM_CACHEABLE_START" would be not aligned somewhere after sram BSS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
  Region  Description       Start                       End                                      Size[KB]  Type              Inner Cache Policy    Outer Cache Policy    Shareable    Executable    Privileged Access    Unprivileged Access
--------  -------------     ----------                  ----------                             ----------  ----------------  --------------------  --------------------  -----------  ------------  -------------------  ---------------------
       0  Whole memory map  0x00000000                  0xFFFFFFFF                                4194304  Strongly Ordered  None                  None                  Yes          No            No Access            No Access
       1  ITCM              0x00000000                  0x0000FFFF                                     64  Strongly Ordered  None                  None                  Yes          Yes           Read/Write           No Access
       2  Program Flash 1   0x40000000                  PFLASH SIZE                           PFLASH SIZE  Normal            Write-Back/Allocate   Write-Back/Allocate   No           Yes           Read-Only            Read-Only
       3  Data Flash        0x10000000                  0x1003FFFF                                    256  Normal            Write-Back/Allocate   Write-Back/Allocate   No           No            Read-Only            Read-Only
       4  UTEST             0x1B000000                  0x1B001FFF                                   8192  Normal            Write-Back/Allocate   Write-Back/Allocate   No           No            Read-Only            Read-Only
       5  DTCM              0x20000000                  0x2001FFFF                                    128  Normal            None                  None                  No           Yes           Read/Write           Read/Write
       6  SRAM CACHE        __RAM_CACHEABLE_START      __RAM_CACHEABLE_END           __RAM_CACHEABLE_SIZE  Normal            Write-Back/Allocate   Write-Back/Allocate   No           Yes           Read/Write           Read/Write
       7  SRAM N-CACHE      __RAM_NO_CACHEABLE_START      __RAM_NO_CACHEABLE_END  __RAM_NO_CACHEABLE_SIZE  Normal            None                  None                  Yes          No            Read/Write           Read/Write
       8  SRAM SHARED       __RAM_SHAREABLE_START      __RAM_SHAREABLE_END           __RAM_SHAREABLE_SIZE  Normal            None                  None                  Yes          No            Read/Write           Read/Write
       9  AIPS_0/1/2        0x40000000                 0x405FFFFF                                    6144  Strongly ordered  None                  None                  Yes          No            Read/Write           Read/Write
      10  AIPS_3            0x40600000                 0x407FFFFF                                    2048  Strongly ordered  None                  None                  Yes          No            Read/Write           Read/Write
      11  QSPI Rx           0x67000000                 0x670003FF                                       1  Strongly ordered  None                  None                  Yes          No            Read/Write           Read/Write
      12  QSPI AHB          0x68000000                 0x6FFFFFFF                                  131072  Normal            Write-Back/Allocate   Write-Back/Allocate   No           Yes           Read/Write           Read/Write
      13  PPB               0xE0000000                 0xE00FFFFF                                    1024  Strongly Ordered  None                  None                  Yes          No            Read/Write           Read/Write
      14  Program Flash 2   0x00800000                 PFLASH SIZE                            PFLASH SIZE  Normal            Write-Back/Allocate   Write-Back/Allocate   No           Yes           Read-Only            Read-Only
      15  ACE               0x44000000                 0x440003FF                                       1  Strongly-ordered  None                  None                  Yes          No            Read/Write           Read/Write
*/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;BR&lt;BR /&gt;Andreas&lt;/P&gt;&lt;P&gt;Edit: Exchanged link to documentation, was another document.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 13:10:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1871986#M35729</guid>
      <dc:creator>AndreasStolze</dc:creator>
      <dc:date>2024-05-27T13:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: S32K3xx RTD default MPU implementation causes problems/seems wrong</title>
      <link>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1875650#M35845</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;
&lt;P&gt;ARMv7E-M is Armv7-M implementation that includes the DSP extension.&lt;/P&gt;
&lt;P&gt;In Arm Cortex-M7 Processor Technical Reference, there is reference to Armv7-M Architecture Reference Manual that I was using in that thread.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.arm.com/documentation/ddi0489/f/memory-protection-unit/mpu-functional-description?lang=en" target="_blank"&gt;https://developer.arm.com/documentation/ddi0489/f/memory-protection-unit/mpu-functional-description?lang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielmartynek_0-1716819625550.png" style="width: 481px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/281008iB38F44E3B7D44014/image-dimensions/481x387?v=v2" width="481" height="387" role="button" title="danielmartynek_0-1716819625550.png" alt="danielmartynek_0-1716819625550.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You use the description from the Cortex-M7 Devices Generic User Guide r1p2&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Optional-Memory-Protection-Unit/MPU-Region-Base-Address-Register?lang=en" target="_blank"&gt;https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Optional-Memory-Protection-Unit/MPU-Region-Base-Address-Register?lang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielmartynek_1-1716819697839.png" style="width: 460px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/281009i1D1CBBC95CE56A9C/image-dimensions/460x385?v=v2" width="460" height="385" role="button" title="danielmartynek_1-1716819697839.png" alt="danielmartynek_1-1716819697839.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which looks different.&lt;/P&gt;
&lt;P&gt;But if the region is 32B, log2(32) = 5 = N.&lt;/P&gt;
&lt;P&gt;For 4KB region, N = 12, and so on.&lt;/P&gt;
&lt;P&gt;The address is written as a 32bit word to the whole register without any bit shift, but it must be alligned, at least 5 zeros at RBAR[4-0].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The system.c does not use the REGION bits of the RBAR register, because VALID = 0, REGION is ignored.&lt;/P&gt;
&lt;P&gt;It uses the RNR register.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielmartynek_2-1716819988630.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/281010iE12836345FBBD6FE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="danielmartynek_2-1716819988630.png" alt="danielmartynek_2-1716819988630.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The size of region 6 is 128KB so a subregion is 16KB.&lt;/P&gt;
&lt;P&gt;The MPU configuration is just an example.&lt;/P&gt;
&lt;P&gt;The configuration is up to the user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't tested the RTD project yet on S32K358.&lt;/P&gt;
&lt;P&gt;I will test it tomorrow and come back to you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 14:32:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1875650#M35845</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2024-05-27T14:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: S32K3xx RTD default MPU implementation causes problems/seems wrong</title>
      <link>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1876061#M35869</link>
      <description>&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;thanks for the reply.&lt;/P&gt;&lt;P&gt;I'm getting it now, however, it is very implicitly done.&lt;/P&gt;&lt;P&gt;Due to the regions being at minimum 32 bytes, if you align the addresses accordingly, the lower 5 bits 0:4 will always be zero, as 2^5 = 32.&lt;BR /&gt;Going further, if you increase the region size, for each doubling, the needed bits shift by two, thus the N comes into place.&lt;/P&gt;&lt;P&gt;So I guess you don't need to test it, the code now makes implicitly sense.&lt;/P&gt;&lt;P&gt;Thank you&lt;BR /&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 07:45:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K3xx-RTD-default-MPU-implementation-causes-problems-seems/m-p/1876061#M35869</guid>
      <dc:creator>AndreasStolze</dc:creator>
      <dc:date>2024-05-28T07:45:36Z</dc:date>
    </item>
  </channel>
</rss>

