ramips: add support for Z-router ZR-2662
authorStijn Tintel <stijn@linux-ipv6.be>
Thu, 13 Jan 2022 16:39:13 +0000 (18:39 +0200)
committerStijn Tintel <stijn@linux-ipv6.be>
Wed, 30 Mar 2022 10:37:42 +0000 (13:37 +0300)
WIP

Without lzma-loader the kernel does not boot:

 Uncompressing Kernel Image ... lzma compressed: uncompress error 1
 Must RESET board to recover

Changing LINUX_LOADADDR to 0x81001000 as used by OEM solves the lzma
error but then the kernel doesn't boot - no output at all on the console
after this line:

 Loading Device Tree to 9be77000, end 9be7c4b7 ... OK

Eventually came accross this forum post:
https://forum.openwrt.org/t/compile-ramips-with-data-address-at-0x81001000-instead-of-0x80001000/97379

Which seems solve the problem. The question is: is there a better way?
Can't find any documentation about lzma-loader, what it does exactly,
and why it is needed, so for now this allows to boot OpenWrt from flash.

target/linux/ramips/dts/mt7621_zrouter_zr-2662-v1.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac

diff --git a/target/linux/ramips/dts/mt7621_zrouter_zr-2662-v1.dts b/target/linux/ramips/dts/mt7621_zrouter_zr-2662-v1.dts
new file mode 100644 (file)
index 0000000..20f5e59
--- /dev/null
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "mt7621.dtsi"
+
+
+/ {
+       compatible = "zrouter,zr-2662-v1";
+       model = "Zrouter ZR-2662 v1.0";
+
+       chosen {
+               bootargs = "console=ttyS0,115200";
+       };
+};
+
+&ethernet {
+       reg = <0x1e100000 0xe000>;
+};
+
+&nand {
+       status = "okay";
+
+       mediatek,bbt;
+       mediatek,bmt-remap-range = <0x180000 0x5800000>;
+
+       partitions {
+               #address-cells = <0x01>;
+               #size-cells = <0x01>;
+               compatible = "fixed-partitions";
+
+               partition@0 {
+                       label = "Bootloader";
+                       reg = <0x0 0x80000>;
+                       read-only;
+               };
+
+               partition@80000 {
+                       label = "Config";
+                       reg = <0x80000 0x80000>;
+                       read-only;
+               };
+
+               factory: partition@100000 {
+                       label = "Factory";
+                       reg = <0x100000 0x80000>;
+                       read-only;
+               };
+
+               partition@180000 {
+                       compatible = "denx,fit";
+                       label = "firmware";
+                       reg = <0x180000 0x5800000>;
+               };
+
+               partition@5980000 {
+                       label = "firmware_backup";
+                       reg = <0x5980000 0x2000000>;
+                       read-only;
+               };
+
+               partition@7b00000 {
+                       label = "zrsave";
+                       reg = <0x7b00000 0x100000>;
+                       read-only;
+               };
+
+               partition@7c00000 {
+                       label = "config2";
+                       reg = <0x7c00000 0x100000>;
+                       read-only;
+               };
+       };
+};
+
+&pcie {
+       status = "okay";
+
+       bus-range = <0x00 0xff>;
+};
+
+&pcie1 {
+       wifi@0,0 {
+               mediatek,mtd-eeprom = <&factory 0x0>;
+       };
+};
+
+&pcie2 {
+       status = "disabled";
+};
+
+&state_default {
+       gpio {
+               groups = "i2c";
+               function = "gpio";
+       };
+};
+
+&switch0 {
+       compatible = "mediatek,mt7530";
+       ports {
+               port@1 {
+                       status = "okay";
+
+                       label = "lan3";
+               };
+
+               port@2 {
+                       status = "okay";
+
+                       label = "lan2";
+               };
+
+               port@3 {
+                       status = "okay";
+
+                       label = "lan1";
+               };
+
+               port@4 {
+                       status = "okay";
+
+                       label = "wan";
+               };
+       };
+};
index 1e9b59d74f0069df07bf55e69d597708f1d0820b..e2a50c2aa27d31c3dea525a9c597bd8a7854a658 100644 (file)
@@ -2030,6 +2030,21 @@ define Device/zio_freezio
 endef
 TARGET_DEVICES += zio_freezio
 
+define Device/zrouter_zr-2662-v1
+  $(Device/dsa-migration)
+  BLOCKSIZE := 128k
+  DEVICE_VENDOR:= Zrouter
+  DEVICE_MODEL := ZR-2662
+  DEVICE_PACKAGES := kmod-mt7915e
+  DEVICE_VARIANT := v1.0
+  IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | append-metadata
+  IMAGE_SIZE := 88576k
+  KERNEL := kernel-bin | lzma | loader-kernel | fit none $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  KERNEL_INITRAMFS := kernel-bin | lzma | loader-kernel | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
+  #KERNEL_LOADADDR := 0x81001000
+endef
+TARGET_DEVICES += zrouter_zr-2662-v1
+
 define Device/zyxel_nr7101
   $(Device/dsa-migration)
   BLOCKSIZE := 128k
index 1fc0ccdd5b54588abe0a2c450b8f962401b419a7..18c2837e88783e4eced9b0c4dccddc3ec397adfa 100644 (file)
@@ -29,7 +29,8 @@ ramips_setup_interfaces()
        xiaomi,mi-router-cr6606|\
        xiaomi,mi-router-cr6608|\
        xiaomi,mi-router-cr6609|\
-       xiaomi,redmi-router-ac2100)
+       xiaomi,redmi-router-ac2100|\
+       zrouter,zr-2662-v1)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
                ;;
        asiarf,ap7621-001|\
@@ -186,6 +187,10 @@ ramips_setup_macs()
                wan_mac=$(mtd_get_mac_ascii Config protest_wan_mac)
                label_mac=$lan_mac
                ;;
+       zrouter,zr-2662-v1)
+               lan_mac=$(mtd_get_mac_ascii Factory lanmac)
+               wan_mac=$(mtd_get_mac_ascii Factory wanmac)
+               label_mac=$lan_mac
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
index 2a47f926be872525cba84c2785b0d733878bfd75..74ab5c97074168bcff23fe7edc7d0a4567ddcfff 100644 (file)
@@ -80,4 +80,10 @@ case "$board" in
                hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
                [ "$PHYNBR" = "1" ] &&  macaddr_add $hw_mac_addr "0x100000" > /sys${DEVPATH}/macaddress
                ;;
+       zrouter,zr-2662-v1)
+               hw_mac_addr_2g="$(mtd_get_mac_binary Factory wifi2gmac)"
+               hw_mac_addr_5g="$(mtd_get_mac_binary Factory wifi5gmac)"
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr_2g "0" > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr_5g "0" > /sys${DEVPATH}/macaddress
+               ;;
 esac