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
已解决! 转到解答。
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.
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
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
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:
Regards,
Lukas
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
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.
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
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.
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
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