So I missed this prior work when I started looking at this again in the past two months....
I was writing my own and going to work on bootloader stuff. So this looks like it should be relatively straightforward to get into openwrt?
Going to try this soon. I already have the flash backed up. Would be nice to know how I can build the ram loader, bl2 and fip with the in tree openwrt u-boot mediatek.
I didn't have success trying to tftpboot the factory bootloader. It always asks for 192.168.1.100 over arp, my computer responds but we don't get anywhere. The httpd recovery works arp works but it the router responds with a mac of all zeroes. I guess that's the switch doing its thing but IDK. Quitting and starting httpd again in u-boot doesn't do the set up again so I think we need to replace the bootloader even for testing.
Of note in the instructions for immortalwrt is using https://github.com/981213/mtk_uartboot
The whole patch from immortalwrt pasted here in it's entirety:
Summary
From 9f73519e62e8290878eeff1acb08abf981ba8228 Mon Sep 17 00:00:00 2001
From: Chuanhong Guo <gch981213@gmail.com>
Date: Mon, 7 Oct 2024 01:05:51 +0800
Subject: [PATCH] mediatek: add support for TP-Link TL-XDR3230 v1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Specifications:
- SoC: Mediatek MT7622B
- RAM: 256M
- Flash: EN25QH128 16M
- Ethernet: RTL8367S 4xGE
- WiFi: MT7622 2.4G 4x4 + MT7905 5G 4x4
- UART: 3.3v, 115200n8
--------------------------
| Layout |
| ∇ |
| ----------------- |
| | VCC GND RX TX | JP1 |
| ----------------- |
--------------------------
Flash instruction:
TP-Link locks down their firmware and serial console, so the firmware
must be flashed with mtk_uartboot.
1. Download mtk_uartboot:
https://github.com/981213/mtk_uartboot/releases
2. Download bootloaders:
RAM loader for mtk_uartboot: https://drive.wrt.moe/uboot/mediatek/mt7622-bl2-ram-1ddr3.bin
BL2: https://drive.wrt.moe/uboot/mediatek/mt7622-tplink_tl-xdr3230-v1-bl2.bin
FIP: https://drive.wrt.moe/uboot/mediatek/mt7622-tplink_tl-xdr3230-v1-fip.bin
3. Open the case, and attach to the UART.
4. Start mtk_uartboot:
./mtk_uartboot -a -s /dev/ttyUSB0 -p mt7622-bl2-ram-1ddr3.bin -f \
mt7622-tplink_tl-xdr3230-v1-fip.bin --brom-load-baudrate 115200 \
--bl2-load-baudrate 115200
5. Cut off the power and re-engage, wait for UART download to complete.
6. Connect to the UART, write new BL2/FIP/Firmware with TFTP.
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
[fixup wifi eeprom and macs, add network configuration, minor fixes]
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
---
.../dts/mt7622-tplink_tl-xdr3230-v1.dts | 291 ++++++++++++++++++
target/linux/mediatek/image/mt7622.mk | 17 +
.../mt7622/base-files/etc/board.d/02_network | 4 +
.../mt7622/base-files/lib/upgrade/platform.sh | 1 +
4 files changed, 313 insertions(+)
create mode 100644 target/linux/mediatek/dts/mt7622-tplink_tl-xdr3230-v1.dts
diff --git a/target/linux/mediatek/dts/mt7622-tplink_tl-xdr3230-v1.dts b/target/linux/mediatek/dts/mt7622-tplink_tl-xdr3230-v1.dts
new file mode 100644
index 00000000000..6a76cf0293a
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7622-tplink_tl-xdr3230-v1.dts
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7622.dtsi"
+#include "mt6380.dtsi"
+
+/ {
+ model = "TP-Link TL-XDR3230 v1";
+ compatible = "tplink,tl-xdr3230-v1", "mediatek,mt7622";
+
+ aliases {
+ led-boot = &red_status_led;
+ led-failsafe = &red_status_led;
+ led-running = &green_status_led;
+ led-upgrade = &green_status_led;
+ label-mac-device = &gmac0;
+ serial0 = &uart0;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ bootargs = "earlycon=uart8250,mmio32,0x11002000 swiotlb=512 root=/dev/fit0 rootwait";
+ rootdisk = <&nor_rootdisk>;
+ };
+
+ memory@40000000 {
+ reg = <0 0x40000000 0 0x10000000>;
+ };
+
+
+ cpus {
+ cpu@0 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+ };
+
+ cpu@1 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ /* It seems that reset isn't connected to any MT7622 GPIO. Here's the WPS button. */
+ button-reset {
+ label = "reset";
+ gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_RESTART>;
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ green_status_led: led-0 {
+ function = LED_FUNCTION_STATUS;
+ color = <LED_COLOR_ID_GREEN>;
+ gpios = <&pio 89 GPIO_ACTIVE_HIGH>;
+ };
+
+ red_status_led: led-1 {
+ function = LED_FUNCTION_STATUS;
+ color = <LED_COLOR_ID_RED>;
+ gpios = <&pio 90 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ rtkgsw: rtkgsw@0 {
+ compatible = "mediatek,rtk-gsw";
+ mediatek,ethsys = <ðsys>;
+ mediatek,mdio = <&mdio>;
+ mediatek,reset-pin = <&pio 54 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+ };
+};
+
+ð {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <ð_pins>;
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+
+ nvmem-cells = <&macaddr_factory_d81c 0>;
+ nvmem-cell-names = "mac-address";
+ phy-connection-type = "2500base-x";
+
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+
+ nvmem-cells = <&macaddr_factory_d81c 1>;
+ nvmem-cell-names = "mac-address";
+ phy-mode = "rgmii";
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ mdio: mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+};
+
+&nor_flash {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi_nor_pins>;
+ status = "okay";
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+
+ spi-tx-bus-width = <4>;
+ spi-rx-bus-width = <4>;
+ spi-max-frequency = <50000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "bl2";
+ reg = <0x0 0x20000>;
+ read-only;
+ };
+
+ partition@20000 {
+ label = "fip";
+ reg = <0x20000 0x40000>;
+ read-only;
+ };
+
+ partition@60000 {
+ label = "factory";
+ reg = <0x60000 0x20000>;
+ read-only;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eeprom_factory_e000: eeprom@e000 {
+ /* actual length 0x400 */
+ reg = <0xe000 0x4da8>;
+ };
+
+ eeprom_factory_f000: eeprom@f000 {
+ reg = <0xf000 0xe00>;
+ };
+
+ macaddr_factory_d81c: macaddr@d81c {
+ compatible = "mac-base";
+ reg = <0xd81c 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+ };
+ };
+
+ nor_rootdisk: partition@80000 {
+ compatible = "denx,fit";
+ label = "firmware";
+ reg = <0x80000 0xf80000>;
+ };
+ };
+ };
+};
+
+&pcie0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie0_pins>;
+ status = "okay";
+};
+
+&pio {
+ epa_elna_pins: epa-elna-pins {
+ mux {
+ function = "antsel";
+ groups = "antsel0", "antsel1", "antsel2", "antsel3",
+ "antsel4", "antsel5", "antsel6", "antsel7",
+ "antsel8", "antsel9", "antsel12", "antsel13",
+ "antsel14", "antsel15", "antsel16", "antsel17";
+ };
+ };
+
+ eth_pins: eth-pins {
+ mux {
+ function = "eth";
+ groups = "mdc_mdio", "rgmii_via_gmac2";
+ };
+ };
+
+ pcie0_pins: pcie0-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie0_pad_perst",
+ "pcie0_0_waken",
+ "pcie0_0_clkreq";
+ };
+ };
+
+ pmic_bus_pins: pmic-bus-pins {
+ mux {
+ function = "pmic";
+ groups = "pmic_bus";
+ };
+ };
+
+ spi_nor_pins: spi-nor-pins {
+ mux {
+ function = "flash";
+ groups = "spi_nor";
+ };
+ };
+
+ uart0_pins: uart0-pins {
+ mux {
+ function = "uart";
+ groups = "uart0_0_tx_rx";
+ };
+ };
+
+ watchdog_pins: watchdog-pins {
+ mux {
+ function = "watchdog";
+ groups = "watchdog";
+ };
+ };
+};
+
+&pwrap {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pmic_bus_pins>;
+ status = "okay";
+};
+
+&rtc {
+ status = "disabled";
+};
+
+&slot0 {
+ mt7915@0,0 {
+ reg = <0x0000 0 0 0 0>;
+ ieee80211-freq-limit = <5000000 6000000>;
+ nvmem-cells = <&eeprom_factory_f000>, <&macaddr_factory_d81c 2>;
+ nvmem-cell-names = "eeprom", "mac-address";
+ };
+};
+
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_pins>;
+ status = "okay";
+};
+
+&watchdog {
+ pinctrl-names = "default";
+ pinctrl-0 = <&watchdog_pins>;
+ status = "okay";
+};
+
+&wmac {
+ nvmem-cells = <&eeprom_factory_e000>, <&macaddr_factory_d81c 0>;
+ nvmem-cell-names = "eeprom", "mac-address";
+ pinctrl-names = "default";
+ pinctrl-0 = <&epa_elna_pins>;
+ status = "okay";
+};
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk
index e1d9a09c643..2155a490f3e 100644
--- a/target/linux/mediatek/image/mt7622.mk
+++ b/target/linux/mediatek/image/mt7622.mk
@@ -326,6 +326,23 @@ define Device/totolink_a8000ru
endef
TARGET_DEVICES += totolink_a8000ru
+define Device/tplink_tl-xdr3230-v1
+ DEVICE_VENDOR := TP-Link
+ DEVICE_MODEL := TL-XDR3230
+ DEVICE_VARIANT := v1
+ DEVICE_DTS := mt7622-tplink_tl-xdr3230-v1
+ DEVICE_DTS_DIR := ../dts
+ DEVICE_PACKAGES := kmod-mt7915-firmware swconfig
+ KERNEL := kernel-bin | lzma
+ KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+ KERNEL_INITRAMFS := kernel-bin | lzma | \
+ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
+ IMAGES := sysupgrade.itb
+ IMAGE/sysupgrade.itb := append-kernel | \
+ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | pad-rootfs | append-metadata
+endef
+TARGET_DEVICES += tplink_tl-xdr3230-v1
+
define Device/ubnt_unifi-6-lr-v1
DEVICE_VENDOR := Ubiquiti
DEVICE_MODEL := UniFi U6 Long-Range
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
index 6bda6e11f37..beabd7acf15 100644
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
@@ -20,6 +20,10 @@ mediatek_setup_interfaces()
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6u@eth0" "5u@eth1"
;;
+ tplink,tl-xdr3230-v1)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:wan" "6u@eth0" "5u@eth1"
+ ;;
ubnt,unifi-6-lr*)
ucidef_set_interface_lan "eth0"
;;
diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
index 61025fb380d..8247d98791a 100755
--- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
@@ -8,6 +8,7 @@ platform_do_upgrade() {
case "$board" in
bananapi,bpi-r64|\
linksys,e8450-ubi|\
+ tplink,tl-xdr3230-v1|\
ubnt,unifi-6-lr-v1-ubootmod|\
ubnt,unifi-6-lr-v2-ubootmod|\
ubnt,unifi-6-lr-v3-ubootmod|\