Skip to content

Instantly share code, notes, and snippets.

@travislee89
Created August 22, 2017 05:33
Show Gist options
  • Save travislee89/91f92d4faa3e9b53ecae147678fd0385 to your computer and use it in GitHub Desktop.
Save travislee89/91f92d4faa3e9b53ecae147678fd0385 to your computer and use it in GitHub Desktop.
自定义WNDR4300-LEDE固件。修改分区使用全部空间;替换dnsmasq和wpad-mini为dnsmasq-full和wpad;增加wifi配置。
#!/bin/bash
VERSION="17.01.2"
WIFI_NAME=WNDR4300
WIFI_NAME_5G=WNDR4300-5G
WIFI_PASS=github.com
wget "https://downloads.lede-project.org/releases/${VERSION}/targets/ar71xx/nand/lede-imagebuilder-${VERSION}-ar71xx-nand.Linux-x86_64.tar.xz"
tar -Jxf lede-imagebuilder-${VERSION}-ar71xx-nand.Linux-x86_64.tar.xz
cd lede-imagebuilder-${VERSION}-ar71xx-nand.Linux-x86_64
cat >wndr4300-lede-${VERSION}.patch<<'EOF'
--- target/linux/ar71xx/image/legacy.mk 2017-06-26 02:39:39.719964648 +0800
+++ target/linux/ar71xx/image/legacy.mk 2017-06-26 02:39:18.200763641 +0800
@@ -281,7 +281,8 @@
wnr2000v4_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,3776k(firmware),64k(art)ro
r6100_mtdlayout=mtdparts=ar934x-nfc:128k(u-boot)ro,256k(caldata)ro,256k(caldata-backup),512k(config),512k(pot),2048k(kernel),122240k(ubi),25600k@0x1a0000(firmware),2048k(language),3072k(traffic_meter)
tew823dru_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro
-wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata)ro,512k(pot),2048k(language),512k(config),3072k(traffic_meter),2048k(kernel),23552k(ubi),25600k@0x6c0000(firmware),256k(caldata_backup),-(reserved)
+#wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata)ro,512k(pot),2048k(language),512k(config),3072k(traffic_meter),2048k(kernel),23552k(ubi),25600k@0x6c0000(firmware),256k(caldata_backup),-(reserved)
+wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata)ro,512k(pot),2048k(language),512k(config),3072k(traffic_meter),2048k(kernel),121856k(ubi),123904k@0x6c0000(firmware),256k(caldata_backup),-(reserved)
zcn1523h_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6208k(rootfs),1472k(kernel),64k(configure)ro,64k(mfg)ro,64k(art)ro,7680k@0x50000(firmware)
mynet_rext_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,7808k(firmware),64k(nvram)ro,64k(ART)ro
zyx_nbg6716_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(env)ro,64k(RFdata)ro,-(nbu);ar934x-nfc:2048k(zyxel_rfsd),2048k(romd),1024k(header),2048k(kernel),-(ubi)
EOF
patch -p0 < wndr4300-lede-${VERSION}.patch
mkdir -p custom/etc/config/
cat > custom/etc/config/wireless<<EOF
config wifi-device 'radio0'
option type 'mac80211'
option hwmode '11g'
option path 'platform/ar934x_wmac'
option htmode 'HT20'
option channel 'auto'
option country 'US'
option txpower '27'
option disabled '0'
config wifi-iface
option device 'radio0'
option network 'lan'
option mode 'ap'
option encryption 'psk2+ccmp'
option key '${WIFI_PASS}'
option ssid '${WIFI_NAME}'
option wmm '0'
config wifi-device 'radio1'
option type 'mac80211'
option hwmode '11a'
option path 'pci0000:00/0000:00:00.0'
option channel 'auto'
option country 'US'
option disabled '0'
option htmode 'HT40'
option txpower '17'
config wifi-iface
option device 'radio1'
option mode 'ap'
option network 'lan'
option encryption 'psk2+ccmp'
option key '${WIFI_PASS}'
option ssid '${WIFI_NAME_5G}'
option wmm '0'
EOF
name="lede-${VERSION}-ar71xx-nand-wndr4300-custom"
make clean
make image PROFILE=WNDR4300V1 PACKAGES="luci luci-theme-bootstrap luci-app-firewall uci dnsmasq-full wpad -wpad-mini -dnsmasq" FILES=custom
mv bin/targets/ar71xx/nand/lede-${VERSION}-ar71xx-nand-wndr4300-squashfs-sysupgrade.tar bin/targets/ar71xx/nand/${name}-squashfs-sysupgrade.tar
mv bin/targets/ar71xx/nand/lede-${VERSION}-ar71xx-nand-wndr4300-ubi-factory.img bin/targets/ar71xx/nand/${name}-ubi-factory.img
sed -i "s/lede-${VERSION}-ar71xx-nand-wndr4300-squashfs-sysupgrade.tar/${name}-squashfs-sysupgrade.tar/g" bin/targets/ar71xx/nand/sha256sums
sed -i "s/lede-${VERSION}-ar71xx-nand-wndr4300-ubi-factory.img/${name}-ubi-factory.img/g" bin/targets/ar71xx/nand/sha256sums
tar -Jcf "${name}.tar.xz" -C bin/targets/ar71xx/nand/ ${name}-squashfs-sysupgrade.tar ${name}-ubi-factory.img sha256sums
@travislee89
Copy link
Author

修改内容

  1. 修改分区使用全部空间;安装后总空间99MB,可用空间94MB。
  2. 增加wifi配置,如果家里没有设备支持有线网络,刷机后无法管理路由器。增加默认wifi配置,密码为github.com。
  3. 替换dnsmasqdnsmasq-full,可以配合ipset实现域名分流。
  4. 替换wpad-miniwpad,支持802.11r,如果有多个LEDE路由器,可以将wifi开启802.11r,实现无线漫游。

使用方法

下载脚本后直接运行即可
需要安装tar, make, xz
运行完毕后,在lede-imagebuilder-17.01.2-ar71xx-nand.Linux-x86_64目录下有文件 lede-17.01.2-ar71xx-nand-wndr4300-custom.tar.xz,包括升级包和原版系统刷机包。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment