下载源代码
git clone https://gitlab.com/etherlab.org/ethercat.git
cd ethercat
./bootstrap
配置
把r8169-4.4-ethercat.c和r8169-4.4-orig.c 复制重命名成 r8169-4.9-ethercat.c 和r8169-4.9-orig.c
./configure --prefix=/opt/etherlab --with-linux-dir=/usr/src/kernel/kernel-4.9 --enable-8139too=no --enable-e1000e=no --enable-generic=no --enable-r8169=yes
可能出现错误 去kernel源代码目录 执行make scripts
make -j 4
make modules
sudo make install
sudo make modules_install
sudo depmod
建立二进制链接
sudo ln -fs /opt/etherlab/etc/init.d/ethercat /etc/init.d/
sudo ln -fs /opt/etherlab/bin/ethercat /usr/local/bin/
sudo mkdir /etc/sysconfig
sudo ln -fs /opt/etherlab/etc/sysconfig/ethercat /etc/sysconfig/
sudo su
sudo echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules
sudo gedit /opt/etherlab/etc/ethercat.conf
sudo gedit /opt/etherlab/etc/sysconfig/ethercat
MASTER0_DEVICE=“”#写上你的eth0的mac
DEVICE_MODULES=“r8169”#这里写r8169
sudo gedit /opt/etherlab/etc/init.d/ethercat
在180行
if [ "${MODULE}" != "generic" ]; then
下面写
output2=$(lspci -v | grep r8168)
if [ -n "$output2" ]; then
echo 0000:02:00.0 > /sys/bus/pci/drivers/r8168/unbind
sleep 3
fi
# check for modules to replace
for MODULE in ${DEVICE_MODULES}; do
ECMODULE=ec_${MODULE}
if ! ${MODINFO} "${ECMODULE}" > /dev/null; then
continue # ec_* module not found
fi
if [ "${MODULE}" != "generic" ]; then
#添加部分---------------------------------------------------------start
output2=$(lspci -v | grep r8168)#添加部分
if [ -n "$output2" ]; then
echo 0000:02:00.0 > /sys/bus/pci/drivers/r8168/unbind
sleep 3
#添加部分---------------------------------------------------------end
fi
if ${LSMOD} | grep "^${MODULE} " > /dev/null; then
if ! ${RMMOD} "${MODULE}"; then
exit_fail
fi
fi
fi
if ! ${MODPROBE} ${MODPROBE_FLAGS} "${ECMODULE}"; then
if [ "${MODULE}" != "generic" ]; then
${MODPROBE} ${MODPROBE_FLAGS} "${MODULE}" # try to restore
fi
exit_fail
fi
done
exit_success
;;
在 /boot/extlinux/extlinux.config
APPEND 行后面 添加 isolcpus=3
类似如下:
APPEND ${cbootargs} quiet root=/dev/sda1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 isolcpus=3
把核心4(下标0 所以参数3)隔离出来
参考这个
把master进程绑定在核心4上面
/etc/init.d/ethercat start