mediatek: add new layout for Xiaomi Redmi Router AX6000 for OpenWrt U-Boot
authorFurong Xu <xfr@outlook.com>
Thu, 22 Dec 2022 02:40:26 +0000 (10:40 +0800)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 29 Dec 2022 03:00:31 +0000 (03:00 +0000)
This new layout is only bootable with OpenWrt U-Boot. It reuses the
two crash partions and expands the ubi partion to the end of whole flash.

Do not use this layout with stock U-Boot!

Signed-off-by: Furong Xu <xfr@outlook.com>
target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000-stock.dts
target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000-ubootmod.dts [new file with mode: 0644]
target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000.dts
target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000.dtsi
target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

index 64342677b38a0c8135ddba7c7648ad7058843123..114076dffcdfb8fc5720856ac3c801ddceedcada 100644 (file)
@@ -8,7 +8,25 @@
        compatible = "xiaomi,redmi-router-ax6000-stock", "mediatek,mt7986a";
 };
 
+&spi_nand_flash {
+       mediatek,nmbm;
+       mediatek,bmt-max-ratio = <1>;
+       mediatek,bmt-max-reserved-blocks = <64>;
+};
+
 &partitions {
+       partition@580000 {
+               label = "crash";
+               reg = <0x580000 0x40000>;
+               read-only;
+       };
+
+       partition@5c0000 {
+               label = "crash_log";
+               reg = <0x5c0000 0x40000>;
+               read-only;
+       };
+
        partition@600000 {
                label = "ubi_kernel";
                reg = <0x600000 0x1e00000>;
diff --git a/target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000-ubootmod.dts b/target/linux/mediatek/dts/mt7986a-xiaomi-redmi-router-ax6000-ubootmod.dts
new file mode 100644 (file)
index 0000000..152bbd2
--- /dev/null
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+/dts-v1/;
+#include "mt7986a-xiaomi-redmi-router-ax6000.dtsi"
+
+/ {
+       model = "Xiaomi Redmi Router AX6000 (OpenWrt U-Boot layout)";
+       compatible = "xiaomi,redmi-router-ax6000-ubootmod", "mediatek,mt7986a";
+};
+
+&partitions {
+       partition@580000 {
+               label = "ubi";
+               reg = <0x580000 0x7a80000>;
+       };
+};
index a8df7866320ea96151c04049f8a432cf098c3ecc..62407334cf058e57abe4966ab3a0383a72924b3b 100644 (file)
@@ -8,7 +8,25 @@
        compatible = "xiaomi,redmi-router-ax6000", "mediatek,mt7986a";
 };
 
+&spi_nand_flash {
+       mediatek,nmbm;
+       mediatek,bmt-max-ratio = <1>;
+       mediatek,bmt-max-reserved-blocks = <64>;
+};
+
 &partitions {
+       partition@580000 {
+               label = "crash";
+               reg = <0x580000 0x40000>;
+               read-only;
+       };
+
+       partition@5c0000 {
+               label = "crash_log";
+               reg = <0x5c0000 0x40000>;
+               read-only;
+       };
+
        /* ubi partition is the result of squashing
         * consecutive stock partitions:
         * - ubi
index 1a80649721cb429d9b5dc5b3f4f696b8e1426688..cd74fbec74279fc141941e8ab3832fe79f4cb731 100644 (file)
        pinctrl-0 = <&spi_flash_pins>;
        status = "okay";
 
-       flash@0 {
+       spi_nand_flash: flash@0 {
                compatible = "spi-nand";
                #address-cells = <1>;
                #size-cells = <1>;
                reg = <0>;
 
-               mediatek,nmbm;
-               mediatek,bmt-max-ratio = <1>;
-               mediatek,bmt-max-reserved-blocks = <64>;
-
                spi-max-frequency = <20000000>;
                spi-tx-buswidth = <4>;
                spi-rx-buswidth = <4>;
                                reg = <0x380000 0x200000>;
                                read-only;
                        };
-
-                       partition@580000 {
-                               label = "crash";
-                               reg = <0x580000 0x40000>;
-                               read-only;
-                       };
-
-                       partition@5c0000 {
-                               label = "crash_log";
-                               reg = <0x5c0000 0x40000>;
-                               read-only;
-                       };
                };
        };
 };
index 8cfed15544d06403430392a48ce151c95e67fec5..d85b12fb6654362df28f7754cc342d28976136a6 100644 (file)
@@ -7,7 +7,8 @@ board_config_update
 
 case $board in
 xiaomi,redmi-router-ax6000|\
-xiaomi,redmi-router-ax6000-stock)
+xiaomi,redmi-router-ax6000-stock|\
+xiaomi,redmi-router-ax6000-ubootmod)
        ucidef_set_led_netdev "wan" "wan" "rgb:network" "wan"
        ;;
 esac
index 1c98dcc7cb31f08b44b2215013bdb2f962bf1e30..608161f0ad97dc24be0fdef24210933470dbc905 100644 (file)
@@ -17,7 +17,8 @@ mediatek_setup_interfaces()
                ucidef_set_interface_macaddr "wan" "$(macaddr_add $(cat /sys/class/net/eth0/address) 1)"
                ;;
        xiaomi,redmi-router-ax6000|\
-       xiaomi,redmi-router-ax6000-stock)
+       xiaomi,redmi-router-ax6000-stock|\
+       xiaomi,redmi-router-ax6000-ubootmod)
                ucidef_set_interfaces_lan_wan "lan2 lan3 lan4" wan
                ;;
        *)
@@ -35,7 +36,8 @@ mediatek_setup_macs()
 
        case $board in
        xiaomi,redmi-router-ax6000|\
-       xiaomi,redmi-router-ax6000-stock)
+       xiaomi,redmi-router-ax6000-stock|\
+       xiaomi,redmi-router-ax6000-ubootmod)
                wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)
                label_mac=$wan_mac
                ;;
index 29c7a1475ed2d2cd6886a7d25e1221726a2e65a5..c2808bc7368f1a810e118409206436b6e5052b62 100755 (executable)
@@ -64,6 +64,10 @@ platform_do_upgrade() {
                CI_ROOT_UBIPART=ubi
                nand_do_upgrade "$1"
                ;;
+       xiaomi,redmi-router-ax6000-ubootmod)
+               CI_KERNPART="fit"
+               nand_do_upgrade "$1"
+               ;;
        *)
                nand_do_upgrade "$1"
                ;;
index 4e3399d120bb801653aedb92149e3067c00c88dd..4b16cff56ef4e4493bb7ce780d213c19b6e7ab44 100644 (file)
@@ -157,3 +157,32 @@ endif
   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += xiaomi_redmi-router-ax6000-stock
+
+define Device/xiaomi_redmi-router-ax6000-ubootmod
+  DEVICE_VENDOR := Xiaomi
+  DEVICE_MODEL := Redmi Router AX6000 (OpenWrt U-Boot layout)
+  DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-ubootmod
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_PACKAGES := kmod-leds-ws2812b
+  KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+  IMAGES := sysupgrade.itb
+  KERNEL_LOADADDR := 0x48000000
+  UBINIZE_OPTS := -E 5
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL_IN_UBI := 1
+  UBOOTENV_IN_UBI := 1
+  KERNEL := kernel-bin | gzip
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
+  IMAGE/sysupgrade.itb := append-kernel | \
+        fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
+  ARTIFACTS := preloader.bin bl31-uboot.fip
+  ARTIFACT/preloader.bin := bl2 spim-nand-ddr4
+  ARTIFACT/bl31-uboot.fip := bl31-uboot xiaomi_redmi-router-ax6000
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+  ARTIFACTS += initramfs-factory.ubi
+  ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel
+endif
+endef
+TARGET_DEVICES += xiaomi_redmi-router-ax6000-ubootmod