You are on page 1of 12

Adaptive MICROSAR CRC

Technical Reference
Adaptive MICROSAR
Version master-3954

Authors Juri Schröder


Status Released
Technical Reference Adaptive MICROSAR CRC

Document Information

History
The change history of this file is part of the component change history. It is documented in
ChangeHistory.txt of the component folder.

Reference Documents
[1] AUTOSAR. Specification of CRC Routines. V4.3.0.

Caution
We have configured the programs in accordance with your specifications in the ques-
tionnaire. Whereas the programs do support other configurations than the one specified
in your questionnaire, Vector´s release of the programs delivered to your company is
expressly restricted to the configuration you have specified in the questionnaire.

© 2021, Vector Informatik GmbH Version: master-3954 1 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Architectural Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.1 Dependencies 4
1.2.2 Component Design 4

2 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 CRC functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Threading behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1 Calculation methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1 Build Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Files and Include Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5 Glossary and Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10


5.1 Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

© 2021, Vector Informatik GmbH Version: master-3954 2 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

Tables

2-1 Parameter explanation for CRC functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3-1 Available calculation methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7


3-2 Default calculation method for the different functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

© 2021, Vector Informatik GmbH Version: master-3954 3 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

1 Introduction

This technical reference describes the features and functionality of the AMSR CRC module.
This component provides functions for calculating CRC checksums.

1.1 Scope
This technical reference only describes the usage and features of the AMSR CRC module. It does not
give a detailed description of CRC calculation.

1.2 Architectural Overview


1.2.1 Dependencies
The CRC module directly depends on LibVAC and Msr4Base. LibVAC is used for the definition of the
input data type crc::CrcData and Msr4Base is necessary to compile the internally used MICROSAR
classic CRC module.

1.2.2 Component Design


The CRC component is split up into two parts:
> libinternal: Contains the code of the MICROSAR classic CRC module which is used to perform
all CRC value calculations.
> libcrc: Contains the public interface and wrapper code to pass each function call to the classic
CRC module.

© 2021, Vector Informatik GmbH Version: master-3954 4 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

2 Functional Description

2.1 Features
In general, including the crc.h header provides a namespace crc:: which contains 6 different
functions for calculating CRC values:
> Calculation of 8-bit CRC values (using two different methods)
> Calculation of 16-bit CRC values
> Calculation of 32-bit CRC values (using two different methods)
> Calculation of 64-bit CRC values
Additionally the data types that serve as input and output to said functions are provided. Their
interaction is described in this chapter.

2.2 Data types


The following data types are available in the crc:: namespace:
> crc::CrcData is defined as
using CrcData = ara::core::Span<std::uint8_t const>; and is used for providing the input
data to the CalculateCrc functions.
> crc::Crc8Value used as return type and start_value for the CalculateCrc8 function.
> crc::Crc8h2fValue used as return type and start_value for the CalculateCrc8h2f function.
> crc::Crc16Value used as return type and start_value for the CalculateCrc16 function.
> crc::Crc32Value used as return type and start_value for the CalculateCrc32 function.
> crc::Crc32p4Value used as return type and start_value for the CalculateCrc32p4 function.
> crc::Crc64Value used as return type and start_value for the CalculateCrc64 function.
The crc::CrcXXValue types are used to realize strong typing for the return type and start_value of
the respective functions. They have a private member which contains the actual result of the CRC
calculation and can be accessed via the get() method.

2.3 CRC functions


The CRC module provides several different functions for calculating CRC values:
> Crc8Value CalculateCrc8(CrcData data) returns the 8-bit CRC value based on the SAE-J1850
Standard (polynomial 1Dh).
> Crc8Value CalculateCrc8(CrcData data, Crc8Value start_value) returns the 8-bit CRC value
based on the SAE-J1850 Standard (polynomial 1Dh). This method shall be used for subsequent
calls in a call sequence. The parameter start_value should contain the return value of the
previous call.
> Crc8h2fValue CalculateCrc8h2f(CrcData data) returns the 8-bit CRC value using the genera-
tor polynomial 2Fh.
> Crc8h2fValue CalculateCrc8h2f(CrcData data, Crc8h2fValue start_value) returns the 8-
bit CRC value using the generator polynomial 2Fh. This method shall be used for subsequent calls
in a call sequence. The parameter start_value should contain the return value of the previous
call.
> Crc16Value CalculateCrc16(CrcData data) returns the 16-bit CRC value based on the CCITT-
FALSE Standard (polynomial 10’21h).
> Crc16Value CalculateCrc16(CrcData data, Crc16Value start_value) returns the 16-bit CRC

© 2021, Vector Informatik GmbH Version: master-3954 5 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

value based on the CCITT-FALSE Standard (polynomial 10’21h). This method shall be used for
subsequent calls in a call sequence. The parameter start_value should contain the return value
of the previous call.
> Crc32Value CalculateCrc32(CrcData data) returns the 32-bit CRC value based on the IEEE-
802.3 CRC32 Ethernet Standard (polynomial 04’C1’1D’B7h).
> Crc32Value CalculateCrc32(CrcData data, Crc32Value start_value) returns the 32-bit CRC
value based on the IEEE-802.3 CRC32 Ethernet Standard (polynomial 04’C1’1D’B7h). This method
shall be used for subsequent calls in a call sequence. The parameter start_value should contain
the return value of the previous call.
> Crc32p4Value CalculateCrc32p4(CrcData data) returns the 32-bit CRC value using the gener-
ator polynomial
F4’AC’FB’13h.
> Crc32p4Value CalculateCrc32p4(CrcData data, Crc32p4Value start_value) returns the 32-
bit CRC value using the generator polynomial
F4’AC’FB’13h. This method shall be used for subsequent calls in a call sequence. The parameter
start_value should contain the return value of the previous call.
> Crc64Value CalculateCrc64(CrcData data, Crc64Values) returns the 64-bit CRC value using
the generator polynomial
42’F0’E1’EB’A9’EA’36’93h.
> Crc64Value CalculateCrc64(CrcData data, Crc64Value start_value) returns the 64-bit CRC
value using the generator polynomial
42’F0’E1’EB’A9’EA’36’93h. This method shall be used for subsequent calls in a call sequence.
The parameter start_value should contain the return value of the previous call.

Parameter Description
data Input data for the CRC calculation.
start_value Initial value when the algorithm starts, i.e. the return value of the previous call
for subsequent calls in a call sequence.

Table 2-1 Parameter explanation for CRC functions

2.4 Threading behavior


The CRC component does not create any threads.

© 2021, Vector Informatik GmbH Version: master-3954 6 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

3 Configuration

The CRC module can be configured to use different calculation methods, depending on the user
requirements.
This configuration is done entirely in the file amsr-vector-fs-crc/lib/libinternal/include/Crc_Cfg.h. The
section where the calculation method can be adapted is indicated by the line:

/***** CRC Calculation configuration *********************************************/

No other section of the file shall be changed. In order to change the calculation method of a CRC
function the corresponding #define has to be adapted. For example, to change the calculation
method of CRC64 from slicing-by-4 to slicing-by-8, change the line

#define CRC_64_MODE (CRC_64_TABLE_4)

to

#define CRC_64_MODE (CRC_64_TABLE_8)

A detailed explanation of a all available modes is given in the following section.

3.1 Calculation methods


There are several different ways to calculate CRC values.
> Runtime: The calculation of the CRC values happens entirely at runtime. This is the slowest
calculation method, but requires the least amount of memory compared to the others.
> Table: A table containing precomputed values is used. This increases memory consumption but
speeds up the calculation.
> Slicing-by-n: Also makes use of precomputed tables, but processes n bytes at a time, which
further improves performance at the cost of even higher memory consumption. Possible values for
n are 4 and 8.
Not all calculation methods are available for all CRC types:

Function Runtime Table Slicing-by-4 Slicing-by-8


CalculateCrc8 Yes Yes No No
CalculateCrc8h2f Yes Yes No No
CalculateCrc16 Yes Yes Yes Yes
CalculateCrc32 Yes Yes No No
CalculateCrc32p4 Yes Yes Yes Yes
CalculateCrc64 Yes Yes Yes Yes

Table 3-1 Available calculation methods

© 2021, Vector Informatik GmbH Version: master-3954 7 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

Table 3-2 shows which calculation method is used by default for each function:

Function Default calculation method


CalculateCrc8 Table
CalculateCrc8h2f Table
CalculateCrc16 Slicing-by-4
CalculateCrc32 Table
CalculateCrc32p4 Slicing-by-4
CalculateCrc64 Slicing-by-4

Table 3-2 Default calculation method for the different functions.

© 2021, Vector Informatik GmbH Version: master-3954 8 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

4 Integration

4.1 Build Dependencies


To build the CRC module the following components are required:
> amsr-vector-fs-libvac.
> amsr-vector-fs-msr4base.

4.2 Files and Include Structure


> Use this Module:
To use CRC simply include the crc.h header file by adding #include "crc/crc.h" to your code.
> Compile and link the Application:
Only the dependencies listed in section 4.1 are necessary to compile and link the application.
> Deploy the Application:
No additional files are necessary to deploy the application.
> Runtime Files:
No files are accessed during runtime.

© 2021, Vector Informatik GmbH Version: master-3954 9 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

5 Glossary and Abbreviations

5.1 Abbreviations

Abbreviation Description
AMSR Adaptive MICROSAR
CRC Cyclic Redundancy Check
MICROSAR Microcontroller Open System Architecture

© 2021, Vector Informatik GmbH Version: master-3954 10 / 11

based on template version 1.00.00


Technical Reference Adaptive MICROSAR CRC

6 Contact

Visit our website for more information on

> News
> Products
> Demo software
> Support
> Training data
> Addresses

www.vector.com

© 2021, Vector Informatik GmbH Version: master-3954 11 / 11

based on template version 1.00.00

You might also like