openwrt补丁

http://wiki.openwrt.org/doc/devel/patches

中文文档:http://andelf.diandian.com/post/2013-05-22/40050677370

首先,如果我们的补丁是一个文件的话,可以将它们放置在openwrt/target/下面,这儿的文件一般情况下就是直接拷贝到build_dir中适当地地方去了,如下图。

而使用quilt制作的补丁文件,则是在需要修改一些Makefile或者Kconfig或者不是自己独有的文件情况下才需要的。

Working with patches

OpenWrt Buildroot integrates quilt for easy patch management. This document outlines some common patching tasks like adding a new patch or editing existing ones.

Prepare quilt configuration

In order to let quilt create patches in OpenWrts preferred format, a configuration file .quiltrc containing common diff and patch options must be created in the local home directory.

 

cat > ~/.quiltrc <<EOF
QUILT_DIFF_ARGS="--no-timestamps --no-index -pab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"
QUILT_PATCH_OPTS="--unified"
QUILT_DIFF_OPTS="-p"
EDITOR="nano"
EOF
  • EDITOR specifies the preferred editor for interactive patch editing
  • The other variables control the patch format property like a/, b/ directory names and no timestamps
  • FreeBSD does not support the --color=auto option and -pab must be written as -p ab

Adding a new patch

To add a completely new patch to an existing package example start with preparing the source directory:

make package/example/{clean,prepare} V=s QUILT=1

For host-side packages, you may want to detail the make target:

make package/example/host/{clean,prepare} V=s QUILT=1

This unpacks the source tarball and prepares existing patches as quilt patch series (if any). The verbose output will show where the source got extracted.

Change to the prepared source directory.

cd build_dir/target-*/example-*

Note : It can happen that you need to go one level lower as the source is extracted in build_dir/target-*/BUILD_VARIANT/example-* . This happens when multiple build variants of a package are defined in the Makefile.

Apply all existing patches using quilt push.

quilt push -a

Create a new, empty patch file with the quilt new command:

quilt new 010-main_code_fix.patch
  • The name should start with a number, followed by a hyphen and a very short description of what is changed
  • The choosen number should be higher than any existing patch - use quilt series to see the list of patches
  • The patch file name should be short but descriptive

After creating the empty patch, files to edit must be associated with it. The quilt add command can be used for that - once the file got added it can be edited as usual.
A shortcut for both adding a file and open it in an editor is the quilt edit command:

quilt edit src/main.c
  • src/main.c gets added to 010-main_code_fix.patch
  • The file is opened in the editor specified with EDITOR in .quiltrc

Repeat that for any file that needs to be edited.

After the changes are finished, they can be reviewed with the quilt diff command.

quilt diff

If the diff looks okay, proceed with quilt refresh to update the 010-main_code_fix.patch file with the changes made.

quilt refresh

Change back to the toplevel directory of the buildroot.

cd ../../../

To move the new patch file over to the buildroot, run update on the package:

make package/example/update V=s

Finally rebuild the package to test the changes:

make package/example/{clean,compile} package/index V=s

If problems occur, the patch needs to be edited again to solve the issues. Refer to the section below to learn how to edit existing patches.

Edit an existing patch

Start with preparing the source directory:

make package/example/{clean,prepare} V=s QUILT=1

Change to the prepared source directory.

cd build_dir/target-*/example-*

List the patches available:

quilt series

Advance to the patch that needs to be edited:

quilt push 010-main_code_fix.patch
  • When passing a valid patch filename to push, quilt will only apply the series until it reaches the specified patch
  • If unsure, use quilt series to see existing patches and quilt top to see the current position
  • If the current position is beyound the desired patch, use quilt pop to remove patches in the reverse order

Edit the patched files using the quilt edit command, repeat for every file that needs changes.

quilt edit src/main.c

Check which files are to be included in the patch:

quilt files

Review the changes with quilt diff.

quilt diff

If the diff looks okay, proceed with quilt refresh to update the current patch with the changes made.

quilt refresh

Change back to the toplevel diretory of the buildroot.

cd ../../../

To move the updated patch file over to the buildroot, run update on the package:

make package/example/update V=s

Finally rebuild the package to test the changes:

make package/example/{clean,compile} package/index V=s

Adding or editing kernel patches

The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.
:!: For the kernel, an additional subdirectory for patches is used, generic/ contains patches common to all architectures and platform/ contains patches specific to the current target.

To prepare the kernel tree, use:

make target/linux/{clean,prepare} V=s QUILT=1

For Attitude Adjustment, the source tree is in the linux-architecture subdirectory:

cd build_dir/linux-*/linux-3.*

For Barrier Breaker (trunk), the source tree is in the target-architecture subdirectory (potentially with a subarch):

cd build_dir/target-*/linux-*/linux-3.*

Moving the changes back over to the buildroot tree from the build tree is done with:

make target/linux/update package/index V=s

(:!: Patches should be named with the correct prefix, platform/000-abc.patch or generic/000-abc.patch. If not the update may not work correctly.)

Afterwards, if we want to verify whether our patch is applied or not, we can go to the top level directory with

cd ../../../../

and preparing again the linux folder for some modification with

make target/linux/{clean,prepare} V=s QUILT=1

During this process all the applied patched will be shown, ours being among them, preceeded by generic/ or platform/ depending on what directory we placed the patch. Another way of retrieving the applied patches is through

quilt series

as explained on the previous sections, after having made make target/linux/{clean,prepare} …

Adding or editing toolchain patches

For example, gcc:

To prepare the tool tree, use:

make toolchain/gcc/{clean,prepare} V=99 QUILT=1

The source tree depends on chosen lib and gcc :

cd build_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/gcc-4.3.3

Refreshing the patches is done with:

make toolchain/gcc/update V=99

Refreshing patches

When a patched package (or kernel) is updated to a newer version, existing patches might not apply cleanly anymore and patch will report fuzz when applying them. To rebase the whole patch series the refresh make target can be used:

make package/example/refresh V=s

For kernels, use:

make target/linux/refresh V=s

Iteratively modify patches without cleaning the source tree

When implementing new changes, it is often required to edit patches multiple times. To speed up the process, it is possible to retain the prepared source tree between edit operations.

  1. Initially prepare the source tree as documented above
  2. Change to the prepared source directory
  3. Advance to the patch needing changes
  4. Edit the files and refresh the patch
  5. Fully apply the remaining patches using quilt push -a (if any)
  6. From the toplevel directory, run make package/example/{compile,install} or make target/linux/{compile,install} for kernels
  7. Test the binary
  8. If further changes are needed, repeat from step 2.
  9. Finally run make package/example/update or make target/linux/update for kernels to copy the changes back to buildroot

Further information

Back to top

doc/devel/patches.txt · Last modified: 2014/06/27 10:59 by jow

 

 

 http://andelf.diandian.com/post/2013-05-22/40050677370

为 OpenWrt 加入新设备支持 // Add New Profile To OpenWrt

最近折腾 TL-MR10U, 可直接刷 WR703N 固件, 不过 USB 不能供电, 网络, LED 正常. 所以需要修复下. 记录+教程.

假定已经有了完整 OpenWrt 开发环境. 包括编辑器, 配置好的 quilt 工具.

经过本人实践, 当前(20130522)在互联网上能找到的大部分教程都不靠谱, 或多或少有错误或者坑, 有的干脆就是错的.

配置开发环境

请参考其他文献设置开发环境. 前几篇恰好写过.

简单介绍下 quilt 工具, quilt 是用来管理代码树中的 patch 的, 嵌入式内核开发利器!

请通过软件包管理器安装 quilt. 然后写入以下配置文件到 ~/.quiltrc , 另外需要 export EDITOR="你编辑利器" .

QUILT_DIFF_ARGS="--no-timestamps --no-index -pab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"
QUILT_PATCH_OPTS="--unified"
QUILT_DIFF_OPTS="-p"
EDITOR="emacs --no-init --quick"

准备工作

假定 ~/openwrt 是你的开发目录, 建议直接在 git branch 下开发.

假设之前已经编译过 bin, 有完整的 .config 和 toolchain.

建立开发 branch: (git 教程自行脑补)

~/openwrt$ git checkout -b add-tl-mr10u-support

清理 tmp 目录!!!!!! 这个是大坑. 直接删除.

~/openwrt$ rm -rvf tmp/

修改 OpenWrt 代码

进入设备硬件目录:

~/openwrt$ cd target/linux/ar71xx

修改以下文件, 里面涉及到 TL-MR10U 固件中设备ID的部分, 是 0x00100101, 这个值从 tp-link 官方网站下载的固件中可以获得.

  • base-files/etc/diag.sh
  • base-files/etc/uci-defaults/02_network
  • base-files/lib/ar71xx.sh
  • base-files/lib/upgrade/platform.sh
  • config-3.8
  • generic/profiles/tp-link.mk
  • image/Makefile

新建文件: files/arch/mips/ath79/mach-tl-mr10u.c , 内容参考 TL-WR703N 设备的文件 mach-tl-wr703n.c, 修改所有出现 wr703n, WR703N 等等大小写混合的部分, emacs 无痛苦完成.

添加 Linux patch

这里就完成了 OpenWrt 的设备支持代码. 为了支持我们的设备, Linux 代码树的部分文件也需要做改动, OpenWrt 采用了 patch 的方式实现.

回退到根目录 ~/openwrt .

清理并准备 patch 树:

~/openwrt$ make target/linux/{clean,prepare} # 后面可加 V=s QUILT=1 参数, 表示静默无输出

进入内核代码目录(其中版本号可能与你的不一致):

~/openwrt$ cd build_dir/target-mips_r2_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.8.12/

这里就是内核代码树了, 里面的代码是已经打过所有 patch 的, 可以用 quilt push 检查看是不是这样:

$ quilt push
File series fully applied, ends at patch platform/902-unaligned_access_hacks.patch

这条输入也告诉我们, 当前最顶的 patch 是 platform/902 (这个是坑啊, 官方文档不带 platform 前缀, 是错的).

为我们的 TL-MR10U 新建个 patch:

$ quilt new platform/920-add-tl-mr10u-support.patch

选择的数字需要大于刚才的那个 902, 然后 quilt 会自动把这个 patch 设置为当前 patch, 所有的改动都针对这个 patch.

然后就是增加代码了

$ quilt edit arch/mips/ath79/Kconfig
$ quilt edit arch/mips/ath79/Makefile
$ quilt edit arch/mips/ath79/machtypes.h

至于怎么改, 参考这些文件里其他硬件的配置, 基本上说 copy TL-WR703N 的就可以了. 保证不重不漏.

然后验证下修改的内容:

$ quilt diff # 查看 diff
$ quilt refresh # 保存所有 diff 到 patch 文件

这个时候我们的 patch 文件还在 build_dir 里, 大概位置是 patches/platform/ 下. 需要同步到 OpenWrt 代码树.

# 退回到顶层工作目录, 执行:
~/openwrt$ make target/linux/update V=s

同步完成后, patch 文件会出现在 target/linux/ar71xx/patches-3.8/ 下.

固件工具代码修改

OpenWrt 包含一个 TP-LINK 固件小工具, tools/firmware-utils/src/mktplinkfw.c , 里面包含 TP-LINK 固件 bin 文件的结构和 md5 hash 验证算法.

修改内容参考 WR703N 就好.

查看效果

这里应该已经完成了所有操作. 可以编译了

# 再次记得, 删除 tmp 目录
~/openwrt$ rm -rvf tmp/
~/openwrt$ make menuconfig
.....
自己编译

所有修改文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index ed269b2..c279cb3 100755
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -134,6 +134,7 @@ get_status_led() {
                ;;
        tl-wdr4300 | \
        tl-wr703n | \
+       tl-mr10u | \
        tl-wr720n-v3)
                status_led="tp-link:blue:system"
                ;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index a9a3ff2..01733d9 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -200,6 +200,7 @@ tl-mr3040 |\
 tl-wa901nd |\
 tl-wa901nd-v2 |\
 tl-wr703n |\
+tl-mr10u |\
 wndap360 |\
 wp543)
        ucidef_set_interface_lan "eth0"
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 194a40b..2ba26e5 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -132,6 +132,9 @@ tplink_board_detect() {
        "254300"*)
                model="TP-Link TL-WR2543N/ND"
                ;;
+       "100101"*)
+               model="TP-Link TL-MR10U"
+               ;;
        "110101"*)
                model="TP-Link TL-MR11U"
                ;;
@@ -441,6 +444,9 @@ ar71xx_board_detect() {
        *"TL-WR720N v3")
                name="tl-wr720n-v3"
                ;;
+       *"TL-MR10U")
+               name="tl-mr10u"
+               ;;
        *"TL-MR11U")
                name="tl-mr11u"
                ;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 817123b..8838234 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -154,6 +154,7 @@ platform_check_image() {
                platform_check_image_openmesh "$magic_long" "$1" && return 0
                return 1
                ;;
+       tl-mr10u | \
        tl-mr11u | \
        tl-mr3020 | \
        tl-mr3040 | \
diff --git a/target/linux/ar71xx/config-3.8 b/target/linux/ar71xx/config-3.8
index ea2be6b..389799d 100644
--- a/target/linux/ar71xx/config-3.8
+++ b/target/linux/ar71xx/config-3.8
@@ -61,6 +61,7 @@ CONFIG_ATH79_MACH_RW2458N=y
 CONFIG_ATH79_MACH_TEW_632BRP=y
 CONFIG_ATH79_MACH_TEW_673GRU=y
 CONFIG_ATH79_MACH_TEW_712BR=y
+CONFIG_ATH79_MACH_TL_MR10U=y
 CONFIG_ATH79_MACH_TL_MR11U=y
 CONFIG_ATH79_MACH_TL_MR3020=y
 CONFIG_ATH79_MACH_TL_MR3X20=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr10u.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr10u.c
new file mode 100644
index 0000000..e3906e1
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr10u.c
@@ -0,0 +1,89 @@
+/*
+ *  TP-LINK TL-MR10U board support
+ *
+ *  Copyright (C) 2011 dongyuqi <729650915@qq.com>
+ *  Copyright (C) 2013 andelf <andelf@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/gpio.h>
+
+#include <asm/mach-ath79/ath79.h>
+
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define TL_MR10U_GPIO_LED_SYSTEM       27
+#define TL_MR10U_GPIO_BTN_RESET        11
+
+#define TL_MR10U_GPIO_USB_POWER        8
+
+#define TL_MR10U_KEYS_POLL_INTERVAL    20      /* msecs */
+#define TL_MR10U_KEYS_DEBOUNCE_INTERVAL        (3 * TL_MR10U_KEYS_POLL_INTERVAL)
+
+static const char *tl_mr10u_part_probes[] = {
+       "tp-link",
+       NULL,
+};
+
+static struct flash_platform_data tl_mr10u_flash_data = {
+       .part_probes    = tl_mr10u_part_probes,
+};
+
+static struct gpio_led tl_mr10u_leds_gpio[] __initdata = {
+       {
+               .name           = "tp-link:blue:system",
+               .gpio           = TL_MR10U_GPIO_LED_SYSTEM,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button tl_mr10u_gpio_keys[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = TL_MR10U_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = TL_MR10U_GPIO_BTN_RESET,
+               .active_low     = 0,
+       }
+};
+
+static void __init tl_mr10u_setup(void)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
+       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
+
+       /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
+       ath79_setup_ar933x_phy4_switch(false, false);
+
+       ath79_register_m25p80(&tl_mr10u_flash_data);
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr10u_leds_gpio),
+                                tl_mr10u_leds_gpio);
+       ath79_register_gpio_keys_polled(-1, TL_MR10U_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(tl_mr10u_gpio_keys),
+                                       tl_mr10u_gpio_keys);
+
+       gpio_request_one(TL_MR10U_GPIO_USB_POWER,
+                        GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+                        "USB power");
+       ath79_register_usb();
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+
+       ath79_register_mdio(0, 0x0);
+       ath79_register_eth(0);
+
+       ath79_register_wmac(ee, mac);
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_MR10U, "TL-MR10U", "TP-LINK TL-MR10U",
+            tl_mr10u_setup);
diff --git a/target/linux/ar71xx/generic/profiles/tp-link.mk b/target/linux/ar71xx/generic/profiles/tp-link.mk
index 4ac6ba9..3057cfa 100644
--- a/target/linux/ar71xx/generic/profiles/tp-link.mk
+++ b/target/linux/ar71xx/generic/profiles/tp-link.mk
@@ -5,6 +5,17 @@
 # See /LICENSE for more information.
 #
 
+define Profile/TLMR10U
+       NAME:=TP-LINK TL-MR10U
+       PACKAGES:=kmod-usb-core kmod-usb2
+endef
+
+define Profile/TLMR10U/Description
+       Package set optimized for the TP-LINK TL-MR10U.
+endef
+$(eval $(call Profile,TLMR10U))
+
+
 define Profile/TLMR11U
        NAME:=TP-LINK TL-MR11U
        PACKAGES:=kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index c6b4dc4..d0485b0 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -927,6 +927,7 @@ $(eval $(call SingleProfile,TPLINK,$(fs_64kraw),TLWR941NV3,tl-wr941nd-v3,TL-WR94
 $(eval $(call SingleProfile,TPLINK,$(fs_64kraw),TLWR941NV4,tl-wr941nd-v4,TL-WR741ND,ttyS0,115200,0x09410004,1,4M))
 $(eval $(call SingleProfile,TPLINK,$(fs_64kraw),TLWR1043,tl-wr1043nd-v1,TL-WR1043ND,ttyS0,115200,0x10430001,1,8M))
 
+$(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLMR10U,tl-mr10u-v1,TL-MR10U,ttyATH0,115200,0x00100101,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLMR11UV1,tl-mr11u-v1,TL-MR11U,ttyATH0,115200,0x00110101,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLMR11UV2,tl-mr11u-v2,TL-MR11U,ttyATH0,115200,0x00110102,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLMR3020,tl-mr3020-v1,TL-MR3020,ttyATH0,115200,0x30200001,1,4Mlzma))
diff --git a/target/linux/ar71xx/patches-3.8/920-add_tl-mr10u_support.patch b/target/linux/ar71xx/patches-3.8/920-add_tl-mr10u_support.patch
new file mode 100644
index 0000000..26e8a00
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.8/920-add_tl-mr10u_support.patch
@@ -0,0 +1,39 @@
+--- a/arch/mips/ath79/Kconfig
++++ b/arch/mips/ath79/Kconfig
+@@ -495,6 +495,16 @@ config ATH79_MACH_EAP7660D
+       select ATH79_DEV_LEDS_GPIO
+       select ATH79_DEV_M25P80
+
++config ATH79_MACH_TL_MR10U
++      bool "TP-LINK TL-MR10U support"
++      select SOC_AR933X
++      select ATH79_DEV_ETH
++      select ATH79_DEV_GPIO_BUTTONS
++      select ATH79_DEV_LEDS_GPIO
++      select ATH79_DEV_M25P80
++      select ATH79_DEV_USB
++      select ATH79_DEV_WMAC
++
+ config ATH79_MACH_TL_MR11U
+       bool "TP-LINK TL-MR11U/TL-MR3040 support"
+       select SOC_AR933X
+--- a/arch/mips/ath79/Makefile
++++ b/arch/mips/ath79/Makefile
+@@ -77,6 +77,7 @@ obj-$(CONFIG_ATH79_MACH_RW2458N)     += mach
+ obj-$(CONFIG_ATH79_MACH_TEW_632BRP)   += mach-tew-632brp.o
+ obj-$(CONFIG_ATH79_MACH_TEW_673GRU)   += mach-tew-673gru.o
+ obj-$(CONFIG_ATH79_MACH_TEW_712BR)    += mach-tew-712br.o
++obj-$(CONFIG_ATH79_MACH_TL_MR10U)     += mach-tl-mr10u.o
+ obj-$(CONFIG_ATH79_MACH_TL_MR11U)     += mach-tl-mr11u.o
+ obj-$(CONFIG_ATH79_MACH_TL_MR3020)    += mach-tl-mr3020.o
+ obj-$(CONFIG_ATH79_MACH_TL_MR3X20)    += mach-tl-mr3x20.o
+--- a/arch/mips/ath79/machtypes.h
++++ b/arch/mips/ath79/machtypes.h
+@@ -78,6 +78,7 @@ enum ath79_mach_type {
+       ATH79_MACH_TEW_632BRP,          /* TRENDnet TEW-632BRP */
+       ATH79_MACH_TEW_673GRU,          /* TRENDnet TEW-673GRU */
+       ATH79_MACH_TEW_712BR,           /* TRENDnet TEW-712BR */
++      ATH79_MACH_TL_MR10U,            /* TP-LINK TL-MR10U */
+       ATH79_MACH_TL_MR11U,            /* TP-LINK TL-MR11U */
+       ATH79_MACH_TL_MR3020,           /* TP-LINK TL-MR3020 */
+       ATH79_MACH_TL_MR3040,           /* TP-LINK TL-MR3040 */
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
index 74a55fd..7596e03 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -43,6 +43,7 @@
 #define HWID_TL_WA901ND_V1     0x09010001
 #define HWID_TL_WA901ND_V2     0x09010002
 #define HWID_TL_WDR4900_V1     0x49000001
+#define HWID_TL_MR10U_V1       0x00100101
 #define HWID_TL_WR703N_V1      0x07030101
 #define HWID_TL_WR720N_V3      0x07200103
 #define HWID_TL_WR741ND_V1     0x07410001
@@ -338,6 +339,11 @@ static struct board_info boards[] = {
                .hw_rev         = 1,
                .layout_id      = "4Mlzma",
        }, {
+               .id             = "TL-MR10Uv1",
+               .hw_id          = HWID_TL_MR10U_V1,
+--- a/arch/mips/ath79/machtypes.h
++++ b/arch/mips/ath79/machtypes.h
+@@ -78,6 +78,7 @@ enum ath79_mach_type {
+       ATH79_MACH_TEW_632BRP,          /* TRENDnet TEW-632BRP */
+       ATH79_MACH_TEW_673GRU,          /* TRENDnet TEW-673GRU */
+       ATH79_MACH_TEW_712BR,           /* TRENDnet TEW-712BR */
++      ATH79_MACH_TL_MR10U,            /* TP-LINK TL-MR10U */
+       ATH79_MACH_TL_MR11U,            /* TP-LINK TL-MR11U */
+       ATH79_MACH_TL_MR3020,           /* TP-LINK TL-MR3020 */
+       ATH79_MACH_TL_MR3040,           /* TP-LINK TL-MR3040 */
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
index 74a55fd..7596e03 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -43,6 +43,7 @@
 #define HWID_TL_WA901ND_V1     0x09010001
 #define HWID_TL_WA901ND_V2     0x09010002
 #define HWID_TL_WDR4900_V1     0x49000001
+#define HWID_TL_MR10U_V1       0x00100101
 #define HWID_TL_WR703N_V1      0x07030101
 #define HWID_TL_WR720N_V3      0x07200103
 #define HWID_TL_WR741ND_V1     0x07410001
@@ -338,6 +339,11 @@ static struct board_info boards[] = {
                .hw_rev         = 1,
                .layout_id      = "4Mlzma",
        }, {
+               .id             = "TL-MR10Uv1",
+               .hw_id          = HWID_TL_MR10U_V1,
+               .hw_rev         = 1,
+               .layout_id      = "4Mlzma",
+       }, {
                .id             = "TL-WR720Nv3",
                .hw_id          = HWID_TL_WR720N_V3,
                .hw_rev         = 1,

参考文献

  • OpenWrt: Working with patches http://wiki.openwrt.org/doc/devel/patches
  • Patchwork [OpenWrt-Devel] ar71xx: add TP-LINK TL-MR10U http://patchwork.openwrt.org/patch/3656/
  • 恩山无线配件网: 自己动手,为OpenWrt加入720N的支持 http://www.right.com.cn/forum/thread-100342-1-1.html

修改记录

20130523 去掉了 mach-tl-mr10u.c 中的 MISP_MACHINE 定义中的 v1, 保证各个脚本工作正常.

 

Merlin添加:

我这儿的操作过程

tf@ubuntu:~/projects/openwrt$ make target/linux/clean
 make[1] target/linux/clean
 make[2] -C target/linux clean
tf@ubuntu:~/projects/openwrt$ make target/linux/prepare
 make[1] target/linux/prepare
 make[2] -C target/linux prepare
tf@ubuntu:~/projects/openwrt$ cd build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49/
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt push
File series fully applied, ends at patch platform/902-unaligned_access_hacks.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt new platform/903-modify_spi_gpio_merlin.patch
Patch platform/903-modify_spi_gpio_merlin.patch is now on top
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt edit arch/mips/ath79/Makefile 
File arch/mips/ath79/Makefile added to patch platform/903-modify_spi_gpio_merlin.patch

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/vim.basic
  4. /usr/bin/vim.tiny

Choose 1-4 [2]: 3
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt edit arch/mips/ath79/Kconfig 
File arch/mips/ath79/Kconfig added to patch platform/903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt diff
--- a/arch/mips/ath79/Kconfig
+++ b/arch/mips/ath79/Kconfig
@@ -338,6 +338,7 @@ config ATH79_MACH_DRAGINO2
        bool "DRAGINO V2 support"
        select SOC_AR933X
        select ATH79_DEV_M25P80
+       select ATH79_DEV_SPI_GPIO
        select ATH79_DEV_GPIO_BUTTONS
        select ATH79_DEV_LEDS_GPIO
        select ATH79_DEV_WMAC
@@ -1068,6 +1069,9 @@ config ATH79_DEV_M25P80
        select ATH79_DEV_SPI
        def_bool n
 
+config ATH79_DEV_SPI_GPIO
+       def_bool n
+
 config ATH79_DEV_AP9X_PCI
        select ATH79_PCI_ATH9K_FIXUP
        def_bool n
--- a/arch/mips/ath79/Makefile
+++ b/arch/mips/ath79/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_ATH79_DEV_ETH)           += dev-eth.
:
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt refresh
Refreshed patch platform/903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ cd ../../../../
tf@ubuntu:~/projects/openwrt$ make target/linux/update V=s
...
xx_generic/linux-3.10.49/patches/platform/901-mdio_bitbang_ignore_ta_value.patch' -> './patches-3.10/901-mdio_bitbang_ignore_ta_value.patch'
'/home/tf/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49/patches/platform/902-unaligned_access_hacks.patch' -> './patches-3.10/902-unaligned_access_hacks.patch'
'/home/tf/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49/patches/platform/903-modify_spi_gpio_merlin.patch' -> './patches-3.10/903-modify_spi_gpio_merlin.patch'
make[3]: Leaving directory `/home/tf/projects/openwrt/target/linux/ar71xx'
make[2]: Leaving directory `/home/tf/projects/openwrt/target/linux'
make[1]: Leaving directory `/home/tf/projects/openwrt'
tf@ubuntu:~/projects/openwrt$ ls
...
723-MIPS-ath79-add-om5p-support.patch
901-mdio_bitbang_ignore_ta_value.patch
902-unaligned_access_hacks.patch
903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/target/linux/ar71xx/patches-3.10$ 

 

 

Merlin添加:

如何修改刚刚的903补丁?

tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt files platform/903-modify_spi_gpio_merlin.patch
arch/mips/ath79/Kconfig
arch/mips/ath79/Makefile
platform/903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt refresh
Patch platform/903-modify_spi_gpio_merlin.patch is unchanged

//由于Kconfig和Makefile已经在903补丁中的记录了,所以直接使用其它编辑器去修改也可以了。如果files命令时没有文件需要更新到补丁中去,那么需要先quilt edit之。

//这儿使用外部编辑器Geany编辑了Kconfig文件的select ATH79_DEV_SPI_GPIO,最末加上了标记 //merlin

tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt edit testMelin
File testMelin added to patch platform/903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$ quilt refresh
Refreshed patch platform/903-modify_spi_gpio_merlin.patch
tf@ubuntu:~/projects/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49$

结果903补丁的内容为:

--- a/arch/mips/ath79/Kconfig
+++ b/arch/mips/ath79/Kconfig
@@ -338,6 +338,7 @@ config ATH79_MACH_DRAGINO2
     bool "DRAGINO V2 support"
     select SOC_AR933X
     select ATH79_DEV_M25P80
+    select ATH79_DEV_SPI_GPIO //merlin
     select ATH79_DEV_GPIO_BUTTONS
     select ATH79_DEV_LEDS_GPIO
     select ATH79_DEV_WMAC
@@ -1068,6 +1069,9 @@ config ATH79_DEV_M25P80
     select ATH79_DEV_SPI
     def_bool n
 
+config ATH79_DEV_SPI_GPIO
+     def_bool n
+
 config ATH79_DEV_AP9X_PCI
     select ATH79_PCI_ATH9K_FIXUP
     def_bool n
--- a/arch/mips/ath79/Makefile
+++ b/arch/mips/ath79/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_ATH79_DEV_ETH)        += dev-eth.
 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS)    += dev-gpio-buttons.o
 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)    += dev-leds-gpio.o
 obj-$(CONFIG_ATH79_DEV_M25P80)        += dev-m25p80.o
+obj-$(CONFIG_ATH79_DEV_SPI_GPIO)    += dev-spi-gpio.o
 obj-$(CONFIG_ATH79_DEV_NFC)        += dev-nfc.o
 obj-$(CONFIG_ATH79_DEV_SPI)        += dev-spi.o
 obj-$(CONFIG_ATH79_DEV_USB)        += dev-usb.o
--- /dev/null
+++ b/testMelin
@@ -0,0 +1 @@
+dkdi.sls

 

对应用程序进行制作补丁patch

make package/utils/xxx/clean V=s

make package/utils/xxx/prepare V=s

这样还没有修改的代码就已经解压到build_dir中了,使用cd build_dir/target.../xxx/到达应用程序目录

使用quiltnew命令新建一个补丁

quilt new 101-test_add_comment.patch

使用quilt edit命令修改某个文件如src/main.c

quilt edit src/main.c

修改完成后保存退出

运行quilt diff看变化前后,

最后运行quilt refresh命令会生成101-test_add_comment.patch

将这个patch文件拷贝到package/utils/xxx/patch下面去,这样在下一次

make package/utils/xxx/prepare V=s

时就会将刚刚的修改应用到该应用程序中了!

posted @ 2014-08-29 08:56  Merlin-magic  阅读(4142)  评论(0编辑  收藏  举报