Metrics_Integration_Manual

Contents

1 Dependencies 1

2 Configuration 1

2.1 Build Time Config 1

2.2 Generator Config 2

3 Memory Mapping 2

3.1 Mapping 2

3.2 Usage 2

Dependencies

ModuleRequired Feature
Rte

Rte_Task_Dispatch() hooks

VFB Trace hooks

DioDio_WriteChannel()
PortPort_SetPinDirection()
NxtrLib

DtrmnElapsedTime_uS_u32()

GetSystemTime_uS_u32()

Os

osdNumberOfAllTasks constant value

osGetStackUsage

oskTcbStackTop

oskTcbStackBottom

Configuration

Build Time Config

ConstantNotesSWC
BC_METRICS_TASKCPUUSEMASKSTD_ON enables build of the task use masking functionality to excluded a user defined set of task CPU use times from the CPU use calculation.
BC_METRICS_STACKUSESTD_ON enables build of the Stack Use monitoringMetrics
BC_METRICS_CPUUSEDIOSTD_ON enables build of the CPU Use digital output based monitoringMetrics
BC_METRICS_CPUUSETMRSTD_ON enables build of the CPU Use timer based monitoringMetrics
ENABLE_CPUUSE_DIOIf defined then CPU usage is output via a DIO where the DIO is high while the CPU is not in the background task.Metrics
RTE_VFB_TRACE=1Enable Rte’s VFB trace functionality to support Rte_Task_Dispatch() hooksRte
Rte_Task_DispatchEnable Rte’s Rte_Task_Dispatch() hooksRte

Generator Config

ConstantNotesSWC
Dio Channel Name: “Metrics”Required when ENABLE_CPUUSE_DIO is definedDio
RTE VFB Trace Hooks
  1. Enable the option “Enable VFB Tracing” under Generation Parameters.

  2. Define/Import task wait event, and wait event return hooks. Insert task start into the wait event return hook, and task end into wait the wait event hook.

  3. Define/Import all desired runnable Start and Return hooks in the “Trace function“ dialog.

Caveats:

  • The runnable runtime metrics methodology requires all preemption entry and exit points are instrumented with Metrics_TaskStart/End to provide the ability to measure and subsequently account for preemption time in the preempted entity.

    • Basic Tasks do not provide an Rte Exit hook, therefore the Metrics_TaskEnd( Id ) must be integrated in the return hook of the last runnable in the Task list.

    • Extended Tasks do provide start and end hooks and therefore do not require the integrator to place the Metrics_TaskEnd( Id ) in any runnable end hook.

  • Tracking all runnables is likely to impact task run times significantly. It may make more sense to enable runnable trace hooks only as necessary.

MPU Global Read AccessGetSystemTime and Dio_WriteChannel Metrics Channel accessed registers must be readable across all application and ISR contexts.Os
MPU Global Read/Write Access

Metrics data structures must be R/W across all application and ISR contexts.

ATTENTION! The metrics data structures are very large, so ensure that adequate memory is allocated to the Global Shared region

OS

Integration Project Changes

  1. Modify the required BSW Irq source functions to place the Metrics_TaskStart and Metrics_TaskEnd hooks around the ISR’s. The recommended practice is to make a copy of the delivered source file renamed to *_NxtrMetrics.c and conditionaly build the altered file in place of the delivered file for Metrics builds.

  2. Modify SchM.c to place the Metrics_TaskStart hook and Metrics_TaskEnd calls appropriately at around the tasks. Note that it might be necessary to place the hooks at a point in the task that will be overwritten when the SchM.c is generated. Diligence will need to used after generation to ensure that the hooks are not inadvertently removed.

  3. Modify ApplCallbacks.c to place Metrics_TaskStart and Metrics_TaskEnd calls appropriately around tasks. Dilligence will be required to ensure the hooks are not removed.

Memory Mapping

Mapping

ConstantNotes
METRICS_START_SEC_VAR_CLEARED_UNSPECIFIEDWritable across all applications

* Each …START_SEC… constant is terminated by a …STOP_SEC… constant as specified in the AUTOSAR Memory Mapping requirements.

Usage

: ARM Cortex R4 Memory Usage
Revision Control Log

FeatureRAMROM
Software task time stamping of task execution
Stack usage monitoring
Item #Rev #Change DescriptionDateAuthor Initials
1
Last modified October 12, 2025: Initial commit (0347a62)