峯言凬语 O ever youthful O ever weeping~
本无意与众不同,怎奈何口味太重。
首页
平水韵
颜色表
ABOUT
文章分类
友情链接
编译新版Q20路由器固件
2023-09-01 |Nonni | Digi

q20ttl.jpg

得到了一块JCG-Q20的板子,通电可用,不过直接编译Q20的固件刷入后无法启动,将本身的uboot换成pboot,还是不行,这种问题一般是交换机配置或者分区配置不对,研究了一下,更改了分区,成功启动。
准备nand分区表参考

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "Bootloader"
mtd1: 00080000 00020000 "Config"
mtd2: 00080000 00020000 "Factory"
mtd3: 00040000 00020000 "crash"
mtd4: 00040000 00020000 "crash_log"
mtd5: 00400000 00020000 "kernel"
mtd6: 07980000 00020000 "ubi"

新固件编译方法
新建型号

vi /target/linux/ramips/image/mt7621.mk

增加新设备定义

define Device/NonniWiFi
  $(Device/dsa-migration)
  BLOCKSIZE := 128k
  PAGESIZE := 2048
  UBINIZE_OPTS := -E 5
  KERNEL_SIZE := 4096k
  IMAGE_SIZE := 91136k
  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 := NONNIX.COM
  DEVICE_MODEL := NonniWiFi
  DEVICE_PACKAGES := kmod-mt7915e uboot-envtools
endef
TARGET_DEVICES += NonniWiFi

新建dts

vi /target/linux/ramips/dts/mt7621_NonniWiFi.dts

增加设备硬件定义,通过16进制计算分区,划分新分区布局

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
    compatible = "NONNIX.COM,NonniWiFi", "mediatek,mt7621-soc";
    model = "NonniWiFi";

    aliases {
        led-boot = &led_status_red;
        led-failsafe = &led_status_red;
        led-running = &led_status_blue;
        led-upgrade = &led_status_blue;
        label-mac-device = &gmac0;
    };

    chosen {
        bootargs = "console=ttyS0,115200";
    };

    leds {
        compatible = "gpio-leds";

        led_status_red: status_red {
            label = "red:status";
            gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
        };

        led_status_blue: status_blue {
            label = "blue:status";
            gpios = <&gpio 15 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 16 GPIO_ACTIVE_LOW>;
            linux,code = <KEY_WPS_BUTTON>;
        };
    };

    ubi-concat {
        compatible = "mtd-concat";
        devices = <&ubi>;

        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;

            partition@0 {
                label = "ubi";
                reg = <0x0 0x5900000>;
            };
        };
    };
};

&nand {
    status = "okay";

    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;

        partition@0 {
            label = "Bootloader";
            reg = <0x0 0x80000>;
            read-only;
        };

        partition@80000 {
            label = "Config";
            reg = <0x80000 0x80000>;
        };

        factory: partition@100000 {
            label = "Factory";
            reg = <0x100000 0x80000>;
            read-only;
        };

        partition@180000 {
            label = "crash";
            reg = <0x180000 0x40000>;
        };

        crash_log: partition@1c0000 {
            label = "crash_log";
            reg = <0x1c0000 0x40000>;
        };

        partition@200000 {
            label = "kernel";
            reg = <0x200000 0x400000>;
        };

        ubi: partition@600000 {
            label = "ubi";
            reg = <0x600000 0x7980000>;
        };


        /*
         * last 512 KiB are for the bad block table
         */
    };
};

&pcie {
    status = "okay";
};

&pcie1 {
    wifi@0,0 {
        compatible = "mediatek,mt76";
        reg = <0x0000 0 0 0 0>;
        mediatek,mtd-eeprom = <&factory 0x0>;
    };
};

&gmac0 {
    mtd-mac-address = <&factory 0x3fff4>;
};

&switch0 {
    ports {
        port@0 {
            status = "okay";
            label = "wan";
            mtd-mac-address = <&factory 0x3fffa>;
        };

        port@1 {
            status = "okay";
            label = "lan1";
        };

        port@4 {
            status = "okay";
            label = "lan2";
        };
    };
};

&state_default {
    gpio {
        groups = "jtag", "wdt";
        function = "gpio";
    };
};

增加新设备网络配置

vi /target/linux/ramips/mt7621/base-files/etc/board.d/02_network

添加

NONNIX.COM,NonniWiFi|\

运行菜单配置,选择设备 NONNIX.COM-NonniWiFi,配置应用

make menuconfig

开始单线程啰嗦模式编译

make V=s -j1

编译好的固件,适合pboot刷入

openwrt-ramips-mt7621-NonniWiFi-squashfs-factory.bin
默认IP 10.20.30.40/16
默认密码 password

完成的固件下载地址

http://pan.nonni.cn/%e4%b8%80%e6%84%8f%e5%ad%a4%e8%a1%8c/%e5%9b%ba%e4%bb%b6/%e8%b7%af%e7%94%b1%e5%99%a8/NonniX/OPENWRT/openwrt-ramips-mt7621-NonniWiFi-squashfs-factory.bin
respond-post-792

添加新评论

请填写称呼
请填写合法的电子邮箱地址
请填写合法的网站地址
请填写内容