下载EtherCAT IGH源码
到官网下载1.5版本的EtherCAT源码,如图4-1:
https://gitlab.com/etherlab.org/ethercat/-/tree/stable-1.5?ref_type=heads
解压EtherCAT源码
hjx@myir-server:/renesas/04_Sources$ tar -xvf ethercat-stable-1.5.tar.bz2
hjx@myir-server:/renesas/04_Sources$ cd ethercat-stable-1.5
编译EtherCAT源码
hjx@myir-server:/renesas/04_Sources/ethercat-stable-1.5$ mkdir output/renesas/04_Sources/ethercat-stable-1.5$ ./configure --prefix=/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output --with-linux-dir=/home/hjx/renesas/04_Sources/myir-renesas-linux --enable-8139too=no --enable-generic=yes --host=aarch64-poky-linux
hjx@myir-server:
(--prefix=/home/hjx/renesas/04_Sources/output 指定输出目录、--with-linux-dir=/home/hjx/renesas/04_Sources/myir-renesas-linux指定内核源码目录)
configure: loading site script /opt/remi-sdk/site-config-aarch64-poky-linux
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-poky-linux-strip... aarch64-poky-linux-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
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... (cached) sed
checking for aarch64-poky-linux-pkg-config... no
checking for pkg-config... /opt/remi-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether make supports the include directive... yes (GNU style)
..........
...............
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
编译源码
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ make
make all-recursive
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
Making all in include
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
Making all in script
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'
Making all in init.d
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
Making all in sysconfig
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'
......
......
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/user'
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ make modules
make[1]: Entering directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'
CC [M] /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/mini.o
LD [M] /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/ec_mini.o
CC [M] /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/cdev.o
CC [M] /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/coe_emerg_ring.o
CC [M] /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/datagram.o
...........
............
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'
4.3. 安装EtherCAT
安装成功后前面指定/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output目录下有编译生成的各种用户空间的文件。
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ make install
Making install in include
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'
/usr/bin/install -c -m 644 ecrt.h ectty.h '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
Making install in script
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'
Making install in init.d
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Nothing to be done for 'install-exec-am'.
...........
..........
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
将EtharCAT相关文件打包
在/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output目录下创建modules文件夹,并复制ec_generic.ko和ec_master.ko到modules下
hjx@myir-server:/renesas/04_Sources/ethercat-stable-1.5$ mkdir -p output/modules/renesas/04_Sources/ethercat-stable-1.5$ cp devices/ec_generic.ko output/modules/
hjx@myir-server:
hjx@myir-server:/renesas/04_Sources/ethercat-stable-1.5$ cp master/ec_master.ko output/modules//renesas/04_Sources/ethercat-stable-1.5$ ls output
hjx@myir-server:
bin etc include lib modules sbin share
压缩output输出文件
hjx@myir-server:/renesas/04_Sources/ethercat-stable-1.5$ tar -jcvf output.tar.bz2 output//renesas/04_Sources/ethercat-stable-1.5$ ls output.tar.bz2
output/
output/etc/
output/etc/ethercat.conf
output/etc/init.d/
output/etc/init.d/ethercat
output/etc/sysconfig/
output/etc/sysconfig/ethercat
output/sbin/
output/sbin/ethercatctl
output/include/
output/include/ectty.h
output/include/ecrt.h
output/modules/
output/modules/ec_master.ko
output/modules/ec_generic.ko
output/share/
output/share/bash-completion/
output/share/bash-completion/completions/
output/share/bash-completion/completions/ethercat
output/bin/
output/bin/ethercat
output/lib/
output/lib/libethercat.so
output/lib/pkgconfig/
output/lib/pkgconfig/libethercat.pc
output/lib/libethercat.so.1.2.0
output/lib/cmake/
output/lib/cmake/ethercat/
output/lib/cmake/ethercat/ethercat-config.cmake
output/lib/libethercat.a
output/lib/libethercat.la
output/lib/libethercat.so.1
hjx@myir-server:
output.tar.bz2
至此IGH交叉编译完成,下面是在对应arm目标板上的操作。
4.5. 移植EtherCAT相关库到开发板
将上面制作好的output.tar.bz2传到开发板上,然后解压出来。
root@myir-remi-1g:~# tar -xvf output.tar.bz2
output/
output/etc/
output/etc/ethercat.conf
output/etc/init.d/
output/etc/init.d/ethercat
output/etc/sysconfig/
output/etc/sysconfig/ethercat
output/sbin/
output/sbin/ethercatctl
output/include/
output/include/ectty.h
output/include/ecrt.h
output/modules/
output/modules/ec_master.ko
output/modules/ec_generic.ko
output/share/
output/share/bash-completion/
output/share/bash-completion/completions/
output/share/bash-completion/completions/ethercat
output/bin/
output/bin/ethercat
output/lib/
output/lib/libethercat.so
output/lib/pkgconfig/
output/lib/pkgconfig/libethercat.pc
output/lib/libethercat.so.1.2.0
output/lib/cmake/
output/lib/cmake/ethercat/
output/lib/cmake/ethercat/ethercat-config.cmake
output/lib/libethercat.a
output/lib/libethercat.la
output/lib/libethercat.so.1
将output目录下各文件目录的内容复制到板子根文件系统根目录下相应目录下,例如:cp bin/ethercat /bin/(include目录不用复制)
root@myir-remi-1g:/output# ls/output# cp bin/ethercat /bin/
bin etc include lib modules sbin share
root@myir-remi-1g:
root@myir-remi-1g:/output# cp etc/ethercat.conf /etc//output# cp etc/init.d/* /etc/init.d
root@myir-remi-1g:
root@myir-remi-1g:/output# cp -r etc/sysconfig/ /etc//output# cp lib/libethercat.* /lib64/
root@myir-remi-1g:
root@myir-remi-1g:/output# cp -r lib/pkgconfig /lib64//output# cp modules/ec_master.ko /lib/modules/5.10.83-cip1-yocto-standard/
root@myir-remi-1g:
root@myir-remi-1g:~/output# cp sbin/ethercatctl /sbin/
启动EtherCAT
配置主站的MAC地址
root@myir-remi-1g:# depmod# modprobe ec_master main_devices=1E:ED:19:27:1A:B3
root@myir-remi-1g:
启动EtherCAT
root@myir-remi-1g:~# /etc/init.d/ethercat start
Starting EtherCAT master 1.5.2 done
更多回帖