ethercat移植至ARM

本文档详细介绍了如何在IMX6Q板上移植和配置EtherCAT协议栈,包括从下载源码、编译、解决编译错误、安装、打包、在目标板上部署以及启动和测试 EtherCAT 的步骤。通过这些步骤,读者可以了解如何在嵌入式系统中实现 EtherCAT 功能。
摘要由CSDN通过智能技术生成

需求:移植ethercat至imx6q板,使用内核版本为4.1.15

准备工作:
1.在官网 http://www.etherlab.org/en/ethercat/ 下载ethercat-1.5.2.tar.bz2。
2.准备目标arm板运行的内核源码,编译通过。
3.安装或者解压目标arm板相应的交叉编译工具。

步骤:
1.解压IGH源码进入目录

#tar xjf ethercat-1.5.2.tar.bz2
#cd ethercat-1.5.2/
#./configure --prefix=/opt/ethercat-1.5.2/ --with-linux-dir=/opt/linux/xxx/kernel_imx --enable-8139too=no --enable-generic=yes CC=arm-none-linux-gnueabi-gcc --host=arm-none-linux-gnueabi

2.编译源码

#make

错误:

/home/mm/work/project/ethercat/ethercat-1.5.2/devices/generic.c: In function 'ec_gen_device_init':
/home/mm/work/project/ethercat/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/mm/work/project/ethercat/ethercat-1.5.2/devices/generic.c:152:19: error: 'alloc_netdev' undeclared (first use in this function)
     dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
                   ^
/home/mm/work/project/ethercat/ethercat-1.5.2/devices/generic.c:152:19: note: each undeclared identifier is reported only once for each function it appears in
/home/mm/work/project/ethercat/ethercat-1.5.2/devices/generic.c:146:10: warning: unused variable 'null' [-Wunused-variable]
     char null = 0x00;
t/ethercat/ethercat-1.5.2/master/ethernet.c:151:72: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
     if (!(eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name, ether_setup))) {
                                                                        ^
/home/mm/work/project/ethercat/ethercat-1.5.2/master/ethernet.c:151:22: error: 'alloc_netdev' undeclared (first use in this function)
     if (!(eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name, ether_setup))) {

修改:

sudo vi devices/generic.c 
152行 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 vi master/ethernet.c
151行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))) {

3.指定交叉编译工具,编译modules

#make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
//编译通过会对应生成ethercat-1.5.2/devices/ec_generic.ko和ethercat-1.5.2/master/ec_master.ko
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值