openwrt補丁

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

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

首先,若是咱們的補丁是一個文件的話,能夠將它們放置在openwrt/target/下面,這兒的文件通常狀況下就是直接拷貝到build_dir中適當地地方去了,以下圖。linux

而使用quilt製做的補丁文件,則是在須要修改一些Makefile或者Kconfig或者不是本身獨有的文件狀況下才須要的。git

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.redis

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:ubuntu

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

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

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.app

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

時就會將剛剛的修改應用到該應用程序中了!

相關文章
相關標籤/搜索