Dear Sir
How to make S32K146 M4 Core user mode and supervisor mode switching?
Do you have demo code for this case? or reference application document ?
Do S32K146 MCAL must do user mode and supervisor mode switching to meets functional security?
Thank you!
Hello,
I am workinh with uC S32K144. I am developing two applications that have different access rights, one runs under supervisor mode, the other under user mode for safety reason.
The problem is, the application that runs under user mode has sometimes the need to read some registers and maube write on them, so it gets rejected and SW resets.
For now I developed a patch to switch to the supervisor mode before running the function that access crticial registers.
Is there another solution for that ? Is there a way to allow limited access for some registers whe we are on user mode ?
Hello,
If you need to switch to User mode, just set the nPRIV bit in CONTROL register
// switch to User (unprivileged) mode
__asm__("mov r0, #0x01");
__asm__("msr control, r0"); // nPRIV = 1
And to switch it back, you need to do it in SVC handler
// make a supervisor call (SVC) to transfer control to privileged software
__asm__("svc #0x00");
void SVC_Handler(void){
// switch to Supervisor (privileged) mode
__asm__("mov r0, #0x00");
__asm__("msr control, r0"); // nPRIV = 0
}
Unfortunately, I’m not familiar with MCAL.
Could you please create a service ticket?
https://community.nxp.com/docs/DOC-329745
Regards,
Daniel
Dear Daniel
Thank you for your help and this problem is solved