SCST operation fault

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

SCST operation fault

跳至解决方案
1,843 次查看
stanley_wu
Contributor I

Hello, to meet ASIL B requirements, we used MPU partition and implemented SCST in 5 ms timer interrupt based on S32K144 MCU. But the problem is if an external interrupt was generated during SCST operation period, the system can't jump to the correct external interrupt service routine, and will always repeated in m4_scst_pass_control_to_user_interrupt routine. But if we disable MPU and run SCST in main loop (not in ISR), this failure will not happen.

As MPU is must to be used, we'd like to know why this failure happened? And is there any configuration incorrect in our system?

We are looking forward for your feedback urgently!

Thanks in advance!

0 项奖励
1 解答
1,824 次查看
naveenm
NXP Employee
NXP Employee

Hi,

Switching between both Thread Privileged/Unprivileged can be done inside the SVCall,  where SVCall is an exception that is triggered by the SVC instruction.

Inside the SVCall handler user can switch between Privileged/Unprivileged modes by writing the nPRIV bit in  the CONTROL register, see below.

More details can be found in the Cortex™-M4 Devices Generic User Guide, which can be downloaded from ARM pages.

 

naveenm_0-1614954007675.jpeg

Here is example of the assembly code.

  /* Set nPRIV bit*/

   MRS     R2,CONTROL     /*Read CONTROL */

   ORR     R2,R2,#1          /*Set nPRIV  */

   MSR     CONTROL,R2  /* Write Control */

 

   /* Clear nPRIV bit */              

    MRS     R2,CONTROL   /* Read CONTROL */

    BIC       R2,R2,#1          /* Clear nPRIV bit  */

    MSR     CONTROL,R2  /* Write CONTROL */

 

Hope this helps.

Regards,

NaveenM

在原帖中查看解决方案

0 项奖励
3 回复数
1,837 次查看
naveenm
NXP Employee
NXP Employee

Hi,

The Cortex SCST Library uses it’s own interrupt vector table for dedicated tests only (Test ID 0-15). In case of these tests are interrupted by an ISR coming from the User Application the SCST Library is able to detect this “alien” interrupt and to forward it back into the User Interrupt Vector table. In such case the SCST API returns the M4_SCST_TEST_WAS_INTERRUPTED return value. Note, that this forwarding mechanism introduces some ISR latency which is documented in the SCST UM.

Second group of tests (ID 16-18) does not replace the interrupt vector table, but it disables all interrupts for some limited time, the ISR latency is also documented in the SCST UM.

Third group of test (ID 19-43) does not replace the interrupt vector table and does not disable interrupts. Documented latency is 0 for these tests.

The problem which I could observe is you execute some tests in ISR (Handler mode)?, see below

But if we disable MPU and run SCST in main loop (not in ISR), this failure will not happen….

Note, that invocation of some tests is not allowed in the Handler mode, as it is documented in the SCST UM, please refer to Table 10 Core Test Invocation Mode.

naveenm_2-1614744343017.jpeg

 

Hope it helps.

Regards,

NaveenM

0 项奖励
1,832 次查看
stanley_wu
Contributor I

Hi NaveenM, thanks for your reply! It's really help us.  As we want to use partition for ASIL B app and QM app, and we don't use an OS, we can only run the ASIL app in ISR, and QM app runs in thread unprivileged. That's why the failure happened.

Here we have a further question: how can we runs ASIL app in thread privileged without an OS? We don't know how to shift the system between thread privileged and thread unprivileged.

0 项奖励
1,825 次查看
naveenm
NXP Employee
NXP Employee

Hi,

Switching between both Thread Privileged/Unprivileged can be done inside the SVCall,  where SVCall is an exception that is triggered by the SVC instruction.

Inside the SVCall handler user can switch between Privileged/Unprivileged modes by writing the nPRIV bit in  the CONTROL register, see below.

More details can be found in the Cortex™-M4 Devices Generic User Guide, which can be downloaded from ARM pages.

 

naveenm_0-1614954007675.jpeg

Here is example of the assembly code.

  /* Set nPRIV bit*/

   MRS     R2,CONTROL     /*Read CONTROL */

   ORR     R2,R2,#1          /*Set nPRIV  */

   MSR     CONTROL,R2  /* Write Control */

 

   /* Clear nPRIV bit */              

    MRS     R2,CONTROL   /* Read CONTROL */

    BIC       R2,R2,#1          /* Clear nPRIV bit  */

    MSR     CONTROL,R2  /* Write CONTROL */

 

Hope this helps.

Regards,

NaveenM

0 项奖励