S32K3xx RTD default MPU implementation causes problems/seems wrong

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K3xx RTD default MPU implementation causes problems/seems wrong

Jump to solution
5,114 Views
AndreasStolze
Contributor IV

Hi all,

we're having problems with MemManage faults being generated on startup. This is either a IACCVIOL or a DACCVIOL error.
This happens not in our own code, but already in RTD or NXP IPCF code.

I'm currently suspecting the MPU setup that's at fault, as when I am not defining MPU_ENABLED it works.

On further investigation, I am very puzzled about the MPU code provided by NXP in this file: "Platform_TS_T40D34M40I0R0\startup\src\system.c"
I am looking at the linker file from the Dio_Example_S32K358 of RTD 4.0.

Before we head into the file itself, I was also confused by this post:
https://community.nxp.com/t5/S32K/S32K312-W-R-FULL-access-MPU-address-leads-to-MemManage-exception/m...

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: https://developer.arm.com/documentation/ddi0489/latest/
This is quite important, as the MPU RBAR are different between those two architectures!

Here are the relevant snippets for Cortex M7:

AndreasStolze_0-1716464543626.png

AndreasStolze_1-1716464560176.png

AndreasStolze_2-1716464576025.png

AndreasStolze_3-1716464597506.png

AndreasStolze_4-1716464656660.png

 

Coming back to the start.c file:

The MPU is configured via the rbar and rasr arrays, for example region 6:

 

 

    /*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 & 8*/
    rasr[6]=((uint32)0x030B0001UL)|(((uint32)__RAM_CACHEABLE_SIZE - 1) << 1)|(1<<15)|(1<<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) << 1);
#endif

 

 

Question 1

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.

Also impacts of course currently the VALID and REGION field.

Question 2 (special case S32K344)

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?

  • 256 KB / 8 * 6 = 192 KB
  • 256 KB / 8 * 5 = 160 KB

Further remark:

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.
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.

 

 

/*
  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
*/

 

 


BR
Andreas

Edit: Exchanged link to documentation, was another document.

0 Kudos
Reply
1 Solution
5,059 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Andreas,

ARMv7E-M is Armv7-M implementation that includes the DSP extension.

In Arm Cortex-M7 Processor Technical Reference, there is reference to Armv7-M Architecture Reference Manual that I was using in that thread.

https://developer.arm.com/documentation/ddi0489/f/memory-protection-unit/mpu-functional-description?...

danielmartynek_0-1716819625550.png

You use the description from the Cortex-M7 Devices Generic User Guide r1p2

https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Optional-Memory-Protection-U...

danielmartynek_1-1716819697839.png

Which looks different.

But if the region is 32B, log2(32) = 5 = N.

For 4KB region, N = 12, and so on.

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].

 

The system.c does not use the REGION bits of the RBAR register, because VALID = 0, REGION is ignored.

It uses the RNR register.

danielmartynek_2-1716819988630.png

 

The size of region 6 is 128KB so a subregion is 16KB.

The MPU configuration is just an example.

The configuration is up to the user.

 

I haven't tested the RTD project yet on S32K358.

I will test it tomorrow and come back to you,

 

Regards,

Daniel

 

 

View solution in original post

2 Replies
5,060 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Andreas,

ARMv7E-M is Armv7-M implementation that includes the DSP extension.

In Arm Cortex-M7 Processor Technical Reference, there is reference to Armv7-M Architecture Reference Manual that I was using in that thread.

https://developer.arm.com/documentation/ddi0489/f/memory-protection-unit/mpu-functional-description?...

danielmartynek_0-1716819625550.png

You use the description from the Cortex-M7 Devices Generic User Guide r1p2

https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Optional-Memory-Protection-U...

danielmartynek_1-1716819697839.png

Which looks different.

But if the region is 32B, log2(32) = 5 = N.

For 4KB region, N = 12, and so on.

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].

 

The system.c does not use the REGION bits of the RBAR register, because VALID = 0, REGION is ignored.

It uses the RNR register.

danielmartynek_2-1716819988630.png

 

The size of region 6 is 128KB so a subregion is 16KB.

The MPU configuration is just an example.

The configuration is up to the user.

 

I haven't tested the RTD project yet on S32K358.

I will test it tomorrow and come back to you,

 

Regards,

Daniel

 

 

5,040 Views
AndreasStolze
Contributor IV

Hi Daniel,

thanks for the reply.

I'm getting it now, however, it is very implicitly done.

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.
Going further, if you increase the region size, for each doubling, the needed bits shift by two, thus the N comes into place.

So I guess you don't need to test it, the code now makes implicitly sense.

Thank you
Andreas

%3CLINGO-SUB%20id%3D%22lingo-sub-1871986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K3xx%20RTD%20default%20MPU%20implementation%20causes%20problems%2Fseems%20wrong%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1871986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3Ewe're%20having%20problems%20with%20MemManage%20faults%20being%20generated%20on%20startup.%20This%20is%20either%20a%20IACCVIOL%20or%20a%20DACCVIOL%20error.%3CBR%20%2F%3EThis%20happens%20not%20in%20our%20own%20code%2C%20but%20already%20in%20RTD%20or%20NXP%20IPCF%20code.%3C%2FP%3E%3CP%3EI'm%20currently%20suspecting%20the%20MPU%20setup%20that's%20at%20fault%2C%20as%20when%20I%20am%20not%20defining%20MPU_ENABLED%20it%20works.%3C%2FP%3E%3CP%3EOn%20further%20investigation%2C%20I%20am%20very%20puzzled%20about%20the%20MPU%20code%20provided%20by%20NXP%20in%20this%20file%3A%20%22Platform_TS_T40D34M40I0R0%5Cstartup%5Csrc%5Csystem.c%22%3CBR%20%2F%3EI%20am%20looking%20at%20the%20linker%20file%20from%20the%20Dio_Example_S32K358%20of%20RTD%204.0.%3C%2FP%3E%3CP%3EBefore%20we%20head%20into%20the%20file%20itself%2C%20I%20was%20also%20confused%20by%20this%20post%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K312-W-R-FULL-access-MPU-address-leads-to-MemManage-exception%2Fm-p%2F1773906%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K312-W-R-FULL-access-MPU-address-leads-to-MemManage-exception%2Fm-p%2F1773906%3C%2FA%3E%3C%2FP%3E%3CP%3EIt%20seems%20to%20me%20that%20for%20the%20S32K3xx%20the%20wrong%20document%20was%20shown%2C%20as%20Cortex%20M7%20is%20afaik%20ARMv7E-M%20architecture%2C%20thus%20not%20the%20Arm%20v7-M%20manual%20but%20this%20document%20must%20be%20used%3A%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fddi0489%2Flatest%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fddi0489%2Flatest%2F%3C%2FA%3E%3CBR%20%2F%3EThis%20is%20quite%20important%2C%20as%20the%20MPU%20RBAR%20are%20different%20between%20those%20two%20architectures!%3C%2FP%3E%3CP%3EHere%20are%20the%20relevant%20snippets%20for%20Cortex%20M7%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasStolze_0-1716464543626.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22AndreasStolze_0-1716464543626.png%22%20style%3D%22width%3A%20325px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280472iE5BF1E5FC296124A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasStolze_0-1716464543626.png%22%20alt%3D%22AndreasStolze_0-1716464543626.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasStolze_1-1716464560176.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22AndreasStolze_1-1716464560176.png%22%20style%3D%22width%3A%20384px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280473i34C843D7CCE94E4E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasStolze_1-1716464560176.png%22%20alt%3D%22AndreasStolze_1-1716464560176.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasStolze_2-1716464576025.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22AndreasStolze_2-1716464576025.png%22%20style%3D%22width%3A%20354px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280474i0683349C4584E914%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasStolze_2-1716464576025.png%22%20alt%3D%22AndreasStolze_2-1716464576025.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasStolze_3-1716464597506.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22AndreasStolze_3-1716464597506.png%22%20style%3D%22width%3A%20296px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280475i2ECE280DDB43A05C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasStolze_3-1716464597506.png%22%20alt%3D%22AndreasStolze_3-1716464597506.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreasStolze_4-1716464656660.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22AndreasStolze_4-1716464656660.png%22%20style%3D%22width%3A%20268px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280476iF31CDDA704431BB0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreasStolze_4-1716464656660.png%22%20alt%3D%22AndreasStolze_4-1716464656660.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3EComing%20back%20to%20the%20start.c%20file%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThe%20MPU%20is%20configured%20via%20the%20rbar%20and%20rasr%20arrays%2C%20for%20example%20region%206%3A%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%20%20%20%20%2F*Ram%20unified%20section*%2F%0A%23if%20defined(S32K396)%20%7C%7C%20defined(S32K394)%20%7C%7C%20defined(S32K344)%20%7C%7C%20defined(S32K324)%20%7C%7C%20defined(S32K314)%20%7C%7C%20defined(S32K374)%7C%7C%20defined(S32K376)%0A%20%20%20%20rbar%5B6%5D%3D(uint32)__INT_SRAM_START%3B%0A%20%20%20%20%2F*%20Size%3A%20import%20information%20from%20linker%20symbol%2C%20Type%3A%20Normal%2C%20Inner%20Cache%20Policy%3A%20Inner%20write-back%2C%20write%20and%20read%20allocate%2C%20Outer%20Cache%20Policy%3A%20Outer%20write-back%2C%20write%20and%20read%20allocate%2C%20Shareable%3A%20No%2C%20Privileged%20Access%3ARW%2C%20Unprivileged%20Access%3ARW%20*%2F%0A%20%20%20%20%2F*%20Disable%20subregion%207%20%26amp%3B%208*%2F%0A%20%20%20%20rasr%5B6%5D%3D((uint32)0x030B0001UL)%7C(((uint32)__RAM_CACHEABLE_SIZE%20-%201)%20%26lt%3B%26lt%3B%201)%7C(1%26lt%3B%26lt%3B15)%7C(1%26lt%3B%26lt%3B14)%3B%0A%23else%0A%20%20%20%20rbar%5B6%5D%3D(uint32)__INT_SRAM_START%3B%0A%20%20%20%20%2F*%20Size%3A%20import%20information%20from%20linker%20symbol%2C%20Type%3A%20Normal%2C%20Inner%20Cache%20Policy%3A%20Inner%20write-back%2C%20write%20and%20read%20allocate%2C%20Outer%20Cache%20Policy%3A%20Outer%20write-back%2C%20write%20and%20read%20allocate%2C%20Shareable%3A%20No%2C%20Privileged%20Access%3ARW%2C%20Unprivileged%20Access%3ARW%20*%2F%0A%20%20%20%20rasr%5B6%5D%3D((uint32)0x030B0001UL)%7C(((uint32)__RAM_CACHEABLE_SIZE%20-%201)%20%26lt%3B%26lt%3B%201)%3B%0A%23endif%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3EQuestion%201%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EWhy%20are%20the%20addresses%20of%20the%20linker%20are%20directly%20written%20into%20RBAR%3F%20The%20ADDR%20field%20is%20high%20withing%20the%2032-bit%20word%2C%20and%20must%20be%20shifted.%20Furthermore%2C%20the%20shift%20is%20dependent%20on%20%22N%22%2C%20which%20itself%20results%20of%20the%20%22SIZE%22%20field%20of%20RASR.%3C%2FP%3E%3CP%3EAlso%20impacts%20of%20course%20currently%20the%20VALID%20and%20REGION%20field.%3C%2FP%3E%3CP%3E%3CSTRONG%3EQuestion%202%20(special%20case%20S32K344)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3ERAM%20section%20is%20256%20KB%2C%20thus%20subregions%20are%2032%20KB%20big.%20Top%202%20regions%207%20and%206%20are%20disabled%20via%20%22SRD%22%20field.%20However%2C%20shouldn't%20region%205%20also%20be%20disabled%20to%20get%20160%20KB%20size%3F%3C%2FP%3E%3CUL%3E%3CLI%3E256%20KB%20%2F%208%20*%206%20%3D%20192%20KB%3C%2FLI%3E%3CLI%3E256%20KB%20%2F%208%20*%205%20%3D%20160%20KB%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EFurther%20remark%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThis%20table%20is%20not%20correct%2C%20at%20least%20because%20the%20code%20uses%20%22__INT_SRAM_START%22%20rather%20than%20%22__RAM_CACHEABLE_START%22%20as%20stated%20in%20the%20table.%20However%2C%20this%20is%20fine%20and%20should%20be%20even%20better%2C%20as%20this%20also%20includes%20the%20sram%20BSS%20section%20which%20should%20be%20fine%20to%20enable%20cache%20on%20as%20well.%3CBR%20%2F%3EAlso%20the%20%22ADDR%22%20must%20somewhat%20be%20aligned%20based%20on%20the%20SIZE%20field.%20In%20the%20example%20__INT_SRAM_START%20is%20set%20to%20%22ORIGIN(int_sram)%22%20(so%20kind%20of%20aligned)%2C%20but%20%22__RAM_CACHEABLE_START%22%20would%20be%20not%20aligned%20somewhere%20after%20sram%20BSS.%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%2F*%0A%20%20Region%20%20Description%20%20%20%20%20%20%20Start%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Size%5BKB%5D%20%20Type%20%20%20%20%20%20%20%20%20%20%20%20%20%20Inner%20Cache%20Policy%20%20%20%20Outer%20Cache%20Policy%20%20%20%20Shareable%20%20%20%20Executable%20%20%20%20Privileged%20Access%20%20%20%20Unprivileged%20Access%0A--------%20%20-------------%20%20%20%20%20----------%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20----------%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20----------%20%20----------------%20%20--------------------%20%20--------------------%20%20-----------%20%20------------%20%20-------------------%20%20---------------------%0A%20%20%20%20%20%20%200%20%20Whole%20memory%20map%20%200x00000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200xFFFFFFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%204194304%20%20Strongly%20Ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20No%20Access%20%20%20%20%20%20%20%20%20%20%20%20No%20Access%0A%20%20%20%20%20%20%201%20%20ITCM%20%20%20%20%20%20%20%20%20%20%20%20%20%200x00000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x0000FFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2064%20%20Strongly%20Ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20No%20Access%0A%20%20%20%20%20%20%202%20%20Program%20Flash%201%20%20%200x40000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PFLASH%20SIZE%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PFLASH%20SIZE%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read-Only%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%0A%20%20%20%20%20%20%203%20%20Data%20Flash%20%20%20%20%20%20%20%200x10000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x1003FFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20256%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%0A%20%20%20%20%20%20%204%20%20UTEST%20%20%20%20%20%20%20%20%20%20%20%20%200x1B000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x1B001FFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%208192%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%0A%20%20%20%20%20%20%205%20%20DTCM%20%20%20%20%20%20%20%20%20%20%20%20%20%200x20000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x2001FFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20128%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%20%206%20%20SRAM%20CACHE%20%20%20%20%20%20%20%20__RAM_CACHEABLE_START%20%20%20%20%20%20__RAM_CACHEABLE_END%20%20%20%20%20%20%20%20%20%20%20__RAM_CACHEABLE_SIZE%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%20%207%20%20SRAM%20N-CACHE%20%20%20%20%20%20__RAM_NO_CACHEABLE_START%20%20%20%20%20%20__RAM_NO_CACHEABLE_END%20%20__RAM_NO_CACHEABLE_SIZE%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%20%208%20%20SRAM%20SHARED%20%20%20%20%20%20%20__RAM_SHAREABLE_START%20%20%20%20%20%20__RAM_SHAREABLE_END%20%20%20%20%20%20%20%20%20%20%20__RAM_SHAREABLE_SIZE%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%20%209%20%20AIPS_0%2F1%2F2%20%20%20%20%20%20%20%200x40000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x405FFFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%206144%20%20Strongly%20ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%2010%20%20AIPS_3%20%20%20%20%20%20%20%20%20%20%20%200x40600000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x407FFFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%202048%20%20Strongly%20ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%2011%20%20QSPI%20Rx%20%20%20%20%20%20%20%20%20%20%200x67000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x670003FF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20%20Strongly%20ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%2012%20%20QSPI%20AHB%20%20%20%20%20%20%20%20%20%200x68000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x6FFFFFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20131072%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%2013%20%20PPB%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200xE0000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200xE00FFFFF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201024%20%20Strongly%20Ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A%20%20%20%20%20%2014%20%20Program%20Flash%202%20%20%200x00800000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PFLASH%20SIZE%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PFLASH%20SIZE%20%20Normal%20%20%20%20%20%20%20%20%20%20%20%20Write-Back%2FAllocate%20%20%20Write-Back%2FAllocate%20%20%20No%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20%20Read-Only%20%20%20%20%20%20%20%20%20%20%20%20Read-Only%0A%20%20%20%20%20%2015%20%20ACE%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x44000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200x440003FF%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20%20Strongly-ordered%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Yes%20%20%20%20%20%20%20%20%20%20No%20%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%20%20%20%20%20%20%20%20%20%20%20Read%2FWrite%0A*%2F%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3EBR%3CBR%20%2F%3EAndreas%3C%2FP%3E%3CP%3EEdit%3A%20Exchanged%20link%20to%20documentation%2C%20was%20another%20document.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1876061%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K3xx%20RTD%20default%20MPU%20implementation%20causes%20problems%2Fseems%20wrong%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1876061%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Daniel%2C%3C%2FP%3E%3CP%3Ethanks%20for%20the%20reply.%3C%2FP%3E%3CP%3EI'm%20getting%20it%20now%2C%20however%2C%20it%20is%20very%20implicitly%20done.%3C%2FP%3E%3CP%3EDue%20to%20the%20regions%20being%20at%20minimum%2032%20bytes%2C%20if%20you%20align%20the%20addresses%20accordingly%2C%20the%20lower%205%20bits%200%3A4%20will%20always%20be%20zero%2C%20as%202%5E5%20%3D%2032.%3CBR%20%2F%3EGoing%20further%2C%20if%20you%20increase%20the%20region%20size%2C%20for%20each%20doubling%2C%20the%20needed%20bits%20shift%20by%20two%2C%20thus%20the%20N%20comes%20into%20place.%3C%2FP%3E%3CP%3ESo%20I%20guess%20you%20don't%20need%20to%20test%20it%2C%20the%20code%20now%20makes%20implicitly%20sense.%3C%2FP%3E%3CP%3EThank%20you%3CBR%20%2F%3EAndreas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1875650%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K3xx%20RTD%20default%20MPU%20implementation%20causes%20problems%2Fseems%20wrong%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1875650%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Andreas%2C%3C%2FP%3E%0A%3CP%3EARMv7E-M%20is%20Armv7-M%20implementation%20that%20includes%20the%20DSP%20extension.%3C%2FP%3E%0A%3CP%3EIn%20Arm%20Cortex-M7%20Processor%20Technical%20Reference%2C%20there%20is%20reference%20to%20Armv7-M%20Architecture%20Reference%20Manual%20that%20I%20was%20using%20in%20that%20thread.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fddi0489%2Ff%2Fmemory-protection-unit%2Fmpu-functional-description%3Flang%3Den%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fddi0489%2Ff%2Fmemory-protection-unit%2Fmpu-functional-description%3Flang%3Den%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_0-1716819625550.png%22%20style%3D%22width%3A%20481px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_0-1716819625550.png%22%20style%3D%22width%3A%20481px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281008iB38F44E3B7D44014%2Fimage-dimensions%2F481x387%3Fv%3Dv2%22%20width%3D%22481%22%20height%3D%22387%22%20role%3D%22button%22%20title%3D%22danielmartynek_0-1716819625550.png%22%20alt%3D%22danielmartynek_0-1716819625550.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20use%20the%20description%20from%20the%20Cortex-M7%20Devices%20Generic%20User%20Guide%20r1p2%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fdui0646%2Fc%2FCortex-M7-Peripherals%2FOptional-Memory-Protection-Unit%2FMPU-Region-Base-Address-Register%3Flang%3Den%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.arm.com%2Fdocumentation%2Fdui0646%2Fc%2FCortex-M7-Peripherals%2FOptional-Memory-Protection-Unit%2FMPU-Region-Base-Address-Register%3Flang%3Den%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_1-1716819697839.png%22%20style%3D%22width%3A%20460px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_1-1716819697839.png%22%20style%3D%22width%3A%20460px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281009i1D1CBBC95CE56A9C%2Fimage-dimensions%2F460x385%3Fv%3Dv2%22%20width%3D%22460%22%20height%3D%22385%22%20role%3D%22button%22%20title%3D%22danielmartynek_1-1716819697839.png%22%20alt%3D%22danielmartynek_1-1716819697839.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhich%20looks%20different.%3C%2FP%3E%0A%3CP%3EBut%20if%20the%20region%20is%2032B%2C%20log2(32)%20%3D%205%20%3D%20N.%3C%2FP%3E%0A%3CP%3EFor%204KB%20region%2C%20N%20%3D%2012%2C%20and%20so%20on.%3C%2FP%3E%0A%3CP%3EThe%20address%20is%20written%20as%20a%2032bit%20word%20to%20the%20whole%20register%20without%20any%20bit%20shift%2C%20but%20it%20must%20be%20alligned%2C%20at%20least%205%20zeros%20at%20RBAR%5B4-0%5D.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20system.c%20does%20not%20use%20the%20REGION%20bits%20of%20the%20RBAR%20register%2C%20because%20VALID%20%3D%200%2C%20REGION%20is%20ignored.%3C%2FP%3E%0A%3CP%3EIt%20uses%20the%20RNR%20register.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_2-1716819988630.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_2-1716819988630.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281010iE12836345FBBD6FE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22danielmartynek_2-1716819988630.png%22%20alt%3D%22danielmartynek_2-1716819988630.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20size%20of%20region%206%20is%20128KB%20so%20a%20subregion%20is%2016KB.%3C%2FP%3E%0A%3CP%3EThe%20MPU%20configuration%20is%20just%20an%20example.%3C%2FP%3E%0A%3CP%3EThe%20configuration%20is%20up%20to%20the%20user.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EI%20haven't%20tested%20the%20RTD%20project%20yet%20on%20S32K358.%3C%2FP%3E%0A%3CP%3EI%20will%20test%20it%20tomorrow%20and%20come%20back%20to%20you%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E