Igh EthercatMaster利用官方给的update.sh脚本生成其他内核版本的网卡驱动

以igb网卡为例。

进入device/igb目录执行update.sh脚本,按照说明填入内核源码位置,需要提取补丁的版本,需要生成的版本

比如以下命令,提取3.18版本的补丁,从~/develop/linux3.16.7目录提取驱动,打上补丁并命名为3.16版本

./update.sh ~/develop/linux-3.16.7 3.18 3.16

 打补丁的过程中会提示某些项目失败,比如

Hunk #31 FAILED at 6495.
Hunk #32 succeeded at 6523 (offset -23 lines).
Hunk #33 succeeded at 6536 (offset -23 lines).
Hunk #34 succeeded at 6580 (offset -23 lines).
Hunk #35 succeeded at 6726 (offset -26 lines).
Hunk #36 succeeded at 6765 (offset -26 lines).
Hunk #37 succeeded at 7120 (offset 81 lines).
Hunk #38 succeeded at 7149 (offset 81 lines).
Hunk #39 succeeded at 7159 (offset 81 lines).
3 out of 39 hunks FAILED -- saving rejects to file igb_main-3.16-ethercat.c.rej
+ for f in $FILES
+ echo igb_ptp.c
igb_ptp.c
+ o=igb_ptp-3.16-orig.c

同时会生成相应的.rej文件。

打开相应的.rej文件,然后手动把这些代码补上。

以3.16.7版本内核为例,会产生

igb_main-3.16-ethercat.c.rej 这个文件

打开可以看到

--- /dev/null
+++ /dev/null
@@ -56,17 +58,17 @@
 #include <linux/dca.h>
 #endif
 #include <linux/i2c.h>
-#include "igb.h"
+#include "igb-3.18-ethercat.h"

 #define MAJ 5
 #define MIN 2
 #define BUILD 15
 #define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
-__stringify(BUILD) "-k"
-char igb_driver_name[] = "igb";
+__stringify(BUILD) "-k-EtherCAT"
+char igb_driver_name[] = "ec_igb";
 char igb_driver_version[] = DRV_VERSION;
 static const char igb_driver_string[] =
-                               "Intel(R) Gigabit Ethernet Network Driver";
+       "Intel(R) Gigabit Ethernet Network Driver (EtherCAT-enabled)";
 static const char igb_copyright[] =
                                "Copyright (c) 2007-2014 Intel Corporation.";

@@ -1828,7 +1863,7 @@
        adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE;
 

这样的代码

@@ -56,17 +58,17 @@ 提示需要修改的代码在第几行附近

-#include "igb.h"
+#include "igb-3.18-ethercat.h"

提示将 #include "igb.h" 修改为 #include "igb-3.18-ethercat.h"

按照提示将igb_main-3.16-ethercat.c文件修改即可。

 

 

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
1.基于Igh-master1.5.2的多种Ethercat IO 模块及伺服电机的操作例子 2.基于Ethercat-Ighmaster二次开发库简化你的开发流程 所有源码及文档托管在码云平台,附件中有代码仓库地址 3.含有IghMaster1.5.2最新版本代码,编译脚本及安装到 最新的代码托管在: https://gitee.com/wllw7176/MyEthercat-IGH-1.5.2.git EtherCAT 1.5.2 编译及使用说明 1.交叉编译源码 源码中有内核模块编译,指令定模块目录 根据实际情况修改build_ethercat-1.5.2.sh中以下几个变量: output_dir='output' #编译输出目录 module_install_dir='module_install' #内核模块安装目录 kernel_source_dir='/mnt/fs_ext/imx6/linux-3.0.35' #内核源码目录 lib_modules_kernel_promt='3.0.35-2666-gbdde708' #内核版本号 host=arm-fsl-linux-gnueabi #交叉编译链前缀 注意要先编译内核,然后编译Ethrecat因为Ethercat依赖于内核通用网卡模块 以root用户运行./build_ethercat-1.5.2.sh #编译具体根据提示选择y/n就可以了 ---------------------------------------------------------------------------------------------------------------------------------------------- 手动安装Ethercat到ARM开发板: 2.内核模块安装 2.1 将output文件下通lib_modules_kernel_promt='3.0.35-2666-gbdde708'(build_ethercat-1.5.2.sh 中定义)放入开发板/lib/modules下 2.2 开发板中执行"depmod"命令 3. output里面的其它文件放入开发板对应位置 4. 设置参数 修改/etc/sysconfig/ethercat MASTER0_DEVICE="e4:f3:f5:c6:41:b6" #与ethercat绑定的Mac地址 DEVICE_MODULES="generic" #通用网卡就填generic,其余支持网卡换成模块名字就行 5.添加udev规则 echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules 6. 启动服务 /etc/init.d/ethercat restart 出现以下信息表明移植成功 Shutting down EtherCAT master 1.5.2 done Starting EtherCAT master 1.5.2 ec_generic: Binding socket to interface 3 (eth0). done 7. 应用层测试 root@linaro-ubuntu-desktop:~# ethercat Please specify a command! Usage: ethercat [OPTIONS] [ARGUMENTS] Commands (can be abbreviated): alias Write alias addresses. config Show slave configurations. 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. 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. 以上内容为基本的使用,进一步使用要结合ethercat说明文档和电机说明。 ---------------------------------------------------------------------------------------------------------------------------------------------- 自动安装Ethercat到ARM开发板: 将output目录复制到开发板然后运行output目录下install_to_arm.sh脚本 执行6,7步骤测试自动安装是否成功 ---------------------------------------------------------------------------------------------------------------------------------------------- 问题汇总: (1)Starting EtherCAT master 1.5.2 EtherCAT ERROR: MAC address may not be empty. FATAL: Error inserting ec_master (/lib/modules/3.0.35-2666-gbdde708-gbdbf2583/mnt/hgfs/win_linux_share/linux/download/ethercat-1.5.2/module_install/master/ec_master.ko): Invalid argument failed Mac地址为空,将对应的mac地址MASTER0_DEVICE="e4:f3:f5:c6:41:b6" (2)编译Ethercat 一定要保证所用编译器与内核与硬件平台一致,否则会出现内核模块不能使用或者其它未知问题 (3)内核源码要先编译通过,否则Ethercat模块将不能编译通过,因为Ethercat模块依赖于内核本身驱动模块。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值