sCheck Test CMU_FM, ISR problem

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

sCheck Test CMU_FM, ISR problem

5,015 Views
Marekp
Contributor I

Hi, I have an issue with the CMU_FM_1 and CMU_FM_2 tests.
The test has been configured in sCheck as a StartUp test.

Additionally, when the test starts, the CMU_FC test is executed as well.

  1. The CMU_FC test is enabled.

  2. An interrupt is installed for CMU_FC with Interrupt ID = 84.

  3. The interrupt for the CMU_FC test is triggered. The ISR(Mcu_Cmu_ClockFail_IRQHandler) from Clock_Ip_Irq.c is executed, which calls the callback function CMU_ClockFailureNotification.

  4. The CMU_FC test finishes successfully.

  5. The test for CMU_FM starts with Interrupt ID = 85.

  6. No interrupt occurs, and the microcontroller resets according to the configuration.

    "Software must ensure that CMU1 interrupt is serviced within POR_WDG timeout. In absence of CMU1 interrupt servicing, the POR_WDG detects this as an FIRC failure and initiates a POR recovery. -  Chapter 57 Clock Monitoring Unit – Frequency Meter (CMU_FM)"

    How should the interrupt for CMU_FM be handled?
    I cannot find the name of the ISR corresponding to CMU_FM_1 or CMU_FM_2 in the codebase.

     

0 Kudos
Reply
24 Replies

4,547 Views
RadoslavB
NXP Employee
NXP Employee

Hi Marek,

are you using EB Tresos MCU plugin?
The MCU plugin supports now only CMU_FC, so there is only this notification:

RadoslavB_0-1744803787275.png

For CMU_FM interrupt handlers you can register them via Platform plugin like this:

RadoslavB_1-1744805017735.png

This is not very well documented in RM Interrupt Map XLS either:

RadoslavB_2-1744805259888.png
CMU_0 is CMU_FC_0
CMU_1 is CMU_FM_1
CMU_2 is CMU_FM_2

So please register the CMU_FM handlers and do the interrupt redirecting to sCheck handler like for example (snippet from SAF Demo example, see the example for more details if needed):

RadoslavB_3-1744805424823.png

 

Kind Regards,
Radoslav

0 Kudos
Reply

4,508 Views
Marekp
Contributor I

Thank you for the guidance. I’m using AUTOSAR and managed to configure the interrupt successfully in DaVinci. The StartUp tests for CMU_FC and CMU_FM complete with a positive result. HOWEVER, the RunTime and ShutDown tests for CMU_FM are failing. The processor frequency is 160 MHz. When the StartUp tests are skipped and only the RunTime tests are executed, the result for CMU_FM is still a failure. This situation occurs consistently, even when CMU_FM tests are not enabled for the StartUp phase.
CPU- S32k322

Marekp_0-1744891630765.png

Marekp_1-1744892001654.png

 

0 Kudos
Reply

4,496 Views
RadoslavB
NXP Employee
NXP Employee

Hi Marek,

difference between startup and runtime/shutdown is that startup is configuring CMU on its own, but runtime/shutdown rely on CMU configuration from customer app.

From the screenshot it seems that CMU_FM is not configured?
You need to setup CMU_FM via registers according to RM + see notes in sCheck UM - chapter: CMU Tests, especially configure REF_CNT at least 3x above the minimum REF_CNT.
You can explore CMU_FM setting during startup test and configure in a same way for runtime.

 

Kind Regards,
Radoslav

0 Kudos
Reply

4,255 Views
Marekp
Contributor I

Hi Radoslav,
Your advice turned out to be very helpful regarding the CMU_FM topic. Thank you very much for your support — we managed to resolve the issue with that test.
However, enabling additional tests has brought up new problems:

  1. The Runtime test for FCCU_NCF is reporting an error —
    FCCU signature = 0x20C80000

  2. eMCEM is not initialized.

  3. I am basing my implementation on the examples provided in the DEMO.

    Here are the values from the sCheck driver configuration:

    • STM Frequency (Hz) (dynamic range) – 40000000
    • FXOSC Frequency (Hz) (dynamic range) – 24000000
    • FIRC Frequency (Hz) – 48000000
    • CMU Bus Clock Frequency (Hz) (dynamic range) – 16000000

      And clock configuration
      Marekp_0-1745825659267.png

       



0 Kudos
Reply

4,189 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

FCCU_NCF test signature 0x20C80000 represents correct test execution, so sCheck_ErrorCodeType shuld return E_OK. Where do you see a problem?

BTW this test is not possible to configure for runtime phase, only startup or shutdown is possible.

If it's executed via  sCheck_ExecuteStartupTests() you don't need to have eMcem_Init() done, but for shutdown it is required.
One condition is to not configure FCCU with HARD LOCK setting.

 

Kind Regards,
Radoslav

0 Kudos
Reply

4,187 Views
Marekp
Contributor I

Hello Radoslav
Yes of course FCCU_NCF test is exucuted on startup test.
Signature which is returned from function sCheck_ExecuteSimpleTestBatch() is equal
0x20C80000

 



Marekp_1-1746001582826.png
But function sCheck_GetTestBatchResult() return SCHECK_TEST_ERROR in IF 

Marekp_2-1746001928858.png

FCCU is of course NO LOCK

Where to look for the cause of the error?

 

0 Kudos
Reply

4,154 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

please could you try to modify file 
\SafetyBase_TS_T40D34M10I4R0\resource\CORTEXM_S32K3XX_s32k322_hdqfp172.properties
or CORTEXM_S32K3XX_s32k322_hdqfp100.properties (depends on what you have selected in Resource module)
find line with text:
sCheck.Fccu_Ncf_Test.FCCU_NCF.Signature:0x20D10000
and change to
sCheck.Fccu_Ncf_Test.FCCU_NCF.Signature:0x20D80000

Regenerate the project and rebuild project and try the NCF test again please.


Kind Regards,
Radoslav

0 Kudos
Reply

3,990 Views
Marekp
Contributor I

Hi Radoslav,

Sorry for the late reply.

Following your recommendations, I updated the signatures in the file:
"SafetyBase_TS_T40D34M10I5R0\resource\CORTEXM_S32K3XX_s32k322_hdqfp100.properties"
Marekp_1-1746428204364.png

 

Marekp_2-1746428244419.png


Unfortunately, the issue still persists. The FCCU tests return the result: SCHECK_TEST_ERROR
The result of the XOR operation in line 305 in function sCheck_GetTestBatchResult(...)


(((0x20C80000)+1UL)^0xDF280000)=0x00100000
I also checked the FCCU (scheck) tests — none of them report any errors, so the problem is most likely related to the generated signature.

0 Kudos
Reply

3,958 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

Sorry for misleading info, correct signature is 0x20C8_0000.
So, if you can change resource file again with this value, the test should pass.

if you can confirm we will create bug ticket for this.

 

Kind Regards,
Radoslav

0 Kudos
Reply

3,878 Views
Marekp
Contributor I

Hi Radoslav,
I have one more issue related to the SWT_0 test — how is this test supposed to be handled?

The problem is that if we use the callback mechanism through the SWT driver, the interrupt flag is cleared within the driver's interrupt handler, and only then is the callback invoked.
Clearing the interrupt flag causes the SWT test to fail.
Since modifying the RTD source code is forbidden, should I configure my own interrupt handler for this test — separate from the one provided by the driver?

This question is realated with Re: SAF sCheck SWT_0 and FCCU_NCF test, s32k322 - NXP Community

0 Kudos
Reply

3,854 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

yes, in this case there is a conflict with ISR coming from RTD driver which handles the HW flags needed for sCheck.

We are internally investigating this use case, but as you should not modify RTD code you might try to temporarily redirect interrupt handler for sCheck purpose right in the sCheck_InstallTestIsr() e.g.

RadoslavB_1-1746548440043.png
And then when calling sCheck_UninstallTestIsr() redirect back to original ISR.

Or if your OS doesn't allow dynamic ISR registration during runtime, alternative approach is to prepare copy of Interrupt Vector Table (with change only for sCheck ISR handler) and temporarily change VTOR.


Kind Regards,
Radoslav

 

0 Kudos
Reply

3,791 Views
Marekp
Contributor I

Hi, just to follow up on the topic —
after enabling the MPU for NULL_PTR checking, I’m still experiencing an issue with the CMU_FC and INTM test, specifically in the FOR loop within a function.
During the second increment of the IndexCmu variable, the code attempts to access the IER register, but its value is NULL_PTR.
This happens because on the S32K322 processor, the Clock_Ip_apxCmu[CLOCK_IP_CMU_INSTANCES_ARRAY_SIZE] array only contains valid entries at indexes 0, 3, 4, and 5, while indexes 1 and 2 are defined as NULL_PTR

Marekp_0-1746682523942.png

Marekp_1-1746682562615.png

Shouldn't there be an additional check to verify whether CmuIsrValue and CmuIerValue are not NULL_PTR?

0 Kudos
Reply

3,646 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

index 0 and 1 are dedicated for CMU_FM, RTD doesn't support CMU_FM config at the moment.
You need to configure CMU_FM via low level register programming.
You can take inspiration from sBoot code for CMU_FM1 in this file: sBoot_Firc.c

Kind Regards,
Radoslav

0 Kudos
Reply

3,601 Views
Marekp
Contributor I

Hi, so my question is: how should the CMU_FM test be performed? Your answer suggests that with memory protection set to NULL_PTR, the test cannot be executed. I do not have the option to change CMU settings in the RTD.
Since these are sCheck INTM tests, CMUFM_1 triggers this error.
Therefore, the two tests mentioned above will not be executed by sCheck.
These tests are necessary to fulfill the safety mechanisms.
SAF V 1.0.5 

0 Kudos
Reply

3,590 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

sCheck CMU_FM tests - RTD can't configure CMU_FM (NULL_PTR), so it will configure only CMU_FC which is done inside Mcu_Init() afterwards you should use CMU_FM registers (see RM) to configure CMU_FM1, CMU_FM2 RCCR register, sCheck test will do the rest (change RCCR to trigger the event etc.).
You need to have monitored and reference clocks enabled and also enabled the CMU_FM interrupts. More details in sCheck UM chapter "ISR to Configure within OS" and CMU test prereqs.

sCheck INTM test - it's using just CMU_FC interrupt for the purpose of the test not CMU_FM, so only enabling CMU_FC_0 interrupt should be ok, see more in INTM test prereqs. chapter.


Kind Regards,
Radoslav

0 Kudos
Reply

3,586 Views
Marekp
Contributor I

Hi, sorry – you're absolutely right, my mistake. I got confused; I meant the CMU_FC0 test – with interrupt vector 84.
I know that for the sCheck INTM/CMU_FC0, everything is prepared according to the sCheck documentation.
The interrupt is configured correctly, and the Install_ISR function has been implemented properly.

My concern is about the Clock_IP_CMU_ClockFail function itself.
When the MPU is configured to catch NULL_PTR accesses, the Clock_IP_CMU_ClockFail function, during the INTM and CMU_FC0 tests, accesses an array where positions 1 and 2 are defined as NULL_PTR – which causes an OS_memory_protection error.

Marekp_0-1747042378779.png

This happens because the for loop tries to read values from the IER fields, which are defined as NULL_PTR.

 

0 Kudos
Reply

3,573 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

ok, but this is not related to SAF product, rather on MCU driver from RTD.

To be honest I have never seen such a rule to check dereferencing to NULL_PTR, I understand this might be useful rule for better robustness of the SW code, but obviously RTD didn't consider such a request and SAF doesn't have such a prevention to avoid reading NULL_PTR as well.
Is this rule coming from OS or your SW guidelines?

If it's a showstopper for your application, please set new community thread right for this topic.

Kind Regards,
Radoslav

0 Kudos
Reply

3,950 Views
Marekp
Contributor I

Hi  
thank you very much for your help — the solution you suggested works perfectly
How is the situation regarding the SAF library update?
Is there a plan for a new SAF package to be generated by your team with these changes?

0 Kudos
Reply

3,947 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

thanks for confirmation, we have created bugticket for this.
Another SAF K3 release is planned for November 2025 unless it will be requested earlier.

Kind Regards,
Radoslav

0 Kudos
Reply

4,174 Views
RadoslavB
NXP Employee
NXP Employee

Hi,

this is strange, didn't you modify generated sCheck cfg file?
You can try to generate cfg files again - it looks like expected signature and accumulated doesn't fit, but in a same time the signature value you posted imply that all tests passed OK so it should fit.

Could you provide list of all sCheck startup test you are executing?

Kind Regards,
Radoslav

0 Kudos
Reply