FlexRay Protocol Stack for Linux

Patches for recent Linux Kernels to add a FlexRay protocol stack to Linux.

All available languages for this article:

FlexRay Protocol Stack for Linux [en]

Categories:

FlexRay 4 Linux


Introduction

This page describes what the FlexRay4Linux patches do, how they work and how to use them. The technical background of FlexRay will not be discussed here, see Bachelor Thesis: Implementation of a FlexRay Communication Interface for Linux for details.

What the patches do

These patches will add a FlexRay protocol family to the Linux kernel, enabling the user to communicate over FlexRay using the simple and well-established Socket-API. This approach is very similar to the SocketCAN implementation which is used to enable CAN-communication for Linux.

Realtime

TODO

Supported Hardware

Unfortunately, there is almost no hardware that is supported at the moment. Only a device driver for a limited "homebrew" Serial to FlexRay interface is currently using this framework.

There exists several commercially available FlexRay interfaces that also include proprietary, closed-source Linux drivers (TZM and Vector). Support for these devices would be nice, but they are too expensive for me to afford (donations are always welcome …).

How the patch works

The patch registers protocol numbers needed for the FlexRay subsystem. This patch cannot be built as a "module" but needs to be applied to the Kernel source tree, before building the Kernel, because it changes several core components of Linux.

The second component is not distrubuted as a patch but as the source-code of a couple of modules. Currently there are two modules that can be build, for more information read on:

  • flexray.ko: The PF_FLEXRAY protocol family
  • flexray_raw.ko: Raw FlexRay sockets

Numbers

flexray_numbers.patch adds the following to core Kernel components:

  • Protocol family
  • Ethernet protocol ID,
  • ARP protocol identifier
  • Line discipline for serial FlexRay adapters

FlexRay Protocol Family

The FlexRay Protocol Family PF_FLEXRAY is used to handle FlexRay devices as network devices.

FlexRay Raw sockets

Raw FlexRay sockets can be used to send and receive on the FlexRay cluster using well known socket calls such as recv() and send(). FlexRay frames transferred over raw sockets also include additional information, such as contents of status registers which can be used to effectively debug a FlexRay cluster.

Using the patch

As stated before, after the numbers-patch has been applied, the whole Kernel needs to be rebuilt, because core components of Linux are changed. The rest can also be built afterwards as modules.

How to apply:

$ cd linux-2.6.xx/
$ patch -p1 < /tmp/flexray_numbers_2.6.xx.patch

Successful patching looks like this:

patching file include/linux/if_arp.h
patching file include/linux/if_ether.h
patching file include/linux/socket.h
patching file include/linux/tty.h
patching file net/core/sock.c

After the kernel has been rebuilt the modules can be built as follows:

$ tar xvfz flexray4linux_2.6.xx.tar.gz
$ cd flexray4linux_2.6.xx/
$ make
$ make install

Output of a successful build:

make -C /usr/src/linux-2.6.37.2/ M=/tmp/flexray4linux_2.6.37 modules
make[1]: Entering directory `/usr/src/linux-2.6.37.2'
  CC [M]  /tmp/flexray4linux_2.6.37/net/flexray/raw.o
  CC [M]  /tmp/flexray4linux_2.6.37/net/flexray/af_flexray.o
  LD [M]  /tmp/flexray4linux_2.6.37/flexray.o
  LD [M]  /tmp/flexray4linux_2.6.37/flexray-raw.o
  Building modules, stage 2.
  MODPOST 2 modules
  CC      /tmp/flexray4linux_2.6.37/flexray-raw.mod.o
  LD [M]  /tmp/flexray4linux_2.6.37/flexray-raw.ko
  CC      /tmp/flexray4linux_2.6.37/flexray.mod.o
  LD [M]  /tmp/flexray4linux_2.6.37/flexray.ko
make[1]: Leaving directory `/usr/src/linux-2.6.37.2'

make -C /usr/src/linux-2.6.37.2/ M=/tmp/flexray4linux_2.6.37 modules_install
make[1]: Entering directory `/usr/src/linux-2.6.37.2'
  INSTALL /tmp/flexray4linux_2.6.37/flexray-raw.ko
  INSTALL /tmp/flexray4linux_2.6.37/flexray.ko
  DEPMOD  2.6.37.2
make[1]: Leaving directory `/usr/src/linux-2.6.37.2'

Using the FlexRay Protocol

The FlexRay Protocol family and the Raw Sockets can be loaded using:

# modprobe flexray
# modprobe flexray_raw

If successfull loaded, dmesg should contain something like this:

[  326.601809] flexray: Initializing FlexRay4Linux protocol stack
[  326.601816] NET: Registered protocol family 38
[  331.464105] flexray-raw: raw protocol initializing
[  331.464111] flexray: protocol 1 successfully registered

For examples of some userspace applications using RAW FlexRay sockets, please see Bachelor Thesis: Implementation of a FlexRay Communication Interface for Linux.

Download

Kernel-Patches

FlexRay Protocol Family

  • Please note: this does not include the drivers for attaching a FlexRay controller over a serial link. This has been mentioned in the thesis, but is pretty much useless to anybody.

 
     
© 1999 - 2018 ScriptKiller
Impressum | Sitemap
Bei der Nutzung dieser Webseite werden IP-Adressen und Informationen über verwendete Browser in Logfiles gespeichert. Mit der Nutzung erkennen Sie diese Tatsache an.