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-AB | v 7.0.1 |
RTA-RTE | v 7.1 |
RTA-BSW | v 5.1 |
RTA-OS | v 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
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
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 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
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
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
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.