AUTOSAR: How-To Trace and Profile Category 1 ISRs

21-Feb-2024

The winIDEA Analyzer supports tracing of ISRs via the AUTOSAR ARTI and ORTI, or via the OS trace hooks provided by the OS vendor. However, in some cases, users might want to trace so-called category 1 ISRs, i.e., ISRs that are not managed by the OS, and therefore usually don't have hooks readily available. In such scenarios, users can manually instrument their ISR, and let winIDEA know about the instrumentation via the Profiler XML file.

This process is currently fully manual and assumes basic knowledge about profiling in winIDEA and an existing Profiler XML file.


Solution

1. Add a global category 1 ISR trace variable, for example, cat1IsrTracing to your application.

2. Instrument category 1 ISRs by adding write access at the beginning and end of the ISR. Write a unique ID for each ISR at the beginning, and `0` for `NO_ISR1` at the end of the ISR function body.

C
// Global Cat1 ISR trace variable
volatile uint32_t cat1IsrTracing = 0;
ISR1(Cat1IsrA)
{
 cat1IsrTracing = 1;
 // ISR1 code
 cat1IsrTracing = 0;
}


3. Add a category 1 ISR Profiler object to the Profiler XML. Duplicate the object for additional cores and change the index and core ID accordingly.

xml <!-- Goes into the <Profiler> section of the XML --> <Object> <Name>RUNNINGISR1[0]</Name> <Definition>RUNNINGISR1[0]</Definition> <Description>Core 0: ISRs1</Description> <Type>TypeEnum_cat1IsrMapping</Type> <DefaultValue>NO_ISR1</DefaultValue> <Expression>cat1IsrTracing</Expression> <Level>IRQ3</Level> <Core>0</Core> <TaskState> <BTFMappingType>TypeEnum_BTF_ISR_Mapping</BTFMappingType> <!-- NOTE: Change the BTF_ISR_Mapping value to point to the existing mapping for ISRs or threads in the Profiler XML. --> </TaskState> </Object>


4. Also in the Profiler XML, add a TypeEnum that signals the ID to ISR mapping.

xml
<!-- Goes into the <Types> section of the XML -->
<TypeEnum>
  <Name>TypeEnum_cat1IsrMapping</Name>
  <Enum><Name>INVALID_ISR1</Name><Value>0</Value></Enum>
  <Enum><Name>Cat1IsrA</Name><Value>1</Value></Enum>
  <Enum><Name>Cat1IsrB</Name><Value>2</Value></Enum>
</TypeEnum>


5. Reload the Profiler XML in winIDEA and select `RUNNINGISR1[0]` in the winIDEA Analyzer Profiler objects configuration. Also, make sure that the instrumentation trace variable `cat1IsrTracing` is being recorded. You should now see category 1 ISRs in the trace, and BTF export should work accordingly.

Was this answer helpful?