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

ath79: add support for TP-Link WDR3500 v1 #2298

Closed
wants to merge 1 commit into from

Conversation

adschm
Copy link
Member

@adschm adschm commented Aug 4, 2019

Patch 1/2 is just a copy of #2284 as it's needed as dependency here.

Device testing complete for WDR3500.

Working:

  • Power and system LED
  • Reset button
  • LAN/WAN/switch configuration
  • 2.4 GHz interface and LED
  • LAN/WAN LEDs are set up correctly
  • RF kill
  • 5 GHz interface and LED
  • USB including LED

(Outdated) forum discussion (in German):
https://forum.freifunk.net/t/ath79-support-for-tp-link-wdr3500/20961/8

@adschm
Copy link
Member Author

adschm commented Aug 4, 2019

@rotanid @kofec

@adschm
Copy link
Member Author

adschm commented Aug 4, 2019

I need some help with the WAN/LAN LEDs here.

Data from ar71xx:

#define AR934X_GPIO_OUT_LED_LINK0	41
#define AR934X_GPIO_OUT_LED_LINK1	42
#define AR934X_GPIO_OUT_LED_LINK2	43
#define AR934X_GPIO_OUT_LED_LINK3	44
#define AR934X_GPIO_OUT_LED_LINK4	45

#define WDR3500_GPIO_LED_WAN		18
#define WDR3500_GPIO_LED_LAN1		19
#define WDR3500_GPIO_LED_LAN2		20
#define WDR3500_GPIO_LED_LAN3		21
#define WDR3500_GPIO_LED_LAN4		22

ath79_gpio_output_select(WDR3500_GPIO_LED_LAN1,
			 AR934X_GPIO_OUT_LED_LINK3);
ath79_gpio_output_select(WDR3500_GPIO_LED_LAN2,
			 AR934X_GPIO_OUT_LED_LINK2);
ath79_gpio_output_select(WDR3500_GPIO_LED_LAN3,
			 AR934X_GPIO_OUT_LED_LINK1);
ath79_gpio_output_select(WDR3500_GPIO_LED_LAN4,
			 AR934X_GPIO_OUT_LED_LINK0);
ath79_gpio_output_select(WDR3500_GPIO_LED_WAN,
			 AR934X_GPIO_OUT_LED_LINK4);

Current implementation:

&pinmux {
	pmx_led_wan: pinmux_led_wan {
		pinctrl-single,bits = <0x12 0x2d 0xff>;
	};

	pmx_led_lan: pinmux_led_lan {
		pinctrl-single,bits = <0x13 0x292a2b2c 0xffffffff>;
	};
};

&builtin_switch {
	pinctrl-names = "default";
	pinctrl-0 = <&pmx_led_wan &pmx_led_lan>;
};

@adschm adschm changed the title [WIP] ath79: add support for TP-Link WDR3500 v1 [WIP/RFC] ath79: add support for TP-Link WDR3500 v1 Aug 4, 2019
@981213
Copy link
Member

981213 commented Aug 4, 2019

The register offset for pinctrl-single,bits needs to be 4-byte aligned, so '0x13' is invalid and it won't work. You need to split that into two entries.

@adschm
Copy link
Member Author

adschm commented Aug 4, 2019

@981213

So, I could do it this way? (Ignoring names for now)

&pinmux {
	pmx_led_wan: pinmux_led_wan {
		pinctrl-single,bits = <0x12 0x2a2b2c2d 0xffffffff>;
	};

	pmx_led_lan: pinmux_led_lan {
		pinctrl-single,bits = <0x16 0x29 0xff>;
	};
};

?

@981213
Copy link
Member

981213 commented Aug 4, 2019

er... (0x12%4)!=0 so 0x12 won't work either. You need 0x10 and 0x14 instead.

@adschm
Copy link
Member Author

adschm commented Aug 4, 2019

er... (0x12%4)!=0 so 0x12 won't work either. You need 0x10 and 0x14 instead.

Ah, sorry, was tricked into decimal numbers...

@adschm
Copy link
Member Author

adschm commented Aug 4, 2019

Okay, narrowed it down to

&pinmux {
	pmx_led_wan_lan: pinmux_led_wan_lan {
		pinctrl-single,bits = <0x10 0x2c2d0000 0xffff0000>,
			<0x14 0x292a2b 0xffffff>;
	};
};

@blocktrron blocktrron added target/ath79 pull request/issue for ath79 target RFC pull request ready for comments labels Aug 5, 2019
@adschm
Copy link
Member Author

adschm commented Aug 5, 2019

@kofec If you have time to test, please do so with the current state of this PR (I can also provide images if required).

@kofec
Copy link

kofec commented Aug 6, 2019

Hi,
I'm on holiday this and next week. So I do not have access to the hardware. I can do this when back. Thanks for your work

@adschm
Copy link
Member Author

adschm commented Aug 7, 2019

Well, have a nice holiday then. I think there is plenty of time for this PR ...

@adschm
Copy link
Member Author

adschm commented Aug 13, 2019

Update:

  • Rebased due to merge of WDR4300 patch.

@rotanid
Copy link
Contributor

rotanid commented Aug 18, 2019

update test results with the branches state from about 10 hours ago:

  • power LED always on
  • system LED blinking slow when flashing, blinking fast during boot
  • WAN LED working correctly
  • all LAN LEDs working correctly
  • rfkill working (now? maybe i didnt test correctly last time)

@adrianschmutzler what do i need to do or put which kmods/packages into my own build to be able to test 5GHz and USB?

@adschm
Copy link
Member Author

adschm commented Aug 18, 2019

@rotanid Thanks for testing.
I would expect both 5 GHz and USB to work already with the current commits. I assume your question implies that this is not the case?

@rotanid
Copy link
Contributor

rotanid commented Aug 18, 2019

I would expect both 5 GHz and USB to work already with the current commits. I assume your question implies that this is not the case?

i'm not sure if i need to include specific packages in my build, or should the default .config for the device work?

USB: when i insert a USB testing device, it gets power at least. When i insert a USB Flashdrive, nothing appears in "dmesg" about any USB activity and the LED also doesn't light up.

5GHz wifi: no sign of it in LUCI or /etc/config/wireless - maybe the following lines from the dmesg output help?

root@OpenWrt:~# dmesg | grep ath9k
[   12.732421] ath9k 0000:00:00.0: enabling device (0000 -> 0002)
[   12.740582] ath9k 0000:00:00.0: Direct firmware load for ath9k-eeprom-pci-0000:00:00.0.bin failed with error -2
[   12.750880] ath9k 0000:00:00.0: Falling back to syfs fallback for: ath9k-eeprom-pci-0000:00:00.0.bin
[   13.495856] firmware ath9k-eeprom-pci-0000:00:00.0.bin: firmware_loading_store: map pages failed
[   13.505621] ath: phy1: Unable to load EEPROM file ath9k-eeprom-pci-0000:00:00.0.bin
[   13.513401] ath9k 0000:00:00.0: Failed to initialize device
[   13.519168] ath9k: probe of 0000:00:00.0 failed with error -22

@adschm
Copy link
Member Author

adschm commented Aug 19, 2019

@rotanid
I should have fixed the 5 GHz Wifi (stupid mistake ...).
For the USB, I just tried something different, don't know whether this will do. So, just check LED and dmesg for this one again, please.

@adschm
Copy link
Member Author

adschm commented Aug 19, 2019

@rotanid

i'm not sure if i need to include specific packages in my build, or should the default .config for the device work?

Normally, all necessary packages should be included automatically by DEVICE_PACKAGES etc.

@rotanid
Copy link
Contributor

rotanid commented Aug 20, 2019

@rotanid
I should have fixed the 5 GHz Wifi (stupid mistake ...).
For the USB, I just tried something different, don't know whether this will do. So, just check LED and dmesg for this one again, please.

5 GHz Wifi works now.
USB still doesn't, no reaction on LED or in dmesg.

@adschm
Copy link
Member Author

adschm commented Aug 20, 2019

@blocktrron @981213
Any idea what I'm doing wrong with USB here?

I tried

&usb {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	hub_port: port@1 {
		reg = <1>;
		#trigger-source-cells = <0>;
	};
};

and

&usb {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	port@1 {
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <1>;
		#trigger-source-cells = <0>;

		hub_port: port@1 {
			reg = <1>;
			#trigger-source-cells = <0>;
		};
	};
};

?

@adschm
Copy link
Member Author

adschm commented Aug 20, 2019

@rotanid Can you provide a full dmesg?

@kofec
Copy link

kofec commented Aug 20, 2019

@rotanid Maybe you should install kmod-usb-storage ?
Maybe you can try any other USB device (keyboard, mouse)?
Maybe you can also install
opkg install usbutils
and than
lsusb

@rotanid
Copy link
Contributor

rotanid commented Aug 20, 2019

@rotanid Can you provide a full dmesg?

hm, just looked at opkg list-installed | grep kmod-usb and it's empty?

it seems, "DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport" is ignored?
i'll add these packages manually to my build now, but as you already said they should be included automatically!

lsusb

already have that. result:
unable to initialize libusb: -99

@kofec
Copy link

kofec commented Aug 20, 2019

On mine wdr3600 so it looks like the modules are missing:

opkg list-installed | grep kmod-usb
kmod-usb-core - 4.19.57-1
kmod-usb-ehci - 4.19.57-1
kmod-usb-ohci - 4.19.57-1
kmod-usb-storage - 4.19.57-1
kmod-usb2 - 4.19.57-1

@adschm
Copy link
Member Author

adschm commented Aug 20, 2019

@rotanid First set of images:
https://www.adrianschmutzler.net/upload/wdr3500-0820-hub.zip

Those are with the supposedly wrong hub setup. I included 3600 and 4300, so do not wonder about the size ...

@adschm
Copy link
Member Author

adschm commented Aug 20, 2019

https://www.adrianschmutzler.net/upload/wdr3500-0820-nohub.zip

That's the version as discussed with 981213.

@adschm
Copy link
Member Author

adschm commented Aug 20, 2019

Will also test again on my 4300 tonight or tomorrow.

@rotanid
Copy link
Contributor

rotanid commented Aug 20, 2019

@rotanid First set of images:
https://www.adrianschmutzler.net/upload/wdr3500-0820-hub.zip

Those are with the supposedly wrong hub setup. I included 3600 and 4300, so do not wonder about the size ...

with this, the LED does not work, but when connecting a usb flash drive it still says in dmesg "new high-speed USB device [...]"

https://www.adrianschmutzler.net/upload/wdr3500-0820-nohub.zip

That's the version as discussed with 981213.

with this the LED works and when connecting a usb flash drive it says in dmesg "new high-speed USB device [...]"

can you update this PR/branch to this one?

@adschm
Copy link
Member Author

adschm commented Aug 21, 2019

@rotanid Updated.
So we got us a fully working version now and the USB issues really seem to be build-related?

@adschm adschm changed the title [WIP/RFC] ath79: add support for TP-Link WDR3500 v1 ath79: add support for TP-Link WDR3500 v1 Aug 21, 2019
@rotanid
Copy link
Contributor

rotanid commented Aug 21, 2019

@rotanid Updated.
So we got us a fully working version now and the USB issues really seem to be build-related?

probably, although i still don't know what i'm doing wrong.

echo "CONFIG_PACKAGE_kmod-usb2=y" >> .config
echo "CONFIG_PACKAGE_kmod-usb-ledtrig-usbport=y" >> .config

without this ^ the packages are not there in the wdr3500 sysupgrade image

@adschm
Copy link
Member Author

adschm commented Aug 21, 2019

@rotanid Both packages are not even present in my config.seed.
I started from buildbot config.seed and then worked backwards (i.e. remove unnecessary devices, do not build all packages etc.) for my test images.
Don't really see anything to help you.

@adschm
Copy link
Member Author

adschm commented Aug 21, 2019

@blocktrron @981213
So this PR is tested and ready for merge
(I also quickly retested WDR4300).

@adschm
Copy link
Member Author

adschm commented Aug 21, 2019

@rotanid
I gave it another try on my WDR4300 and started from scratch, so config.buildinfo (former config.seed) is just:

CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_generic=y
CONFIG_TARGET_MULTI_PROFILE=y
CONFIG_TARGET_DEVICE_ath79_generic_DEVICE_tplink_tl-wdr3500-v1=y
CONFIG_TARGET_DEVICE_PACKAGES_ath79_generic_DEVICE_tplink_tl-wdr3500-v1=""
CONFIG_TARGET_DEVICE_ath79_generic_DEVICE_tplink_tl-wdr3600-v1=y
CONFIG_TARGET_DEVICE_PACKAGES_ath79_generic_DEVICE_tplink_tl-wdr3600-v1=""
CONFIG_TARGET_DEVICE_ath79_generic_DEVICE_tplink_tl-wdr4300-v1=y
CONFIG_TARGET_DEVICE_PACKAGES_ath79_generic_DEVICE_tplink_tl-wdr4300-v1=""
CONFIG_TARGET_PER_DEVICE_ROOTFS=y
# CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE is not set
# CONFIG_TARGET_ROOTFS_INITRAMFS is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2 is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4 is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ is not set

Note that I always used "CONFIG_TARGET_PER_DEVICE_ROOTFS=y", which actually should have an influence on how packages are selected.

@rotanid
Copy link
Contributor

rotanid commented Aug 21, 2019

Note that I always used "CONFIG_TARGET_PER_DEVICE_ROOTFS=y", which actually should have an influence on how packages are selected.

thanks, working now!

@kofec
Copy link

kofec commented Aug 30, 2019

Hi,
Is it still needed to test it or it can be merged as it is - already tested by rotanid.

@adschm
Copy link
Member Author

adschm commented Aug 31, 2019

IMO, this is ready for merge.
@kofec If you want to test, too, feel free to do so, but I do not consider it necessary for merge (as it's already tested by rotanid).

@adschm
Copy link
Member Author

adschm commented Aug 31, 2019

I've updated this PR and taken the chance to remove kmod-usb-core treewide, so no more copy/paste additions :-)
https://patchwork.ozlabs.org/patch/1156189/

@blocktrron
Copy link
Member

Don't know where this comes from, but could you remove the executable flag from ar9344_tplink_tl-wdrxxxx.dtsi and ar9344_tplink_tl-wdr3500-v1.dts?

@adschm
Copy link
Member Author

adschm commented Sep 2, 2019

Done.

Hardware:
SoC:      AR9344
CPU:      560 MHz
Flash:    8 MiB
RAM:      128 MiB
WiFi:     Atheros AR9340 2.4GHz 802.11bgn
          Atheros AR9300 5GHz 802.11an
Ethernet: AR934X built-in switch, WAN on separate physical interface
USB:      1x 2.0

Flash instruction (WebUI):
Download *-factory.bin image and upload it via the firmwary upgrade
function of the stock firmware WebUI.

Flash instruction (TFTP):
1. Set PC to fixed ip address 192.168.0.66
2. Download *-factory.bin image and rename it to
   wdr3500v1_tp_recovery.bin
3. Start a tftp server with the image file in its root directory
4. Turn off the router
5. Press and hold Reset button
6. Turn on router with the reset button pressed and wait ~15 seconds
7. Release the reset button and after a short time
the firmware should be transferred from the tftp server
8. Wait ~30 second to complete recovery.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
@adschm
Copy link
Member Author

adschm commented Sep 3, 2019

Removed the double newline, but I do not think it's worth cherry-picking only for that again.

@blocktrron
Copy link
Member

@blocktrron blocktrron closed this Sep 3, 2019
@adschm adschm deleted the ath3500 branch September 5, 2019 22:05
@kofec
Copy link

kofec commented Nov 8, 2019

Is it worth to backport this to 19.07 ? As this will not be release ?

@adschm
Copy link
Member Author

adschm commented Nov 8, 2019

Well, normally device support is not backported to stable branches. In 19.07, wdr3500 is supported in ar71xx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC pull request ready for comments target/ath79 pull request/issue for ath79 target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants