Ubuntu下编译TPLink TL-WR743N V2的Openwrt固件-替代法
此方法是在TL-WR703N的源码上进行修改,用743替代703,原703失效
环境要求
编译一个可以安装的OpenWrt固件镜像文件(大约8MB大小的),你需要:
- 一个纯净的OpenWrt编译系统大约需要200MB的空间。
- 一个包含feeds的OpenWrt编译系统大约需要300MB的空间。
- 编译feeds中的软件包大约需要2.1GB的空间用于存放下载来的源代码。
- 构建OpenWrt并生成固件文件需要大约3-4 GB的空间。
- 编译OpenWrt需要大约1-4 GB的内存。
以非root用户来进行工作
1、下载源码
git clone git://git.openwrt.org/15.05/openwrt.git
从最新代码恢复为15.05的主干代码
git checkout 483dac821788b457d349233e770329186a0aa860
openwrt/include/version.mk文件可以查看版本号
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),15.05)
2、配置
cd openwrt
下载并安装所有可用的"feeds",这是为了下载和安装让luci之类的第三方包的源码,如果不进行这步的话配置菜单是没有非openwrt的包给你选的
./scripts/feeds update -a
./scripts/feeds install -a
运行下面的命令让OpenWrt编译系统检查你的编译环境中缺失的软件包:
make defconfig
make prereq
然后
make menuconfig
选编译的目标系统(Atheros AR7XXX架构,profile为703N):
选缺省组件:
编辑完成后点击“save”保存配置文件:
3、修改源文件
make前修改如下文件:
1)增加网口:703只有一个网口,743有1个WAN,4个LAN口,粗体为修改部分
openwrt\target\linux\ar71xx\files\arch\mips\ath79\mach-tl-wr703n.c
ath79_register_usb();
//ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
//ywb
ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
ath79_register_mdio(0, 0x0);
//ath79_register_eth(0);
//ywb
/* LAN ports */
ath79_register_eth(1);
/* WAN port */
ath79_register_eth(0);
if (sec_ethernet)
2)修改指示灯,粗体为修改部分
修改openwrt\target\linux\ar71xx\files\arch\mips\ath79\mach-tl-wr703n.c
#include <linux/gpio.h>
#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/ar71xx_regs.h>
#include "common.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_WR703N_GPIO_LED_SYSTEM 27
#define TL_WR743_GPIO_LED_SYSTEM 27
#define TL_WR743_GPIO_LED_QSS 26
#define TL_WR743_GPIO_LED_WLAN 0
#define TL_WR743_GPIO_LED_WAN 17
#define TL_WR743_GPIO_LED_LAN1 13
#define TL_WR743_GPIO_LED_LAN2 14
#define TL_WR743_GPIO_LED_LAN3 15
#define TL_WR743_GPIO_LED_LAN4 16
#define TL_WR743_GPIO_LED_3G 1
#define TL_WR743_GPIO_BTN_RESET 11
#define TL_WR703N_GPIO_BTN_RESET 11
...
static struct flash_platform_data tl_wr703n_flash_data = {
.part_probes = tl_wr703n_part_probes,
};
/*
static struct gpio_led tl_wr703n_leds_gpio[] __initdata = {
{
.name = "tp-link:blue:system",
.gpio = TL_WR703N_GPIO_LED_SYSTEM,
.active_low = 1,
},
};*/
static struct gpio_led tl_wr743_leds_gpio[] __initdata = {
{
.name = "tp-link:green:system",
.gpio = TL_WR743_GPIO_LED_SYSTEM,
.active_low = 1,
}, {
.name = "tp-link:green:lan1",
.gpio = TL_WR743_GPIO_LED_LAN1,
.active_low = 0,
}, {
.name = "tp-link:green:lan2",
.gpio = TL_WR743_GPIO_LED_LAN2,
.active_low = 0,
}, {
.name = "tp-link:green:lan3",
.gpio = TL_WR743_GPIO_LED_LAN3,
.active_low = 0,
}, {
.name = "tp-link:green:lan4",
.gpio = TL_WR743_GPIO_LED_LAN4,
.active_low = 0,
}, {
.name = "tp-link:green:wan",
.gpio = TL_WR743_GPIO_LED_WAN,
.active_low = 1,
}, {
.name = "tp-link:green:qss",
.gpio = TL_WR743_GPIO_LED_QSS,
.active_low = 0,
}, {
.name = "tp-link:green:wlan",
.gpio = TL_WR743_GPIO_LED_WLAN,
.active_low = 0,
}, {
.name = "tp-link:green:3g",
.gpio = TL_WR743_GPIO_LED_3G,
.active_low = 0,
},
};
static struct gpio_keys_button tl_wr703n_gpio_keys[] __initdata = {
{
...
ath79_register_m25p80(&tl_wr703n_flash_data);
//ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr703n_leds_gpio),
// tl_wr703n_leds_gpio);
ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr743_leds_gpio),
tl_wr743_leds_gpio);
ath79_register_gpio_keys_polled(-1, TL_WR703N_KEYS_POLL_INTERVAL,
ARRAY_SIZE(tl_wr703n_gpio_keys),
tl_wr703n_gpio_keys);
修改openwrt/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
tl-wr741nd-v4)
ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x04"
ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x10"
ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
;;
tl-wr703n)
ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x02"
ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x04"
ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x08"
ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x10"
ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
ucidef_set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
;;
3)修改主机型号为743
替换WEB页面的显示型号为743
openwrt/target/linux/ar71xx/base-files/lib/ar71xx.sh
echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
if echo $AR71XX_MODEL|grep 703; then
AR71XX_MODEL="TP-LINK TL-WR743N v2"
fi
echo "$AR71XX_MODEL" > /tmp/sysinfo/model
4、执行编译
对于第一次编译,请不要开多线程。。。。因为不好排错
make V=99
如果第一次编译成功的话,之后的编译可以充分发挥多核心的优势了
首先执行:
ulimit -s 10240
这个命令是防止爆栈
对make加入多线程编译支持
make V=99 -j线程数
速度比单线程快N倍
第二次编译命令示例:
rm .config
rm -rf tmp
make defconfig
make menuconfig
ulimit -s 10240
make V=99 -j8
如修改了源文件,需要在build目录删除.o文件,并将修改后的文件拷贝到build相应目录,如:
/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.18.36/arch/mips/ath79/mach-tl-wr703n.c
发表评论