ramips: add support for Dlink DIR-878 A1

Specifications:
* SoC: MT7621AT
* RAM: 128MB
* Flash: 16MB NOR SPI flash
* WiFi: MT7615N (2.4GHz) and MT7615N (5Ghz)
* LAN: 5x1000M
* Firmware layout is Uboot with extra 96 bytes in header
* Base PCB is AP-MTKH7-0002
* LEDs Power Green,Power Orange,Internet Green,Internet Orange
* LEDs "2.4G" Green & "5G" Green connected directly to wifi module
* Buttons Reset,WPS,WIFI

Flash instruction:

Upload image via emergency recovery mode via Windows "not working with Linux"
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.
Give it ~30 seconds, to boot the recovery mode GUI
Connect your client computer to LAN1 of the device
Set your client IP address manually to 192.168.0.2 / 255.255.255.0.
Call the recovery page for the device at http://192.168.0.1
Use the provided emergency web GUI to upload and flash a new firmware to the device

MAC addresses:

lan      factory 0xe000 *:55 (label)
wan      factory 0xe006 *:58
2.4 GHz  factory 0x0004 *:56
5.0 GHz  factory 0x8004 *:57

Signed-off-by: Alan Luck <luckyhome2008@gmail.com>
This commit is contained in:
Alan Luck 2019-12-03 21:39:04 +11:00 committed by AmadeusGhost
parent 478a80a5dc
commit 4c8ded996c
5 changed files with 222 additions and 0 deletions

View File

@ -423,6 +423,47 @@ 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);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
static const struct of_device_id mtdsplit_uimage_ubootpad96_of_match_table[] = {
{ .compatible = "ubootpad96,uimage" },
{},
};
#endif
static struct mtd_part_parser uimage_ubootpad96_parser = {
.owner = THIS_MODULE,
.name = "ubootpad96-fw",
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
.of_match_table = mtdsplit_uimage_ubootpad96_of_match_table,
#endif
.parse_fn = mtdsplit_uimage_parse_ubootpad96,
};
/**************************************************
* OKLI (OpenWrt Kernel Loader Image)
**************************************************/
@ -490,6 +531,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;

View File

@ -0,0 +1,153 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7621.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
compatible = "dlink,dir-878-a1", "mediatek,mt7621-soc";
model = "D-Link DIR-878 A1";
aliases {
led-boot = &led_power_orange;
led-failsafe = &led_power_green;
led-running = &led_power_green;
led-upgrade = &led_net_orange;
label-mac-device = &ethernet;
};
chosen {
bootargs = "console=ttyS0,57600";
};
leds {
compatible = "gpio-leds";
led_power_orange: power_orange {
label = "dir-878-a1:orange:power";
gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
};
led_power_green: power_green {
label = "dir-878-a1:green:power";
gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
};
led_net_orange: net_orange {
label = "dir-878-a1:orange:net";
gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
};
net_green {
label = "dir-878-a1:green:net";
gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
};
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
wps {
label = "wps";
gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
wifi {
label = "wifi";
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RFKILL>;
};
};
};
&spi0 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
m25p,fast-read;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};
factory: partition@40000 {
label = "factory";
reg = <0x40000 0x20000>;
read-only;
};
partition@60000 {
compatible = "ubootpad96,uimage";
label = "firmware";
reg = <0x60000 0xfa0000>;
};
};
};
};
&pcie {
status = "okay";
};
&pcie0 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0000>;
ieee80211-freq-limit = <2400000 2500000>;
led {
led-active-low;
};
};
};
&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
led {
led-active-low;
};
};
};
&ethernet {
mtd-mac-address = <&factory 0xe000>;
mediatek,portmap = "llllw";
};
&state_default {
gpio {
ralink,group = "i2c", "uart3", "jtag", "wdt";
ralink,function = "gpio";
};
};

View File

@ -87,6 +87,11 @@ define Build/netis-tail
sed 's/../\\\\x&/g' | xargs echo -ne >> $@
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:6' > $(1).compat; \
@ -220,6 +225,22 @@ define Device/dlink_dir-860l-b1
endef
TARGET_DEVICES += dlink_dir-860l-b1
define Device/dlink_dir-878-a1
BLOCKSIZE := 64k
IMAGE_SIZE := 16000k
DEVICE_VENDOR := D-Link
IMAGES += factory.bin
DEVICE_MODEL := DIR-878
DEVICE_VARIANT := A1
DEVICE_PACKAGES := kmod-mt7615e wpad-basic
KERNEL_INITRAMFS := $$(KERNEL) | ubootpad96
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | ubootpad96 |\
pad-rootfs | check-size $$$$(IMAGE_SIZE) | append-metadata
IMAGE/factory.bin := append-kernel | append-rootfs | ubootpad96 |\
check-size $$$$(IMAGE_SIZE)
endef
TARGET_DEVICES += dlink_dir-878-a1
define Device/d-team_newifi-d2
IMAGE_SIZE := 32448k
DEVICE_VENDOR := Newifi

View File

@ -29,6 +29,10 @@ gehua,ghl-r-001)
dlink,dir-860l-b1)
ucidef_set_led_netdev "wan" "wan" "$boardname:green:net" "eth0.2"
;;
dlink,dir-878-a1)
ucidef_set_led_switch "wan-green" "WAN 1Ghz" "$boardname:green:net" "switch0" "0x10" "0x08"
ucidef_set_led_switch "wan-orange" "WAN 10/100Mhz" "$boardname:orange:net" "switch0" "0x10" "0x06"
;;
gnubee,gb-pc1|\
gnubee,gb-pc2)
ucidef_set_led_switch "lan1" "lan1" "$boardname:green:lan1" "switch0" "0x01"

View File

@ -90,6 +90,7 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
;;
dlink,dir-878-a1|\
d-team,newifi-d2)
ucidef_add_switch "switch0" \
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
@ -181,6 +182,7 @@ ramips_setup_macs()
;;
alfa-network,quad-e4g|\
asus,rt-ac57u|\
dlink,dir-878-a1|\
d-team,newifi-d2|\
d-team,pbr-m1|\
elecom,wrc-1167ghbk2-s|\