How to configure the MPU to protect RAM sections in S32K344

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

How to configure the MPU to protect RAM sections in S32K344

838 Views
lega_06
Contributor I

Hi.

I've been trying to configure the MPU to protect RAM sections, I mean I want to change the RAM section to Read-only, but I couldn't set it, I have these sections in MPU.

    /*Ram unified section */
    rbar[6]=0x20400000UL;
    rasr[6]=0x160B0023UL;

    /*Ram non-cache section plus */
    rbar[7]=0x20420000UL;
    rasr[7]=0x030C001FUL;

    /*Ram stack section*/
    rbar[8]=0x20424000UL;
    rasr[8]=0x130B001FUL;

    /*Ram shareable section*/
    rbar[9]=0x2043C000UL;
    rasr[9]=0x130C0029UL;

within my linker file,I have the same address like in each rbar

int_sram_c0 : ORIGIN = 0x20400000, LENGTH = 0x00020000 /* 98kB */ /*128kB*/
int_sram_no_cacheable_c0 : ORIGIN = 0x20420000, LENGTH = 0x00004000 /* 16kB */

int_sram_stack_c0 : ORIGIN = 0x20424000, LENGTH = 0x00004000 /* 64kB */ /*16kB*/
int_sram_c1 : ORIGIN = 0x20428000, LENGTH = 0x00004000 /* 16kB */
int_sram_no_cacheable_c1 : ORIGIN = 0x2042C000, LENGTH = 0x00004000 /* 16kB */
int_sram_stack_c1 : ORIGIN = 0x20430000, LENGTH = 0x00008000 /* 32kB */
int_sram_shareable : ORIGIN = 0x2043C000, LENGTH = 0x00004000 /* 16kB */
ram_rsvd2 : ORIGIN = 0x20440000, LENGTH = 0 /* End of SRAM */

I've tried to set Read-only, within RAM unified section the AP encondig according to the next table 

lega_06_0-1690397757293.png


But I can still write in that RAM area , I would expect to see a some reset in my board after writting in this area , also somehow the only RAM section that I can put in Read only is Ram shareable section within region#9 , if change from rasr[9]=0x130C0029UL to rasr[9]=0x160C0029UL.I'm not sure why this is happening.

How should I configure RAM unified as Read-only ? , is there anything else that I need to set it up? 

 

0 Kudos
Reply
5 Replies

801 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@lega_06

Senlent_0-1690435965467.png

0x130C0029UL->AP[2:0] = 011 = RW->Full accsss

0x160C0029UL->AP[2:0] = 110 = RO->Read only,by privileged or unprivileged software.

0 Kudos
Reply

794 Views
lega_06
Contributor I

Hi, @Senlent  I have set those bits for Read only in Region#6 (RAM unified section), but I can write into this section, because after setting the MPU, I try to write  4 bytes with 0xFF in 0x20400000, and I can see it from 0x20400000 until 0x20400004, although I have that region set as Read only I can still write it.

I wonder why I can still write in this section that should be protected.

0 Kudos
Reply

731 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@lega_06

Senlent_0-1690517178035.png

I tried to configure it according to your method, and the program entered hardfault.
Can you provide a complete project file, I need to reproduce the problem, which takes a lot of time.

0 Kudos
Reply

672 Views
lega_06
Contributor I

I can't put all project, but I found in Tressos that we have 0 RAM Sector in our project, I'm wondering if we need to set these 4 RAM sections within Tressos as well?

0 Kudos
Reply

655 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@lega_06

Thank you for your reply,
I don't know the EB tool you are using, and I don't know the process of configuring MPU on EB, so I can't give you a suitable suggestion,
You can create a new topic and add EB or MCAL as the keyword. We will have experts in EB and MCAL to help you answer your questions.
I'm sorry for not being able to provide a valid opinion.

0 Kudos
Reply