×

Happy to Help!

This website doesn't store cookies. Enjoy the experience, without worrying about your data!

Great, thanks!

How to Integrate J1939 Software Stack With an Automotive ECU: A Step-by-Step Tutorial

  • 0

How to Integrate J1939 Software Stack With an Automotive ECU: A Step-by-Step Tutorial

If you are an embedded software engineer (or an enthusiast) ready to kick start your career in the exciting automotive ECU development space; this tutorial can serve as a high-level hands-on of J1939 stack integration with automotive ECU and/or tooling applications

Why J1939 stack integration in automotive ECU applications:

Before we start with our J1939 tutorial and address the step-by-step process involved behind the J1939 software stack integration, let us first look at the significance of J1939 integration.

  • J1939 software stack is compliant with SAE J1939 standard.
  • This software standard, defined by Society of Automotive Engineers (SAE), has been designed to ensure that Electronic Control Units (ECU) (manufactured by different automotive suppliers) follow a standard format to communicate with each other.
  • This standardization ensures interoperability between control units from different suppliers along with other benefits
  • J1939 software stack, in particular, supports communication and diagnostics services over CAN bus for commercial vehicle applications

 

Decoding J1939 software stack integration process:

In the system architecture diagram shown below, we observe that:

  • The J1939 stack is the middleware (middle layer) software
  • J1939 software stack is integrated between the Low Level Device Drivers (LLDs’) and automotive application.
  • In addition to this, there is also a J1939 based Bootloader software (part of the J1939 stack) and a Scheduler software, that are part of the ECU software architecture

J1939 based Bootloader software
 

Following are the steps involved in J1939 software stack integration:

Step 1: Development of APIs’ (and device drivers) for integration with target platform and application layer:

  • The Low-Level Device Driver layer consists of all the device driver software code that facilitate access to the underlying hardware platform (MCU, I/O ports, Timer) and other integrated peripherals
  • To enable communication of this Low-Level Device Driver layer with the Middleware Software (aka J1939 stack), an API software is designed
  • Such an API is designed to leverage following advantages:
    • The customer (an Automotive OEM/Supplier/Tooling vendor) may choose to provide only limited or no access of the low-level device drivers to the third party J1939 stack vendor. (Reason: This helps to safe-guard the mission critical data and architecture.)
    • In such scenarios, the software services vendor develops this API (as part of the J1939 package) which can be integrated with the low-level layer by the customer’s in-house software development team.

    • Since low-level device driver programming is more complicated, the higher level interface, facilitated by an API, makes configuration, customization and/or modification much simpler for the software developers
  • An API is also designed to enable integration with the target application layer of the ECU/Tooling system

 

Step 2: Configuration of the Middleware layer (J1939 stack)

  • There are several off-the-shelf J1939 software solutions available in the market.
  • Automotive companies, over the years, have shown confidence in such pre-tested stack solutions. Such ready-to-deploy J1939 stacks add value by saving development time and cost
  • However, to integrate this stack solution, the vendor provides support for the configuration of Application (J1939 – 71) and Diagnostics (J1939 – 73) layers
  • The level of configuration and customization required, depends on the business needs of the end-user application
  • Configuration of J1939/71 Layer: This layer is configured to define Parameter Group Numbers (PGNs), Suspect Parameter Numbers (SPNs) with the Scaling, Limits and Parameter Offset Size.
  • Configuration of J1939/73 Layer: This layer is configured to define Diagnostic Trouble Codes (DTC), Diagnostic Parameter Group Definitions and Diagnostic Messages (DM)

 

Pro-tip: This blog tells you how to test the quality of J1939 source code before integrating it with your ECU application.
 

Step 3: Compilation and Porting of the code on Target Hardware Platform

The general steps for compilation of source code into an executable file, are as follows:

  • Pre-processing: In this step the source code file is processed and transformed for compilation.
  • For an instance, if the code is written in C or C++ then the source code file will be in .c or .cpp format. The output of the pre-processing stage is .i or .ii file format.

  • Compilation: The output of the compilation stage is a file containing assembly language code to be interpreted by the assembler.
  • Assemble: In this stage the input file of assembly language code is converted into machine language file.
  • Linking: The linking phase of compilation process is responsible for producing an executable file.

To summarise, using an Integrated Development Environment (IDE),the source code is converted into an executable format. The compiled output files which are in .hex and .s19 format can be ported directly on the target Hardware platform.
 
Other optional steps involved for the integration of J1939 software stack:

  • J1939 Bootloader software development:
  • The Bootloader software is required for re-programming of the Automotive ECU. The bootloader functionality is a part of the J1939 software stack.

    Depending on the automotive application requirements, the J1939 bootloader sequence can be configured.

    Also, the bootloader logic is implemented separately for both boot and application areas.

  • Scheduler software development for non-RTOS systems:
  • In simple terms, a scheduler helps the embedded system to multitask in an organized way.

    Scheduling of tasks is imperative, due to increasing complexity of functionality in the layered system architecture.

    The scheduler software can be configured in two ways:

    • Based on the required time constraints set upon each tasks
    • Based on the number of tasks that have to be configured within a particular timestamp.

 

Challenges you may face during integration of J1939 Software Stack:

As you may have realized, integration of J1939 stack involves ensuring compatibility between three layers: Low-Level Device Drivers, J1939 stack layer and the Application Layer

The challenges during such a J1939 integration project are encountered due to faults at or limited access to the device drivers layer and/or application layer of the customer devices

If your J1939 stack source code is robust, pre-tested and has been proven by integrations across different platforms for different projects, then it is unlikely that you will face challenges due to faults or errors in the middleware software layer

Following are some suggestions to resolve a road-block during a J1939 software integration project:

  • When a specific software module in the LLD is faulty:
  • Fault may occur during J1939 software stack integration with the LLD layer, due to reason such as improper functioning of CAN module.

    In such a scenario, the error can be handled by carrying out the RCA (Root cause analysis).

    In cases where the customer shares limited access or no access to the LLD layer, the concerned teams from both the customer and vendor’s organization need to collaborate to resolve the issue.

  • When the application layer sequence is faulty:
  • The end user application can create a hurdle if it does not function properly.

    For example,if a data identifier does not have a proper sequence or format then, the particular diagnostic instruction will not be interpreted accurately by the ECU.

    If the application is developed by the customer, it is recommended to share the legacy library with the team responsible for integration of J1939 stack.

    This legacy library has details of the interface requirement of the application. This knowledge can help a software development team to resolve critical issues.

For more details or queries regarding integration of J1939 solution, please get in touch with our experienced team of automotive software developers


  • 0

What is J1939 software stack?

Learn about the layered architecture and diagnostic trouble codes (DTC)

What is SAE J1939 – an introduction?

SAE J1939 is a software standard defined by Society of Automotive Engineers (SAE). This software standard has been designed to ensure that Electronic Control Units (ECU) manufactured by different automotive suppliers are able to communicate with each other within an in-vehicle network.

SAE J1939 standard is defined for applications in commercial vehicles for CAN (Controller Area Network) bus.

What is J1939 stack?

J1939 stack is an embedded software stack with layered architecture, compliant with SAE J1939 standard.

This pre-tested software stack, designed by our embedded automotive engineers, can be easily integrated with commercial vehicle applications for diagnostics and communication services.

Our product engineering team has also developed J1939 bootloader for automotive ECU reprogramming services.

J1939 layered architecture specifications – as defined by SAE

The Society of Engineers (SAE) has defined all the functions supported by different layers of the J1939 software stack.

.
J1939 Stack
.

Following are the details:

  • J1939/21 – Data Link/ Transport Layer: This layer defines the Message/Frame Format, Protocol Data Unit (PDU) Formats, Message Type, Message Priority, Bus Access, Arbitration, Error Detection, PGNs and Transport Protocol Functions
  • J1939/81 – Network Management Layer: This layer defines Name ECU, Address, Network Management Procedure, Network Error Management, Address Claim and ECU Initialization procedures
  • J1939/71 – Vehicle Application Layer: This layer defines Parameter Group Numbers (PGNs), Suspect Parameter Numbers (SPNs) with the Scaling, Limits and Parameter Offset Size. 
  • J1939/73 – Application Layer for Diagnostics services: This layer defines Diagnostic Trouble Codes (DTC), Diagnostic Parameter Group Definitions and Diagnostic Messages (DM)
    (Source: SAE)

What is Diagnostic Trouble Code (DTC) in J1939 stack?

When certain failure occurs in an automotive ECU, it is noted in the form of a Diagnostic Trouble Code (DTC), also known as Fault Code. DTCs’ are defined by SAE J1939 standard.

Diagnostic Trouble Code (DTC) has the following fields:

.
DTC In J1939
.

Where:

SPN is Suspect Parameter Number (19 bits)

FMI is Failure Mode Identifier (5 bits)

OC is Occurrence Count (7 bits)

CM is SPN Conversion Method (1 bit).

With help of DTC one can understand failure that has been reported.

For Example:

SPN = 91 Suspect parameter is accelerator pedal position

FMI = 3 Failure mode is identified as voltage above normal

OC = 9 Occurrence count indicates trouble has occurred 9 times

CM = 0 Conversion Method is Intel.

What are Diagnostic Messages (DM) in J1939 software stack?

Diagnostic Messages are messages which give information about the health of the system, intimating about the malfunctions which have currently occurred in the automotive system.

Following are the examples of some of the Diagnostic Messages (DM) in J1939:

  • DM1 Message (Active Diagnostic Trouble Codes):

Diagnostic Message 1 (DM1) reports active diagnostic codes that are preceded by the diagnostic lamp status in the message byte. It reports diagnostic condition of the automotive ECU over the In-Vehicle Network with Suspect Parameter Number, Failure Mode Identifier and Occurrence Count.

  • DM2 Message (Previously Active Diagnostic Trouble Codes):

Diagnostic Message 2 (DM2) reports previously active diagnostic codes that are preceded by the diagnostic lamp status in the message byte. It reports diagnostic condition of the Automotive ECU over the in-vehicle network with same details.

  • DM3 Message (Diagnostics Data Clear):

This message indicates that all the Diagnostic information pertaining to the previously active trouble codes should be cleared or non-active trouble codes should be reset. This ensures that the active trouble codes, which are present in ECU, are not impacted.

Get in touch with our J1939 stack development team:

For any queries regarding the J1939 software stack or automotive ECU and tooling applications, get in touch with our team. Send us your Queries

Know more about our J1939 stack solutions and services here