igh+preempt_rt主战搭建

目录

一、内核编译安装

1.下载相关资料包

2.解压

3.合并补丁

4.内核配置

5.修改grub启动配置文件

 6.测试

二、安装igh主站

三、装igh的错误操作

参考链接


一、内核编译安装

1.下载相关资料包

当前环境为ubuntu18.04版本,已安装ros-melodic环境,先查看当前系统内核版本

uname -a

得出:

Linux robotarm 5.4.0-89-generic #100~18.04.1-Ubuntu SMP Wed Sep 29 10:59:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

下载补丁,内核版本与补丁版本保持一致。

补丁下载地址: https://www.kernel.org/pub/linux/kernel/projects/rt/
内核地址: http://www.kernel.org/pub/linux/kernel/ 

patches-5.4.154-rt65.tar.gz                        20-Oct-2021 15:15    389
linux-5.4.154.tar.gz                               17-Oct-2021 08:48    163M2、

2.解压

先解压内核,再把补丁拷贝进内核目录

tar -xvf linux-5.4.154.tar.gz
tar -xvf patches-5.4.154-rt65.tar.gz 
mv patches linux-5.4.154
cd linux-5.4.154

3.合并补丁

将patches解压出来的文件合并

#!/bin/sh
cat ./patches/series | while read line
do
    patch -p1 < ./patches/$line
done

4.内核配置

sudo chrt 10 bash
make mrproper
cp /boot/config-5.4.0-89-generic .config

安装依赖包

sudo apt-get install libncurses-dev   bison   flex  bc   libelf-dev
sudo apt-get install libssl-dev

进入菜单配置界面

make menuconfig

igh+preempt_rt主战搭建_第1张图片

 进入“General setup”, 在"Preemption Model"中选择“Fully Preemptible Kernel(Real-Time)”

igh+preempt_rt主战搭建_第2张图片

 这里按enter键会先保存好然后返回上一层,然后再用方向右键移到exit那里,然后返回上一层,找到Device Drivers

igh+preempt_rt主战搭建_第3张图片

 找到staging drivers ,(在比较后面,慢慢找),然后按空格键,把它去掉。

igh+preempt_rt主战搭建_第4张图片

  然后save 、exit。

igh+preempt_rt主战搭建_第5张图片

可以使用lscpu指令查看当前cpu的逻辑核心数:4

lscpu
架构:           x86_64
CPU 运行模式:   32-bit, 64-bit
字节序:         Little Endian
CPU:             4
在线 CPU 列表:  0-3
每个核的线程数: 2
每个座的核数:   2
座:             1
NUMA 节点:      1
厂商 ID:        GenuineIntel
CPU 系列:       6
型号:           69
型号名称:       Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz
步进:           1
CPU MHz:        2294.841
CPU 最大 MHz:   2600.0000
CPU 最小 MHz:   800.0000
BogoMIPS:       3791.50
虚拟化:         VT-x
L1d 缓存:       32K
L1i 缓存:       32K
L2 缓存:        256K
L3 缓存:        3072K
NUMA 节点0 CPU: 0-3

执行下面的指令,其中,'getconf_NPROCESSORS_ONLN' 表示内核数量是多少个。编译内核的操作会比较耗时,所以尽可能的开启多个逻辑核同时编译,可以减少编译时间。

make -j$(getconf _NPROCESSORS_ONLN)
或者  make -j4
安装内核模块
make modules_install 
安装内核
make install  

然后报错了

# make modules_install 
sed: 无法读取 modules.order: 没有那个文件或目录
Makefile:1351: recipe for target '_modinst_' failed
make: *** [_modinst_] Error 2

# make modules
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CHK     include/generated/compile.h
  CHK     kernel/kheaders_data.tar.xz
make[1]: *** 没有规则可制作目标“debian/canonical-certs.pem”,由“certs/x509_certificate_list” 需求。 停止。
Makefile:1734: recipe for target 'certs' failed
make: *** [certs] Error 2

我猜可能是因为我的当前内核版本跟下载的内核版本不一样吧,就想重新去官网下载了跟5.4.0-89一样的版本,好家伙,压根没有89的。

还是先试着解决报错的问题,一个一个百度,编辑.config文件,把下面两行注释掉

gedit .config

CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"
CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"
make -j4
make modules_install -j4
make install
root@robotarm:/home/robotarm/文档/ethercat_master_file/linux-5.4.154# make install -j4
sh ./arch/x86/boot/install.sh 5.4.154-rt65 arch/x86/boot/bzImage \
	System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
update-initramfs: Generating /boot/initrd.img-5.4.154-rt65
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
I: /vmlinuz.old is now a symlink to boot/vmlinuz-5.4.0-89-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-5.4.0-89-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-5.4.154-rt65
I: /initrd.img is now a symlink to boot/initrd.img-5.4.154-rt65
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.4.154-rt65 /boot/vmlinuz-5.4.154-rt65
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.154-rt65
Found initrd image: /boot/initrd.img-5.4.154-rt65
Found linux image: /boot/vmlinuz-5.4.0-89-generic
Found initrd image: /boot/initrd.img-5.4.0-89-generic
Found linux image: /boot/vmlinuz-5.4.0-87-generic
Found initrd image: /boot/initrd.img-5.4.0-87-generic
Found linux image: /boot/vmlinuz-4.15.0-142-generic
Found initrd image: /boot/initrd.img-4.15.0-142-generic
Found linux image: /boot/vmlinuz-4.15.0-45-generic
Found initrd image: /boot/initrd.img-4.15.0-45-generic
Found linux image: /boot/vmlinuz-4.9.38-xenomai-3.1
Found initrd image: /boot/initrd.img-4.9.38-xenomai-3.1
Adding boot menu entry for EFI firmware configuration
done

(我似乎下载了好几次内核吧,反正这次是154版本的)

查看编译后的内核大小: 18G

du -sh

18G	.

5.修改grub启动配置文件

安装完内核之后,再手动更新一下grub。

update-grub

gedit编辑/etc/default/grub文件,改动三处:

将 "GRUB_TIMEOUT_STYLE=hidden" 注释掉(在前面加上“#”)。

将 "GRUB_TIMEOUT" 的值改为“15”。

将 "GRUB_CMDLINE_LINUX_DEFAULT" 的值改为“text”。

再更新一遍配置文件

update-grub

 6.测试

reboot重启后进入GRUB界面,选154那个,然后

uname -a
Linux robotarm 5.4.154-rt65 #1 SMP PREEMPT_RT Thu Nov 4 10:21:44 CST 2021 x86_64 x86_64 x86_64 GNU/Linux

好像成功了,测试一下,运行五个线程,线程优先级为80,无限循环。

T: 0     序号为0的线程
P: 0     线程优先级为0
C: 9397  计数器。线程的时间间隔每达到一次,计数器加1
I: 1000  时间间隔为1000微秒(us)
Min:     最小延时(us)
Act:     最近一次的延时(us)
Avg:    平均延时(us)
Max:    最大延时(us) 

sudo apt-get install rt-tests
sudo cyclictest -t 5 -p 80 -n 
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 3.63 1.72 0.90 1/711 2801          

T: 0 ( 2797) P:80 I:1000 C:   6258 Min:      3 Act:    3 Avg:    4 Max:      31
T: 1 ( 2798) P:80 I:1500 C:   4172 Min:      3 Act:    4 Avg:    5 Max:      30
T: 2 ( 2799) P:80 I:2000 C:   3129 Min:      3 Act:    4 Avg:    5 Max:      21
T: 3 ( 2800) P:80 I:2500 C:   2503 Min:      3 Act:    3 Avg:    4 Max:      32
T: 4 ( 2801) P:80 I:3000 C:   2086 Min:      3 Act:    4 Avg:    5 Max:      27

看起来误差不大,跑ethercat通信应该没有问题

二、安装igh主站

具体详情见另一篇博客

igh主站搭建过程:e1000e / generic_ze3000的博客-CSDN博客

用到的指令:

mkdir ec_igh
cd ec_igh/
git clone http://gitlab.com/etherlab.org/ethercat.git
cd ethercat/
./bootstrap 
./configure --enable-8139too=no
sudo make
sudo make modules
sudo make install
sudo make modules_install 

ifconfig
cd /opt/etherlab 
sudo gedit /etc/sysconfig/ethercat

MASTER0_DEVICE="00:e8:4c:68:30:cd"
DEVICE_MODULES="generic"
sudo cp etc/sysconfig/ethercat /etc/sysconfig/
sudo ln -s /opt/etherlab/etc/init.d/ethercat /etc/init.d/

sudo /etc/init.d/ethercat start

gedit ~/.bashrc
PATH=$PATH:/opt/etherlab/bin
source ~/.bashrc
sudo depmod


gitlab下载主站的源代码

robotarm@robotarm:~$ mkdir ec_igh
robotarm@robotarm:~$ cd ec_igh/
robotarm@robotarm:~/ec_igh$ git clone http://gitlab.com/etherlab.org/ethercat.git
正克隆到 'ethercat'...
warning: 重定向到 https://gitlab.com/etherlab.org/ethercat.git/
remote: Enumerating objects: 18385, done.
remote: Counting objects: 100% (2391/2391), done.
remote: Compressing objects: 100% (887/887), done.
remote: Total 18385 (delta 1690), reused 2137 (delta 1504), pack-reused 15994
接收对象中: 100% (18385/18385), 41.13 MiB | 292.00 KiB/s, 完成.
处理 delta 中: 100% (13865/13865), 完成.
robotarm@robotarm:~/ec_igh$ ls
ethercat
robotarm@robotarm:~/ec_igh$ cd ethercat/
robotarm@robotarm:~/ec_igh/ethercat$ ls
AUTHORS          configure.ac    devices        ethercat.spec.in  globals.h  Kbuild.in    Makefile.kbuild  README      TODO
bootstrap        COPYING         documentation  examples          include    lib          master           README.EoE  tool
CodingStyle.txt  COPYING.LESSER  Doxyfile.in    FEATURES          INSTALL    Makefile.am  NEWS             script      tty
robotarm@robotarm:~/ec_igh/ethercat$ ./bootstrap 
+ touch ChangeLog
+ mkdir -p m4
+ autoreconf -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'autoconf'.
libtoolize: copying file 'autoconf/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:58: installing 'autoconf/ar-lib'
configure.ac:57: installing 'autoconf/compile'
configure.ac:60: installing 'autoconf/config.guess'
configure.ac:60: installing 'autoconf/config.sub'
configure.ac:44: installing 'autoconf/install-sh'
configure.ac:44: installing 'autoconf/missing'
examples/dc_user/Makefile.am: installing 'autoconf/depcomp'
robotarm@robotarm:~/ec_igh/ethercat$ ./configure --enab
--enable-8139too              --enable-e1000e               --enable-loop-control         --enable-silent-rules
--enable-ccat                 --enable-eoe                  --enable-r8169                --enable-static
--enable-cycles               --enable-fast-install         --enable-refclkop             --enable-tool
--enable-debug-if             --enable-FEATURE              --enable-regalias             --enable-tty
--enable-debug-ring           --enable-generic              --enable-rtdm                 --enable-userlib
--enable-dependency-tracking  --enable-hrtimer              --enable-rt-syslog            --enable-wildcards
--enable-e100                 --enable-igb                  --enable-shared               
--enable-e1000                --enable-kernel               --enable-sii-assign           
robotarm@robotarm:~/ec_igh/ethercat$ ./configure --enab
--enable-8139too              --enable-e1000e               --enable-loop-control         --enable-silent-rules
--enable-ccat                 --enable-eoe                  --enable-r8169                --enable-static
--enable-cycles               --enable-fast-install         --enable-refclkop             --enable-tool
--enable-debug-if             --enable-FEATURE              --enable-regalias             --enable-tty
--enable-debug-ring           --enable-generic              --enable-rtdm                 --enable-userlib
--enable-dependency-tracking  --enable-hrtimer              --enable-rt-syslog            --enable-wildcards
--enable-e100                 --enable-igb                  --enable-shared               
--enable-e1000                --enable-kernel               --enable-sii-assign           
robotarm@robotarm:~/ec_igh/ethercat$ ./configure --enable-8139too=no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether to build kernel modules... yes
checking for Linux kernel sources... /home/robotarm/文档/ethercat_master_file/linux-5.4.154 (Kernel 5.4)
checking for Linux modules installation directory... ethercat
checking whether to build the CCAT driver... no
checking for RTAI path... not specified.
checking for Xenomai path... not specified.
checking whether to build RTDM interface... no
checking whether to build the debug interface... no
checking whether to build the debug ring... no
checking whether to build with EoE support... yes
checking whether to use the CPU timestamp counter... no
checking whether to use high-resolution timers for scheduling... no
checking whether to read alias addresses from registers... no
checking whether to force the reference clock to OP... no
checking whether to build the command-line tool... yes
checking whether to build the userspace library... yes
checking whether to build the tty driver... no
checking whether to allow identification wildcards... no
checking for number of Ethernet devices... 1 (Redundancy disabled)
checking whether to assign the SII to PDI... yes
checking whether to syslog in realtime context... yes
checking whether to use loop control registers... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Doxyfile
config.status: creating Kbuild
config.status: creating Makefile
config.status: creating devices/Kbuild
config.status: creating devices/Makefile
config.status: creating devices/ccat/Kbuild
config.status: creating devices/ccat/Makefile
config.status: creating devices/e1000/Kbuild
config.status: creating devices/e1000/Makefile
config.status: creating devices/e1000e/Kbuild
config.status: creating devices/e1000e/Makefile
config.status: creating devices/igb/Kbuild
config.status: creating devices/igb/Makefile
config.status: creating ethercat.spec
config.status: creating examples/Kbuild
config.status: creating examples/Makefile
config.status: creating examples/dc_rtai/Kbuild
config.status: creating examples/dc_rtai/Makefile
config.status: creating examples/dc_user/Makefile
config.status: creating examples/mini/Kbuild
config.status: creating examples/mini/Makefile
config.status: creating examples/rtai/Kbuild
config.status: creating examples/rtai/Makefile
config.status: creating examples/rtai_rtdm/Makefile
config.status: creating examples/rtai_rtdm_dc/Makefile
config.status: creating examples/tty/Kbuild
config.status: creating examples/tty/Makefile
config.status: creating examples/user/Makefile
config.status: creating examples/xenomai/Makefile
config.status: creating examples/xenomai_posix/Makefile
config.status: creating include/Makefile
config.status: creating lib/Makefile
config.status: creating lib/libethercat.pc
config.status: creating master/Kbuild
config.status: creating master/Makefile
config.status: creating script/Makefile
config.status: creating script/init.d/Makefile
config.status: creating script/init.d/ethercat
config.status: creating script/sysconfig/Makefile
config.status: creating tool/Makefile
config.status: creating tty/Kbuild
config.status: creating tty/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
robotarm@robotarm:~/ec_igh/ethercat$ sudo make
[sudo] robotarm 的密码: 
make  all-recursive
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat”
Making all in include
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/include”
make[2]: 对“all”无需做任何事。
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/include”
Making all in script
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/script”
Making all in init.d
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script/init.d”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script/init.d”
Making all in sysconfig
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script”
/bin/sed -e 's,[@]VERSION[@],1.5.2,g' -e 's,[@]bindir[@],/usr/local/bin,g' -e 's,[@]sbindir[@],/usr/local/sbin,g' -e 's,[@]sysconfdir[@],/usr/local/etc,g' < ethercatctl.in > ethercatctl
/bin/sed -e 's,[@]VERSION[@],1.5.2,g' -e 's,[@]bindir[@],/usr/local/bin,g' -e 's,[@]sbindir[@],/usr/local/sbin,g' -e 's,[@]sysconfdir[@],/usr/local/etc,g' < ethercat.service.in > ethercat.service
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/script”
Making all in devices
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices”
Making all in ccat
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
Making all in e1000
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
Making all in e1000e
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
Making all in igb
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[3]: 对“all”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices”
make[3]: 对“all-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices”
Making all in master
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/master”
make[2]: 对“all”无需做任何事。
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/master”
Making all in tool
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/tool”
  CC       ../master/soe_errors.o
  CXX      ethercat-Command.o
  CXX      ethercat-CommandAlias.o
  CXX      ethercat-CommandCrc.o
  CXX      ethercat-CommandCStruct.o
  CXX      ethercat-CommandConfig.o
  CXX      ethercat-CommandData.o
  CXX      ethercat-CommandDebug.o
  CXX      ethercat-CommandDomains.o
  CXX      ethercat-CommandDownload.o
  CXX      ethercat-CommandFoeRead.o
  CXX      ethercat-CommandFoeWrite.o
  CXX      ethercat-CommandGraph.o
  CXX      ethercat-CommandIp.o
  CXX      ethercat-CommandMaster.o
  CXX      ethercat-CommandPdos.o
  CXX      ethercat-CommandRegRead.o
  CXX      ethercat-CommandRegWrite.o
  CXX      ethercat-CommandRescan.o
  CXX      ethercat-CommandSdos.o
  CXX      ethercat-CommandSiiRead.o
  CXX      ethercat-CommandSiiWrite.o
  CXX      ethercat-CommandSlaves.o
  CXX      ethercat-CommandSoeRead.o
  CXX      ethercat-CommandSoeWrite.o
  CXX      ethercat-CommandStates.o
  CXX      ethercat-CommandUpload.o
  CXX      ethercat-CommandVersion.o
  CXX      ethercat-CommandXml.o
  CXX      ethercat-DataTypeHandler.o
  CXX      ethercat-FoeCommand.o
  CXX      ethercat-MasterDevice.o
  CXX      ethercat-NumberListParser.o
  CXX      ethercat-SdoCommand.o
  CXX      ethercat-SoeCommand.o
  CXX      ethercat-main.o
  CXX      ethercat-sii_crc.o
  CXX      ethercat-CommandEoe.o
  CXXLD    ethercat
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/tool”
Making all in lib
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/lib”
  CC       libethercat_la-common.lo
  CC       libethercat_la-domain.lo
  CC       libethercat_la-master.lo
  CC       libethercat_la-reg_request.lo
  CC       libethercat_la-sdo_request.lo
  CC       libethercat_la-slave_config.lo
  CC       libethercat_la-voe_handler.lo
  CCLD     libethercat.la
ar: `u' modifier ignored since `D' is the default (see `U')
/bin/sed -e 's,%libdir%,/usr/local/lib,' -e 's,%includedir%,/usr/local/include,' EtherCATConfig.cmake.in > EtherCATConfig.cmake
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/lib”
Making all in examples
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/examples”
Making all in dc_user
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
  CC       ec_dc_user_example-main.o
  CCLD     ec_dc_user_example
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
Making all in user
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/user”
  CC       ec_user_example-main.o
  CCLD     ec_user_example
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/user”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples”
make[3]: 对“all-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/examples”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat”
robotarm@robotarm:~/ec_igh/ethercat$ sudo make modules
make -C "/home/robotarm/文档/ethercat_master_file/linux-5.4.154" M="/home/robotarm/ec_igh/ethercat" INSTALL_MOD_DIR="ethercat" modules
make[1]: 进入目录“/home/robotarm/文档/ethercat_master_file/linux-5.4.154”
  CC [M]  /home/robotarm/ec_igh/ethercat/devices/generic.o
  LD [M]  /home/robotarm/ec_igh/ethercat/devices/ec_generic.o
  CC [M]  /home/robotarm/ec_igh/ethercat/examples/mini/mini.o
  LD [M]  /home/robotarm/ec_igh/ethercat/examples/mini/ec_mini.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/cdev.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/coe_emerg_ring.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/datagram.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/datagram_pair.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/device.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/domain.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/eoe_request.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/flag.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fmmu_config.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/foe_request.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_change.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_coe.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_eoe.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_foe.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_master.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_pdo.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_pdo_entry.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_sii.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_slave.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_slave_config.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_slave_scan.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/fsm_soe.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/ioctl.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/mailbox.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/master.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/module.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/pdo.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/pdo_entry.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/pdo_list.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/reg_request.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/sdo.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/sdo_entry.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/sdo_request.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/slave.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/slave_config.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/soe_errors.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/soe_request.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/sync.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/sync_config.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/voe_handler.o
  CC [M]  /home/robotarm/ec_igh/ethercat/master/ethernet.o
  LD [M]  /home/robotarm/ec_igh/ethercat/master/ec_master.o
  Building modules, stage 2.
  MODPOST 3 modules
  CC [M]  /home/robotarm/ec_igh/ethercat/devices/ec_generic.mod.o
  LD [M]  /home/robotarm/ec_igh/ethercat/devices/ec_generic.ko
  CC [M]  /home/robotarm/ec_igh/ethercat/examples/mini/ec_mini.mod.o
  LD [M]  /home/robotarm/ec_igh/ethercat/examples/mini/ec_mini.ko
  CC [M]  /home/robotarm/ec_igh/ethercat/master/ec_master.mod.o
  LD [M]  /home/robotarm/ec_igh/ethercat/master/ec_master.ko
make[1]: 离开目录“/home/robotarm/文档/ethercat_master_file/linux-5.4.154”
robotarm@robotarm:~/ec_igh/ethercat$ sudo make install
Making install in include
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/include”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/include”
make[2]: 对“install-exec-am”无需做任何事。
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 ecrt.h ectty.h '/usr/local/include'
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/include”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/include”
Making install in script
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/script”
Making install in init.d
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/script/init.d”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script/init.d”
make[3]: 对“install-exec-am”无需做任何事。
 /bin/mkdir -p '/usr/local/etc/init.d'
 /usr/bin/install -c ethercat '/usr/local/etc/init.d'
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script/init.d”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/script/init.d”
Making install in sysconfig
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[3]: 对“install-exec-am”无需做任何事。
 /bin/mkdir -p '/usr/local/etc/sysconfig'
 /usr/bin/install -c -m 644 ethercat '/usr/local/etc/sysconfig'
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/script/sysconfig”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/script”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/script”
 /bin/mkdir -p '/usr/local/etc'
 /usr/bin/install -c -m 644 ethercat.conf '/usr/local/etc'
 /bin/mkdir -p '/usr/local/sbin'
 /usr/bin/install -c ethercatctl '/usr/local/sbin'
 /bin/mkdir -p '/lib/systemd/system'
 /usr/bin/install -c -m 644 ethercat.service '/lib/systemd/system'
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/script”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/script”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/script”
Making install in devices
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/devices”
Making install in ccat
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/ccat”
Making install in e1000
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000”
Making install in e1000e
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/e1000e”
Making install in igb
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices/igb”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/devices”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/devices”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/devices”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/devices”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/devices”
Making install in master
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/master”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/master”
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/master”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/master”
Making install in tool
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/tool”
  CXXLD    ethercat
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/tool”
 /bin/mkdir -p '/usr/local/bin'
  /bin/bash ../libtool   --mode=install /usr/bin/install -c ethercat '/usr/local/bin'
libtool: install: /usr/bin/install -c ethercat /usr/local/bin/ethercat
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/tool”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/tool”
Making install in lib
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/lib”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/lib”
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ../libtool   --mode=install /usr/bin/install -c   libethercat.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libethercat.so.1.1.0 /usr/local/lib/libethercat.so.1.1.0
libtool: install: (cd /usr/local/lib && { ln -s -f libethercat.so.1.1.0 libethercat.so.1 || { rm -f libethercat.so.1 && ln -s libethercat.so.1.1.0 libethercat.so.1; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libethercat.so.1.1.0 libethercat.so || { rm -f libethercat.so && ln -s libethercat.so.1.1.0 libethercat.so; }; })
libtool: install: /usr/bin/install -c .libs/libethercat.lai /usr/local/lib/libethercat.la
libtool: install: /usr/bin/install -c .libs/libethercat.a /usr/local/lib/libethercat.a
libtool: install: chmod 644 /usr/local/lib/libethercat.a
libtool: install: ranlib /usr/local/lib/libethercat.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/lib/cmake'
 /usr/bin/install -c -m 644 EtherCATConfig.cmake '/usr/local/lib/cmake'
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libethercat.pc '/usr/local/lib/pkgconfig'
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/lib”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/lib”
Making install in examples
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat/examples”
Making install in dc_user
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/dc_user”
Making install in user
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/user”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples/user”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/user”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/examples/user”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat/examples”
make[3]: 进入目录“/home/robotarm/ec_igh/ethercat/examples”
make[3]: 对“install-exec-am”无需做任何事。
make[3]: 对“install-data-am”无需做任何事。
make[3]: 离开目录“/home/robotarm/ec_igh/ethercat/examples”
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat/examples”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat/examples”
make[1]: 进入目录“/home/robotarm/ec_igh/ethercat”
make[2]: 进入目录“/home/robotarm/ec_igh/ethercat”
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/home/robotarm/ec_igh/ethercat”
make[1]: 离开目录“/home/robotarm/ec_igh/ethercat”
robotarm@robotarm:~/ec_igh/ethercat$ sudo make modules_install 
make -C "/home/robotarm/文档/ethercat_master_file/linux-5.4.154" M="/home/robotarm/ec_igh/ethercat" INSTALL_MOD_DIR="ethercat" modules_install
make[1]: 进入目录“/home/robotarm/文档/ethercat_master_file/linux-5.4.154”
  INSTALL /home/robotarm/ec_igh/ethercat/devices/ec_generic.ko
  INSTALL /home/robotarm/ec_igh/ethercat/examples/mini/ec_mini.ko
  INSTALL /home/robotarm/ec_igh/ethercat/master/ec_master.ko
  DEPMOD  5.4.154-rt65
make[1]: 离开目录“/home/robotarm/文档/ethercat_master_file/linux-5.4.154”
robotarm@robotarm:~/ec_igh/ethercat$ 

 ifconfig 查看网卡信息

cd /opt/etherlab 

sudo gedit /etc/sysconfig/ethercat
MASTER0_DEVICE="00:e8:4c:68:30:cd"
DEVICE_MODULES="generic"

然后

sudo cp etc/sysconfig/ethercat /etc/sysconfig/
sudo ln -s /opt/etherlab/etc/init.d/ethercat /etc/init.d/

启动主站

robotarm@robotarm:/opt/etherlab$ sudo /etc/init.d/ethercat start
Starting EtherCAT master 1.5.2  done

添加命令行工具

gedit ~/.bashrc
把下面这行加进入
PATH=$PATH:/opt/etherlab/bin
保存,然后
source ~/.bashrc
sudo depmod
robotarm@robotarm:/opt/etherlab$ ethercat
Please specify a command!

Usage: ethercat  [OPTIONS] [ARGUMENTS]

Commands (can be abbreviated):
  alias      Write alias addresses.
  config     Show slave configurations.
  crc        CRC error register diagnosis.
  cstruct    Generate slave PDO information in C language.
  data       Output binary domain process data.
  debug      Set the master's debug level.
  domains    Show configured domains.
  download   Write an SDO entry to a slave.
  eoe        Display Ethernet over EtherCAT statictics.
  foe_read   Read a file from a slave via FoE.
  foe_write  Store a file on a slave via FoE.
  graph      Output the bus topology as a graph.
  ip         Set EoE IP parameters.
  master     Show master and Ethernet device information.
  pdos       List Sync managers, PDO assignment and mapping.
  reg_read   Output a slave's register contents.
  reg_write  Write data to a slave's registers.
  rescan     Rescan the bus.
  sdos       List SDO dictionaries.
  sii_read   Output a slave's SII contents.
  sii_write  Write SII contents to a slave.
  slaves     Display slaves on the bus.
  soe_read   Read an SoE IDN from a slave.
  soe_write  Write an SoE IDN to a slave.
  states     Request application-layer states.
  upload     Read an SDO entry from a slave.
  version    Show version information.
  xml        Generate slave information XML.

Global options:
  --master  -m   Comma separated list of masters
                         to select, ranges are allowed.
                         Examples: '1,3', '5-7,9', '-3'.
                         Default: '-' (all).
  --force   -f           Force a command.
  --quiet   -q           Output less information.
  --verbose -v           Output more information.
  --help    -h           Show this help.

Numerical values can be specified either with decimal (no
prefix), octal (prefix '0') or hexadecimal (prefix '0x') base.

Call 'ethercat  --help' for command-specific help.

Send bug reports to [email protected].


分割线

三、装igh的错误操作

网上的一些教程偏低而且麻烦,配置的很多东西为也不知道是什么。。。,总之就是错的

下载

http://etherlab.org/download/ethercat/ethercat-1.5.2.tar.bz2

tar -vxf ethercat-1.5.2.tar.bz2
cd ethercat-1.5.2/
./configure --with-linux-dir=/usr/src/linux-headers-5.4.0-89-generic/ --enable-8139too=no --enable-wildcards=yes

make -j4
make modules -j4

然后报错了
CC [M]  /home/robotarm/ethercat-1.5.2/devices/generic.o
/home/robotarm/ethercat-1.5.2/devices/generic.c: In function ‘ec_gen_device_init’:
/home/robotarm/ethercat-1.5.2/devices/generic.c:152:77: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
     dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
                                                                             ^
/home/robotarm/ethercat-1.5.2/devices/generic.c:152:19: error: ‘alloc_netdev’ undeclared (first use in this function); did you mean ‘alloc_netdev_mqs’?
     dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
                   ^~~~~~~~~~~~
                   alloc_netdev_mqs
/home/robotarm/ethercat-1.5.2/devices/generic.c:152:19: note: each undeclared identifier is reported only once for each function it appears in
/home/robotarm/ethercat-1.5.2/devices/generic.c:146:10: warning: unused variable ‘null’ [-Wunused-variable]
     char null = 0x00;
          ^~~~
In file included from ./include/linux/skbuff.h:20:0,
                 from ./include/linux/if_arp.h:22,
                 from /home/robotarm/ethercat-1.5.2/devices/generic.c:40:
/home/robotarm/ethercat-1.5.2/devices/generic.c: In function ‘ec_gen_device_create_socket’:
./include/linux/socket.h:181:19: warning: passing argument 1 of ‘sock_create_kern’ makes pointer from integer without a cast [-Wint-conversion]
 #define AF_PACKET 17 /* Packet family  */
                   ^
./include/linux/socket.h:235:19: note: in expansion of macro ‘AF_PACKET’
 #define PF_PACKET AF_PACKET
                   ^~~~~~~~~
/home/robotarm/ethercat-1.5.2/devices/generic.c:210:28: note: in expansion of macro ‘PF_PACKET’
     ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),
                            ^~~~~~~~~
In file included from ./include/linux/skbuff.h:26:0,
                 from ./include/linux/if_arp.h:22,
                 from /home/robotarm/ethercat-1.5.2/devices/generic.c:40:
./include/linux/net.h:235:5: note: expected ‘struct net *’ but argument is of type ‘int’
 int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res);
     ^~~~~~~~~~~~~~~~
/home/robotarm/ethercat-1.5.2/devices/generic.c:211:13: warning: passing argument 4 of ‘sock_create_kern’ makes integer from pointer without a cast [-Wint-conversion]
             &dev->socket);
             ^
In file included from ./include/linux/skbuff.h:26:0,
                 from ./include/linux/if_arp.h:22,
                 from /home/robotarm/ethercat-1.5.2/devices/generic.c:40:
./include/linux/net.h:235:5: note: expected ‘int’ but argument is of type ‘struct socket **’
 int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res);
     ^~~~~~~~~~~~~~~~
/home/robotarm/ethercat-1.5.2/devices/generic.c:210:11: error: too few arguments to function ‘sock_create_kern’
     ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),
           ^~~~~~~~~~~~~~~~
In file included from ./include/linux/skbuff.h:26:0,
                 from ./include/linux/if_arp.h:22,
                 from /home/robotarm/ethercat-1.5.2/devices/generic.c:40:
./include/linux/net.h:235:5: note: declared here
 int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res);
     ^~~~~~~~~~~~~~~~
scripts/Makefile.build:262: recipe for target '/home/robotarm/ethercat-1.5.2/devices/generic.o' failed
make[3]: *** [/home/robotarm/ethercat-1.5.2/devices/generic.o] Error 1
scripts/Makefile.build:497: recipe for target '/home/robotarm/ethercat-1.5.2/devices' failed
make[2]: *** [/home/robotarm/ethercat-1.5.2/devices] Error 2
Makefile:1734: recipe for target '/home/robotarm/ethercat-1.5.2' failed
make[1]: *** [/home/robotarm/ethercat-1.5.2] Error 2
make[1]: 离开目录“/home/robotarm/文档/ethercat_master_file/linux-5.4.154”
Makefile:834: recipe for target 'modules' failed
make: *** [modules] Error 2



。。。可能,也许,是内核版本不对吧,重新按照个试试,然后手滑,不小心卸载了一些东西,问题应该不大吧。

下列软件包是自动安装的并且现在不需要了:
  amd64-microcode intel-microcode iucode-tool linux-hwe-5.4-headers-5.4.0-84 linux-hwe-5.4-headers-5.4.0-87 linux-hwe-5.4-headers-5.4.0-89
  linux-image-generic-hwe-18.04 thermald
使用'sudo apt autoremove'来卸载它(它们)。
下列软件包将被【卸载】:
  linux-generic-hwe-18.04 linux-headers-5.4.0-87-generic linux-headers-5.4.0-89-generic linux-headers-generic-hwe-18.04
  linux-signed-generic-hwe-18.04
升级了 0 个软件包,新安装了 0 个软件包,要卸载 5 个软件包,有 5 个软件包未被升级。
解压缩后将会空出 28.6 MB 的空间。
(正在读取数据库 ... 系统当前共安装有 273602 个文件和目录。)
正在卸载 linux-signed-generic-hwe-18.04 (5.3.0.62.115) ...
正在卸载 linux-generic-hwe-18.04 (5.4.0.89.100~18.04.79) ...
正在卸载 linux-headers-5.4.0-87-generic (5.4.0-87.98~18.04.1) ...
正在卸载 linux-headers-generic-hwe-18.04 (5.4.0.89.100~18.04.79) ...
正在卸载 linux-headers-5.4.0-89-generic (5.4.0-89.100~18.04.1) ...

赶紧重新下载回来

sudo apt install linux-headers-5.4.0-89

再认真看看报错信息,好像是里面的参数传的值少了,可能是内核版本5.4的少了点什么吧

sudo gedit devices/generic.c +154

// dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
   dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null,NET_NAME_UNKNOWN, ether_setup);


sudo gedit master/ethernet.c +150
// if (!(eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name, ether_setup))) {
   if (!(eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name,NET_NAME_UNKNOWN, ether_setup))) {
还有一个问题是这样的

int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res);

linux2.x版本是:
int sock_create_kern(int family, int type, int protocol, struct socket **res)
{
    return __sock_create(family, type, protocol, res, 1);
}
linux3.x的版本是
int sock_create_kern(int family, int type, int protocol, struct socket **res)
{
    return __sock_create(&init_net, family, type, protocol, res, 1);
}
linux4.x的版本是
int sock_create_kern(struct net *net, int family, int type, int protocol, struct socket **res)
{
    return __sock_create(net, family, type, protocol, res, 1);
}

而在generic.c里的调用方式是
ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),&dev->socket);
int 
所以会导致出问题
在4.x的版本可以这样调用
sock_create_kern(&init_net, family, type, protocol, res);
所以第211行改为
// ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),
    ret = sock_create_kern(&init_net,PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),

然后再编译一次

sudo make modules

home/robotarm/ethercat-1.5.2/examples/mini/mini.c: In function ‘init_mini_module’:
/home/robotarm/ethercat-1.5.2/examples/mini/mini.c:495:5: error: implicit declaration of function ‘init_timer’; did you mean ‘init_timers’? [-Werror=implicit-function-declaration]
     init_timer(&timer);
     ^~~~~~~~~~
     init_timers
/home/robotarm/ethercat-1.5.2/examples/mini/mini.c:496:20: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     timer.function = cyclic_task;

...example里的,我都不想管了。直接注释掉。

 CC [M]  /home/robotarm/ethercat-1.5.2/master/cdev.o
/home/robotarm/ethercat-1.5.2/master/cdev.c:89:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .fault = eccdev_vma_fault
              ^~~~~~~~~~~~~~~~
/home/robotarm/ethercat-1.5.2/master/cdev.c:89:14: note: (near initialization for ‘eccdev_vm_ops.fault’)
In file included from /home/robotarm/ethercat-1.5.2/master/cdev.c:42:0:
/home/robotarm/ethercat-1.5.2/master/cdev.c: In function ‘eccdev_vma_fault’:
/home/robotarm/ethercat-1.5.2/master/cdev.c:279:46: error: ‘struct vm_fault’ has no member named ‘virtual_address’
             " offset = %lu, page = %p\n", vmf->virtual_address, offset, page);
                                              ^
/home/robotarm/ethercat-1.5.2/master/master.h:115:38: note: in definition of macro ‘EC_MASTER_DBG’
                     master->index, ##args); \

先去把62行改为,其他的报错注释掉

#define PAGE_FAULT_VERSION KERNEL_VERSION(5, 4, 154)

继续报错

/home/robotarm/ethercat-1.5.2/master/master.c: In function ‘ec_master_eoe_start’:
/home/robotarm/ethercat-1.5.2/master/master.c:1637:12: error: variable ‘param’ has initializer but incomplete type
     struct sched_param param = { .sched_priority = 0 };
            ^~~~~~~~~~~
/home/robotarm/ethercat-1.5.2/master/master.c:1637:35: error: ‘struct sched_param’ has no member named ‘sched_priority’
     struct sched_param param = { .sched_priority = 0 };
                                   ^~~~~~~~~~~~~~
/home/robotarm/ethercat-1.5.2/master/master.c:1637:52: warning: excess elements in struct initializer
     struct sched_param param = { .sched_priority = 0 };
                                                    ^
/home/robotarm/ethercat-1.5.2/master/master.c:1637:52: note: (near initialization for ‘param’)
/home/robotarm/ethercat-1.5.2/master/master.c:1637:24: error: storage size of ‘param’ isn’t known
     struct sched_param param = { .sched_priority = 0 };
                        ^~~~~
/home/robotarm/ethercat-1.5.2/master/master.c:1637:24: warning: unused variable ‘param’ [-Wunused-variable]

#include ,在头文件添加了这个还是报错。。。那就手动加入

    struct sched_param
    {
        int sched_priority;
    };

...其实也不行,最后发现是linux系统目录的问题,,,///,

下一篇重写吧 (于是又错了一天)

linux5.4内核搭建igh主站第二次尝试_ze3000的博客-CSDN博客

参考链接 

 Linux内核打实时补丁preempt_rt - 知乎

实时Linux内核(PREEMPT_RT)的编译安装以及测试_v6543210的专栏-CSDN博客_preempt_rtLinux内核编译错误:make[1]: *** 没有规则可制作目标“debian/canonical-certs.pem”,由“certs/x509_certificate_list” 需求。 停止_m0_51203305的博客-CSDN博客

服务器上使用Ubuntu18.04编译内核5.4.0 - 知乎
实时Linux内核(PREEMPT_RT)的编译安装以及测试_v6543210的专栏-CSDN博客_preempt_rt

你可能感兴趣的:(ethercat,linux,linux,ethercat)