RTA Knowledge Base

1. Table of Contents

2. Introduction

2.1 - Scope

This Application Note describes how to add End to End (E2E) protection to an existing RTA-CAR project. This should not be confused with the AUTOSAR E2EXf concept.

Unlike the E2EXf concept, the user must develop E2E Protection Wrapper functions which handle the calling of the E2E library. These protection wrappers are then called inside the application code. We will go through how to configure the E2E module and provide the necessary code examples required to implement the protocol.

2.2 - Definitions and Abbreviations

E2E:

BSW: AUTOSAR Basic Software, Hardware independent service layer

RTE: AUTOSAR Real Time Environment

OS: AUTOSAR Operating System

SWC: Software Component

ASW: Autosar Software

CRC: Cyclic Redundancy Checks

Crc: The Crc module, part of the RTA-SAFE stack

E2EXf: End-to-End Protection Transformer.

2.3 - Toolchain

It is assumed you are using the RTA-CAR 9.2.0 toolchain:

RTA-CAR 9.2.0 toolchain

ISOLAR-ABv 9.2.0
RTA-RTEv 7.5.0
RTA-BSWv 6.1.2
RTA-OSv 6.2.0

3. Prerequisites

In order to successfully follow this guide, you must have the RTA-CAR 9.2.0 toolchain installed and you must be familiar with the AUTOSAR specifications, terminology and methodology.

It is recommended that End To End configuration is added to an existing project, with ASW and a System Configuration.

Hint: The AUTOSAR E2E specification AUTOSAR_PRS_E2EProtocol.pdf can be used to learn about the End to End.

4. Workflow

4.1 - Workflow Description

In AUTOSAR, the End to End library provides mechanisms for end-to-end communication. It provides software routines to protect the data exchange between software components for both inter and intra ECU communication. It also supports mechanisms for failure detection and sender-receiver authentication.

This module is not currently supported by the RTA-BSW Configuration Generator so it must be manually configured. In this workflow we will go through the steps required to configure the E2E module. We will create and configure the E2E module, the required elements nessesary to support the module, and then

How you configure the module depends on the chosen E2E profile. This guide assumes profile 2 is being used, which requires a Counter, Data ID (for CRC calculation) and CRC. 

E2E MechanismDetected communication faults
CounterRepetition, Loss, insertion, incorrect sequence, blocking
Data ID + CRCMasquerade and incorrect addressing, insertion
CRCCorruption

Table 7-2: Specification of SW-C End-to-End Communication Protection Library AUTOSAR CP Release 4.3.0

4.2 - Workflow Summary

Step 1. We will create the Sender Receiver interface required by the E2E module.

Step 2. We will configure the Sender Receiver interface so that it contains 3 Data Elements.

Step 3. We will create and E2E Software Component and configure it with the necessary values.

Step 4. We will create the necessary data access points which reference the Data Elements created previously.

Step 5. We will create a Data Received Event on the E2E Software Component.

Step 6. We will add the E2ESWC to the TopLevelComposition and map its ports.

Step 7. We will create and configure the E2E BSW module.

Step 8. We will create and configure the CRC BSW module.

Step 9. We will generate the RTA-BSW code for the E2E and CRC module.

Step 10. We will map the E2ESWC Data Received Event to the OsTask_BSW.

Step 11. We will generate the RTA-RTE code.

Step 12. We will configure the necessary code required for the E2E protection wrappers and a function to test the E2E module.

4.3.1 - Create a Sender Receiver Interface

First, in order for the data to be communicated using E2E, we need to create a new Sender Receiver Interface. Right click on Software and select Create Interface > Create Port Interface > Elements | Sender Receiver Interface.


Name it E2E_DataInterface and place it in the system_config folder like so:


Select Finish. You can see our new SR interface has been created under Port Interfaces here:

4.3.2 - E2E Data Interface Configuration

We now need to configure some data elements inside the E2E_DataInterface we have just created. Open E2E_DataInterface in the generic editor by right clicking on the element and selecting Open With > Generic Editor like so:


This will open up the interface in the generic editor:


Now right click on E2E_DataInterface and select New Child > Data Elements | Variable Data Prototype to create a new Variable Data Prototype:


Repeat the step 2 more times so that you have 3 Data Elements:


Click on Data Elements [3], this will display the 3 elements in a table. Change their shortnames to CKS, Alive_Cnt, and Data. Set all their types to uint8 (unsigned integer 8). The final result of this step is shown below:

4.3.3 - Create and configure an E2E Software Component

Now that we have our SR Interface set up, we need create the software component for the E2E.

To create a new software component, right click on Software and select Create Component > Elements | Application Sw Component Type


Set the name to E2ESWC and configure the path like in the image below:


Open the new SWC in the component editor by right clicking on the element and selecting Open With > Component Editor. Click Create PPorts...


In the dialog window select the E2E_DataInterface we have just created. Then select Finish.


Repeat this but this time selecting Create RPorts... Again selecting the E2E_DataInterface we created previously. You will now have a PPort and an RPort, set the shortnames so they match the image below:

4.3.4 - Create Data Access points for new E2E SWC

Now with the E2ESWC we have just created still open in the component editor, switch to the functions tab and then on the left switch to the data access points tab on the right. First we need to create an internal behavior for the SWC. Click on the green plus icon next to the IB selection box. A dialog box will pop up asking for a short name, leave it as the default value and select OK.


Now select the + Runnables link on the left to create a runnable entity, set the Runnable Entity to RE_TestE2E and set its function name also to RE_TestE2E:


Now select the + Access Points... link.


In the Dialog window that pops up, select PPort_E2E_Tx under DataSendPoints, and select RPort_E2E_Rx under DataReceivePointByArguments:


Click OK. You will see 6 Data Access Points created on the table on the right. 2 have been created for each of the Data Elements we created earlier. Set their short names to match the image below:

4.3.5 - Create a Data Received Event

In order for our runnable entity to be triggered, we'll need to create an event to trigger it. As we want it to run when it receives data, we will create a Data Received Event.

Navigate from Functions tab to the Events tab:


Navigate to the green plus button in the top left, and select the drop down arrow on the right. Then select DataReceivedEvent:


A dialog box will appear. Check 'Data' in the table and select OK:


The data received event will be created in the table. Configure the values so they match the screenshot below:

4.3.6 - Connecting The E2ESWC

We now need to add the E2ESWC to the TopLevelComposition and map it to the ReceivingSWC and TransmittingSWC. This is assuming you are using the project created as a result of following workflows 01 through to 05. You can look at our RTA-CAR 9.2.0 Standard Starter Kit for another example of how this component can be mapped.

Open the TopLevelComposition by double clicking it:


In the editor navigate to the green plus button in the top left, select the drop down arrow to the left of it and then select Component Prototype in the drop down menu:


In the dialog box that appears, check the E2ESWC component, and select OK:


Now navigate to the Manuel Connection Editor tab in the bottom left. Then in the Source Component selection box on the left, select CPT_E2ESWC and in the Target Component selection box on the right, select CPT_MyReceivingSWC_ApplicationECU. Under the E2ESWC, check PPort_E2E_Tx, and under MyReceivingSWC, check the RPort. Finally click the large connect button in the middle to connect the two ports.


Now repeat this with the MyTransmittingSWC, this time conntecting RPort_E2E_Rx to the PPort on TransmittingSWC:

4.3.7 - Create E2E Module

We now need to create the E2E module. Open the ECU Navigator and right click on Bsw Modules. Select Create Other Modules > Create E2E


In the Dialog window that pops up, Set the module name to E2E and the file name to E2E_EcuCValues.arxml. Place it in the ecu_config/bsw/ecucValues folder and select Finish.


You will see the module created under Other Modules:


Double click on the module to open it up in the BSW editor and set the values of E2ERbGeneral_0 to match the image below:

4.3.8 Create CRC Module

We now need to create the Cyclic Redundancy Check module. Right click on Bsw Modules and select Create Service > Create Crc:


In the dialog box that pops up, set the name to module name to CRC and the file name to CRC_EcuCValues.arxml. Place it in the ecu_config/bsw/ecucValues folder.


The module will appear under services. Double click it to open it in the BSW editor. Configure the values so they match the image below:

4.3.9 - RTA-BSW Code Generation

Now open up the RTA Code Generator Dialog, and select the BSW modules E2E and CRC:

Select apply, close the window and select Generate RTA-BSW:

4.3.10 - Mapping The Event

Now in the ECU Navigator, double click on the EcucValueCollection to open it in the RTE Mapping Editor:


And drag the E2ESWC runnable created earlier over to OsTask_BSW:

4.3.11 - RTA-RTE Code Generation

Now generate the RTA-RTE:

4.3.9 - E2E Protection Wrapper (E2EPW)/ Application Software

To access the data in the E2E interface, an E2E Protection Wrapper is created. See the AUTOSAR "Specification of SW-C End-to-End Communication Protection Library" document, Section 12.1 for more details.

The E2E Protection Wrapper is responsible for calling the Rte_Write and Rte_Read functions, and invoking the protecting/validating the data using the E2E Library.

The Protection Wrappers are created of the form E2EPW_Write_<port>_<operation>(<data>) and E2EPW_Read_<p>_<o>(<data>), and return 32-bit integers that represent the status. The 32-bit return status contains four 8-bit statuses: byte 0 is the RTE API status, byte 1 is the status of runtime checks done within Protection Wrapper, byte 2 is the return value of E2E_PXXProtect/Check function and byte 3 is currently unused, therefore is populated with E2E_E_OK.

The two functions below are examples of E2E protection wrappers, these are from the RTA-CAR 9.2.0 Standard Starter Kit. Now that you have completed the necessary steps needed to configure the E2E module in your project, you will need to add some code to interact with it. You can place the 2 functions below in a file within your project, it is recommended you place it in the same file as the application code you will also need to implement in order to use this module.

Example E2E Protection Wrappers
/* E2E Protection Wrapper to read data from the relevant ports for E2E_Rx then check data  */
FUNC(uint32, E2E_InterSWC_2) E2EPW_Read_E2E_E2E_Rx(E2EImplementationDataType *data)
{
    uint32 E2EPW_error = E2E_E_OK;
    Std_ReturnType E2E_error;
    E2EImplementationDataType data_tmp;

    /*Read the data*/
    Rte_Read_RPort_E2E_Rx_Alive_Cnt(&(data_tmp.Impl_Alive_Cnt));
    Rte_Read_RPort_E2E_Rx_CKS(&(data_tmp.Impl_CKS));
    Rte_Read_RPort_E2E_Rx_Data(&(data_tmp.Impl_Data));

    E2E_P02ReceiverState_E2ESWC.NewDataAvailable = TRUE;

    /*Data serialization can be done here if necessary */

    /* Check if the data received is correct (Checksum and alive counter)*/
    E2E_error = E2E_P02Check(&E2E_P02_StaticCfg_E2ESWC, &E2E_P02ReceiverState_E2ESWC, (uint8 *) &data_tmp);

    if ((E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_OK) ||
        (E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_INITIAL) ||
        (E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_OKSOMELOST))
    {
        *data = *(E2EImplementationDataType *) &data_tmp;
    }

    return ((RTE_E_OK) | (E2EPW_error << 8) | (E2E_error << 16) | (E2E_P02ReceiverState_E2ESWC.Status << 24));
}

/* E2E Protection Wrapper to protect data then write to the relevant ports for E2E_Tx */
FUNC(uint32, E2E_InterSWC_1) E2EPW_Write_E2E_E2E_Tx(E2EImplementationDataType *data)
{
    uint32 E2EPW_error = E2E_E_OK;
    Std_ReturnType E2E_error;

    /* Call E2E library function to protect the data that will be transmitted over the port*/
    E2E_error = E2E_P02Protect(&E2E_P02_StaticCfg_E2ESWC, &E2E_P02SenderState_E2ESWC, (uint8 *) data);

    /* Transmit the data with alive counter and calculated CKS over the port */
    Rte_Write_PPort_E2E_Tx_Alive_Cnt(data->Impl_Alive_Cnt);
    Rte_Write_PPort_E2E_Tx_CKS(data->Impl_CKS);
    Rte_Write_PPort_E2E_Tx_Data(data->Impl_Data);

    return ((RTE_E_OK) | (E2EPW_error << 8) | (E2E_error << 16));
} 


This is an example implemention of a function which utilises the two protection wrappers discussed above. This is also from the RTA-CAR 9.2.0 Standard Starter Kit. For the purpose of this workflow you can paste this function and the 2 above into the same file within your project. It is recommended you place this application code in the same location as the rest of your application code. You can find an example of our implementation in the src/asw folder of our RTA-CAR 9.2.0 Standard Starter Kit.

Example E2E Protection Wrappers
/* Example Runnable */ FUNC(void, MasterSWC_CODE) RE_TestE2E(void)
{
    E2EImplementationDataType E2E_InterSWC_TestRx;
    E2EImplementationDataType E2E_InterSWC_TestTx;
    uint8 directAccess_E2E_InterSWC_TestRx;
    uint32 E2EPW_error = E2E_E_OK;

    /* Get port data item, and call E2E Protection Wrapper. */
    Rte_Read_RPort_E2E_Rx_Data(&directAccess_E2E_InterSWC_TestRx);
    E2EPW_error = E2EPW_Read_E2E_E2E_Rx(&E2E_InterSWC_TestRx);

    /* When received initial protected 1, send 2. */
    if ((1u == E2E_InterSWC_TestRx.Impl_Data) && (E2EPW_error == (E2E_P02STATUS_INITIAL << 24)))
    {
        E2E_InterSWC_TestTx.Impl_Data = 2u;
        E2EPW_Write_E2E_E2E_Tx(&E2E_InterSWC_TestTx);
    }

        /* When received invalid 3, send 4. Need to access data in port because E2EPW will
        not read with error. */
    else if ((3u == directAccess_E2E_InterSWC_TestRx) && (E2E_E_OK != E2EPW_error))
    {
        E2E_InterSWC_TestTx.Impl_Data = 4u;
        E2EPW_Write_E2E_E2E_Tx(&E2E_InterSWC_TestTx);
    }
}