EtherCAT MainDevice Software on Linux
- EtherCAT and Linux
- acontis EC-Master EtherCAT MainDevice stack for Linux
- Architecture 1: Linux Network Driver based on RAW sockets (SOCK_RAW)
- Architecture 2: acontis Real-time Driver
- Architecture 3: acontis Real-time Driver with Linux Device Support
- Architecture 4: Linux Network Driver based on XDP sockets (AF_XDP)
- Architecture 5: Linux Network Driver based DPDK (Data Plane Development Kit)
- Real-time Ethernet Drivers (Link Layers)
- Kernel versions and distributions
- More Information
EtherCAT and Linux
Today, EtherCAT has become one of the world's most popular real-time Ethernet solutions. The EtherCAT Technology Group (ETG) is responsible for keeping the EtherCAT technology open to all potential users. The ETG is the fieldbus organization with the largest number of members in the world, and the complete list of members is available online.
While on x86 PCs, the dominating operating system is still Microsoft© Windows©, the operating systems used in embedded systems are much more numerous and varied. Over the past several years, as high-end ARM-based microcontrollers have become increasingly complex, this diversification has been significantly reduced, and today Real-time Linux is by far the most popular real-time operating system (RTOS) for such embedded MCUs. See also how the operating system usage has changed for acontis' EtherCAT customers here.
Given the trends, running an EtherCAT MainDevice Software on Linux has become increasingly essential in many applications. However, Linux presents some unique challenges, including performance optimizations and GPL (GNU General Public License) compliance requirements when using patented EtherCAT technology.
acontis EC-Master EtherCAT MainDevice stack for Linux
The acontis EtherCAT MainDevice stack software architecture has been approved by the OSADL (Open Source Automation Development Lab) as conforming to GPL rules given that all software runs in user space, avoiding patent conflicts. Combined with real-time user mode drivers, this architecture guarantees the highest possible deterministic real-time performance.
The EtherCAT MainDevice Software EC-Master supports Linux on x86, x64, ARM, AArch64/ARM64, and PowerPC architectures. It supports many different CPUs and Ethernet controllers, providing out-of-the-box Linux EtherCAT solutions for many different platforms.
Due to its scalability and modular design, EC-Master can run on low-end systems ranging from a Cortex-M7 microcontroller to high-end Intel® Core™ i7 CPUs.
Designed to run entirely in Linux user space, EC-Master enables fast and convenient development while remaining GPL-compilant. To achieve EtherCAT's extremely fast, high-speed update rates (short cycle times) that it is known for, the implementation must not use any blocking kernel functions (APIs) in the cyclic part.
Architecture 1: Linux Network Driver based on RAW sockets (SOCK_RAW)
In this approach, the EC-Master stack communicates with the SubDevices by sending and receiving EtherCAT frames using a standard Ethernet network adapter (MAC). The Linux operating system includes network drivers for the different adapters made by different manufacturers. These Linux network drivers can be used by an application like the EC-Master stack via an abstracted independent raw socket interface called SOCK_RAW
, to send and receive frames. However, in this implementation, the performance may be poor, and real-time constraints are typically not possible to maintain because the Linux network stack inclusion and driver code are not optimized for high-performance cyclical operations.
Since the raw socket interface is broadly available with nearly every Linux distribution’s kernel, the pre-compiled demo application included with EC-Master (EcMasterDemo
) supports SOCK_RAW
and can, therefore, be used to evaluate the EC-Master library‘s general functionality without compiling any files for the host system.
However, for SubDevices requiring strict timing (for example, those using Distributed Clocks like drives), the raw socket option is most likely unable to send and receive frames fast enough, and the EtherCAT devices will not operate correctly. Therefore, SOCK_RAW
should only be used for initial evaluation purposes and be replaced with the acontis real-time driver, as explained below.
Architecture 2: acontis Real-time Driver
The acontis Real-time Driver replaces the standard Linux Ethernet network adapter (MAC) driver for real-time EtherCAT usage. The driver runs in user space and handles the MAC directly for high-performance cyclic operation. The driver requires direct access to the MAC, which is made possible by the kernel module called atemsys,
which is available under GPL. The atemsys
kernel module must be compiled to match the running Linux kernel. To compile the kernel module, refer to the available methods in the Linux distribution‘s documentation. Additionally, acontis includes a build recipe for Yocto Linux.
The Real-time Driver is not available under GPL and must be licensed from acontis. It needs the atemsys
kernel module loaded on the Linux target to be able to run. Once this is in place, the driver is granted access to the MAC hardware, and the driver can operate very quickly on sending and receiving frames because it completely bypasses the Linux network stack. Note that it is not possible to use the standard Linux network adapter driver at the same time on the same interface as the acontis Real-time Driver. It is necessary to unbind the network adapter instance by removing the driver from the system and unbinding the instance using the virtual sys-fs
, or by modifying the Linux Device Tree if using an embedded system.
The atemsys
kernel module is delivered with EC-Master and is updated when EC-Master is updated.
Architecture 3: acontis Real-time Driver with Linux Device Support
The Linux operating system provides drivers for the most common Ethernet controllers and the related physical transceivers (PHY). A dedicated kernel driver handles the manufacturer-specific PHY circuit.
To make use of this infrastructure, the acontis kernel module atemsys has to be included in the Linux device tree as an official driver for the Ethernet controller. As a result, atemsys can interact with Linux drivers.
Depending on the hardware architecture, atemsys can grant access to the MDIO bus to the Linux drivers, or request MDIO operations by Linux drivers.
The PHY “OS Driver” functionality is configured exclusively through the Linux device tree and doesn’t require additional configuration at the application level.
Architecture 4: Linux Network Driver based on XDP sockets (AF_XDP)
In this approach, the EC-Master stack communicates with the SubDevices by sending and receiving EtherCAT frames via the Linux XDP kernel driver that controls the Ethernet network adapter (MAC).
The Linux kernel includes different network drivers for different adapter types. The Linux network driver can be used by means of an abstracted network adapter type independent interface called AF_XDP to send and receive frames. The XDP sockets interface has a better performance compared to the RAW sockets, but the Linux operating system must be designed for it and configured accordingly:
- The kernel must be at least V5.3 or newer
- The network driver must have XDP support (DRV mode) and be up-to-date
- CONFIG_XDP_SOCKETS must be enabled in the kernel configuration
- Required components: libxdp and libbpf
Architecture 5: Linux Network Driver based on DPDK (Data Plane Development Kit)
In this approach, the EC-Master stack communicates with the SubDevices by sending and receiving EtherCAT frames via the Data Plane Development Kit (DPDK) that controls the Ethernet network adapter (MAC). Data Plane Development Kit (DPDK) is a Linux Foundation project that consists of libraries to accelerate packet processing workloads running on a wide variety of CPU architectures.
The acontis real-time Ethernet driver emlldpdk uses DPDK libraries with an optimized packet processing path for fast transmission of EtherCAT frames. The library librte_eal provides the foundational API for DPDK, facilitating access to hardware resources such as memory, timers, and logs and is mainly used during initialization. The library librte_mbuf handles packet buffers that are crucial for packet transmission and reception. The library librte_ethdev offers an API for configuring and querying Ethernet devices. It supports various operations, including sending and receiving packets.
The system requirements and the kernel configuration for using DPDK on Linux are available here. The kernel must be at least V5.1 or newer.
DPDK does not use the standard Linux Ethernet drivers but provides its own drivers for a variety of different Ethernet controllers, including Intel Gigabit, NXP ENETFEC, etc. The complete list is available here.
Detailed instructions for using the real-time Ethernet driver emlldpdk can be found in the user documentation.
Real-time Ethernet Drivers (Link Layers)
- Linux network driver (emllSockRaw): x86, x64, ARM, AArch64, PPC, RISCV
- Intel Pro/100 (emllI8255x): x86
- Intel Pro/1000 (emllI8254x): x86, x64, ARM, AArch64
- Intel Cyclone V (emllDW3504): ARM
- Realtek 100MBit (emllRTL8139): x86
- Realtek Gigabit (emllRTL8169): x86, x64, ARM, AArch64
- Texas Instruments AM33xx, AM43xx, AM57xx (emllCPSW): ARM
- Texas Instruments AM33xx, AM57xx (emllICSS): ARM
- NXP TSEC/eTSEC controller, LS1021A (emllETSEC): ARM, PPC
- NXP i.MX6, i.MX7, i.MX8 (emllFslFec): ARM
- Renesas RZ/G1E (emllSHEth): ARM
- Xilinx Zynq-7000 , UltraScale (emllGEM): ARM, AArch64, RISCV
- Beckhoff CCAT (emllCCAT): x86, x64, ARM
- Nvidia, Jetson TX2 (emllI8254x): AArch64
- STMicroelectronics STM32MP1 (emllDW3504): ARM
Kernel versions and distributions
The EC-Master can be used with any recent Linux distribution supporting custom Kernel module compilation like Ubuntu, Debian, etc. The Kernel Module atemsys handles legacy Kernel versions down to 2.6.18. Motion control and the usage of drives typically need real-time support, which must be supported by the hardware and Kernel (CONFIG_PREEMPT_RT or Xenomai).
More Information
- EC-Master Main Page
- Features Overview
- Linux Kernel Module atemsys
- EC-Master vs Open Source
- Data sheets and evaluation versions are available in the download area.