S32K144's MPU issue

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

S32K144's MPU issue

Jump to solution
3,537 Views
MPC8313ERDB_h
Contributor III

I have an issue with the S32K144's MPU. I'm trying to protect an application depended region.
This implies that RGD0_WORDn should be modified (or disabled) because the default setting, out of reset, permits access to the entire P-flash.
However, once I try to modify any one of the RGD0_WORDn's registers (which disables RGD0 descriptor), I run to an exception. Furthermore, I duplicated RGD0 values to RGD1 (the UM says there is 'OR' relationship exists between the 8 descriptors), so that they are fully overlapped. Clearing RGD0_WORD3[valid] bit causes exception, but clearing RGD1_WORD1[valid] bit causes no exception.
My quick conclusion is that the descriptors must be sequentially enabled. If this is the case, (which I could not find in the UM) how to modify the default MPU setting?

Two notes:
1. All MPU manipulations executed after disabling CESR[valid] bit, meaning MPU is disabled.
2. After the exception I monitor the MPU registers and all ERDn registers remain cleared.

Here is the MPU setting before 'touching' RGD0 registers:

CESR: 0x00814000 @4000d000
EAR0: 0x00000000 @4000d010
EDR0: 0x00000000 @4000d014
EAR1: 0x00000000 @4000d018
EDR1: 0x00000000 @4000d01c
EAR2: 0x00000000 @4000d020
EDR2: 0x00000000 @4000d024
EAR3: 0x00000000 @4000d028
EDR3: 0x00000000 @4000d02c

RGD0_WORD0: 0x00000000 @4000d400
RGD0_WORD1: 0xFFFFFFFF @4000d404
RGD0_WORD2: 0x0061F7DF @4000d408
RGD0_WORD3: 0x00000001 @4000d40c
RGD1_WORD0: 0x00000000 @4000d410
RGD1_WORD1: 0xFFFFFFFF @4000d414
RGD1_WORD2: 0x0061F7DF @4000d418
RGD1_WORD3: 0x00000001 @4000d41c

RGD2_WORD0: 0x00000000 @4000d420
RGD2_WORD1: 0x0000001F @4000d424
RGD2_WORD2: 0x00000000 @4000d428
RGD2_WORD3: 0x00000000 @4000d42c

RGDAAC0: 0x0061F7DF @4000d800
RGDAAC1: 0x0061F7DF @4000d804
RGDAAC2: 0x00000000 @4000d808
RGDAAC3: 0x00000000 @4000d80c
RGDAAC4: 0x00000000 @4000d810
RGDAAC5: 0x00000000 @4000d814
RGDAAC6: 0x00000000 @4000d818
RGDAAC7: 0x00000000 @4000d81c

Labels (1)
1 Solution
3,352 Views
danielmartynek
NXP TechSupport
NXP TechSupport

You can use the Region Descriptor Alternate Access Control 0 (RGDAAC0) register to change the masters' (but not the debugger's) rights in the first descriptor. For example, you can use Descriptor 1 to give the core access to a part of the memory and then use the RGDAAC0 register to disable the core access in the Descriptor 0. Then, the core can access only the memory defined by Descriptor 1.

Regards,

Daniel

View solution in original post

6 Replies
3,352 Views
MPC8313ERDB_h
Contributor III

Excellent. Thank you Daniel!

David

0 Kudos
Reply
3,352 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi David,

It has been already discussed here on the community.

Could you please refer to these threads first:

MPU Region0  

MPU S32K144 can not change region descriptor (RGD) 

Thanks,

BR, Daniel

3,352 Views
MPC8313ERDB_h
Contributor III

Thank you, Daniel. Is that imply that I can't debug the MPU during my development phase?

0 Kudos
Reply
3,352 Views
danielmartynek
NXP TechSupport
NXP TechSupport

David, can you please elaborate?

0 Kudos
Reply
3,352 Views
MPC8313ERDB_h
Contributor III

I would like to change the default MPU setting to my requirements. But, since RGD0 can't be modified during the debug session, and since it allows access to the entire space, how can I debug my new setting (with S32DS)?

Thanks,

David

0 Kudos
Reply
3,353 Views
danielmartynek
NXP TechSupport
NXP TechSupport

You can use the Region Descriptor Alternate Access Control 0 (RGDAAC0) register to change the masters' (but not the debugger's) rights in the first descriptor. For example, you can use Descriptor 1 to give the core access to a part of the memory and then use the RGDAAC0 register to disable the core access in the Descriptor 0. Then, the core can access only the memory defined by Descriptor 1.

Regards,

Daniel