OpenWrt support for D-Link DIR-1960

Any plans to support this router?

It's built on the AP-MTKH7-0002 REV1.0 board
shared with the DIR-878 & DIR-882 but with 128M NAND Flash a bit like the DIR-853-A3
so it's won't be hard but someone who has one has to do it



These are the changes I made for my router. credit to Lucky1 for the work he has done on the DIR-878.

This is my DTS

/dts-v1/;

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/{
	compatible = "dlink,dir-853-a3", "mediatek,mt7621-soc";
	model = "D-Link DIR-853 A3";

	aliases {
		led-boot = &led_power_amber;
		led-failsafe = &led_power_amber;
		led-running = &led_power_blue;
		led-upgrade = &led_power_amber;
		label-mac-device = &gmac0;
	};

	chosen {
		bootargs = "console=ttyS0,57600";
	};

	leds {
		compatible = "gpio-leds";

		wlan1 {
			label = "dir-853-a3:blue:wlan2g";
			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
		};

		wlan0 {
			label = "dir-853-a3:blue:wlan5g";
			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
		};

		led_power_amber: power{
			label = "dir-853-a3:amber:power";
			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
		};

		led_power_blue: power2{
			label = "dir-853-a3:blue:power";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
		};

		net {
			label = "dir-853-a3:amber:internet";
			gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
		};

		net2 {
			label = "dir-853-a3:blue:internet";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
		};
		usb {
			label = "dir-853-a3:blue:usb";
			gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
			trigger-sources = <&xhci_ehci_port1>, <&ehci_port2>;
			linux,default-trigger = "usbport";
		};
	};

	keys {
		compatible = "gpio-keys";

		wps {
			label = "wps";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WPS_BUTTON>;
		};

		wifi {
			label = "wifi";
			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RFKILL>;
		};

		reset {
			label = "reset";
			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};
};

&nand {
	status = "okay";

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

		partition@0 {
			label = "bootloader";
			reg = <0x0 0x80000>;
			read-only;
		};

		partition@80000 {
			label = "config";
			reg = <0x80000 0x80000>;
		};

		factory: partition@100000 {
			label = "factory";
			reg = <0x100000 0x40000>;
			read-only;
		};

		partition@140000 {
			label = "config2";
			reg = <0x140000 0x40000>;
			read-only;
		};

		partition@180000 {
			compatible = "ubootpad96,uimage";
			label = "firmware";
			reg = <0x180000 0x2800000>;
		};

		partition@2980000 {
			label = "private";
			reg = <0x2980000 0x2000000>;
		};

		partition@4980000 {
			label = "kernel2";
			reg = <0x4980000 0x2800000>;
		};

		partition@7180000 {
			label = "mydlink";
			reg = <0x7180000 0x600000>;
		};

		partition@7780000 {
			label = "reserved";
			reg = <0x7780000  0x800000>;
		};
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	mt76@0,0 {
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x0>;
	};
};

&gmac0 {
	mtd-mac-address = <&factory 0xe000>;
};

&switch0 {
	ports {
		port@0 {
			status = "okay";
			label = "lan4";
		};

		port@1 {
			status = "okay";
			label = "lan3";
		};

		port@2 {
			status = "okay";
			label = "lan2";
		};

		port@3 {
			status = "okay";
			label = "lan1";
		};

		port@4 {
			status = "okay";
			label = "wan";
			mtd-mac-address = <&factory 0xe006>;
		};
	};
};

&state_default {
	gpio {
		groups = "uart3", "jtag", "wdt";
		function = "gpio";
	};
};

And this is the output of a git diff

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 525ad8218b..15cb0a4863 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -407,6 +407,43 @@ static struct mtd_part_parser uimage_fonfxc_parser = {
 	.parse_fn = mtdsplit_uimage_parse_fonfxc,
 };
 
+/**************************************************
+ * ubootpad96
+ **************************************************/
+
+#define ubootpad96_PAD_LEN		96
+
+static ssize_t uimage_find_ubootpad96(u_char *buf, size_t len, int *extralen)
+{
+	if (uimage_verify_default(buf, len, extralen) < 0)
+		return -EINVAL;
+
+	*extralen = ubootpad96_PAD_LEN;
+
+	return 0;
+}
+
+static int
+mtdsplit_uimage_parse_ubootpad96(struct mtd_info *master,
+			      const struct mtd_partition **pparts,
+			      struct mtd_part_parser_data *data)
+{
+	return __mtdsplit_parse_uimage(master, pparts, data,
+				       uimage_find_ubootpad96);
+}
+
+static const struct of_device_id mtdsplit_uimage_ubootpad96_of_match_table[] = {
+	{ .compatible = "ubootpad96,uimage" },
+	{},
+};
+
+static struct mtd_part_parser uimage_ubootpad96_parser = {
+	.owner = THIS_MODULE,
+	.name = "ubootpad96-fw",
+	.of_match_table = mtdsplit_uimage_ubootpad96_of_match_table,
+	.parse_fn = mtdsplit_uimage_parse_ubootpad96,
+};
+
 /**************************************************
  * OKLI (OpenWrt Kernel Loader Image)
  **************************************************/
@@ -470,6 +507,7 @@ static int __init mtdsplit_uimage_init(void)
 	register_mtd_parser(&uimage_netgear_parser);
 	register_mtd_parser(&uimage_edimax_parser);
 	register_mtd_parser(&uimage_fonfxc_parser);
+	register_mtd_parser(&uimage_ubootpad96_parser);
 	register_mtd_parser(&uimage_okli_parser);
 
 	return 0;
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index c2e96160cf..68749e18a3 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -81,6 +81,11 @@ define Build/iodata-mstc-header
 	)
 endef
 
+define Build/ubootpad96
+	uimage_padhdr -i $@ -o $@.new -l 96
+	mv $@.new $@
+endef
+
 define Build/ubnt-erx-factory-image
 	if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \
 		echo '21001:7' > $(1).compat; \
@@ -212,6 +217,26 @@ define Device/buffalo_wsr-600dhp
 endef
 TARGET_DEVICES += buffalo_wsr-600dhp
 
+define Device/dlink_dir-853-a3
+	IMAGE_SIZE := 40960k
+	UBINIZE_OPTS := -E 5
+	BLOCKSIZE := 128k
+	PAGESIZE := 2048
+	KERNEL_SIZE := 4096k
+	DEVICE_VENDOR := D-Link
+	DEVICE_MODEL := DIR-853
+	DEVICE_VARIANT := A3
+	IMAGES += factory.bin
+	KERNEL_INITRAMFS := $$(KERNEL) | ubootpad96
+	DEVICE_PACKAGES :=  kmod-mt7615e kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic
+	IMAGE/default := append-kernel | ubootpad96 | pad-to $$$$(KERNEL_SIZE)|\
+	append-ubi
+	IMAGE/factory.bin := $$(IMAGE/default) append-rootfs | pad-rootfs |\
+	check-size
+	IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += dlink_dir-853-a3
+
 define Device/dlink_dir-860l-b1
   $(Device/seama)
   BLOCKSIZE := 64k
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 fdfd29d011..836e2238f2 100755
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
@@ -29,6 +29,12 @@ gehua,ghl-r-001)
 dlink,dir-860l-b1)
 	ucidef_set_led_netdev "wan" "wan" "$boardname:green:net" "wan"
 	;;
+dlink,dir-853-a3)
+	ucidef_set_led_netdev "wan" "wan" "$boardname:amber:internet" "wan"
+	ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "wan"
+	ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "$boardname:blue:wlan2g" "wlan0"
+	ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "$boardname:blue:wlan5g" "wlan1"
+	;;
 gnubee,gb-pc1|\
 gnubee,gb-pc2)
 	ucidef_set_led_netdev "lan1" "lan1" "$boardname:green:lan1" "lan1"
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 290069f4d3..49d88141a0 100755
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -73,7 +73,8 @@ ramips_setup_macs()
 		wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
 		lan_mac=$wan_mac
 		;;
-	dlink,dir-860l-b1)
+	dlink,dir-860l-b1|\
+	dlink,dir-853-a3)
 		lan_mac=$(mtd_get_mac_ascii factory lanmac)
 		wan_mac=$(mtd_get_mac_ascii factory wanmac)
 		;;

If anyone want to forward support for this router here is a start
this is still very beta so i recommend only those with serial access
& knowledge to use the initramfs image to backup you flash partitions first


http://luckys.onmypc.net/openwrt/DIR-1960/

Hi! I terribly miss using OpenWrt ever since I've switched to this router. I see that there is a pretty active development going on for this device and I am inclined to flash this on my device. But before that I thought I should ask the helpful folks over here how their experience has been so far. I'll be grateful if you could tell me a few things.

Can the snapshot be used as a daily driver?
Is the PPOE mode working alright?
Do any of you have the unencrypted stock firmware that you could share?
Any hiccups in the flashing process?
Any other pointers you think is relevant.

Thank you!

Can the snapshot be used as a daily driver?
that depends n the day and what you use
Is the PPOE mode working alright?
don't use can't comment
Do any of you have the unencrypted stock firmware that you could share?
http://luckys.onmypc.net/openwrt/DIR-1960/

Any hiccups in the flashing process?
other than needed the unencrypted version to return it back
maybe problems with flashing form linux but windows in Private mode is fine

Any other pointers you think is relevant.
the wifi is still not there yet it keeps getting better all the time but not there yet
works but very slow
you do get DFS channels tho :slight_smile:

1 Like

Is there anything I can do to help with the development?

It has made it into the master branch :slight_smile:
you can always try the snapshots and follow up on faults you find
I think really we are waiting on the next version of openwrt 20.x.x or 21.x.x

1 Like

Can anyone report on speed tests using the snapshot? it uses the mt76 driver for the mt7615n correct?

I have had issues with a previous MT7621/mt7615n based router and openwrt.

The old router was some cheap chinese ac1200 rebranded as a hootoo nd001.

I just dont want to have the same issues with stability as i did with the old one

Secondly, i found out that there is often a second dual core chip on the MT7621 board that is populated but not activated. more information about that can be found here Support for Strong 1200

Has anyone looked into this, its a little out of my comfort zone.

I can't speak to the DIR-1960, but the Strong 1200 was a special case. They used the dual core MT7621AT chip, but their factory boot loader only enabled a single core. Any other MT7621AT device I've seen already enables both cores by default.

There is also the single core MT7621ST chip, which uses the same boot loader code. I'm guessing it was just a miss-configuration on the part of the people who developed that Strong / HooToo / MTC router

I'll also note that a bunch of improvements in the stability of the MT7621 platform, its network switch, and the MT76 drivers has been ongoing in the master branch (eventually version 20.x or 21.x depending on when it heads to release)

Ok, I will just wait for the master to increment and include the new pulls. I hope the DIR-1960 has both CPUs enabled, if it does not we should be able to flip the bit in the bootloader in a similar fashion.

Then I guess ill update the HooToo 1200 at the same time and use it as a access-point/mesh/something.