From 40c1bef04b780266561a44bcc1d20bd02691b883 Mon Sep 17 00:00:00 2001 From: Sinbiosis Date: Sun, 8 Jan 2023 00:36:08 -0500 Subject: [PATCH] ramips: Add support for D-Link DIR-3040 A1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds support for the A1 hardware revision of the DIR-3040. It is an exact copy of the DIR-3060 save for some cosmetic changes to the housing. Even going so far as having the same FCC ID. Hardware specification: SoC: MediaTek MT7621AT Flash: Winbond W29N01HVSINA 128MB RAM: Micron MT41K128M16JT-125 256MB Ethernet: 5x 10/100/1000 Mbps WiFi1: MT7615DN 2.4GHz N 2x2:2 WiFi2: MT7615DN 5GHz AC 2x2:2 WiFi3: MT7615N 5GHz AC 4x4:4 Button: WPS, Reset Flash instructions: OpenWrt can be installed via D-Link Recovery GUI: NOTE: Seems to only work in Firefox on Windows. Tried with Chrome on Windows, Firefox in Linux, and Chromium in Linux. None of these other browsers worked. 1. Push and hold reset button (on the bottom of the device) until power led starts flashing (about 10 secs or so) while plugging in the power cable. 2. Give it ~30 seconds, to boot the recovery mode GUI 3. Connect your client computer to LAN1 of the device 4. Set your client IP address manually to 192.168.0.2 / 255.255.255.0. 5. Call the recovery page for the device at http://192.168.0.1/ 6. Use the provided emergency web GUI to upload and flash a new firmware to the device Thanks to @Lucky1openwrt and @iivailo for creating the DIR-3060 DTS file and related changes, so it was possible for me to adapt them to the DIR-3040, build images, test and fix minor issues. MAC Addresses: | use | address | example | | --- | --- | --- | | LAN | label | f4:*:61 | | WAN | label + 4 | f4:*:65 | | WI1/2g | label + 2 | f4:*:63 | | WI1/5g | label + 1 | f4:*:62 | | WI2/5g | label + 3 | f4:*:64 | The label MAC address was found in Factory, 0xe000 Checklist: ✓ nand ✓ ethernet ✓ button ✓ wifi2g ✓ wifi5g ✓ wifi5g ✓ mac ✓ led Signed-off-by: Vince McKinsey --- .../ramips/dts/mt7621_dlink_dir-3040-a1.dts | 67 +++++++++++++++++++ .../ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi | 8 ++- target/linux/ramips/image/mt7621.mk | 7 ++ .../mt7621/base-files/etc/board.d/01_leds | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 ++ .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_dlink_dir-3040-a1.dts diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-3040-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-3040-a1.dts new file mode 100644 index 00000000000000..4bb35a948d09e3 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_dlink_dir-3040-a1.dts @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_dlink_dir-xx60-a1.dtsi" + +/ { + compatible = "dlink,dir-3040-a1", "mediatek,mt7621-soc"; + model = "D-Link DIR-3040 A1"; +}; + +&wps { + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; +}; + +&leds { + usb2_white { + function = LED_FUNCTION_USB; + color = ; + function-enumerator = <0>; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&ehci_port2>; + linux,default-trigger = "usbport"; + }; + + usb3_white { + function = LED_FUNCTION_USB; + color = ; + function-enumerator = <1>; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + trigger-sources = <&xhci_ehci_port1>; + linux,default-trigger = "usbport"; + }; + + wlan2g { + function = LED_FUNCTION_WLAN_2GHZ; + color = ; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + wlan5glb { + function = LED_FUNCTION_WLAN_5GHZ; + color = ; + function-enumerator = <0>; + gpios = <&gpio 9 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + wlan5ghb { + function = LED_FUNCTION_WLAN_5GHZ; + color = ; + function-enumerator = <1>; + gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy2radio"; + }; +}; + +&wifi0 { + nvmem-cells = <&eeprom_factory_0>, <&macaddr_factory_e000 1>; + nvmem-cell-names = "eeprom", "mac-address"; + ieee80211-freq-limit; + /delete-property/ ieee80211-freq-limit; +}; + +&wifi1 { + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_factory_e000 3>; + nvmem-cell-names = "eeprom", "mac-address"; +}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi b/target/linux/ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi index 7b7228b8c36d6a..e14d3c48e593c9 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi +++ b/target/linux/ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi @@ -24,7 +24,7 @@ linux,code = ; }; - wps { + wps: wps { label = "wps"; gpios = <&gpio 18 GPIO_ACTIVE_LOW>; linux,code = ; @@ -47,12 +47,14 @@ }; led_net_orange: net_orange { - label = "orange:net"; + function = LED_FUNCTION_WAN; + color = ; gpios = <&gpio 4 GPIO_ACTIVE_LOW>; }; net_white { - label = "white:net"; + function = LED_FUNCTION_WAN; + color = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; }; }; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index fb8cfce5894fcd..10e78576140f10 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -783,6 +783,13 @@ define Device/dlink_dir-2660-a1 endef TARGET_DEVICES += dlink_dir-2660-a1 +define Device/dlink_dir-3040-a1 + $(Device/dlink_dir-xx60-a1) + DEVICE_MODEL := DIR-3040 + DEVICE_VARIANT := A1 +endef +TARGET_DEVICES += dlink_dir-3040-a1 + define Device/dlink_dir-3060-a1 $(Device/dlink_dir-xx60-a1) DEVICE_MODEL := DIR-3060 diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 3eba20bb79a010..6848bebd0010cc 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -96,6 +96,7 @@ dlink,dir-2640-a1|\ dlink,dir-2660-a1) ucidef_set_led_netdev "wan" "wan" "white:net" "wan" ;; +dlink,dir-3040-a1|\ dlink,dir-3060-a1) ucidef_set_led_netdev "net_white" "WAN Link" "white:net" "wan" "link" ucidef_set_led_netdev "net_orange" "WAN Activity" "orange:net" "wan" "tx rx" 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 962e1f7019776d..0ec46bb0eab8b7 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 @@ -60,6 +60,11 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_add $hw_mac_addr 4 > /sys${DEVPATH}/macaddress ;; + dlink,dir-3040-a1) + lan_mac_addr="$(mtd_get_mac_binary factory 0xe000)" + [ "$PHYNBR" = "0" ] && \ + macaddr_add $lan_mac_addr 2 > /sys${DEVPATH}/macaddress + ;; dlink,dir-853-a3) [ "$PHYNBR" = "0" ] && \ macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \ 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 eba02e6599860a..93fbc470ad58e0 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -73,6 +73,7 @@ platform_do_upgrade() { dlink,dir-1960-a1|\ dlink,dir-2640-a1|\ dlink,dir-2660-a1|\ + dlink,dir-3040-a1|\ dlink,dir-3060-a1|\ dlink,dir-853-a3|\ etisalat,s3|\