参考
硬件:树莓派4b
系统:Ubnutu22.04 Desktop
内核版本:
uname -a
Linux pi 5.15.0-1015-raspi #17-Ubuntu SMP PREEMPT Mon Sep 12 13:14:51 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
安装参考官方仓库安装说明
仓库地址:https://gitlab.com/etherlab.org/ethercat
下载仓库
sudo apt install git
git clone https://gitlab.com/etherlab.org/ethercat.git
cd ethercat
// 切换稳定分支
git checkout stable-1.5
编译安装
参考仓库内的 INSTALL 文件
sudo apt install automake libtool build-essential
cd ethercat
./bootstrap
autoupdate
./bootstrap
./configure --enable-8139too=no
// 如果提示找不到linux头文件,安装头文件
// sudo apt install linux-headers-5.15.0-1015-raspi
// 如果是自己编译的内核,如实时内核,linux头文件需要和内核一致,可将linux源码目录放到家目录或自行指定源码目录
make all modules
sudo make modules_insatll install
sudo depmod
sudo ln -s /usr/local/etc/init.d/ethercat /etc/init.d/ethercat
sudo mkdir -p /etc/sysconfig
sudo cp /usr/local/etc/sysconfig/ethercat /etc/sysconfig/
sudo vim /etc/sysconfig/ethercat
// 填写 MASTER0_DEVICE="MAC地址" (ifconfig命令或者ip addr命令查看) 比如:11:22:33:aa:bb:cc
// 填写 DEVICE_MODULES="generic"
命令行测试
将主站运行起来
sudo /etc/init.d/ethercat start
提示Starting EtherCAT master 1.5.2 done说明运行成功
运行命令行工具
ethercat
// 查看主站信息
sudo ethercat master
错误处理
configure.ac:60: error: possibly undefined macro: AC_PROG_LIBTOOL
sudo apt install libtool