About your next automotive-friendly prototype

Vincent Jordan
Oct 19, 2020 · 7 min read

You have cool project idea and you want to make a prototype more compatible with the automotive world? Here are some design choices for you…

Of course, some old-school hard real-time C code running bare metal on a microcontroller would always rekindle the heart of automotive engineers, but for quick prototyping it is definitely not the most convenient target. On the other hand, using a Linux-based target is unfortunately not real-time, but enables to leverage many open-source libraries.

This article uses inastitch as sample project to explain how each library was used in a practical example.

inastitch 3-camera hardware prototype in its 3D-printed case

Inastitch is a prototype for a digital rear-view mirror, by stitching 3 live video streams together into a single wider stream. Each camera is independent and connected to a network.

Logging with DLT

One design goal of using DLT is to have a trace which contains everything required to debug a system made of multiple ECUs. When a explanation will be needed for a specific behavior, the idea is to provide an expert with a single DLT trace file, which should contain everything needed, instead of asking always more traces.

In inastitch, following the DLT terminology, each camera is an ECU and each binary is a different APP. Contexts (CTX) follow this pattern:

  • APP:MAIN for general information such as binary version (i.e., git tag) and git hash to track the corresponding source code. Start-up parameters are also logged here.
  • APP:FRAM for summarized information about video frames. Single frame should not be traced because it is too high frequency and would overload the trace budget.
  • SYS:JOUR for syslog. The Linux system journal of the whole target is copied to DLT. It will help checking for side-effects coming from the Linux system.
DLT viewer showing live trace

Other interesting information to trace (which are not implemented in inastitch):

  • Overall and per-process CPU load and memory allocation. It will help to debug infinite loop and memory leak.

DLT open-source implementation is: https://github.com/GENIVI/dlt-daemon
License: Mozilla Public License (MPL 2.0).

Check DLT packets with WireShark

Decoding a DLT frame with WireShark

Note: dlt-daemon on each ECU will keep the trace in a local buffer until a dlt-client connects. There will not be any DLT communication to decode if no DLT viewer (for instance) is reading the trace. Likewise, the client can select different levels of tracing and only those traces will be sent over the network.

DLT and file transfer

After enabling the FileTransfer plug-in in DLT viewer, files can be extracted from the trace itself.

DLT viewer showing a file transfer

DLT and coredumps

See the DLT built parameter WITH_DLT_COREDUMPHANDLERand this wiki page.

TODO: enable DLT coredump handler in inastitch.

DLT injection

For a more automotive-friendly solution, I would rather suggest to enable those debug modes via a DLT injection. DLT communications do not work only one way (i.e., from dlt-daemon to dlt-client). Requests from the client (aka injections) can be forwarded to the application.

The advantage of this approach are:

  • No SSH access to the target is required
  • No need to restart the application to enable or disable the debug mode
  • Everything is logged in the trace if someone analyses it later

TODO: add some DLT injections in inastitch.

Remote control with SOME/IP

SOME/IP can work statically by defining all methods and events on all involved nodes, but this architecture is difficult to maintain and update.

One advantage of this framework is Service Discovery (aka SD). It makes it easier to design an interface that can be provided by applications from different suppliers which may run in different configurations.

In inastitch, SOME/IP was used to control camera settings. All three cameras subscribe to a remote event published by the stitcher board. When the requested camera setting is changed by the stitcher application, SOME/IP takes care of notifying all the subscribers.

SOME/IP open-source implementation is: https://github.com/GENIVI/vsomeip
License: Mozilla Public License (MPL 2.0).

Trace SOME/IP with DLT

Showing SOME/IP event with DLT viewer

Check SOME/IP packets with WireShark

Decoding a SOME/IP event with WireShark

Unlike DLT viewer, WireShark will decode SOME/IP requests and events.

Video stream with AVTP

Because AVB networks are used for communications which are neither video nor audio, new features were added and is referred as TSN. It stands for Time-Sensitive Network.

AVB/TSN networks are extensions of the standard Ethernet network added to add guarantees on the delivery of stream packets from one or more Talkers to one or more Listeners.

In inastitch, video frames of all three cameras are sent in a synchronized manner so that they can be stitched without buffering (i.e., without increased latency).

Check AVTP packets with WireShark

Decoding a UDP/AVTP with custom dissector on WireShark

Note: AVTP can be embedded onto Raw Ethernet. To save on implementation effort for inastitch, the streams are sent over UDP and IP.
This is an officially specified alternative.

Clock synchronization with gPTP

In inastitch, PTP synchronizes the Linux system clocks among the camera boards. This clock is then used as reference for frame alignment.

Check PTP packets with WireShark

Decoding PTP with WireShark

Note: PTP is configured in inastitch to run over UDP, but it can also run in Raw Ethernet.

Other considerations

Update with packages

In inastitch, both camera and stitcher applications are delivered as Debian packages. Generating such package is made easy with CMake’s CPack extension. This solution integrates well with the Raspberry PI OS.

If the OS is built from scratch (e.g., yocto linux recipes), another more lightweight choice is to use OPKG as package manager.

Open-source licenses

In inastitch, library dependencies are reduced to simple libraries with permissive licenses.

For example:

  • libboost with permissive Boost license
  • libturbojpeg with BSD license
  • libdlt and libvsomeip with MPL license
  • OpenCV with BSD license

Better code analysis with clang

Even if the final binary is always built with gcc, keeping the option to build with clang as well will bring the possibility to use Google Sanitizers such as MemorySanitizer (aka MSAN).

Systemd and watchdog

Build static libraries

Fun projects at Inatech

New ideas from engineers working at Inatech

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store