ethercat
注意:使用 EtherCAT 协议需要系统版本 V4.0.4及以上。
使用前网络配置
注意:EtherCAT 协议与以太网协议互斥,无法共存,开发板默认使用 eth0 作为 DHCP 管理接口,如果用户想使用 eth0 作为 EtherCAT 网络接口,可以使用下面的几种方案进行网络配置,点击查看使用eth0作为ethercat主站。
特别注意:RDK S100默认使用 eth0作为 DHCP 网口,如果用户原本使用 eth0作为 SSH 连接开发板的主要模式,在使用 eth0作为 EtherCAT 主站后,需要配置 eth1为 DHCP,或配置用户本地网络可用的固定 IP 作为 SSH 连接方式,并且将连接的网线改接到 eth1网口。 点击查看使用 eth0 作为主站时的 eth1 网络配置方案。
注意:EtherCAT 协议与以太网协议互斥,无法共存,开发板默认使用 eth0 作为 DHCP 管理接口,如果用户想使用 eth0 作为 EtherCAT 网络接口,可以使用下面的几种方案进行网络配置,点击查看使用eth0作为ethercat主站。
特别注意:RDK S600默认使用 eth0作为 DHCP 网口,如果用户原本使用 eth0作为 SSH 连接开发板的主要模式,在使用 eth0作为 EtherCAT 主站后,需要配置 eth1为 DHCP,或配置用户本地网络可用的固定 IP 作为 SSH 连接方式,并且将连接的网线改接到 eth1网口。 点击查看使用 eth0 作为主站时的 eth1 网络配置方案。
EtherCAT 使用指南
- 确认硬件连接:
- 从站已上电。
- 网线已接到你选择的主站网口(
eth0或eth1)。
- 选择主站网口(在选择主站端口前,请仔细阅读 使用前网络配置中的注意事项:
- 使用
eth0作为主站:看 使用 eth0 作为 EtherCAT 主站。 - 使用
eth1作为主站:看 使用 eth1 作为 EtherCAT 主站。
- 使用
- 启动 EtherCAT 主站(使用 ethercatctl):
sudo ethercatctl start
- 如果是 IgH 1.5.x(S100 固件默认版本),且配置了 NetworkManager 不管理主站网口,则在使用前需要先手动启用网口:
- 如果是 IgH 1.5.x(S600 固件默认版本),且配置了 NetworkManager 不管理主站网口,则在使用前需要先手动启用网口:
sudo ip link set dev eth0 up
# 若主站网口为 eth1,则替换为 eth1
- 使用用户层命令检查主站:
sudo ethercat master
# Sample output:
sunrise@ubuntu:~$ sudo ethercat master
Master0
Phase: Idle
Active: no
Slaves: 0
Ethernet devices:
Main: c8:30:76:63:2d:93 (attached)
Link: UP
Tx frames: 9477
Tx bytes: 568620
Rx frames: 0
Rx bytes: 0
Tx errors: 0
Tx frame rate [1/s]: 124 125 89
Tx rate [KByte/s]: 7.3 7.3 5.2
Rx frame rate [1/s]: 0 0 0
Rx rate [KByte/s]: 0.0 0.0 0.0
Common:
Tx frames: 9477
Tx bytes: 568620
Rx frames: 0
Rx bytes: 0
Lost frames: 9477
Tx frame rate [1/s]: 124 125 89
Tx rate [KByte/s]: 7.3 7.3 5.2
Rx frame rate [1/s]: 0 0 0
Rx rate [KByte/s]: 0.0 0.0 0.0
Loss rate [1/s]: 124 125 89
Frame loss [%]: 100.0 100.0 100.0
Distributed clocks:
Reference clock: None
DC reference time: 0
Application time: 0 - 配置 IgH 服务自启动:
sudo systemctl enable ethercat
EtherCAT 开发指南
软件栈
地瓜 RDK S100 默认提供 EtherCAT-IgH 1.5 版本软件栈(本节以 S100 为例,S600 同理)。EtherCAT-IgH软件栈是目前主流的开源 EtherCAT 主站协议。
EtherCAT 官网:EtherLab | EtherCAT EtherCAT 开源代码仓库:Gitlab | EtherLab - EtherCAT
编译和部署
Host 端构建
Host 端构建支持两种构建方式:
-
单独编译 debian 包并部署
# Construct debian package
./mk_debs.sh hobot-ethercat
# Deploy
## Transfer generated out/product/deb_packages/hobot-ethercat_<***>_arm64.deb package to RDK S100, the "<***>" is the version string
## On RDK S100, presuming debian package is transferred to /userdata
dpkg -i /userdata/hobot-ethercat_4.0.4-20250827135836_arm64.debhobot-ethercat 的构建包括内核模块+用户层应用两个大模块。内核模块构建依赖用户本地构建的内核输出物。在用户没有在本地构建过内核时会自动跳过内核模块的构建。
-
整编
默认 rdk-gen 构建系统在整编 disk 镜像后,镜像内会默认集成 hobot-ethercat debian 包,内部包括内核模块及用户层应用。
板端构建
- 下载源码:
git clone https://gitlab.com/etherlab.org/ethercat.git -b stable-1.5 - 构建
# Install build dependencies
sudo apt install automake libtool m4 autoconf
# Setup kernel module build environment
sudo apt install flex bison
sudo make -C /lib/modules/$(uname -r)/build prepare
# Setup build environment
cd ethercat
./bootstrap
./configure --enable-kernel --enable-generic --enable-igb --disable-eoe --enable-hrtimer --disable-8139too --with-linux-dir=/lib/modules/$(uname -r)/build/
# Compile and install
make -j
make modules -j
sudo make install
sudo make modules_install - 编辑
/usr/local/etc/ethercat.conf,添加以下内容:MASTER0_DEVICE="eth0" // Device or MAC
DEVICE_MODULES="generic"