Skip to content

Commit

Permalink
ramips: add initial support for TP-LINK TL-WR840N v4
Browse files Browse the repository at this point in the history
This patch adds initial support for wireless router TP-LINK TL-WR840N v4.

Specification:
- SoC: MediaTek MT7628NN (580MHz)
- RAM: 64 MiB (Winbond W9751G6JB-25)
- Flash: 8 MiB (GigaDevice GD25Q64CSIG)
- LAN: 4x 100M
- WAN: 1x 100M
- Antennas: 2x non-detachable
- LED: 5x green
- Buttons: 1x reset

Instalation:
TP-Link firmware uses recent firmware v3 header, please see
  https://github.com/xdarklight/mktplinkfw3.
Therefore direct upgrade from TP-Link web UI is not supported yet.

Upgrade from the TP-Link firmware is possible using common TFTP recovery mode.
Rename file lede-ramips-mt7628-tl-wr840n-v4-squashfs-factory.bin
to tp_recovery.bin and put it on a TFTP server with IP 192.168.0.66.
Hold reset buton when connecting power until TFTP transfer begins.

For upgrade from LEDE use generic sysupgrade method.

LEDE uses uImage firmware header instead of the TP-Link v3 firmware
header. In order to  recover the original TP-Link firmware please
use TFTP recovery mode. The header has to be removed from
the original firmware:
  dd if=TL-WR840Nv4_0.9.1_3.16_up_boot\(161011\).bin \
    bs=512 skip=1 > tp_recovery.bin

Signed-off-by: Vaclav Svoboda <svoboda@neng.cz>
  • Loading branch information
svobodavac committed Mar 23, 2017
1 parent 2f09a1e commit 8706b60
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 0 deletions.
5 changes: 5 additions & 0 deletions target/linux/ramips/base-files/etc/board.d/01_leds
Expand Up @@ -323,6 +323,11 @@ tiny-ac)
set_wifi_led "$board:orange:wifi"
set_usb_led "$board:green:usb"
;;
tl-wr840n-v4)
set_wifi_led "$board:green:wireless"
ucidef_set_led_switch "lan" "lan" "$board:green:lan" "switch0" "0x1e"
ucidef_set_led_switch "wan" "wan" "$board:green:wan" "switch0" "0x01"
;;
vocore)
ucidef_set_led_netdev "eth" "ETH" "$board:orange:eth" "eth0"
set_wifi_led "$board:green:status"
Expand Down
1 change: 1 addition & 0 deletions target/linux/ramips/base-files/etc/board.d/02_network
Expand Up @@ -151,6 +151,7 @@ ramips_setup_interfaces()
mzk-wdpr|\
rb750gr3|\
rt-n14u|\
tl-wr840n-v4|\
ubnt-erx|\
ur-326n4g|\
wrtnode|\
Expand Down
1 change: 1 addition & 0 deletions target/linux/ramips/base-files/etc/diag.sh
Expand Up @@ -35,6 +35,7 @@ get_status_led() {
nbg-419n2|\
pwh2004|\
r6220|\
tl-wr840n-v4|\
vr500|\
wnce2001|\
wndr3700v5|\
Expand Down
3 changes: 3 additions & 0 deletions target/linux/ramips/base-files/lib/ramips.sh
Expand Up @@ -478,6 +478,9 @@ ramips_board_detect() {
*"Timecloud")
name="timecloud"
;;
"TP-LINK TL-WR840N v4")
name="tl-wr840n-v4"
;;
*"UBNT-ERX")
name="ubnt-erx"
;;
Expand Down
1 change: 1 addition & 0 deletions target/linux/ramips/base-files/lib/upgrade/platform.sh
Expand Up @@ -135,6 +135,7 @@ platform_check_image() {
tew-714tru|\
timecloud|\
tiny-ac|\
tl-wr840n-v4|\
ur-326n4g|\
ur-336un|\
v22rw-2x2|\
Expand Down
141 changes: 141 additions & 0 deletions target/linux/ramips/dts/TL-WR840NV4.dts
@@ -0,0 +1,141 @@
/dts-v1/;

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

#include "mt7628an.dtsi"

/ {
compatible = "tplink,tl-wr840n-v4", "mediatek,mt7628an-soc";
model = "TP-LINK TL-WR840N v4";

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

memory@0 {
device_type = "memory";
reg = <0x0 0x4000000>;
};

gpio-keys-polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;

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

gpio-leds {
compatible = "gpio-leds";

power {
label = "tl-wr840n-v4:green:power";
gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
};

wireless {
label = "tl-wr840n-v4:green:wireless";
gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
};

ethernet {
label = "tl-wr840n-v4:green:lan";
gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
};

internet {
label = "tl-wr840n-v4:green:wan";
gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
};

wps {
label = "tl-wr840n-v4:green:wps";
gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
};
};
};

&pinctrl {
state_default: pinctrl0 {
gpio {
ralink,group = "i2c", "i2s", "uart1", "uart2", "p0led_an", "p2led_an" ;
ralink,function = "gpio";
};
};
};

&spi0 {
status = "okay";

m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
m25p,chunked-io = <32>;

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

partition@20000 {
label = "firmware";
reg = <0x20000 0x7a0000>;
};

partition@7c0000 {
label = "config";
reg = <0x7c0000 0x10000>;
read-only;
};

factory: partition@07d0000 {
label = "romfile";
reg = <0x7d0000 0x10000>;
read-only;
};

partition@07e0000 {
label = "rom";
reg = <0x7e0000 0x10000>;
read-only;
};

partition@07f0000 {
label = "radio";
reg = <0x7f0000 0x10000>;
read-only;
};
};
};

&usbphy {
status = "disabled";
};

&ehci {
status = "disabled";
};

&ohci {
status = "disabled";
};

&wmac {
status = "okay";
mtd-mac-address = <&factory 0xf100>;
};

&ethernet {
mtd-mac-address = <&factory 0xf100>;
mediatek,portmap = "llllw";
};
15 changes: 15 additions & 0 deletions target/linux/ramips/image/mt7628.mk
Expand Up @@ -2,6 +2,10 @@
# MT7628 Profiles
#

define Build/prepend-to
dd bs=1 seek=$(1) if=$@ of=$@.new && mv $@.new $@
endef

define Device/mt7628
DTS := MT7628
BLOCKSIZE := 64k
Expand All @@ -26,6 +30,17 @@ define Device/miwifi-nano
endef
TARGET_DEVICES += miwifi-nano

define Device/tl-wr840n-v4
DTS := TL-WR840NV4
IMAGE_SIZE := 7808k
DEVICE_TITLE := TP-Link TL-WR840N v4
DEVICE_PACKAGES :=
KERNEL := $(KERNEL_DTB) | prepend-to 448 | uImage lzma
IMAGES += factory.bin
IMAGE/factory.bin := pad-extra 131072 | $$(sysupgrade_bin)
endef
TARGET_DEVICES += tl-wr840n-v4

define Device/vocore2
DTS := VOCORE2
IMAGE_SIZE := $(ralink_default_fw_size_16M)
Expand Down
1 change: 1 addition & 0 deletions target/linux/ramips/mt7628/config-4.4
Expand Up @@ -192,6 +192,7 @@ CONFIG_SPI_MT7621=y
# CONFIG_SPI_RT2880 is not set
CONFIG_SRCU=y
CONFIG_SWCONFIG=y
CONFIG_SWCONFIG_LEDS=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_SYS_HAS_CPU_MIPS32_R1=y
CONFIG_SYS_HAS_CPU_MIPS32_R2=y
Expand Down
1 change: 1 addition & 0 deletions target/linux/ramips/mt7628/config-4.9
Expand Up @@ -195,6 +195,7 @@ CONFIG_SPI_MT7621=y
# CONFIG_SPI_RT2880 is not set
CONFIG_SRCU=y
CONFIG_SWCONFIG=y
CONFIG_SWCONFIG_LEDS=y
CONFIG_SWPHY=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_SYS_HAS_CPU_MIPS32_R1=y
Expand Down

0 comments on commit 8706b60

Please sign in to comment.