Table of Contents
Introduction
Scope
The final goal of this application note is to provide an overview of the Post Build Selectable feature within RTA-CAR and be able to configure a project that makes use of this feature.
To reach this general scope, this application note covers a practical use case. A sample project will be configured with the following variants:
- Variant_Tx_Enabled: all the TX frames present in the system description are transmitted by the ECU
- Variant_Tx_Disabled: a TX frame of the system description is not transmitted by the ECU
Definitions and Abbreviations
BSW: AUTOSAR Basic Software, Hardware independent service layer
ECU: Electronic Control Unit
EcuM: ECU State Manager
RTE: AUTOSAR Run-Time Environment
OS: AUTOSAR Operating System
SWC: Software Component
Toolchain
It is assumed you are using the RTA-CAR 9.2.0 toolchain:
RTA-CAR 9.2.0 toolchain | |
---|---|
ISOLAR-AB | v 9.2.0 |
RTA-RTE | v 7.5.0 |
RTA-BSW | v 6.1.2 |
RTA-OS | v 6.2.0 |
Post Build Selectable - Overview
Post Build Selectable feature allows to manage different variants after the code build process. This means that the binary file that is generated at compile time, and that is being flashed in the ECU, is able to support all the variants that have been defined in the project. In this case, the ECU must be instructed to be able to select the variant that should be executed during the startup phase. In particular, the EcuM module, after the initialization of the drivers, invokes a routine to select the variant that must be used for the current execution.
It must be noticed that the Post Build Selectable implementation has the following drawbacks:
- Higher resource consumption: the executable binary file must be able to handle all the variants at run time. This means that it should include all the source code, and data structures for the handling of the different variants.
- Implementation of a startup logic: The integrator shall define a logic to determine the variant that must be executed at ECU initialization. Please notice that the routine invoked by the EcuM module runs immediately after the driver initialization. Therefore, the logic shall rely on the ECU capabilities that are available at this specific point of time, e.g., port pin configurations.
- "Superset" configuration definition: The integrator shall define at system and BSW levels a "superset" configuration, that is able to cover all the different variants.
- Example: if for the message A has to be defined for the variant A, the message B has to be defined for the variant B and the message C has to be defined for the variant C, then, all the messages A, B and C must be defined in the project.
Post Build Selectable - General concepts in RTA-BSW
General Overview
A BSW configuration can be seen as a collection of containers. Post Build Selectable feature in RTA-BSW acts on this to differentiate the variants. The integrator shall define variation points on BSW containers, and assign the containers to the desired variant configuration.
Therefore, the main concept to successfully use this feature is the following:
- The integrator shall define different BSW container sets in order that the complete set defined for a variant is a "complete" BSW configuration. In other words, the container set for a variant shall be defined in such a way that if the containers of the other variants are removed from the BSW configuration of the project, the BSW should be able to be generated without errors.
Please Notice: the containers that do not contain any variation point, apply for all the variants defined in the project.
All the containers for which a variation point is defined, are identified through a green "V icon" in the top left part
The following example shows that only a subset of the overall BSW configuration is assigned to a single variant.
How to define variation points
In order to define variation points in BSW configuration, the integrator should right click on the BSW container that must be applied only to a subset of variants and select Configure Post Build Variants, and select for which variant the selected container should be applied.
If this option appears as disabled, the Post Build Variant is not supported for the selected container. Please, refer to the RTA-BSW Reference Guide to check Post Build Selectable capabilities of RTA-BSW stacks (Can, Eth, Diag, etc...).
Post Build Selectable - Example Project Configuration
Step 1 - Define the variants
It is needed to declare variants in the "Variant Info" section of the AR explorer
The created variants will be displayed under the "Variant Info" section. By double clicking on one of the variant, the "Variant Configurator Editor" is opened. In this case, we have to configure a Post Build variant, therefore the Post Build tab must be selected.
At this point it is possible to complete the variant configuration by adding "Post Build Criterion Value", "Post Build Criterion", "Compu Method" to the predefined variants.
Once the CompuMethod is created, the Data Dictionary Editor is opened, and here, it is possible to configure the "CompuScales" of the variants. It is possible to define as many "CompuScale" as needed. In particular, it is possible to create a number of "CompuScale" equal to the number of variants required in the project. An enumeration will be generated to manage the different variants accordingly to the configured Texttable(Vt) - Enum Index.
At this point it is possible to finalize the variant configuration, assigning to the "Post Build Criterion Value" of each variant the enumeration value defined in the previous step.
Step 2 - Reference variants in Ecuc
Before defining the variation points into the BSW configuration, it is needed to reference the variants in the Ecuc module.
Step 3 - Add Variation Points to BSW configuration
At this point it is needed to configure the variation points on the project, accordingly to the needs. Refer to the Variation Point Configuration chapter for the creation of a variation point.
Since the aim of the example project is to disable the communication stack for a specific CAN frame for the Variant_Tx_Disabled, we need to select all the containers of the BSW configuration associated to this frame, and create Variation Points to assign these containers to the Variant_Tx_Enabled.
Proceeding with a bottom-up approach, first we need to create Variation Point on the CanIf. In particular we need to create Variation Point for the following containers:
- CanIfTxPduCfg containing the configuration of the Tx frame that has to be disabled
- CanIfBufferCfg referenced by the CanIfTxPduCfg
- CanIfHthCfg referenced by the CanIfBufferCfg
Since the data of the Tx frame are received by means of a routing path, a configuration of a Variation Point in PduR module is required:
- PduRRoutingPath that is configured to route the Com signal to the CanIf module
To conclude the Variation Point configuration, we need to create Variation Points also in the following containers of the Com module:
- ComIPdu configuration of the Com I Pdu routed to the CanIf for transmission
- ComSignal of all the signals associated to the ComIPdu
Step 4 - ECU Initialization BSW Configuration
Depending on project needs and constraints (MCAL), it could be required to initialize the drivers with the post build configuration pointer. Therefore, the EcuM configuration can be updated (if needed).
Also the BSW initialization shall be updated if needed. In particular, BSW module initialization function requires a configuration pointer as input parameter as specified by AUTOSAR (e.g. CanIf)
If variation points are added in a BSW module, therefore, configuration pointers that have to be provided in initialization functions are different. The different configuration pointers are generated by RTA-BSW (e.g. CanIf)
Therefore, different initialization procedures have to be executed depending on which variant is selected by the EcuM module. To achieve this, it is possible to define variation points in BswM in order to execute different initialization action list for the different variants. Each action list will trigger the proper actions that which will invoke the BSW Init function with the proper configuration pointer.
For example, in our project we created variation points for the following modules: CanIf, PduR, Com. Therefore, the following BswMRule have been defined as variation points (triggered from the same BswMLogicalExpression)
And a couple of BswMActionList have been defined for the different variants (BswM_AL_BswModules_InitListReadAll_Tx_Disable and BswM_AL_BswModules_InitListReadAll_Tx_Enable).
The action list BswM_AL_BswModules_InitListReadAll_Tx_Disable, contains all the action that are needed for the Variant_Tx_Disable:
The action list BswM_AL_BswModules_InitListReadAll_Tx_Enable, contains all the action that are needed for the Variant_Tx_Enable:
Step 5 - Determine Post Build Variant
The logic to choose which variant has to be executed, accordingly to the AUTOSAR specification, is performed by the EcuM after the drivers initialization. In particular, it is responsible to invoke the function EcuM_DeterminePbConfiguration(). The integrator shall provide a logic by implementing this function, which template can be found in the BSW generated source code EcuM/integration/EcuM_Callout_Stubs.c .
In particular the integrator shall implement the logic, to pick the right index in order to return the EcuM_EcuMConfigurations_cpcast[ ] associated to the desired variant.
In our sample project it is checked a GPIO line. In particular, if the GPIO state is HIGH, the Variant_Tx_Enabled is selected, if the GPIO state is LOW, instead, the Variant_Tx_Disabled is selected. Therefore, the template function has updated as follows:
Additional Notes
Refine BSW Configuration
Activating the Post Build feature, it is possible that some specific BSW configuration has to be performed. For example, if CanNm is configured in the project, the parameter CanNmMaxNumberOfPnsConfigurableAtPostBuildTime shall be configured. Please, refer to RTA-BSW Reference Guide for details on configuration parameters.
RTA-BSW Code Generation Variation Points handling
During RTA-BSW Code Generation, some values are forwarded in the BSW configuration. This happens also when Post Build is configured. In this case, all the forwarded values (normally IDs), are handled by the tool by means of variation points.