|
本帖最后由 dsanke 于 2023-5-28 17:45 编辑
我这边网络需求比较复杂,需要用ebtables做DHCP snooping,也需要魔改DHCP客户端(即busybox集成的udhcpc)来获取指定的IP段,又要多个LAN段对应多个虚拟WAN口,所以一定要自己编译openwrt
刷机第一步,先拿到shell的权限,就用这个工具就可以
我是在linux虚拟机里运行的,中间提示从本地建立服务器还是从github拉取文件,我这边选1本地服务器都失败了,不知为何,所以只能选2,不过要确保路由器本身能访问github才行
拿到权限以后,telnet连进去,先查看分区
得到分区表
- root@XiaoQiang:/tmp# cat /proc/mtd
- dev: size erasesize name
- mtd0: 01000000 00010000 "ALL"
- mtd1: 00020000 00010000 "Bootloader"
- mtd2: 00010000 00010000 "NULL"
- mtd3: 00010000 00010000 "Factory"
- mtd4: 00010000 00010000 "crash"
- mtd5: 00010000 00010000 "cfg_bak"
- mtd6: 00100000 00010000 "overlay"
- mtd7: 00c60000 00010000 "OS1"
- mtd8: 00b00000 00010000 "rootfs"
- mtd9: 00240000 00010000 "disk"
- mtd10: 00010000 00010000 "Config"
复制代码
把分区表保存,然后备份mtd0,即备份整个flash
- dd if=/dev/mtd0 of=/tmp/mtd0_ALL_backup
复制代码
用winscp走ftp连接路由器,去tmp下面把mtd0_ALL_backup下载到电脑里
提取0x30000开始的0x10000,这是eeprom,也保存备用
接下来是刷入breed,使用breed-mt7688-reset38这个版本
先下载breed到本地,然后使用winscp传到/tmp下面
用命令刷入breed
- mtd write /tmp/breed-mt7688-reset38.bin Bootloader
复制代码
刷好以后可以通过breedenter中断启动,或者按住reset键上电,即可进入breed
接下来是源码修改,lean的lede并没有适配这款机器的breed分区,所以要手动修改分区
- diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi
- index 5e146f201..d8746e26c 100644
- --- a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi
- +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi
- @@ -71,25 +71,19 @@
- reg = <0x20000 0x10000>;
- read-only;
- };
- -
- - factory: partition@30000 {
- - label = "factory";
- +
- + partition@30000 {
- + label = "crash";
- reg = <0x30000 0x10000>;
- read-only;
- };
-
- - partition@40000 {
- - label = "crash";
- + factory: partition@40000 {
- + label = "factory";
- reg = <0x40000 0x10000>;
- read-only;
- };
-
- - partition@50000] {
- - label = "cfg_bak";
- - reg = <0x50000 0x10000>;
- - read-only;
- - };
- -
- /* additional partitions in DTS */
- };
- };
- diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts
- index 37797fc36..3d9f1d75d 100644
- --- a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts
- +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts
- @@ -8,15 +8,9 @@
- };
-
- &partitions {
- - partition@60000 {
- - label = "overlay";
- - reg = <0x60000 0x100000>;
- - read-only;
- - };
- -
- - partition@160000 {
- + partition@50000 {
- label = "firmware";
- - reg = <0x160000 0xea0000>;
- + reg = <0x50000 0xfb0000>;
- compatible = "denx,uimage";
- };
- };
复制代码
以上修改之后编译出的固件,就能在breed里面直接刷入了
由于eeprom分区的位置也发生了变化,也要从breed里面刷入一次备份的eeprom(其实就是从0x30000挪到了0x40000)
最后附上 lean 源码修改后编译的固件,去掉了 nlbwmon,加了 ipv6 支持,纯净固件,管理IP 192.168.8.1
链接: https://pan.baidu.com/s/1HMte_pAiyrvM_wnA898JUQ 提取码: 35bz |
|