Invokation of OsIf_GetCounter in Autosar program causes E_OS_CALLEVEL Hi Team, We are using the NXP S32K588 in an AUTOSAR-based program, with ETAS OS and EB MCAL. Several MCAL components provide a timeout mechanism where the timeout method can be configured as either: OSIF_COUNTER_SYSTEM OSIF_COUNTER_DUMMY When the timeout method is configured as OSIF_COUNTER_SYSTEM, the affected drivers attempt to access OSIF counters through OsIf_GetCounter() during their initialization sequence. Since these driver initialization functions are called from EcuM_Init(), the AUTOSAR OS reports an error via: ErrorHook => E_OS_CALLEVEL Our understanding is that this occurs because AUTOSAR OS counter APIs are only permitted to be accessed from valid OS contexts such as Tasks or ISRs, whereas EcuM_Init() executes before the OS scheduler is started. Could you please advise on the recommended approach to handle this situation? Specifically: Is there a recommended configuration for MCAL timeout handling during pre-OS initialization? Should OSIF_COUNTER_DUMMY be used for drivers initialized from EcuM_Init()? Are there any ETAS OS, EB MCAL, or NXP-specific guidelines/workarounds to enable timeout functionality safely during the pre-OS phase? Re: Invokation of OsIf_GetCounter in Autosar program causes E_OS_CALLEVEL Hi,
thanks, let me ask SW/RTD team if they can provide any additional feedback.
BR, Petr Re: Invokation of OsIf_GetCounter in Autosar program causes E_OS_CALLEVEL Hi,
Your analysis seems correct. If a driver configured with OSIF_COUNTER_SYSTEM is initialized from EcuM_Init() before the OS is started, calls to OsIf_GetCounter() may result in E_OS_CALLEVEL, depending on the AUTOSAR OS implementation.
For modules initialized during the pre-OS phase, a common workaround is to avoid using OS-based timing services and use OSIF_COUNTER_DUMMY (or another non-OS timing source) instead.
The exact recommendation may also depend on the ETAS OS implementation and the MCAL/RTD version being used. Could you please share the S32DS and RTD (or MCAL) versions for further verification?
BR, Petr
Re: Invokation of OsIf_GetCounter in Autosar program causes E_OS_CALLEVEL Hi,
see below feedback from RTD team... BR, Petr
This timeout configuration (OSIF_COUNTER_SYSTEM / OSIF_COUNTER_DUMMY) is NXP vendor-specific and is not defined by the AUTOSAR standard itself.
The root cause of the E_OS_CALLEVEL error is that OSIF_COUNTER_SYSTEM internally calls OS counter APIs, which are only valid after StartOS() has been called. Since EcuM_Init() executes before StartOS(), calling OS APIs at this stage violates the AUTOSAR OS calling level rules.
Recommended solution:
For all MCAL drivers initialized from EcuM_Init() (pre-OS phase), please configure the timeout method as:
OsIf Counter Type: OSIF_COUNTER_DUMMY
TimeoutValue: use the default value as defined in the EB MCAL configuration
OSIF_COUNTER_DUMMY does not invoke any OS API and is safe to use in pre-OS context
View full article