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

RTA-CAR 9.1.0 toolchain

ISOLAR-ABv 9.1.0
RTA-RTEv 7.4.1
RTA-BSWv 6.1.0
RTA-OSv 6.1.3

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

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


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 Logical Expression describes the logic used for mode arbitration. An expression is made up of one or more conditions 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 Mode Condition describes a condition to be evaluated as a part of a logical expression.

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 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. Starting 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 Arbitration Rule (AR), Logical Expression (LE), 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 the 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 an Arbitration Rule

In the ECU Navigator view right-click on BswM module and select Open with --> BswM Editor.



To create an Arbitration Rule click on the plus button near to Rules, as shown in the image:



A new rule is created with name BswMRule_0 edit it to BswMRule_InitBlockTwo.



Then, set the initial state to BSWM_FALSE.


Create a Logical Expression

To create a Logical Expression click on the plus button near to Logical Expression. 



Change the ShortName to BswM_LE_StartupOne.


Create a Mode Condition

To create a Mode Condition click on the plus sign near to Add MC.



Then click New.



Edit the Mode Condition, setting the condition type by double clicking on Equals and click on BSWM_EQUALS.



Create the container holding the value to compare the ECU mode with; double click on Condition Value and select the  BswMModeDeclaration:



Then click on the newly created BswMModeDeclaration container in the Condition Value column and select the reference to mode ECU_STARTUP_ONE under BswMModeValueRef in the Properties view:


Create a Mode Request Port

To create Mode Request Port click on Add MRP (Mode Request Port)



Set the attribute of the Mode Request Port by clicking on the new port created and then on the right by setting the BswMRequestProcessing to DEFERRED.



Then add the Source parameter, by double clicking in the cell and setting it to BswMBswModeNotification. 



Then click on the Source parameter and set the Mode Declaration Group, by writing "/AUTOSAR_BswM/ModeDeclarationGroups/MDG_ECUM_STATE" in the Properties section under BswMRbBswModeDeclarationGroup :

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

Create an Action List

To create an action list click on the plus sign near to Action List:



Rename it as BswM_ALI_Switch_Two



Create an Action

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 click on Add Action.



Then click on New.



Now double click in the Action cell and select the BswMSchMSwitch:



Then, click on the Action cell and in the Properties view select the mode ECU_STARTUP_TWO.



Finally click under index and write 0.


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.