TP-Link WR841N(D) patch needed for USB mod on 18.06.9

Hello to everyone! :slight_smile: I've made the HW mod to add the USB 2.0 port to a WR841N V7.2 but the patch linked in the Wiki is no longer downloadable (the link is dead, quite obviously after so many time has passed). I've found an alternative source here but that patch (as the one originally linked in the Wiki which I suppose being the same exact one) is for older versions with an older kernel. Now my question is: "Is that patch supposed to be adapted or is the approach completely different with newer versions?".
This question arises in my mind because the paths (at least but I'm sure not only) are completely wrong (for example: target/linux/ar71xx/patches-3.7/ VS target/linux/ar71xx/patches-4.9/) and I don't even imagine from where to start with adapting it but I'm almost sure that changing the paths isn't enough.
Also, similar mods exist for many other routers, for example the Mi-4c and Mi-4a and the approach seems completely different. Now, please don't misunderstand me: I perfectly know we're talking about COMPLETELY different hardware but maybe the approach has changed not only because of that but because with newer versions (like the 18.06.9) everything is handled differently.
I don't know: the only thing I know is that having succeeded in making the HW mod but being stuck on the SW side is a real shame! :frowning:

I just had a short look on this: Seems like the only required change is the addition of GPIO 6 to enable USB power. For the current ath79 target, you need to edit the device's dts and add a gpio-hog (or gpio-export) definition for GPIO 6. Don't forget to also enable the USB nodes in the dts.

Your required DTS: https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/dts/ar7241_tplink_tl-wr841-v7.dts
And a template you can use, taken from: https://github.com/openwrt/openwrt/blob/087a8e39be56866804b09574b0d63fff7c667ad1/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts

/ {
	gpio-export {
		compatible = "gpio-export";

		gpio_usb_power {
			gpio-export,name = "tp-link:power:usb";
			gpio-export,output = <1>;
			gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
		};
	};
};

&usb {
	status = "okay";
};

&usb_phy {
	status = "okay";
};

NB: If you use gpio-hog, you can't change its state during runtime. If you use gpio-export, you can toggle power via a node in /sys/class/gpio.

@andyboeh

Thanks for your kind and comprehensive reply and please excuse me for being so late with giving you a follow-up but I'm experiencing some issues at home and I'm sidelined with the rest. :frowning:
I'm confident the HW modification is fine because I've checked everything with a multimeter getting the readings I expected (maybe I would post some photos along with those readings later on if needed) but there is definitively something wrong. I've tried to flash the prebuilt Barrier Breaker image downloadable from that polish site I've linked above but nothing: I get a few generic messages about usb in dmesg output but absolutely nothing after connecting a pendrive. I've also tried to patch a more actual 18.06.9 using the let's say old patch but still nothing and this time I get nothing at all reading dmesg output, those generic messages I've got with Barrier Breaker neither.
Reading only now what you advice, it could well be that that old patch isn't suitable for newer sources. I would try my best to apply your advices and let's hope it would work out (I'm not doubting your advices which are certainly right but my HW modification, that's clear).
Have a nice day! :slight_smile:

@andyboeh

I've taken a look at those two files you've pointed out to me using your advices as a reference but unfortunately it's beyond my knowledge. Also, I get usb power from a step-down converter directly connected to the router power socket with the router fed by another 9V PSU with a better current rating than the genuine one and it is the only thing which certainly works. Only D+ and D- are connected to the motherboard. Here are the photos of the modification made by me:

Please note that, as instructed to do by the guides, I've added two 15KOhm resistors respectively between D+ and GND and D- and GND, soldered to the childboard with the USB ports. I'm a bit doubtful about this because even the SMD resistors on the motherboard which I've connected D+ and D- to as instructed to do are 15KOhm resistors...
With the motherboard and the childboard disconnected I get 14.9KOhm between D+ and GND and D- and GND, 29,8KOhm between D+ and D- (child) 14.9KOhm between R602 (unused terminal) and D- and R601 (unused terminal) and D+ (mother) while when the two boards are connected I get continuity between D+ and D+ and D- and D- ends on them while I get 7.4KOhm both between R602 (unused terminal) and D- (child side) and R601 (unused terminal) and D+ (still child side).
Finally, if I connect an usb tester to one of the ports on the child I get 5.02V steady. Everyting seems to be fine HW side (or at least it should be) but I'm completely lost on the rest. Also, I didn't expect the 18.06.9 image patched and built by me to work but the fact that USB support doesn't work with the prebuilt Barrier Breaker image neither doesn't look that much promising...
I think I should give up and accept having just lost quite a lot of time. :frowning: Not your fault or anyone's else, just my lack of knowledge and maybe the overkill idea to mod this router instead of scouring one already with working USB ports. My fault. Thanks for your help anyway! :slight_smile:

I'm sorry, I don't have the hardware to test this out myself. And I haven't done such a mod, I can only tell you how to forward-port the patch. It is also possible that your image does not contain the USB drivers, maybe check with make menuconfig if the USB host drivers are enabled (probably "kmod-usb-ohci", "komd-usb-ehci" and/or "kmod-usb-uhci").
If you go through the boot log (via logread or dmesg) you should see a line saying "hogged GPIO 6 as
tp-link:power:usb" or similar (on a recent build with the changed dts).

@andyboeh

Hello again! :slight_smile: It isn't a matter of having the hardware or not or me being lazy. Building that patched 18.06.9 (patched in the wrong way according to the path to follow outlined by you but I had already done it when I've read) has been quite time consuming but if you want to achieve something you need to put time and effort on it, I know.
The issue is that, by the very least that I've understood (absolutely not your fault, only mine), I would certainly do some mistake somewhere when building again following the right procedure and the last time it has taken something like a whole afternoon to build so I can't afford it again without being certain that the sources are correctly patched. Being certain about that, then I'm free to build everything again and make all the necessary testing on my router but unfortunately my knowledge doesn't let me take that fundamental starting point for granted.
Also, quite a big off topic, I know that we're talking about an outdated router but I don't know why after 18.06.9 an image for the WR841N(D) hasn't been made available anymore and I was wondering if I could try to build newer versions or not (still my lack of knowledge). Have a nice day.

Because of this:

Or, in short: It just hasn't got enough memory for newer releases.

Do yourself a favor and get something bigger. Devices like the TL-WDR4300 or even better are used incredibly cheap.
Even a unused HomeHub5A was cheaper than the shipping from the UK to Germany...
And both devices (and a lot more) are supported by 22.03.

1 Like

@elder_tinkerer

Thanks for your purchase suggestions. I know the both of them and I own and use the latter. It remains that I'd like to succeed with this useless project.

Whatever suits you.
Good luck.