SMPU MPC5744P PID

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

SMPU MPC5744P PID

3,172 Views
Mennazz
Contributor II

Hello, I want to ask about setting a process ID for a region while configuring the SMPU.

the SMPU_EnableProcessIdentifier () function present in the smpu_hw_access.h uses WORD4, which is undefined in any of the MPC5744P files, so my question is how to set a process ID for every region using SMPU

 

Mennazz_0-1681986343372.png

 

26 Replies

2,551 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Mennazz 

process identifier feature is not available on MPC5744P. The drivers are common for all MPC57xx devices. File xxxx_features.h then says if a feature is available or not:

lukaszadrapa_0-1682003422587.png

Or you can check reference manual for the device.

Process identifier feature is available on MPC5748G devices and their derivatives.

Regards,

Lukas

 

0 Kudos

2,549 Views
Mennazz
Contributor II

Okay so, do you know how to configure a memory region for specific task in MPC5744P?

0 Kudos

2,546 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

There's also core MPU (CMPU) which supports the process identifier.

I checked the SDK but I can't see an option how to configure it in processor expert. I found only this:

c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\platform\drivers\src\mpu_e200\

It seems that it would be necessary to configure the structures manually.

Another option is to do that without the drivers. I shared this example here:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5744P-CMPU-Initialization-GHS614/ta-p...

There's also link to excel tool "CMPU configurator" which can help to generate asm code for initialization. Or you can just use the generated values and then use function from the mentioned driver.

Process identifier is not used in the example. But it shouldn't be a problem - it's just necessary to set TID (and optionally TIDMSK) for your descriptors and then set PID core register as needed at beginning/end of your task. More information can be found in Chapter 10:

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

Regards,

Lukas

 

0 Kudos

2,479 Views
Mennazz
Contributor II


Do you mean that it is possible to configure a process ID for every region using CMPU? If yes, could you please explain how in more detail?

To my knowledge, when exploring the functions used to configure the MPU, they are nearly the same as those used to configure the SMPU and are using the same macro  FEATURE_SMPU_HAS_PROCESS_IDENTIFIER

Mennazz_1-1682607026450.png

 

 

0 Kudos

2,443 Views
Mennazz
Contributor II

@lukaszadrapa  Could you please reply ?

While I am investigating how to configure the CMPU with PID, I found that the MPC5744P_features.h file does not contain anything related to the CMPU, so does it mean that not all CMPU capabilities are available in MPC5744P as it is configured using the SMPU?

0 Kudos

2,415 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Mennazz 

my recommendation is to use mentioned configurator. This is the simplest method. All you need to do is to set TID as needed (and optionally set also mask inTIDMSK if needed).

Entry with TID 0 is considered as global and matches with all tasks. So, just configure the TID in the configurator for each entry:

lukaszadrapa_0-1683006253185.png

Regards,

Lukas

0 Kudos

2,397 Views
Mennazz
Contributor II

Hello @lukaszadrapa 

 this configurator configure only one region right? so to configure multiple regions  I shall generate code for every region separately right ?

could you please explain this register usage in more details ?

Mennazz_0-1683105436000.png

and How to integrate this generated assembly code to my c code ?

0 Kudos

2,389 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Mennazz 

attached is example (the one I shared earlier created in GHS) ported to S32DS.

You can use cmpu.s file, just update it as needed. Here's the result when running the code:

lukaszadrapa_0-1683180301071.png

It should also explain the ESEL and INST field. There are separate configurations for instruction and data because those are two separate buses:

lukaszadrapa_1-1683181183803.png

 

Notice that the CMPU needs to be enabled by writing MPUEN bit in MPU0CSR0 core register. This can be found at the end of initialization. This is not generated by the configurator.

Regards,

Lukas

 

0 Kudos

2,344 Views
Mennazz
Contributor II

I didn't get what ESEL really does. Could you please explain more?
Another question, please: is there a way to rewrite the used assembly code into c-code as we did before while setting the task ID with the mtspr register?

0 Kudos

2,333 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

There are 24 descriptors in total:

lukaszadrapa_0-1683617570102.png

ESEL is used to select  a descriptor you need.

INST says if you are going to use descriptor for instruction region or for data region.

SHD then allows you to use shared regions for both instruction and data.

In the screenshot shared earlier, there are two descriptors used in instruction region (you can use up to 6 descriptors) and three descriptors used in data region (you can use up to 12 descriptors). Shared region is not used there but you can use up to 6 descriptors. So, all the descriptors are selectable by ESEL and by INST and SHD which select between instruction/data/shared regions.

lukaszadrapa_1-1683618069440.png

 

Regards,

Lukas

0 Kudos

2,330 Views
Mennazz
Contributor II

Okay what about this question  is there a way to rewrite the used assembly code into c-code as we did before while setting the task ID with the mtspr register?

0 Kudos

2,328 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Well, you could write the MASx registers in the same way and then call asm function which would execute mpuwe and mpusync instructions. So, yes, this could work too.

0 Kudos

2,318 Views
Mennazz
Contributor II

Could you explain more with an example since the example sent contains these  assembly lines?
e_lis r3, 0xA100
e_or2i r3, 0x0F00
mtspr mas0, r3

0 Kudos

2,279 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here's an example:

//write one descriptor
mtspr(624, 0xXXXXXXXX); //write MAS0
mtspr(625, 0xXXXXXXXX); //write MAS1
mtspr(626, 0xXXXXXXXX); //write MAS2
mtspr(627, 0xXXXXXXXX); //write MAS3
CMPU_WriteDescriptor();

For CMPU_WriteDescriptor, you can re-use file cmpu.s from previous example, just create a function like this:

CMPU_WriteDescriptor:
mpuwe
mpusync
se_blrl

And then create one more function to enable the CMPU like:

CMPU_Enable:
e_lis r3, 0x0000
e_or2i r3, 0x0001
mtspr 1014, r3
se_blr


And from the example you shared above:
e_lis r3, 0xA100
e_or2i r3, 0x0F00
mtspr mas0, r3

That's value 0xA1000F00 which should be written to MAS0, so:
mtspr(624, 0xA1000F00);//write MAS0

 

Regards,

Lukas

0 Kudos

2,273 Views
Mennazz
Contributor II

Looks great ! 

but what about these lines

 mpuwe
mpusync
se_blrl

How to write them in C 

0 Kudos

2,257 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

As I wrote - you can use cmpu.s file as a template. That's file for asm code.

Or there's second option - you can write the same instructions to C code like this:

 

To write a descriptor:

asm("mpuwe");
asm("mpusync");

 

To enable CMPU:

asm("e_lis %r3, 0x0000");
asm("e_or2i %r3, 0x0001");
asm("mtspr 1014, %r3");

 

Regards,

Lukas

0 Kudos

2,153 Views
Mennazz
Contributor II

Okay It works Thank you 
But could you tell me how to detect violations if a task with a task ID accessed a memory location configured with a different task ID?

0 Kudos

2,145 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Access violation is signaled by ISI or DSI (instruction storage interrupt or data storage interrupt), so Machine Check / IVOR1 should be triggered.

Regards,

Lukas

0 Kudos

2,121 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I have to correct my answer little bit - IVOR2  is triggered in case of data access violation and IVOR3 is triggered in case of instruction access violation. Attached is original example modified to test both violations.

Regards,

Lukas

0 Kudos

2,051 Views
Mennazz
Contributor II

Can I split the RAM into multiple regions ? 

e.g. 

Region 1 from 0x4000 0000 to 0x4002 0000   with TID =2 

Region 2 from 0x4003  0000 to 0x4004 0000 with TID =3 
 and so on 

 

0 Kudos