From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

XCP and CCP Seedkey Server

Code and Documents

Attachment

Version 1.0 for LabVIEW 2010 (source and executable) and 2011 (executable).

Remote Seed/Key Access for XCP and CCP Masters.

This is an example that ships with the ECU Measurement and Calibration Toolkit 2.2+. It is simply built here as an executable for those without LabVIEW to use. For example, those who use the ECU Measurement and Calibration Toolkit with NI VeriStand.

1. Background

Electronic control units (ECUs) use a locking mechanism to prevent accessing the ECUs by unauthorized persons.

This is working the following way:

  1. The master program asks the ECU for a seed value (e.g. a random number).
  2. The master uses a known algorithm to calculate the key based on the seed and sends this key to the ECU.
  3. The ECU creates the key on the same algorithm internally and checks if the key sent by the master is the same as the internally calculated key. Only if the key is correct, the access is unlocked.
  4. Every time the master requests a seed from the ECU it gets a new seed value, so reusing a key logged on CAN bus is not possible.

2. Technical Implementation

ASAM Measurement and Calibration standard defines an interface to a DLL which implements a function to create a key from the seed. The DLL has to contain a function with a given name. CCP defines one function to obtain the key. If for the priviledges Calibration, DAQ and Programming different algorithms are used, the master has to use 3 different DLLs implementing the algorithms. XCP defines a function with a parameter describing the priviledge to unlock, so one function can implement different algorithms for the given priviledge.

3. Remote Seed/Key Access

This allows the ECUMC master to call the DLL which is placed on another computer. This can be usefull for example when the available DLL is compiled for Windows and cannot be executed on VxWorks or Pharlap RT system.

4. Using Remote Seed/Key Access

4 DLLs for remote access are included. These DLLs connect to the seedkey server, which then calls the real seedkey DLLs:

  • rskCcpCal.dll (or .out on VxWorks) for the CCP Calibration Access
  • rskCcpDaq.dll (or .out on VxWorks) for the CCP DAQ Access
  • rskCcpPgm.dll (or .out on VxWorks) for the CCP Programmig Access
  • rscXcp.dll (or .out on VxWorks) for XCP priviledge access

1. Change the seedkey DLL names in your .a2l file to reference these DLLs.

See below for examples in CCP and XCP A2L file:

  • CCP A2L file:

    /begin SEED_KEY

        "rskCcpCal.dll" "rskCcpDaq.dll" "rskCcpPgm.dll"

    /end SEED_KEY

  • XCP A2L file:

        SEED_AND_KEY_EXTERNAL_FUNCTION "rskXcp.dll"

2. Start the server on Windows and select your seedkey DLL for every access type you want use on the RT system.

3. Create an ecumc.ini file in which you configure the port number (which is selected in the server) and the server IP address (displayed by the server) and copy this file to the root directory of the RT system. (using FTP)

The following shows an example of the ecumc.ini file content:

[SeedkeyServer]

name="10.89.1.107"

port=17444

(Example ecumc.ini file is in the built directory)

4. Use your ECUMC application

Stephen B

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors