aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package/boot/uboot-envtools/files/ramips3
-rw-r--r--target/linux/ramips/dts/mt7621_zyxel_wsm20.dts233
-rw-r--r--target/linux/ramips/image/mt7621.mk39
-rw-r--r--target/linux/ramips/mt7621/base-files/etc/board.d/02_network3
-rw-r--r--target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac5
-rwxr-xr-xtarget/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh4
-rw-r--r--target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh39
7 files changed, 324 insertions, 2 deletions
diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
index bc56210036..4b7eeb8960 100644
--- a/package/boot/uboot-envtools/files/ramips
+++ b/package/boot/uboot-envtools/files/ramips
@@ -62,7 +62,8 @@ h3c,tx1801-plus|\
h3c,tx1806|\
jcg,q20|\
linksys,e7350|\
-netgear,wax202)
+netgear,wax202|\
+zyxel,wsm20)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
haier,har-20s2u1|\
diff --git a/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts b/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts
new file mode 100644
index 0000000000..315e2e1d79
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts
@@ -0,0 +1,233 @@
+// 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 = "zyxel,wsm20", "mediatek,mt7621-soc";
+ model = "ZyXEL WSM20";
+
+ aliases {
+ led-boot = &led_system_white;
+ led-failsafe = &led_system_red;
+ led-running = &led_system_white;
+ led-upgrade = &led_system_red;
+ label-mac-device = &gmac0;
+ };
+
+ chosen {
+ bootargs-override = "console=ttyS0,115200n1";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led_system_white: led-0 {
+ gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+ label = "white:system";
+ };
+
+ led_system_red: led-1 {
+ gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+ label = "red:system";
+ };
+
+ led-2 {
+ gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+ label = "green:led1";
+ };
+
+ led-3 {
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+ label = "white:led2";
+ };
+
+ led-4 {
+ gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+ label = "green:led3";
+ };
+
+ led-5 {
+ gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
+ label = "red:led4";
+ };
+
+ led-6 {
+ gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+ label = "white:led5";
+ };
+ };
+
+ keys {
+ compatible = "gpio-keys";
+
+ led {
+ label = "led";
+ gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+ linux,code = <BTN_0>;
+ };
+
+ reset {
+ label = "reset";
+ gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_RESTART>;
+ };
+
+ wps {
+ label = "wps";
+ gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_WLAN>;
+ };
+ };
+};
+
+&nand {
+ status = "okay";
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ reg = <0x0 0x100000>;
+ label = "Bootloader";
+ read-only;
+ };
+
+ partition@100000 {
+ reg = <0x100000 0x100000>;
+ label = "Config";
+ };
+
+ factory: partition@200000 {
+ reg = <0x200000 0x1c0000>;
+ label = "Factory";
+ read-only;
+ };
+
+ partition@3c0000 {
+ reg = <0x3c0000 0x2800000>;
+ label = "firmware";
+
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "kernel";
+ reg = <0x0 0x800000>;
+ };
+
+ partition@800000 {
+ label = "ubi";
+ reg = <0x800000 0x2000000>;
+ };
+ };
+
+ partition@2bc0000 {
+ reg = <0x2bc0000 0x2800000>;
+ label = "Kernel2";
+ };
+
+ partition@53c0000 {
+ reg = <0x53c0000 0x100000>;
+ label = "persist";
+ };
+
+ partition@54c0000 {
+ reg = <0x54c0000 0x400000>;
+ label = "rootfs_data";
+ read-only;
+ };
+
+ partition@58C0000 {
+ reg = <0x58c0000 0x25c0000>;
+ label = "app";
+ read-only;
+ };
+
+ partition@7e80000 {
+ reg = <0x7e80000 0x100000>;
+ label = "crt";
+ read-only;
+ };
+ };
+};
+
+&gmac0 {
+ nvmem-cells = <&macaddr_factory_1fdfa>;
+ nvmem-cell-names = "mac-address";
+};
+
+&gmac1 {
+ status = "okay";
+ label = "wan";
+ phy-handle = <&ethphy0>;
+
+ nvmem-cells = <&macaddr_factory_1fdf4>;
+ nvmem-cell-names = "mac-address";
+};
+
+&mdio {
+ ethphy0: ethernet-phy@0 {
+ reg = <0>;
+ };
+};
+
+&pcie {
+ status = "okay";
+};
+
+&pcie1 {
+ wifi@0,0 {
+ compatible = "mediatek,mt76";
+ reg = <0x0000 0 0 0 0>;
+ mediatek,mtd-eeprom = <&factory 0x0>;
+ mediatek,disable-radar-background;
+ };
+};
+
+&pcie2 {
+ status = "disabled";
+};
+
+&switch0 {
+ ports {
+ port@1 {
+ status = "okay";
+ label = "lan3";
+ };
+ port@2 {
+ status = "okay";
+ label = "lan2";
+ };
+ port@3 {
+ status = "okay";
+ label = "lan1";
+ };
+ };
+};
+
+&state_default {
+ gpio {
+ groups = "i2c", "uart3", "jtag", "wdt";
+ function = "gpio";
+ };
+};
+
+&factory {
+ compatible = "nvmem-cells";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ macaddr_factory_1fdfa: macaddr@1fdfa {
+ reg = <0x1fdfa 0x6>;
+ };
+
+ macaddr_factory_1fdf4: macaddr@1fdf4 {
+ reg = <0x1fdf4 0x6>;
+ };
+};
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index df89877c9a..96bfab3fef 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -62,6 +62,29 @@ define Build/iodata-mstc-header
)
endef
+define Build/znet-header
+ $(eval version=$(word 1,$(1)))
+ ( \
+ data_size_crc="$$(dd if=$@ 2>/dev/null | gzip -c | \
+ tail -c 8 | od -An -N4 -tx4 --endian big | tr -d ' \n')"; \
+ payload_len="$$(dd if=$@ bs=4 count=1 skip=1 2>/dev/null | od -An -tdI --endian big | tr -d ' \n')"; \
+ payload_size_crc="$$(dd if=$@ ibs=1 count=$$payload_len 2>/dev/null | gzip -c | \
+ tail -c 8 | od -An -N4 -tx4 --endian big | tr -d ' \n')"; \
+ echo -ne "\x5A\x4E\x45\x54" | dd bs=4 count=1 conv=sync 2>/dev/null; \
+ echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tac | tr -d '\n')" | \
+ dd bs=4 count=1 conv=sync 2>/dev/null; \
+ echo -ne "$$(echo $$data_size_crc | sed 's/../\\x&/g')" | \
+ dd bs=4 count=1 conv=sync 2>/dev/null; \
+ echo -ne "$$(echo $$payload_size_crc | sed 's/../\\x&/g')" | \
+ dd bs=4 count=1 conv=sync 2>/dev/null; \
+ echo -ne "\x12\x34\x56\x78" | dd bs=4 count=1 conv=sync 2>/dev/null; \
+ echo -ne "$(version)" | dd bs=28 count=1 conv=sync 2>/dev/null; \
+ dd if=/dev/zero bs=262096 count=1 conv=sync 2>/dev/null | tr "\000" "\377"; \
+ cat $@; \
+ ) > $@.new
+ mv $@.new $@
+endef
+
define Build/belkin-header
$(eval magic=$(word 1,$(1)))
$(eval hw_ver=$(word 2,$(1)))
@@ -2875,3 +2898,19 @@ define Device/zyxel_wap6805
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += zyxel_wap6805
+
+define Device/zyxel_wsm20
+ $(Device/dsa-migration)
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ KERNEL_SIZE := 8192k
+ IMAGE_SIZE := 41943040
+ UBINIZE_OPTS := -E 5
+ DEVICE_VENDOR := ZyXEL
+ DEVICE_MODEL := WSM20
+ DEVICE_PACKAGES := kmod-mt7915-firmware
+ KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0
+ KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += zyxel_wsm20
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index e357b47a4c..39c8080e83 100644
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -49,7 +49,8 @@ ramips_setup_interfaces()
xiaomi,mi-router-cr6606|\
xiaomi,mi-router-cr6608|\
xiaomi,mi-router-cr6609|\
- xiaomi,redmi-router-ac2100)
+ xiaomi,redmi-router-ac2100|\
+ zyxel,wsm20)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
asiarf,ap7621-001|\
diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index b6337f397b..f042830e02 100644
--- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -181,4 +181,9 @@ case "$board" in
[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
;;
+ zyxel,wsm20)
+ hw_mac_addr="$(mtd_get_mac_binary Factory 0x1fdfa)"
+ [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+ [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+ ;;
esac
diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
index bfdbd6a09d..ce5fdd61ed 100755
--- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
@@ -155,6 +155,10 @@ platform_do_upgrade() {
CI_KERNPART="Kernel"
nand_do_upgrade "$1"
;;
+ zyxel,wsm20)
+ zyxel_mstc_upgrade_prepare
+ nand_do_upgrade "$1"
+ ;;
*)
default_do_upgrade "$1"
;;
diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh
new file mode 100644
index 0000000000..59c8d237dd
--- /dev/null
+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2023 OpenWrt.org
+#
+
+. /lib/functions.sh
+
+zyxel_mstc_prepare_fail() {
+ echo "failed to check and prepare the environment, rebooting..."
+ umount -a
+ reboot -f
+}
+
+zyxel_mstc_upgrade_prepare() {
+ local persist_mtd="$(find_mtd_part persist)"
+ local firmware_mtd="$(find_mtd_part firmware)"
+
+ if [ -z "$persist_mtd" ] || [ -z "$firmware_mtd" ]; then
+ echo 'cannot find mtd partition(s) "persist" or "firmware"'
+ zyxel_mstc_prepare_fail
+ fi
+
+ local bootnum=$(hexdump -s 4 -n 1 -e '"%x"' ${persist_mtd})
+
+ if [ "$bootnum" != "1" ] && [ "$bootnum" != "2" ]; then
+ echo "failed to get bootnum, please check the value at 0x4 in ${persist_mtd}"
+ zyxel_mstc_prepare_fail
+ fi
+ echo "current: bootnum => ${bootnum}"
+
+ [ "$(fw_printenv -n bootmenu_delay)" = "3" ] || fw_setenv bootmenu_delay 3
+
+ if [ "$bootnum" = "2" ]; then
+ if ! ( echo -ne "\x01" | dd of=${persist_mtd} count=1 bs=1 seek=4 conv=notrunc 2>/dev/null ); then
+ echo "failed to set new boot partition"
+ zyxel_mstc_prepare_fail
+ fi
+ echo "### switch to 1st os-image on next boot ###"
+ fi
+}