爲 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, 保證各個腳本工做正常.