我在深圳和故乡使用的路由器分别是 Netgear R6220 和 Netgear R6800 + Tenda AC9。

其中 R6220 和 AC9 分别使用 PandoraBox(OpenWRT)和 AsusWRT,这里是我对他们进行的基础配置/固件定制,记录备忘。

Netgear R6220 基础配置

https://github.com/deepjia/r6220-pb-init

刷写固件

R6220 的原厂固件比较糟糕,继承了网件一贯缓慢的启动速度和配置页面访问速度、对初级和高级用户均不友好的配置界面、以及匮乏的扩展性,却没有很好地继承网件优秀的稳定性。

R6220 的 OpenWrt 固件的无线驱动尚未达到可用的程度,仅有 PandoraBox 可堪一用。

(作为对比,R6800 的原厂固件虽然难用,却具有很好的稳定性,值得一用。两者同源的芯片也证明了不是 MTK 的锅。)

固件来源

http://www.right.com.cn/forum/thread-208580-1-1.html

下载 PandoraBox 固件:

https://eyun.baidu.com/s/3ge9QCq3

前往 「R6220」-「R6220潘多拉固件」,下载最新固件。

开启 telnet

直接访问:

http://192.168.1.1/setup.cgi?todo=debug

刷入 uboot

root 用户登录:

telnet 192.168.1.1

检查 eeprom 地址:

logread|grep Factory

若 Factory 地址在 0x2e00000 则继续,否则不要直接刷机,也不要使用后续配置脚本:

下载 uboot:

cd /tmp
wget https://breed.hackpascal.net/breed-mt7621-r6220.bin
# md5: https://breed.hackpascal.net/md5sum.txt

若不方便或者无法下载,可通过 U 盘拷贝,U 盘挂载点位于 /mnt/shares

刷入 uboot:

mtd_write write pb-boot-r6220.bin Bootloader

显示如下为刷写成功:

Unlocking Bootloader ...
       Writing from pb-boot-r6220.bin to Bootloader ...  [w]

访问 uboot:

按住 reset 开机,访问 192.168.1.1。

刷入 PandoraBox:

在 uboot 界面上传固件完成固件刷写。完成后可恢复一次出厂设置。

初始化配置

我的自动化配置脚本:

https://github.com/deepjia/r6220-pb-init

Tenda AC9 固件定制

AC9 硬件配置方案同华硕 RT-AC1200G+,但闪存减半;信号和速度都令人满意,但固件不够稳定。

所以把华硕开源固件精简到了 8M,删除了 Samba、NTFS 等功能。

构建好的固件:

https://pan.baidu.com/s/1nu6XsvR

定制参考:

http://blog.iytc.net/wordpress/?p=2193

构建固件

固件来源

https://www.asus.com/Networking/RT-AC1200G-plus/HelpDesk_Download/

编译准备

以下基于 Ubuntu 16.04 AMD64

安装编译环境依赖

sudo apt-get install --no-install-recommends autoconf automake bash bison bzip2 diffutils file flex g++ gawk gcc-multilib gettext gperf groff-base libncurses-dev libexpat1-dev libslang2 libssl-dev libtool libxml-parser-perl make patch perl pkg-config python sed shtool tar texinfo unzip zlib1g zlib1g-dev
sudo apt-get install lib32stdc++6 lib32z1-dev
sudo apt-get --no-install-recommends install automake1.11
sudo apt-get install libelf-dev:i386 libelf1:i386
sudo apt-get --no-install-recommends install lib32z1-dev lib32stdc++6
sudo apt-get install intltool autopoint vim imagemagick pngquant cmake

下载并解压源代码

sudo mkdir -p /opt/ac1200g
sudo chown $USER:$USER /opt/ac1200g
cd /opt/ac1200g
wget http://dlcdnet.asus.com/pub/ASUS/wireless/RT-AC1200G+/GPL_RT_AC1200G+_300438218991.zip
unzip GPL_RT_AC1200G*.zip
tar xvf GPL_RT-AC1200G*.tgz

改按键定义

sed -i '/defined(RTAC1200GP)/,/led_usb_gpio/{s/btn_rst_gpio.*/btn_rst_gpio"\, 7|GPIO_ACTIVE_LOW);/}' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/router/rc/init.c
sed -i '/defined(RTAC1200GP)/,/led_usb_gpio/{s/btn_wps_gpio.*/btn_wps_gpio", 9|GPIO_ACTIVE_LOW);/}' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/router/rc/init.c
sed -i '/defined(RTAC1200GP)/,/led_usb_gpio/{s/led_pwr_gpio.*/led_pwr_gpio", 15);/}' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/router/rc/init.c
sed -i '/defined(RTAC1200GP)/,/led_usb_gpio/{s/led_wps_gpio.*/led_wps_gpio", 10);/}' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/router/rc/init.c
sed -i '/defined(RTAC1200GP)/,/led_usb_gpio/{s/led_usb_gpio.*/led_usb_gpio", 1);/}' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/router/rc/init.c

精简

精简语言包

sed -i '/RT-AC1200G+/,/MODEL/{s/EN.*/EN,CN/}' /opt/ac1200g/asuswrt/release/src/router/tools/Lnx_AsusWrtDictPrep/dictctrl.txt

压缩图片

cd /opt/ac1200g/asuswrt/release/
find ./ -name '*.jpg' -exec convert -quality 10 {} {} \;
find ./ -name '*.png' -exec pngquant --force --ext .png {} \;

精简组件

sed -i 's/export RT-AC1200G_BASE :=.*/export RT-AC1200G_BASE := IPV6SUPP=y ARM=y BCM57=n NTFS="none" AUTODICT=y BBEXTRAS=y USBEXTRAS=y EBTABLES=y SAMBA3=n MEDIASRV=n PARENTAL2=y USB="USB" GRO=y APP="none" DNSMQ=y SHP=y NVRAM_64K=y RTAC1200G=y BCMWL6=y BCMWL6A=y TUNEK="n" BCM5301X=n DISK_MONITOR=n LANWAN_LED=n OPTIMIZE_XBOX=y MDNS=y HFS="none" DUMP_OOPS_MSG=y DEBUGFS=n BCM9=y TEMPROOTFS=y BTN_WPS_ALLLED=y REBOOT_SCHEDULE=y JFFS2=y JFFS2LOG=n HTTPS=n SSH=n ODMPID=y LAN50=y ATCOVER=y GETREALIP=y/' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/target.mak
sed -i 's/export RT-AC1200G+ +=.*/export RT-AC1200G+ += BUILD_NAME="RT-AC1200G+" MODEM=n BECEEM=n ACCEL_PPTPD=n PRINTER=y WEBDAV=n SMARTSYNCBASE=n PROXYSTA=y NEW_USER_LOW_RSSI=y VPNC=n YANDEXDNS=n REPEATER=y DISABLE_REPEATER_UI=y  MULTICASTIPTV=y QUAGGA=n NO_SAMBA=y NO_FTP=n/' /opt/ac1200g/asuswrt/release/src-rt-9.x/src/target.mak

注释掉 samba 菜单:

sed -i 's|.*samba|//&|' /opt/ac1200g/asuswrt/release/src-rt/router/www/require/modules/menuTree.js
sed -i 's|.*samba|//&|' /opt/ac1200g/asuswrt/release/src-rt/router/www/require/menuTrees/menuTree_no_bwdpi.jsken
sed -i 's|.*samba|//&|' /opt/ac1200g/asuswrt/release/src-rt/router/www/require/menuTrees/menuTree_bwdpi_traffic_analyzer.js
sed -i 's|.*samba|//&|' /opt/ac1200g/asuswrt/release/src-rt/router/www/require/menuTrees/menuTree_bwdpi_no_traffic_analyzer.js

清空厂商信息映射、SSL证书

echo '{}'> /opt/ac1200g/asuswrt/release/src/router/networkmap/networkmap.oui.js
rm -rf /opt/ac1200g/asuswrt/release/src/router/rom/rom/etc/ssl/certs/*

修改编译参数,提高压缩率

sed -i 's/noappend/& -b 1M/' /opt/ac1200g/asuswrt/release/src-rt/router/Makefile

规避 BUG

MODEM=n 后,需要恢复 is_usb_modem_ready 的函数定义。

若有特殊需求 IPV6SUPP=n,还需要恢复 get_ipv6_service 的函数定义。

echo -e >>/opt/ac1200g/asuswrt/release/src-rt/router/libdisk/usb_info.c "\
#ifndef RTCONFIG_USB_MODEM
int is_usb_modem_ready(int wan_type){return 0;}
#endif"

echo -e >>/opt/ac1200g/asuswrt/release/src-rt/router/shared/misc.c "\
#ifndef RTCONFIG_IPV6
int get_ipv6_service(void){return 0;}
#endif"

修改产品名

替换 LOGO

假设新 LOGO 在当前目录下, 为 asustitle.png

cp asustitle.png /opt/ac1200g/asuswrt/release/src/router/www/images/New_ui/asustitle.png

修改型号

sed -i 's/^Web_Title=.*/Web_Title=Tenda Wireless Router AC9/' /opt/ac1200g/asuswrt/release/src/router/www/EN.dict
sed -i 's/^Web_Title2=.*/Web_Title2=AC9(ZVMODELVZ)/' /opt/ac1200g/asuswrt/release/src/router/www/EN.dict

sed -i 's/^Web_Title=.*/Web_Title=Tenda Wireless Router AC9/' /opt/ac1200g/asuswrt/release/src/router/www/CN.dict
sed -i 's/^Web_Title2=.*/Web_Title2=AC9(ZVMODELVZ)/' /opt/ac1200g/asuswrt/release/src/router/www/CN.dict

修改版本号,防止自动升级

sed -i 's/SERIALNO=./SERIALNO=9/' /opt/ac1200g/asuswrt/release/src-rt/version.conf

编译

export PATH=$PATH:/opt/ac1200g/asuswrt/release/src-rt-9.x/src/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin
cd /opt/ac1200g/asuswrt/release/src-rt-9.x/src/
make RT-AC1200G+

刷写固件

路由器页面直接上传并恢复出厂设置;

或者电脑固定 IP 地址 192.168.0.X 后按住 reset 通电路由器直到 ping 通 CFE(192.168.0.1),然后 CFE 恢复 NVRAM 并上传。

参考链接

http://blog.iytc.net/wordpress/?p=2193

<推广> 本站使用 BWHCN2 套餐搭建个人网络服务。