RTA Knowledge Base

Table of Content

Introduction

Scope

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

Please notice that Mode Mangement is a complex topic and it is not the scope of this document to treat this topic exhaustively. The objective is instead to describe how to provide to the user an overview on the fundamental blocks of Mode Management and describe how to create them using RTA-CAR toolchain. As example, it 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. This will be just an example but you can repeat the same steps 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 7.0.1 toolchain:

RTA-CAR 7.0.1 toolchain

ISOLAR-ABv 7.0.1
RTA-RTEv 7.1
RTA-BSW5.1
RTA-OSv 6.0.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; to have a mode switching two entities are required: a mode manager and a mode user; the mode manager is responsible of providing the mode switch request, 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 perform 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 element 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 from/to the BswM. These interfaces are SWCD ports when the request originates from an application SWCs or C functions if a BSW module makes the request.

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). Operator is only required therefore if there are more than one conditions.

The Arbitration Rule contains a logical expression, initial boolean state, and instructions on what to do if the expression is evaluated false or true (Action list to execute).

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 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:

Now edit the ModeDeclarationGroup setting the initial mode 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 and set its attribute BswMRequestProcessing to DEFERRED; then add the BswMModeRequestSource parameter setting it to the Mode Declaration Group created:


NB: 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 and select New Child --> BswMModeCondition


Edit the Mode Condition setting 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

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 actions to create without a the memory stack is just 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

Expand the Action container, a BswMAvailableActions must be selected; there are several available actions. The action to switch ECU mode must be configured as a BswMSchMSwitch and the reference to the ECU_STARTUP_TWO mode must be added as shown here

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

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; Configure this item with a reference to the new Action and add 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 a 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 along as part of the RTA Starter Kit. This complete configuration can be reused in other projects.