前言 上个月80块钱买了个1G运行内存的ZN-M2
,对别人的固件不太放心,于是想自己编译openwrt固件,顺带编译了一下ZTE E8820S
固件,用的openwrt版本是最新的openwrt-23.05,特此记录
编译ZN-M2固件 ZN-M2 是一个高通IPQ6000方案,高通是不开源的,只有神秘社区恩山论坛 上流传的IPQ6000
github仓库
这里我用的仓库也是fork别人的
我的github zn-m2源码仓库
根据官方的步骤,要编译就要经过以下步骤
git clone 源码仓库
安装依赖
scripts/feeds update -a
scripts/feeds install -a
make menuconfig
make download -j4 && make -j$(nproc) V=sc
这里用了别人的源码仓,也不需要修改什么,只需要根据自己的需求修改config即可,我这里不需要wifi,则关闭所有wifi相关的选项
这里关闭了wifi以后编译有些地方会报错,所以要关就关全,我经过了一星期 的试错才修改出完整编译不会报错的.config
最终我的.config
文件是这样的
CONFIG_TARGET_qualcommax=y CONFIG_TARGET_qualcommax_ipq60xx=y CONFIG_TARGET_qualcommax_ipq60xx_DEVICE_zn_m2=y CONFIG_DEVEL=y CONFIG_CCACHE=y CONFIG_PACKAGE_luci-app-upnp=y CONFIG_PACKAGE_luci-app-firewall=y CONFIG_PACKAGE_luci-app-ntpc=y CONFIG_PACKAGE_kmod-macvlan=y CONFIG_PACKAGE_luci-app-switch=y # remove wifi module CONFIG_DEFAULT_ath11k-firmware-ipq6018=n CONFIG_DEFAULT_kmod-ath=n CONFIG_DEFAULT_kmod-ath11k=n CONFIG_DEFAULT_kmod-ath11k-ahb=n # Qca CONFIG_PACKAGE_kmod-qca-nss-crypto=y CONFIG_PACKAGE_nss-eip-firmware=y CONFIG_PACKAGE_qca-ssdk-shell=y # custom plugins CONFIG_PACKAGE_dnsmasq_full=y CONFIG_PACKAGE_dnsmasq_full_ipset=y CONFIG_PACKAGE_ipset=y CONFIG_PACKAGE_libipset=y CONFIG_PACKAGE_ipset-dns=y CONFIG_PACKAGE_ipset-lists=y # dns CONFIG_PACKAGE_adguardhome=y CONFIG_PACKAGE_luci-app-smartdns=y CONFIG_PACKAGE_smartdns=y # CONFIG_PACKAGE_luci-app-vlmcsd=y this package would lead to compile error. So I disabled it. CONFIG_PACKAGE_luci-app-wol=y ## zerotier CONFIG_PACKAGE_luci-app-zerotier=y CONFIG_PACKAGE_zerotier=y ## passwall CONFIG_PACKAGE_luci-app-passwall=y CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=y CONFIG_PACKAGE_luci-app-flowoffload=y CONFIG_PACKAGE_luci-app-cpufreq=y ## iptables CONFIG_PACKAGE_iptables-mod-tproxy=y CONFIG_PACKAGE_iptables-mod-socket=y CONFIG_PACKAGE_iptables-mod-iprange=y CONFIG_PACKAGE_iptables-mod-conntrack-extra=y
步骤没问题就直接make就行了,毕竟坑我都帮你们踩过了
编译ZTE 8820s 这个路由器是我一年前花50多买的,方案是经典的mt7621,其实也没什么好说的,但由于我编译的固件是最新版本的,有些依赖会有奇怪的问题
先拿到openwrt源码
git clone https://github.com/openwrt/openwrt -b openwrt-23.05
首先官方的库是不支持E8820s的,这里要在target/linux/ramips/image/mt7621.mk
添加相应的支持 添加下面的一段
define Device/zte_e8820s $(Device/uimage-lzma-loader) $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k UBINIZE_OPTS := -E 5 IMAGE_SIZE := 129280k IMAGES += factory.bin IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ check-size DEVICE_VENDOR := ZTE DEVICE_MODEL := E8820S DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 \ kmod-usb3 endef TARGET_DEVICES += zte_e8820s
然后还要添加target/linux/ramips/dts/mt7621_zte_e8820s.dts
文件
/ { model = "ZTE E8820S" ; compatible = "zte,e8820s" , "mediatek,mt7621-soc" ; aliases { led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; led-upgrade = &led_power; label-mac-device = &gmac0; }; chosen { bootargs = "console=ttyS0,115200" ; }; leds { compatible = "gpio-leds" ; led_sys: sys { label = "white:sys" ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; }; led_power: power { label = "white:power" ; gpios = <&gpio 16 GPIO_ACTIVE_LOW>; }; }; keys { compatible = "gpio-keys" ; reset { label = "reset" ; gpios = <&gpio 18 GPIO_ACTIVE_LOW>; linux,code = <KEY_RESTART>; }; wps { label = "wps" ; gpios = <&gpio 8 GPIO_ACTIVE_LOW>; linux,code = <KEY_WPS_BUTTON>; }; wifi { label = "wifi" ; gpios = <&gpio 10 GPIO_ACTIVE_LOW>; linux,code = <KEY_RFKILL>; }; }; }; &nand { status = "okay" ; partitions { compatible = "fixed-partitions" ; partition@0 { label = "u-boot" ; reg = <0x0 0x80000>; read-only; }; partition@80000 { label = "u-boot-env" ; reg = <0x80000 0x80000>; read-only; }; factory: partition@100000 { label = "factory" ; reg = <0x100000 0x40000>; read-only; }; partition@140000 { label = "kernel" ; reg = <0x140000 0x400000>; }; partition@540000 { label = "ubi" ; reg = <0x540000 0x7a40000>; }; /* * Leave 512 KiB for the bad block table */ }; }; &pcie { status = "okay" ; reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>, <&gpio 4 GPIO_ACTIVE_LOW>; }; &pcie0 { mt76@0,0 { reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0000>; ieee80211-freq-limit = <2400000 2500000>; led { led-active-low; }; }; }; &pcie1 { mt76@0,0 { reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x8000>; ieee80211-freq-limit = <5000000 6000000>; led { led-sources = <2>; led-active-low; }; }; }; &gmac0 { nvmem-cells = <&macaddr_factory_e000>; nvmem-cell-names = "mac-address" ; }; &switch0 { ports { port@0 { status = "okay" ; label = "lan1" ; }; port@1 { status = "okay" ; label = "lan2" ; }; port@2 { status = "okay" ; label = "lan3" ; }; port@3 { status = "okay" ; label = "lan4" ; }; port@4 { status = "okay" ; label = "wan" ; mtd-mac-address = <&factory 0xe000>; }; }; }; &state_default { gpio { groups = "jtag" , "uart2" , "uart3" , "wdt" ; function = "gpio" ; }; }; &factory { compatible = "nvmem-cells" ; macaddr_factory_e000: macaddr@e000 { reg = <0xe000 0x6>; }; };
然后就make menuconfig
按照正常流程编译即可
完整config请见github
虽然能开机,但是使用一段时间后5G路由器会重启! 不使用5G是没问题的,之前用别人的固件也会出现这样的情况。我决定换用源码lede源码
主要的.config
如下
CONFIG_TARGET_ramips=y CONFIG_TARGET_ramips_mt7621=y CONFIG_TARGET_ramips_mt7621_DEVICE_zte_e8820s=y # luci app CONFIG_PACKAGE_luci=y CONFIG_PACKAGE_luci-app-passwall=y CONFIG_PACKAGE_luci-app-passwall_Nftables_Transparent_Proxy=y CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=y CONFIG_PACKAGE_luci-i18n-base-zh-cn=y CONFIG_PACKAGE_luci-lua-runtime=y # usb support CONFIG_PACKAGE_kmod-usb-ehci=y CONFIG_PACKAGE_kmod-usb-ohci=y CONFIG_PACKAGE_kmod-usb-uhci=y CONFIG_PACKAGE_kmod-usb2=y CONFIG_PACKAGE_kmod-usb-storage=y CONFIG_PACKAGE_kmod-usb-storage-extras=y CONFIG_PACKAGE_kmod-usb-net-rndis=y CONFIG_PACKAGE_samba4-server=y CONFIG_PACKAGE_zerotier=y CONFIG_PACKAGE_block-mount=y CONFIG_PACKAGE_kmod-fs-ext4=y CONFIG_PACKAGE_adguardhome=y CONFIG_PACKAGE_luci-app-smartdns=y # conflict enable it if dnsmasq error # CONFIG_PACKAGE_dnsmasq=n
注意,官方源码的话,这里需要设置CONFIG_PACKAGE_dnsmasq=n
,否则必报错,别问我怎么知道的。 其源码默认是使用闭源wifi的,若想使用开源wifi则需在上面的配置的基础上添加
# default wifi kmod CONFIG_PACKAGE_kmod-mt7603=y CONFIG_PACKAGE_kmod-mt7603e=n CONFIG_PACKAGE_kmod-mt76x2=y CONFIG_PACKAGE_kmod-mt76x2-common=y CONFIG_PACKAGE_kmod-mt76x2e=n
接着就make等待固件编译完成就行了