Memory Protection Unit

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Memory Protection Unit

跳至解决方案
3,724 次查看
Mennazz
Contributor II

Hello, please! I want to know more about how to configure the memory protection unit for MPC5744P
and I need to know how to use this configurator.

(1) Core MPU configurator - NXP Community

Thanks in advance 

标记 (1)
0 项奖励
回复
1 解答
3,656 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

The basic idea is following: you will configure two descriptors covering the same region. You will also enable the PID in both descriptors, so these descriptors are not considered as overlapping because also PID will be used to check if there's a hit or not. So, you can configure access rights for each process ID separately.

There's Process ID register in the core which is used to check if there's a hit or not. Your SW just writes this register as needed.

lukaszadrapa_0-1678902000580.png

Now let's say we have descriptor X and descriptor Y covering the same area.

Descriptor X is configured for PID 3 and descriptor Y for PID 4.

Default value of PID (for main task) is 0.

How to use it with tasks:

void task1(void) /* covered by descriptor(s) X */

{

// Set Process ID 3
__MTSPR(SPR_PID,3);

/*  run your code */

// Set Process ID back to 0
__MTSPR(SPR_PID,0);

}

void task2(void) /* covered by descriptor(s) Y */

{

// Set Process ID 4
__MTSPR(SPR_PID,4);

/*  run your code */

// Set Process ID back to 0
__MTSPR(SPR_PID,0);

}

I'm not really sure if this can be implemented to MBDT, please ask here:

https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/bd-p/mbdt

Regards,

Lukas

在原帖中查看解决方案

0 项奖励
回复
10 回复数
3,679 次查看
Mennazz
Contributor II

Hi @lukaszadrapa 

Do you know if it is possible to configure a specific memory location for each application?

For example, if I have 2 tasks, I want

task1: has read access to region 1

           -> has a read / write access to region2 

Task2: "has read/write access to region 1"

         -> has read access for region 2 

Thanks in advance 

 

0 项奖励
回复
3,663 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Mennazz 

yes, that's possible. There's TID (Task identifier) which is compared with current PID (Process identifier) which is a core register configured by user. See core reference manual for more details (just search for TID keyword):

https://www.nxp.com/webapp/Download?colCode=E200Z4RM&location=null

Unfortunately this is general e200z4 RM only, there's also e200z425 variant used on MPC5744P. This is not available on our web page. If needed, I can provide this one under NDA. In this case, submit a ticket here:

https://support.nxp.com/s/?language=en_US

You can configure the descriptors using this tool:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Core-MPU-configurator/ta-p/1100529

And you can do the same when using SMPU (System MPU) which sits on crossbar. Here is an example for MPC5748G. This should help to understand how it works:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-SMPU-initialization-Process-ID-...

Regards,

Lukas

 

0 项奖励
回复
3,661 次查看
Mennazz
Contributor II

Hello @lukaszadrapa 

Could you tell me more about how to set the TID for every application and the PID  with SMPU for every region, as it is not clear in the example you sent?

And could you tell me whether it can be done using your MBD toolbox ?

Thanks in advance 

0 项奖励
回复
3,657 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

The basic idea is following: you will configure two descriptors covering the same region. You will also enable the PID in both descriptors, so these descriptors are not considered as overlapping because also PID will be used to check if there's a hit or not. So, you can configure access rights for each process ID separately.

There's Process ID register in the core which is used to check if there's a hit or not. Your SW just writes this register as needed.

lukaszadrapa_0-1678902000580.png

Now let's say we have descriptor X and descriptor Y covering the same area.

Descriptor X is configured for PID 3 and descriptor Y for PID 4.

Default value of PID (for main task) is 0.

How to use it with tasks:

void task1(void) /* covered by descriptor(s) X */

{

// Set Process ID 3
__MTSPR(SPR_PID,3);

/*  run your code */

// Set Process ID back to 0
__MTSPR(SPR_PID,0);

}

void task2(void) /* covered by descriptor(s) Y */

{

// Set Process ID 4
__MTSPR(SPR_PID,4);

/*  run your code */

// Set Process ID back to 0
__MTSPR(SPR_PID,0);

}

I'm not really sure if this can be implemented to MBDT, please ask here:

https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/bd-p/mbdt

Regards,

Lukas

0 项奖励
回复
3,652 次查看
Mennazz
Contributor II

Hello @lukaszadrapa 

I nearly got it. You gave me an example of how to set a PID for each memory region, right? 
Now my question is how to give each application or task a specific ID so that it only accesses its own specific region.

Thanks in advance.

0 项奖励
回复
3,640 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

That's what I wrote last time:

lukaszadrapa_0-1678946730470.png

Those are writes to the core register PID. This value is then compared with PID defined in MPU descriptor.

Regards,

Lukas

 

0 项奖励
回复
3,633 次查看
Mennazz
Contributor II

Hello @lukaszadrapa 

Thanks for your effort 
I have one more question. I cannot find this register in the MPC5744P document, so could you tell me more about it,  explain it in details, and tell me where I can find it since when I put it into my code it encounters an error?

Thanks in advance 

Mennazz_0-1678980877524.png

 

0 项奖励
回复
3,618 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

That's core register described in the core reference manual:
https://www.nxp.com/webapp/Download?colCode=E200Z4RM&location=null

Because it's core register, it's not memory mapped and it can be accessed only via asm instructions mtspr and mfspr.
Take a look at this post how to access it in C:
https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/160022...

And notice that SPR number of PID register is 48.

Regards,
Lukas

0 项奖励
回复
3,593 次查看
Mennazz
Contributor II

Hello @lukaszadrapa 

It works thanks for your support 

0 项奖励
回复
3,690 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Mennazz 

please take a look at:

https://community.nxp.com/t5/MPC5xxx/What-is-the-difference-between-the-SMPU-and-MPU-in-MPC5744P/m-p...

There's also link to SW example for MPC5744P.

Regards,

Lukas

0 项奖励
回复