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-AB | v 8.0.1 |
RTA-RTE | v 7.3.0 |
RTA-BSW | v 6.0.0 |
RTA-OS | v 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.
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
AUTOSAR defines some overall ECU state management Mode Declarations,it is recommended :
ECU Startup Management
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
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
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"
BswMAvailableActions container, and select New Child --> BswMSchMSwitch. Configure BswMSchMSwitch to select the ECU_STARTUP_TWO mode.
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.