TDW-9980 16MB flash upgrade

Having had an extroot for ages there have been many days where I wanted to have a 16mb flash on this xrx200 device
Someone has done it over at https://janfla.slask.pl/2021/01/tp-link-td-w8970v1-16m-mod/ and using his files I was able to get uboot to at least work with the 128mbit chip.
Documenting my doings publicly since I figured it out
First of all you need uboot to recognize the chip, you can refer to this uboot repository https://github.com/GreenTeaDev/u-boot/tree/tdw8970-16m , to build this you use the toolchain from the mkresin repo . This apparently supports both Winbond W25Q128, EON EN25Q128, MX25L12855E and the M25P128. All SO16 Packages SO8 Packages or SMD 8 pin editions seem pin compatable but refer to the Winbond pinout to be sure. I tested it with the Winbond W25Q128 but it is currently obsolete so sourcing it might be difficult.
Flashing uboot can be done with any programmer using u-boot.lq or you can use tftpboot when booted from serial using the u-boot.asc file and sending it over serial with cat then use tftpboot to move the u-boot.lq file into ram and then flash it with sf write.
The openwrt image is relatively simple to obtain, you need to adjust the mktplinkfw2.c in the firmware utils to have the correct .fw_max_len , and to partition the dts file correctly, just expanding the firmware partion. The diff file for that is this one, credit to russell-- from the openwrt-devel forums and to the original blogpost.

diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980-16m.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980-16m.dts
new file mode 100644
index 00000000000000..053ee96a1ef790
--- /dev/null
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980-16m.dts
@@ -0,0 +1,78 @@
+#include "vr9_tplink_tdw89x0.dtsi"
+
+/ {
+       compatible = "tplink,tdw8980-16m", "tplink,tdw89x0", "lantiq,xway", "lantiq,vr9";
+       model = "TP-LINK TD-W8980 16M";
+};
+
+&leds {
+       wifi2 {
+               label = "green:wlan5ghz";
+               gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
+       };
+};
+
+&gpio {
+       state_default: pinmux {
+               pci_rst {
+                       lantiq,pins = "io21";
+                       lantiq,output = <1>;
+                       lantiq,open-drain;
+               };
+       };
+};
+
+&spi {
+        status = "okay";
+
+        flash@4 {
+                partitions {
+                        partition@20000 {
+                                reg = <0x20000 0xfa0000>;
+                                label = "firmware";
+                        };
+
+                        partition@7c0000 {
+                                reg = <0xfc0000 0x10000>;
+                                label = "config";
+                                read-only;
+                        };
+
+                        partition@7d0000 {
+                                reg = <0xfd0000 0x30000>;
+                                label = "boardconfig";
+                                read-only;
+
+                                boardconfig: nvmem-layout {
+                                        compatible = "fixed-layout";
+                                        #address-cells = <1>;
+                                        #size-cells = <1>;
+
+                                        macaddr_ath9k_cal_f100: macaddr@f100 {
+                                                compatible = "mac-base";
+                                                reg = <0xf100 0x6>;
+                                                #nvmem-cell-cells = <1>;
+                                        };
+                                };
+                        };
+                };
+        };
+};
+
+&pci0 {
+       status = "okay";
+
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
+};
+
+&boardconfig {
+       cal_boardconfig_21000: calibration@21000 {
+               reg = <0x21000 0x3d8>;
+       };
+};
+
+&ath9k {
+       compatible = "pci168c,002e";
+       nvmem-cells = <&macaddr_ath9k_cal_f100 2>, <&cal_boardconfig_21000>;
+       nvmem-cell-names = "mac-address", "calibration";
+};
\ No newline at end of file
diff --git a/target/linux/lantiq/image/tp-link_legacy.mk b/target/linux/lantiq/image/tp-link_legacy.mk
index d9bcd35d10f0de..7bcf76fc40ca12 100644
--- a/target/linux/lantiq/image/tp-link_legacy.mk
+++ b/target/linux/lantiq/image/tp-link_legacy.mk
@@ -44,3 +44,16 @@ define Device/tplink_tdw8980
   SUPPORTED_DEVICES += TDW8980
 endef
 TARGET_DEVICES += tplink_tdw8980
+define Device/tplink_tdw8980-16m
+  $(Device/dsa-migration)
+  $(Device/lantiqTpLink)
+  DEVICE_MODEL := TD-W8980-16M
+  DEVICE_VARIANT := v1
+  TPLINK_FLASHLAYOUT := 16Mltq-8Mflsh
+  TPLINK_HWID := 0x89800001
+  TPLINK_HWREV := 14
+  IMAGE_SIZE := 15872k
+  DEVICE_PACKAGES:= kmod-ath9k kmod-owl-loader wpad-basic-mbedtls kmod-usb-dwc2 kmod-usb-ledtrig-usbport
+  SUPPORTED_DEVICES += TDW8980-16M
+endef
+TARGET_DEVICES += tplink_tdw8980-16m
diff --git a/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network
index 9088de86b10cbf..25d10aa792882d 100644
--- a/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network
+++ b/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network
@@ -16,7 +16,8 @@ lantiq_setup_interfaces()
 		ucidef_set_interface_lan "lan1 lan2"
 		;;
 	tplink,tdw8970|\
-	tplink,tdw8980)
+	tplink,tdw8980|\
+	tplink,tdw8980-16m)
 		ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
 		;;
 	netgear,dm200)
@@ -56,7 +57,8 @@ lantiq_setup_macs()
 		wan_mac=$(macaddr_add "$lan_mac" 1)
 		;;
 	tplink,tdw8970|\
-	tplink,tdw8980)
+	tplink,tdw8980|\
+	tplink,tdw8980-16m)
 		wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1)
 		;;
 	esac
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 62222b6dafc2d8..c62f075bf01d54 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -10,12 +10,12 @@ PKG_NAME:=firmware-utils
 PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git
+PKG_SOURCE_URL=https://github.com/Notupus/firmware-utils.git
 PKG_SOURCE_DATE:=2024-10-20
-PKG_SOURCE_VERSION:=4b7638925d3eac03e614e40bc30cb49f5877c46d
-PKG_MIRROR_HASH:=ea0e30f2b20211e4153704019ebb3f8789269893a4af6d853a85fae7c091802c
+PKG_SOURCE_VERSION:=5835a3f7abe55fe0fedf37f030a973eb4a186fd2
 
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/cmake.mk
 
 $(eval $(call HostBuild))
+
diff --git a/target/linux/lantiq/image/tp-link.mk b/target/linux/lantiq/image/tp-link.mk
index c2f5b95dd6a015..34f7353aa7ab72 100644
--- a/target/linux/lantiq/image/tp-link.mk
+++ b/target/linux/lantiq/image/tp-link.mk
@@ -44,3 +44,16 @@ define Device/tplink_vr200v
   SUPPORTED_DEVICES += VR200v
 endef
 TARGET_DEVICES += tplink_vr200v
+define Device/tplink_tdw8980-16m
+  $(Device/dsa-migration)
+  $(Device/lantiqTpLink)
+  DEVICE_MODEL := TD-W8980-16M
+  DEVICE_VARIANT := v1
+  TPLINK_FLASHLAYOUT := 16Mltq-8Mflsh
+  TPLINK_HWID := 0x89800001
+  TPLINK_HWREV := 14
+  IMAGE_SIZE := 15872k
+  DEVICE_PACKAGES:= kmod-ath9k kmod-owl-loader wpad-basic-mbedtls kmod-usb-dwc2 kmod-usb-ledtrig-usbport
+  SUPPORTED_DEVICES += TDW8980-16M
+endef
+TARGET_DEVICES += tplink_tdw8980-16m
\ No newline at end of file
diff --git a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
index 6c35c7a4debb18..c94a8bf5556c17 100644
--- a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
+++ b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
@@ -42,6 +42,7 @@ lantiq_setup_interfaces()
 	avm,fritz7490|\
 	avm,fritz7490-micron|\
 	buffalo,wbmr-300hpd|\
+	tplink,tdw8980-16m|\
 	tplink,vr200|\
 	tplink,vr200v)
 		ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
@@ -140,6 +141,9 @@ lantiq_setup_macs()
 	tplink,vr200v)
 		wan_mac=$(macaddr_add "$(mtd_get_mac_binary romfile 0xf100)" 1)
 		;;
+	tplink,tdw8980-16m)
+		wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1)
+		;;
 	esac
 
 	[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"

I added it to both the xrx200 and the xrx200_legacy in order to be able to choose if you want to not have the additional kernel configs for different flash. Both work and you can get slightly smaller images with xrx200_legacy at no cost the diff file is on commit openwrt/openwrt@f105d1a and can be applied with git apply . Below are some sample commands for uboot operations, you will need a full flash dump from the original flash chip and you will need to do the following command from the guide to get radio.bin

dd if=oldSPI.bin of=radio.bin bs=1 skip=8192000
sf erase 0x0 0x1000000(optional if you erased with your programmer)

setenv ipaddr (an ip in the same subnet with the server that is not used)
setenv serverip (some server in the same subnet)
tftpboot 0x81000000 uboot.lq
sf write 0x81000000 0x0 0x20000
tftpboot 0x81000000 sysupgrade.bin
sf write 0x81000000 0x20000 0xfa0000
tftpboot 0x81000000 radio.bin
sf write 0x81000000 0xfd0000 0x30000
reset

This can likely be adapted to work with much larger spi flash up to probably 256mb doing similar edits to uboot and the dts file. 16MB hopefully should at least last one more decade. This works with all TDW-8980 based targets and probably with TDW-8970 but I am not sure on the wifi and leds.

1 Like