前言
上个月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
文件是这样的
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
|
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
注意,以下所指的官方库是openwrt/openwrt
这个路由器是我一年前花50多买的,方案是经典的mt7621,其实也没什么好说的,但由于我编译的固件是最新版本的,有些依赖会有奇怪的问题
先拿到openwrt源码
git clone https://github.com/openwrt/openwrt -b openwrt-23.05
首先官方的库是不支持E8820s的,这里要在target/linux/ramips/image/mt7621.mk
添加相应的支持
添加下面的一段
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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
文件
注意,这一段nand只适用于breed B70内存分区,uboot请确定你适用版本的分区,否则不要刷
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
|
##include "mt7621.dtsi"
##include <dt-bindings/gpio/gpio.h>
##include <dt-bindings/input/input.h>
/ {
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";
#address-cells = <1>;
#size-cells = <1>;
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";
#address-cells = <1>;
#size-cells = <1>;
macaddr_factory_e000: macaddr@e000 {
reg = <0xe000 0x6>;
};
};
|
若你不使用breed b70的breed,你可以看下面对应修改
以下为immortalwrt/immortalwrt给出的uboot内存分区参数
对应这个uboot
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
|
&nand {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "Bootloader";
reg = <0x0 0x220000>;
read-only;
};
partition@80000 {
compatible = "nvmem-cells";
label = "config";
reg = <0x220000 0x140000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
macaddr_config_12: macaddr@12 {
compatible = "mac-base";
reg = <0x12 0x6>;
#nvmem-cell-cells = <1>;
};
};
};
factory: partition@360000 {
compatible = "nvmem-cells";
label = "factory";
reg = <0x360000 0x140000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
eeprom_factory_f000: eeprom@f000 {
reg = <0xf000 0x400>;
};
eeprom_factory_f800: eeprom@f800 {
reg = <0xf800 0x200>;
};
};
};
partition@4a0000 {
label = "kernel";
reg = <0x4a0000 0x400000>;
};
partition@8a0000 {
label = "ubi";
reg = <0x8a0000 0x76e0000>;
};
};
};
|
然后就make menuconfig
按照正常流程编译即可
完整config请见github
虽然能开机,但是使用一段时间后5G路由器会重启! 不使用5G是没问题的,之前用别人的固件也会出现这样的情况。我决定换用源码
lede源码
主要的.config
如下
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
|
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则需在上面的配置的基础上添加
1
2
3
4
5
6
|
## 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等待固件编译完成就行了
参考:编译中兴E8820s必要的准备工作