Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: add initial support for TP-LINK TL-WR840N v4 #974

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to investigate poor wireless performance, which was described by @sanitariu
The thing I noticed here is that the EEPROM address was not defined, so it uses default value from mt7628an.dtsi, which is wrong for this hardware:
mediatek,mtd-eeprom = <&factory 0x0000>;
Real EEPROM is located in radio partition, so we must declare this:

&spi0 {
...
	m25p80@0 {
...
		radio: partition@07f0000 {
...
&wmac {
...
	mediatek,mtd-eeprom = <&radio 0x0000>;
};

But performance is still bad though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you make some patch for the correct eeprom ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are the author of this https://raxp.ru/index.php/2017/06/21/lede-for-wr841n-v13wr840n-v4-ru/ ?
Can share the developments?

};

&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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the existing pad-extra instead of your custom prepend-to.

pad-extra 448 | $(KERNEL_DTB) | uImage lzma

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it's not possible.
KERNEL_DTB = kernel-bin | patch-dtb | lzma
Calling pad-extra before making KERNEL_DTB causes, that all leading zeroes crated by pad-extra are subject of lzma a will be comprimed:(
I can't find better/simpler solution.

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