Ubuntu14.04搭建igh
0,安装依赖
sudo apt-get install autoconf autogen libtool
1,下载ethercat
cd XenomaiIgh
https://github.com/ribalda/ethercat
git clone https://github.com/ribalda/ethercat
2,配置
cd ethercat
./bootstrap //如果没有configure文件则执行此语句
./configure --with-linux-dir=/usr/src/linux-headers-4.9.38-xenomai-3.0.5 --with-module-dir=/lib/modules/4.9.38-xenomai-3.0.5 --enable-generic=yes --enable-8139too=yes --enable-e1000=yes --enable-e1000e=yes --enable-r8169=yes --enable-rtdm=yes --enable-cycles=yes --enable-hrtimer=yes --with-xenomai-dir=/usr/xenomai
./configure --with-linux-dir=/usr/src/linux-headers-4.9.38-xenomai-3.0.5 --with-module-dir=/lib/modules/4.9.38-xenomai-3.0.5 --enable-generic=yes --enable-8139too=yes --enable-e1000=yes --enable-e1000e=yes --enable-r8169=yes --enable-rtdm=yes --enable-cycles=yes --enable-hrtimer=yes --with-xenomai-dir=/usr/xenomai
3,编译安装
make #编译用户态的库
make modules #编译ethercat驱动
sudo su #登录root用户
make install #安装库文件
make modules_install #安装驱动
安装目录在/opt/etherlab或者/usr/local,安装完了可以打开看看
4,配置项
cd /etc
sudo mkdir sysconfig
sudo cp /usr/local/etherlab/etc/sysconfig/ethercat /etc/sysconfig
sudo cp /usr/local/etherlab/etc/init.d/ethercat /etc/init.d
sudo cp /usr/local/etherlab/etc/ethercat.conf /etc
5,配置网卡的mac地址
ifconfig
hh@hh:~$ ifconfig eth0 Link encap:Ethernet HWaddr
00:e0:4c:c2:08:15
inet6 addr: fe80::2e0:4cff:fec2:815/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:227 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:42692 (42.6 KB)
sudo gedit /etc/ethercat.conf
sudo gedit /etc/sysconfig/ethercat
在上面2个文件中的MASTER0_DEVICE=后添加你的网卡的mac地址
MASTER0_DEVICE=“00:e0:4c:c2:08:15”, DEVICE_MODULES=添加"generic"或r8169形如DEVICE_MODULES="generic"
sudo depmod
6,运行
sudo /etc/init.d/ethercat start #启动ethercat
sudo /etc/init.d/ethercat stop #停止ethercat
sudo /etc/init.d/ethercat restart #重新启动ethercat
7,配置用户态库和依赖
7.1修改ethercat设备权限
cd /etc/udev/rules.d #进入udev rules文件夹
sudo gedit 99-ethercat.rules #新建一个ethercat的rule文件
然后在该文件中添加
KERNEL=="EtherCAT[0-9]", MODE="0777"
7.2,配置实时权限
sudo gedit /etc/security/limits.conf
然后在该文件中添加
<username> hard rtprio 99