Wavlink WL-WN586X3 ver. A sysupgrade files are wrong

So an update. I have the ver. A of this router. Using info from the patches that @XT-Martinez, who has the ver. B, posted (https://github.com/XT-Martinez/openwrt/commit/e5d9e121600d1dc2d81a82fa0a8264397e3b5ff3) I was finally able to get this up and running. What I have found out is the original sysupgrade file that is generated is not a proper sysupgrade file. It works fine for the initial install but is not a tar file. Therefore the router never finds the files needed during the upgrade and just bootloops. In my case, I also found that my particular router has a spi-nor Boya flash chip. There are no drivers included with OpenWrt for this chip. I was able to put one together so that the flash chip is now recognized. I changed the filogic.mk file so that I can generate a good sysupgrade file. It is up and running and I can upgrade without issue now.

Please note, the images that are currently generated for ver. A of this router in snapshot will still throw the router into a bootloop.

24-10-04

When you edit such an old post (especially one with no replies), it's difficult to follow.

I'm glad you got it working. Is this device officially supported?

Just thought it would be better than starting another thread.

So, technically it is supported but the images that are created currently in snapshot are incorrect. They will work for flashing via the instructions but will not work for sysupgrade. They are not tar files. Also, the router I have must have received a different flash chip than the one that the builds are based on. (https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=33db9146071a470f4f8781d7d11fa2ad43069707) Due to the different and unsupported flash chip in mine there was no way it was ever going to work. I could install the initramfs file and it would run but I could never "install" until I added support for the Boya Microelectronics flash chip. (https://www.boyamicro.com/download/SPI_NOR_Flash/BY25Q128AS.pdf)
(https://lore.kernel.org/linux-mtd/874kgjcn8o.fsf@figgyc.uk/)

Deleted, no longer applicable.

May 4 2025

Boya chip patch (kernel 6.6):

Date: Fri, 27 September 2024 13:21:53 +0200
Subject: [PATCH] mtd: spi-nor: Add support for Boya BY25Q128AS

Add MTD support for the Boya BY25Q128AS SPI NOR chip.
The chip has 16MB of total capacity, divided into a total of 256
sectors, each 64KB sized. The chip also supports 4KB sectors.

---
 drivers/mtd/spi-nor/Makefile |  1 +
 drivers/mtd/spi-nor/boya.c   | 21 +++++++++++++++++++++
 drivers/mtd/spi-nor/core.c   |  1 +
 drivers/mtd/spi-nor/core.h   |  1 +
 4 files changed, 24 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/boya.c

--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -2,6 +2,7 @@
 
 spi-nor-objs			:= core.o sfdp.o swp.o otp.o sysfs.o
 spi-nor-objs			+= atmel.o
+spi-nor-objs            += boya.o
 spi-nor-objs			+= catalyst.o
 spi-nor-objs			+= eon.o
 spi-nor-objs			+= esmt.o

--- /dev/null
+++ b/drivers/mtd/spi-nor/boya.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2005, Intec Automation Inc.
+ * Copyright (C) 2014, Freescale Semiconductor, Inc.
+ */
+
+#include <linux/mtd/spi-nor.h>
+
+#include "core.h"
+
+static const struct flash_info boya_nor_parts[] = {
+       /* Boya Microelectronics */
+       { "BY25Q128AS", INFO(0x684018, 0, 64 * 1024, 256)
+               NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+};
+
+const struct spi_nor_manufacturer spi_nor_boya = {
+       .name = "boya",
+       .parts = boya_nor_parts,
+       .nparts = ARRAY_SIZE(boya_nor_parts),
+};

--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2001,6 +2001,7 @@
 
 static const struct spi_nor_manufacturer *manufacturers[] = {
 	&spi_nor_atmel,
+    &spi_nor_boya,
 	&spi_nor_catalyst,
 	&spi_nor_eon,
 	&spi_nor_esmt,

--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -631,6 +631,7 @@
 
 /* Manufacturer drivers. */
 extern const struct spi_nor_manufacturer spi_nor_atmel;
+extern const struct spi_nor_manufacturer spi_nor_boya;
 extern const struct spi_nor_manufacturer spi_nor_catalyst;
 extern const struct spi_nor_manufacturer spi_nor_eon;
 extern const struct spi_nor_manufacturer spi_nor_esmt;

Tested and it flashed fine to the Boya chip.

this is my dts file...

// SPDX-License-Identifier: (GPL-2.0 OR MIT)

/dts-v1/;

#include "mt7981b.dtsi"

/ {
	model = "WAVLINK WL-WN586X3";
	compatible = "wavlink,wl-wn586x3", "mediatek,mt7981";

	aliases {
		label-mac-device = &wifi;
		led-boot = &led_status_blue;
		led-failsafe = &led_status_blue;
		led-running = &led_status_blue;
		led-upgrade = &led_status_blue;
		serial0 = &uart0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	gpio-keys {
		compatible = "gpio-keys";

		button-reset {
			label = "reset";
			linux,code = <KEY_RESTART>;
			gpios = <&pio 11 GPIO_ACTIVE_LOW>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led-0 {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_WAN;
			gpios = <&pio 5 GPIO_ACTIVE_LOW>;
		};

		led-1 {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_WLAN;
			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};

		led_status_blue: led-2 {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_STATUS;
			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
		};

		led-3 {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_LAN;
			function-enumerator = <1>;
			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
		};

		led-4 {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_LAN;
			function-enumerator = <2>;
			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
		};

	};
};

&uart0 {
	status = "okay";
};

&watchdog {
	status = "okay";
};

&eth {
	status = "okay";

	gmac0: mac@0 {
		compatible = "mediatek,eth-mac";
		reg = <0>;
		phy-mode = "2500base-x";
		nvmem-cells = <&macaddr_hw_44e 0>;
		nvmem-cell-names = "mac-address";

		fixed-link {
			speed = <2500>;
			full-duplex;
			pause;
		};
	};

	gmac1: mac@1 {
		compatible = "mediatek,eth-mac";
		reg = <1>;
		phy-mode = "gmii";
		phy-handle = <&int_gbe_phy>;
		nvmem-cells = <&macaddr_hw_44e 1>;
		nvmem-cell-names = "mac-address";
	};
};

&mdio_bus {
	switch: switch@1f {
		compatible = "mediatek,mt7531";
		reg = <31>;
		reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
		interrupt-controller;
		#interrupt-cells = <1>;
		interrupt-parent = <&pio>;
		interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
	};
};

&spi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_flash_pins>;
	status = "disabled";
};

&spi2 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi2_flash_pins>;
	status = "okay";

	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;

		compatible = "jedec,spi-nor";
		reg = <0>;

		spi-max-frequency = <50000000>;
		
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "bl2";
				reg = <0x00000 0x40000>;
				read-only;
			};

			partition@40000 {
				label = "u-boot-env";
				reg = <0x40000 0x10000>;
				read-only;
			};

			factory: partition@50000 {
				label = "factory";
				reg = <0x50000 0xb0000>;
				read-only;

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

					eeprom_factory_0: eeprom@0 {
						reg = <0x0 0x1000>;
					};
				};
			};

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

			partition@f0000 {
                label = "firmware";
				reg = <0x180000 0xe00000>;
			};

			partition@f80000 {
				label = "hw";
				reg = <0xf80000 0x80000>;

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

					macaddr_hw_44e: macaddr@44e {
						compatible = "mac-base";
						reg = <0x44e 0x11>;
						#nvmem-cell-cells = <1>;
					};
				};
			};
		};
	};
};

&pio {
	spi0_flash_pins: spi0-pins {
		mux {
			function = "spi";
			groups = "spi0", "spi0_wp_hold";
		};
	};

	spi2_flash_pins: spi2-pins {
		mux {
			function = "spi";
			groups = "spi2", "spi2_wp_hold";
		};

		conf-pu {
			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
			drive-strength = <8>;
			bias-pull-up = <103>;
		};

		conf-pd {
			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
			drive-strength = <8>;
			bias-pull-down = <103>;
		};
	};
};

&switch {
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@1 {
			reg = <1>;
			label = "lan2";
		};

		port@2 {
			reg = <2>;
			label = "lan1";
		};

		port@6 {
			reg = <6>;
			ethernet = <&gmac0>;
			phy-mode = "2500base-x";

			fixed-link {
				speed = <2500>;
				full-duplex;
				pause;
			};
		};
	};
};

&wifi {
	status = "okay";

	nvmem-cells = <&eeprom_factory_0>;
	nvmem-cell-names = "eeprom";
};

Remove two lines at the end otherwise both wifi radios get the same mac address.

Updated filogic.mk file.

define Device/wavlink_wl-wn586x3
  DEVICE_VENDOR := WAVLINK
  DEVICE_MODEL := WL-WN586X3
  DEVICE_DTS := mt7981b-wavlink-wl-wn586x3
  DEVICE_DTS_DIR := ../dts
  DEVICE_DTS_LOADADDR := 0x47000000
  DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware
  IMAGE_SIZE := 14336k
  KERNEL := kernel-bin | lzma | \
	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += wavlink_wl-wn586x3

Boya chip patch (kernel 6.12):


Date: Fri, 27 September 2024 13:21:53 +0200
Subject: [PATCH] mtd: spi-nor: Add support for Boya BY25Q128AS

Add MTD support for the Boya BY25Q128AS SPI NOR chip.
The chip has 16MB of total capacity, divided into a total of 256
sectors, each 64KB sized. The chip also supports 4KB sectors.

---
 drivers/mtd/spi-nor/Makefile |  1 +
 drivers/mtd/spi-nor/boya.c   | 25 +++++++++++++++++++++++++
 drivers/mtd/spi-nor/core.c   |  1 +
 drivers/mtd/spi-nor/core.h   |  1 +
 4 files changed, 28 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/boya.c

--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -2,6 +2,7 @@
 
 spi-nor-objs			:= core.o sfdp.o swp.o otp.o sysfs.o
 spi-nor-objs			+= atmel.o
+spi-nor-objs            += boya.o
 spi-nor-objs			+= eon.o
 spi-nor-objs			+= esmt.o
 spi-nor-objs			+= everspin.o

--- /dev/null
+++ b/drivers/mtd/spi-nor/boya.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2005, Intec Automation Inc.
+ * Copyright (C) 2014, Freescale Semiconductor, Inc.
+ */
+
+#include <linux/mtd/spi-nor.h>
+
+#include "core.h"
+
+static const struct flash_info boya_nor_parts[] = {
+       /* Boya Microelectronics */
+       { 
+		        .id = SNOR_ID(0x68, 0x40, 0x18),
+               .name = "BY25Q128AS",
+               .size = SZ_16M,
+		        .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
+       }
+};
+
+const struct spi_nor_manufacturer spi_nor_boya = {
+       .name = "boya",
+       .parts = boya_nor_parts,
+       .nparts = ARRAY_SIZE(boya_nor_parts),
+};

--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1966,6 +1966,7 @@
 
 static const struct spi_nor_manufacturer *manufacturers[] = {
 	&spi_nor_atmel,
+    &spi_nor_boya,
 	&spi_nor_eon,
 	&spi_nor_esmt,
 	&spi_nor_everspin,

--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -580,6 +580,7 @@
 
 /* Manufacturer drivers. */
 extern const struct spi_nor_manufacturer spi_nor_atmel;
+extern const struct spi_nor_manufacturer spi_nor_boya;
 extern const struct spi_nor_manufacturer spi_nor_eon;
 extern const struct spi_nor_manufacturer spi_nor_esmt;
 extern const struct spi_nor_manufacturer spi_nor_everspin;