以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文件修改即可。