补丁
-
下载 linux source code and patch file: linux-4.4.113 patch-4.4.113-rt128
http://mirrors.163.com/kernel/v4.x/
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.4/incr/ -
Patch and Compile
cd /linux-4.4.113
patch -p1 < patch-4.4.113-rt128.patch
cp /boot/config-4.4.0-31-generic ./config
sudo apt-get install kernel-package
sudo apt-get install libncurses5-dev
sudo apt-get install libssl-dev
make menuconfig
- setup
General setup => Timers subsystem => Timer tick handling (Full dynaticks system tickless)
processor type and features => preemption model (fully preemptible kernel RT)
fakeroot make-kpkg --initrd --append-to-version -4.4.113-rt kernel_image kernel_headers -j4
- Install
sudo dpkg -i linux-header* linux-image*
sudo update-grub
- Test
sudo apt install rt-tests
sudo cyclictest -t 5 -p 80
T: 0 序号为0的线程
P: 0 线程优先级为80
C: 9397 计数器。线程的时间间隔每达到一次,计数器加1
I: 1000 时间间隔为1000微秒(us)
Min: 最小延时(us)
Act: 最近一次的延时(us)
Avg:平均延时(us)
Max: 最大延时(us)
Etherlib
-
download
https://etherlab.org/en/ethercat/ , 新的版本在5.3.0-53-generic核上已经可以安装,不过补丁的方式没有试过。 -
Install
cd /ethercat-1.5.2
chmod 777 configure
./configure --enable-cycles --enable-hrtimer --enable-8139too=no --prefix=/opt/etherlab
make all modules
sudo make modules_install 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 -i
echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules
- Configuration of network
gedit /etc/sysconfig/ethercat
modify the Hw_address: MASTER0_DEVICE=”00:xx:xx:xx:5c:xx”
modify Hw_driver: DEVICE_MODULES=”generic”
- Test
sudo /etc/init.d/ethercat start
sudo ethercat slaves