Kernel module that grants direct access to hardware, improving the performance of the LinkLayers, used in the EtherCAT Master Stack Software EC-Master and EtherCAT Network Simulation Software EC-Simulator.
It provides usermode access to:
- PCI configuration space
- Device IO memory
- Contiguous DMA memory
- Single device interrupt
The following diagram shows the architecture of EC-Master on Linux.
Atemsys can be built natively on the target device:
git clone https://github.com/acontis/atemsys.git
sudo apt-get install linux-headers-$(uname -r)
ℹ️ If kernel headers cannot be installed, see the cross-compiling section below.
cd atemsys
make modules
sudo insmod atemsys.ko
The atemsys kernel module can also be cross compiled for a target device.
To do this, the additional parameters ARCH=
, CROSS_COMPILE=
and KERNELDIR=
must be passed to make
e.g.:
- ARM 32 Bit:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KERNELDIR=<path to target kernel dir>
- ARM 64 Bit:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- KERNELDIR=<path to target kernel dir>
- Clone with git:
git clone -b v4.4.189 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
- Download from kernel.org: https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.4.189.tar.gz
⚠️ Warning: The kernel version and source code must exactly match that installed on the target. Custom kernels with patched sources are often used in embedded devices. Contact the manufacturer for the appropriate sources for your device.
zcat config.gz > linux/.config
cd linux
make ARCH=<...> CROSS_COMPILE=<...> oldconfig
make ARCH=<...> CROSS_COMPILE=<...> prepare
make ARCH=<...> CROSS_COMPILE=<...> modules_prepare
cd ..
git clone https://github.com/acontis/atemsys.git
cd atemsys
make ARCH=<...> CROSS_COMPILE=<...> KERNELDIR=<path to target kernel dir> modules
sudo insmod atemsys.ko
There are recipes for creating atemsys with Yocto. Further information can be found here https://github.com/acontis/meta-acontis.
Atemsys as device tree based platform device driver for the Ethernet MAC can handle several upcoming issues:
- Latest Linux versions bring more complex power saving behavior. To solve this a Linux driver is necessary to claim the same as the native driver from the Linux power-related management systems.
- Some PHY configurations are currently not supported by the EC-Master. As Linux driver the atemsys can use the corresponding Linux PHY driver.
- Systems with 2 Ethernet ports and a shared Mdio bus can be separated more easily between Linux and the EC-Master. The Ethernet port that provides the Mdio bus should be assigned to Linux.
The device tree file can be customized before compiling the kernel and modules at <kernel sources>/arch/<cpu architecture>/boot/dts
.
On the running system the compiled device tree file can be generally found next to the kernel image, which is normally in the /boot
folder of the system. The *.dtb
-file can be converted with the device tree compiler
> dtc -I dtb -O dts -f <file name>.dtb -o <file name>.dts
and recompiled with
> dtc -I dts -O dtb -f <file name>.dts -o <file name>.dtb
- Assign the Ethernet device tree node to the atemsys device driver by assigning the value
atemsys
to thecompatible
property. It is also possible to addatemsys
to the existingcompatible
list - Add the properties
atemsys-Ident
andatemsys-Instance
.atemsys-Ident
for the name of the link layeratemsys-Instance
with the instance number that is to be used by EC-Master.- See also
EC_LINK_PARMS_IDENT_*
inEcLink.h
- Remove all interrupt properties, like
interrupt-parent
andinterrupts
, in theethernet-phy
sub-node. - To support PHY reset via a GPIO pin add (with your values)
- atemsys-phy-reset-gpios = <0x4a 0x05 0x01>;
- atemsys-phy-reset-duration = <0x0a>;
- [atemsys-phy-reset-post-delay = <0x64>;]
- [atemsys-phy-reset-active-high = <0x1>;]]
ℹ️ More example device trees for different platforms can be found in the Wiki.
Ethernet device node for FslFec on Freescale/NXP i.MX6DL
ethernet@02188000 {
compatible = "atemsys";
atemsys-Ident = "FslFec";
atemsys-Instance = <0x1>;
reg = <0x2188000 0x4000>;
interrupts-extended = <0x1 0x0 0x76 0x4 0x1 0x0 0x77 0x4>;
clocks = <0x2 0x75 0x2 0x75 0x2 0xbe>;
clock-names = "ipg", "ahb", "ptp";
stop-mode = <0x4 0x34 0x1b>;
fsl,wakeup_irq = <0x0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0x3e>;
phy-mode = "rmii";
phy-handle = <0x3f>;
mdio {
#address-cells = <0x1>;
#size-cells = <0x0>;
ethernet-phy@0 {
reg = <0x0>;
micrel,led-mode = <0x0>;
linux,phandle = <0x3f>;
phandle = <0x3f>;
};
};
};