RTA Knowledge Base

Table of Content

Introduction

Scope

This application note describes how to add Mode Management to an existing RTA-CAR project.

Please note that Mode Management is a complex topic and it is not the scope of this document to treat this topic exhaustively. The objective is instead to give an overview of the fundamentals of Mode Management, and describe how they can be created using the RTA-CAR toolchain. As an example, you will be shown how to create the ModeDeclarations needed at the ASW level, and how you can configure the BswM for the Ecu Startup Management. These steps can be repeated in order to configure other parts of BswM (for example, handling Shutdown or other Mode changes).

Definitions and Abbreviations

BSW: AUTOSAR Basic Software, Hardware independent service layer

RTE: AUTOSAR Real Time Environment

OS: AUTOSAR Operating System

SWC: Software Component

Toolchain

It is assumed you are using the RTA-CAR 8.0.1 toolchain:

RTA-CAR 8.0.1 toolchain

ISOLAR-ABv 8.0.1
RTA-RTEv 7.3.0
RTA-BSWv 6.0.0
RTA-OSv 6.1.0

Prerequisites

In order to successfully follow this guide, you must have the RTA-CAR toolchain installed and you must be familiar with the AUTOSAR specifications, terminology and methodology.

It is recommended that Mode Management configuration is added to an existing project, with ASW and a System Configuration.

Hint: The AUTOSAR Mode Management specification AUTOSAR_EXP_ModemanagementGuide.pdf can be used to learn about Mode Management.

Workflow description

AUTOSAR defines a mode as a state of the ECU; it is a global variable maintained by the RTE. The possible values the state can have are defined by a ModeDeclarationGroup. Mode switching is used to trigger executable entities, and requires two entities; a mode manager and a mode user. The mode manager is responsible for providing the mode switch request, and the mode user is informed of the executed switch. The Mode Management is implemented in the Basic Software layer, by the BswM module. This module arbitrates mode requests from Application SWC or other BSW modules and performs actions based on the arbitration result.

As detailed in the AUTOSAR specifications, the two main BSW modules involved in Mode Management are EcuM and BswM. In the AUTOSAR documentation (see also see 'AUTOSAR Mode Management Guide') you can find details on how these two modules interact.

The BswM must be configured to perform the mode switch operations, handle the start-up, restart and shutdown phases.

Some important elements you need to have in your configuration are:

  • Mode Request Port (MRP)
  • Mode Condition (MC)
  • Logical Expression (LE)
  • Action List (AL)
  • Arbitration Rule (AR)


The Mode Request Port defines a connection to the BswM used to pass requests or indicate modes to/from the BswM. These interfaces are SWCD ports when the request originates from application SWCs, or C functions when the request originates from a BSW module.

The Mode Condition describes a condition to be evaluated as a part of a logical expression.

The Logical Expression describes the logic used for mode arbitration. An expression is made up of one or more conditions (see above) the result of each evaluation is aggregated with a logical operator (AND, NAND, OR, XOR). An operator is only required if there are more than one conditions.

The Arbitration Rule contains a logical expression, initial boolean state, and instructions on what to do (An action list) depending on the result of the expression.

The Action List is a list of Action Items which are functions (actions) to be executed as a result of an Arbitration Rule evaluation (either to TRUE or FALSE).

The configuration of BswM is visualized below:

Create a BswM module

Starting from an existing project, create a new BswM module; to do that from the ECU navigator menu right click on Bsw Modules and select Create Mode Mgm --> Create BswM.


In the "New AR Element Creation" popup, enter the name of the BswM as "BswM" and give the AR Package a matching name. Then click Finish.

In the BswMGeneral container, configure the parameters, including enabling the required modules according to the project and setting a main function period value expressed in seconds.

Create a ModeDeclarationGroup

All the possible ECU states must be grouped into a ModeDeclarationGroup; first create one and populate it with the modes. To create a ModeDeclarationGroup right click on Software and select Create Infrastructure --> Create Mode Declaration --> Create Mode Declaration Group



Create the ECU modes by right clicking on create ModeDeclarationGroup and selecting New Child --> Mode Declarations | Mode Declaration


AUTOSAR defines some overall ECU state management Mode Declarations,it is recommended create a new Mode Declaration for each of the modes listed below:

Now edit the ModeDeclarationGroup by setting InitialMode to "ECU_STARTUP_ONE"

ECU Startup Management

The following configuration steps provide an overview of how to configure a mode change (creation of the Mode request port, action list, and so on). This is presented as an example, and can be replicated for any other type of mode management configuration.

As defined by AUTOSAR specification, an initial rule must be created to execute the initialization of basic driver required for access to the NVRAM; this means that all the modules involved in memory management must be initialized (SPI, EEp, Fls; NvM) and the NvM readAll operation shall be performed.

Create a Mode Request Port

First create a Mode Request Port; to do so, double click on the BswM module to open it; expand the BswMConfig container, right click on BswM Arbitration and select New Child --> BswMModeRequestPort


Edit the ModeRequestPort short name to "BswM_MRP_BswM_MDG" and set its attribute BswMRequestProcessing to DEFERRED.

then add the BswMModeRequestSource parameter inside of the created BswMModeRequestSource, setting it to the Mode Declaration Group created previously, "/AUTOSAR_BswM/ModeDeclarationGroups/MDG_ECUM_STATE":


Note: You must insert the correct AUTOSAR path of the Mode Declaration Group Prototype.

Create a Mode Condition

Mode Request Port value is evaluated comparing it to a Mode condition; for the startup, the condition to execute the first list of actions is to have the mode equal to ECU_START_ONE. To create a Mode Condition right click on BswM Arbitration inside of BswMConfig and select New Child --> BswMModeCondition


Edit the Mode Condition, setting the ShortName to BswM_MC_StartupOne, the BswMConditionType to BSWM_EQUALS and the BswMConditionMode to the new request port.

Create the container holding the value to compare the ECU mode with; right click on created BswMModeCondition and select New Child --> BswMConditionValue:

Right click on the Condition value and select New Child --> BswMModeDeclaration:

Double click on the new Mode declaration and select the reference to mode ECU_STARTUP_ONE:

Create a Logical Expression

Before creating a rule, a Logical Expression must be created; this is required for when multiple Mode Conditions must be combined to evaluate a rule; in the startup case, when the ECU is still in ECU_STARTUP_ONE mode the Logical Expression is simply equal to the Mode Condition but in other cases more Mode Conditions can be combined. To create a Logical Expression right click on BswM Arbitration and select New Child --> BswMLogicalExpression

Change the ShortName to BswM_LE_StartupOne, and reference the Mode Condition in the new Logical Expression.


Create an Action

Before creating the rule, create all the actions that must be executed when the rule will be evaluated; in the Startup case the only action required is the switch to ECU_STARTUP_TWO.

Note: If the memory stack is not configured, the two modes ECU_STARTUP_ONE and ECU_STARTUP_TWO can be merged into a single mode.

To create an action expand the BswMModeControl container, right click on it and select New Child --> BswMAction, and rename it to "BswM_Action_StartupTwo"


Right click the BswMAvailableActions container, and select New Child --> BswMSchMSwitch. Configure BswMSchMSwitch to select the ECU_STARTUP_TWO mode. 

Note: the signatures of some initialization functions may be dependent on the MCAL used

Create an Action List

The actions must be placed into Action Lists with the desired order; to create an action list right click on the BswMModeControl and select New Child --> BswMActionList


The list is created with an initial Action. Fill in the values for ShortName, BswMAbortOnFail, BswMActionListItemIndex and BswMActionListItemRef as shown.


More action list items can be added with a reference to the new Action and the desired index of execution; AUTOSAR specifies a recommended order of memory stack initialization in the startup phase - detailed in the AUTOSAR_EXP_ModemanagementGuide document.

Create a rule

Finally you can create the rule; right click on BswM Arbitration and select New Child --> BswMRule

Edit the rule adding the reference to the Logical Expression, to the Action List(s) and setting an initial state:

Conclusions

Following this workflow, you should be able to create a complete Mode Management configuration. The steps need to be repeated for each desired Mode.

A complete configuration is provided as part of the RTA Starter Kit. This complete configuration can be reused in other projects.