1.安装linux-headers
sudo apt-get install linux-headers-4.19*
2.下载这两个驱动文件之前,我们需要下载一下依赖包
用命令
sudo apt install mercurial build-essential automake tree dkms bison flex
回车执行
安装完重启不然后面make build 指令会报错
3.接下来我们开始编译安装第一个驱动文件【Etherlabmaster】
用命令
sudo git clone https://github.com/icshwi/etherlabmaster
fatal: unable to access ‘http://’: Could not resolve host: info
出现上面警告:github为外网如果下载不到直接打开网页下载源代码
cd etherlabmaster
make init
//出现错误abort: Permission denied: '/opt/etherlabmaster-master/etherlabmaster-code'
//给下这个文件夹权限就好
sudo chmod 777 -R /opt/etherlabmaster-master/
echo "ENABLE_CYCLES = NO" > configure/CONFIG_OPTIONS.local
make build
make install
echo "ETHERCAT_MASTER0=eth0" > ethercatmaster.local
这里eth0可能要修改成ens33
注意一下:上条命令 eth0 这个参数,需要根据自己系统的实际值去做修改,给大家一个方法:新打开一个终端窗口,输入命令 ip addr 回车执行,找到有MAC/IP 的那一段的开头名称 ,就是对应的这个参数,更换掉就行。
make dkms_add
make dkms_build
make dkms_install
make setup
sudo mkdir -p /usr/include/linuxcnc
sudo ln -s /opt/etherlab/include/*.h /usr/include/linuxcnc/
sudo ln -s /opt/etherlab/lib/lib* /usr/lib/
以上命令执行完后,驱动就安装成功
为了驱动正常启动生效
用命令
sudo reboot
执行重启一下
开机之后我们来检测一下是否成功安装完成了
ethercat master
Master0
Phase: Idle
Active: no
Slaves: 0
Ethernet devices:
Main: 00:0c:29:68:53:c6 (attached)
Link: UP
Tx frames: 2809
Tx bytes: 168540
Rx frames: 0
Rx bytes: 0
Tx errors: 5
Tx frame rate [1/s]: 125 112 39
Tx rate [KByte/s]: 7.3 6.5 2.3
Rx frame rate [1/s]: 0 0 0
Rx rate [KByte/s]: 0.0 0.0 0.0
Common:
Tx frames: 2809
Tx bytes: 168540
Rx frames: 0
Rx bytes: 0
Lost frames: 2809
Tx frame rate [1/s]: 125 112 39
Tx rate [KByte/s]: 7.3 6.5 2.3
Rx frame rate [1/s]: 0 0 0
Rx rate [KByte/s]: 0.0 0.0 0.0
Loss rate [1/s]: 125 112 39
Frame loss [%]: 100.0 100.0 100.0
Distributed clocks:
Reference clock: None
DC reference time: 0
Application time: 0
2000-01-01 00:00:00.000000000
ethercat slaves
为空白的话是因为没有连接从站
能看到输出信息及说明安装成功