Modify

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#13201 closed defect (fixed)

USB on tp-link mr3420 v2.1 doesn't work at all.

Reported by: dani@… Owned by: developers
Priority: high Milestone: Bugs Paradise
Component: kernel Version: Trunk
Keywords: Cc:

Description

Hello,
with r36085 the usb port of tp-link mr3420 v2.1 doesn't work at all,
i compiled kmod usb modules, usbutils, usb mode switch, tried two UVC webcams, one 3g stick..

root@mr3420:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

With oem tp-link firmware the 3g usb stick will power up and even work to provide Internet access.

Attachments (0)

Change History (45)

comment:1 Changed 5 years ago by davor.herga@…

Also with r36083 none of the two USB ports on Asus WL-5000gP v1 won't work.

comment:2 Changed 5 years ago by Davor Herga <davor.herga@…>

That is Asus WL-500gP v1 ...

comment:3 Changed 5 years ago by Davor Herga <davor.herga@…>

Some update -

Trying to do lsusb on Asus I get:

unable to initialize libusb: -99

comment:4 Changed 5 years ago by Dmytro <dioptimizer@…>

Dani
try do next in console:

echo 8 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio8/direction
echo 1 > /sys/class/gpio/gpio8/value

After this, try test USB connection with your devices...

The problem may consist in the fact that is registered wrong GPIO No. in the kernel profile to enable Power over USB.

comment:5 Changed 5 years ago by dani@…

i'm sorry Dmytro, i still cannot see anything at lsusb, i tried a webcam, plugged, unplugged and in again.

comment:6 Changed 5 years ago by davor.herga@…

Some update -

USB ports on Asus WL-500gP v1 do work with kernel 3.6.11
The problem appears with kernel 3.8.3

Didn't test other kernels yet.

comment:7 Changed 5 years ago by dani@…

anyone has any idea please? seems like usb on mr3420 v2.1 does not power at all..
thanks!

comment:8 Changed 5 years ago by Dmytro <dioptimizer@…>

Dani
Need to switch-high one by one all GPIOs (which are available to control) after each switch-on, check the USB port on the availability of Power - so we will define what exactly GPIO-pin is responsible for USB Power

How to enable GPIO, I showed in the example above, you can simply substitute another value instead of the number "echo 8" in export.

On the processor AR9341 - 0...23 GPIOs

comment:9 Changed 5 years ago by dani@…

thanks Dmytro, will try it today.
any chance i can damage the unit with these tests? :)

comment:10 Changed 5 years ago by dani@…

Dmytro just tried them all, nothing powered my webcam..

comment:11 Changed 5 years ago by Dmytro <dioptimizer@…>

To make sure you did everything right, please connect the device to the USB port, then turn-on all GPIOs in high value, then follow these commands and please write here the result

cat /sys/kernel/debug/gpio
cat /sys/kernel/debug/usb/devices

comment:12 Changed 5 years ago by dani@…

root@mr3420:~# cat /sys/kernel/debug/gpio
GPIOs 0-22, ath79:

gpio-0 (sysfs ) out lo
gpio-1 (sysfs ) out lo
gpio-2 (sysfs ) out lo
gpio-3 (sysfs ) out lo
gpio-4 (USB power ) out hi
gpio-5 (sysfs ) out hi
gpio-6 (sysfs ) out lo
gpio-7 (sysfs ) out lo
gpio-8 (sysfs ) out hi
gpio-9 (sysfs ) out hi
gpio-10 (sysfs ) out hi
gpio-11 (sysfs ) out hi
gpio-12 (sysfs ) out hi
gpio-13 (sysfs ) out hi
gpio-14 (sysfs ) out hi
gpio-15 (sysfs ) out hi
gpio-16 (WPS ) in hi
gpio-17 (Reset button ) in hi
gpio-18 (sysfs ) out hi
gpio-19 (sysfs ) out hi
gpio-20 (sysfs ) out hi
gpio-21 (sysfs ) out hi
gpio-22 (sysfs ) out hi

root@mr3420:~# cat /sys/kernel/debug/usb/devices

T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1
B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.08
S: Manufacturer=Linux 3.8.3 ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=ehci-platform
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms

comment:13 Changed 5 years ago by Dmytro <dioptimizer@…>

I think I understand what the problem is.
Your device use a TPS2041 switch to turn-on USB Power on negative value.

set GPIO4 (USB power) in low value

echo out > /sys/class/gpio/gpio4/direction
echo 0 > /sys/class/gpio/gpio4/value

then check USB device)

comment:14 Changed 5 years ago by dani@…

root@mr3420:~# echo out > /sys/class/gpio/gpio4/direction
-ash: can't create /sys/class/gpio/gpio4/direction: nonexistent directory

root@mr3420:~# ls /sys/class/gpio/gpio4/
active_low subsystem uevent value

comment:15 Changed 5 years ago by Dmytro <dioptimizer@…>

This should be enough:

echo 0 > /sys/class/gpio/gpio4/value

In any case, with this command, it should identify USB device:

cat /sys/kernel/debug/usb/devices

If that does not work, then use this firmware, with this it should be working USB port.
https://www.box.com/s/qebaprwq0798dyu19h1c

comment:16 Changed 5 years ago by dani@…

tried the AA firmware, it correctly lights up the leds and i can see the webcam at /sys/kernel/debug/usb/devices ...

on this functional firmware:
root@OpenWrt:/sys/kernel/debug# cat gpio
GPIOs 0-22, ath79:

gpio-4 (USB power ) in hi
gpio-12 (tp-link:green:lan4 ) out hi
gpio-13 (tp-link:green:wlan ) out lo
gpio-14 (tp-link:green:system) out lo
gpio-15 (tp-link:green:qss ) out hi
gpio-16 (RFKILL switch ) in hi
gpio-17 (Reset button ) in hi
gpio-18 (tp-link:green:wan ) out hi
gpio-19 (tp-link:green:lan1 ) out hi
gpio-20 (tp-link:green:lan2 ) out hi
gpio-21 (tp-link:green:lan3 ) out hi

on the BB trunk r36115 with usb (and leds..) not working:
root@mr3420:~# cat /sys/kernel/debug/gpio
GPIOs 0-22, ath79:

gpio-4 (USB power ) out hi
gpio-16 (WPS ) in hi
gpio-17 (Reset button ) in hi

maybe a developer can help us with the corrections? maybe in target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c ??

comment:17 Changed 5 years ago by dani@…

this modification taken from AA fixes usb power (leds still not working) :

Index: target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c
===================================================================
--- target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c (revision 36115)
+++ target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c (working copy)
@@ -175,19 +175,22 @@

{

tl_ap123_setup();


  • ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
  • tl_wr841n_v8_leds_gpio);

-

  • ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
  • ARRAY_SIZE(tl_mr3420v2_gpio_keys),
  • tl_mr3420v2_gpio_keys);

-

/* enable power for the USB port */

  • gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,

+/* gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,

GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,

  • "USB power");

+ "USB power");*/
+ gpio_request(TL_MR3420V2_GPIO_USB_POWER,"USB power");
+ gpio_direction_input(TL_MR3420V2_GPIO_USB_POWER);

ath79_register_usb();

+
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
+ tl_wr841n_v8_leds_gpio);
+
+ ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(tl_mr3420v2_gpio_keys),
+ tl_mr3420v2_gpio_keys);
+

}


MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2",

comment:18 Changed 5 years ago by Dmytro <dioptimizer@…>

This patch is not correct, because we set GPIO-pin in Input mode!
There are two types of chip Power switch - controlled by the logic 1 and logic 0 (GPIO Output hight and GPIO Output low). If we set the GPIO-pin in Input mode - what formally will be logic 0 current >40mA, unlike "out low" with a current ~10mA.
In general, I have a suspicion that GPIO4 sits on NOT disabled JTAG.

There is a conflict GPIO4 and TCK (JTAG) - Photo

This could damage the device in the long term!
JTAG port is present on the router TL-WR841N V8 - same AP123 platform.

comment:19 Changed 5 years ago by Dmytro <dioptimizer@…>

On photo track GPIO4=TCK(JTAG on TL-WR841N-V8) goes to the U25 chip workaround

comment:20 Changed 5 years ago by dani@…

the modified file ("patch") works fine for usb, it is setting it exactly like in the AA version you posted above.

comment:21 Changed 5 years ago by anonymous

guys

I am no programmer BUT we have a working bin file for version 2 with USB support here

http://www.rfactory.org/OpenWRT/index.html#WNR3500L

comment:22 Changed 5 years ago by anonymous

bin file from post above really working. But, LED still not working so fix is not full. Any info about post by Dmytro? Cat it damage router?

comment:23 Changed 5 years ago by martignlo@…

Same problem here (with a TP-Link 3420). Would it make sense to try to apply myself the (potentially dangerous) patch pasted above by dani@? Is there any plan to submit a better fix to trunk?

comment:24 Changed 5 years ago by imranbhullar

Guys is there any update on this, I have been suffering from this with my MR3420 v2.1. Is this patch ok to be applied ??

comment:25 Changed 5 years ago by martignlo@…

I applied the patch but I didn't see any benefit. It could be that I used the wrong codebase. I am currently running a prebuilt image mentioned in another thread (which I don't remember now) and the USB is powered. I attached a USB internet key and everything works. However, I don't feel comfortable running such code and I hope I'll be able to run the standard OpenWrt firmware or compile it myself.

comment:26 follow-up: Changed 5 years ago by Dmytro <dioptimizer@…>

Please check USB port on Trunk or yourself build after r37194 changes.
If also does not work full control gpio4 (in/out > hi/low) let me know.
Thank you.

comment:27 in reply to: ↑ 26 Changed 5 years ago by uduvgp@…

Replying to Dmytro <dioptimizer@…>:

Please check USB port on Trunk or yourself build after r37194 changes.
If also does not work full control gpio4 (in/out > hi/low) let me know.
Thank you.

from /etc/banner:
BARRIER BREAKER (Bleeding Edge, r37207)

tl-mr3420 v2.1
USB still don't works, it's unpowered.
((also does not work full control gpio4 (in/out > hi/low)))

echo 1 >  /sys/class/gpio/gpio4/value
cat  /sys/class/gpio/gpio4/value 
0

ls  /sys/class/gpio/gpio4/
active_low  subsystem   uevent      value

comment:28 follow-up: Changed 5 years ago by uduvgp@…

Dear Dmytro
I install firmware from here https://app.box.com/s/qebaprwq0798dyu19h1c/1/596285208
And USB works on my 3420v2.1

I found firmware on forum https://forum.openwrt.org/viewtopic.php?pid=188467#p188467
User "cindy.wijaya" also give the patch he used to firmware (AA_RC1).

If you know how to insert (apply) this patch in trunk please do.

comment:29 in reply to: ↑ 28 Changed 5 years ago by anonymous

Replying to uduvgp@…:

Dear Dmytro
I install firmware from here https://app.box.com/s/qebaprwq0798dyu19h1c/1/596285208
And USB works on my 3420v2.1

I found firmware on forum https://forum.openwrt.org/viewtopic.php?pid=188467#p188467
User "cindy.wijaya" also give the patch he used to firmware (AA_RC1).

If you know how to insert (apply) this patch in trunk please do.

Also USB indicator don't works on https://app.box.com/s/qebaprwq0798dyu19h1c/1/596285208
But when i change qss-led trigger to usbdev qss-led show usb status.

comment:30 Changed 5 years ago by Dmytro <dioptimizer@…>

I do not have the possibility to test, but their assumptions, I wrote to the developers.
http://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg18970.html

comment:31 follow-ups: Changed 5 years ago by anonymous

Hey, some problems with downloads from app.box.com, can anybody do a backup of usb-working wr3420 firmware? great tnx

comment:32 in reply to: ↑ 31 Changed 5 years ago by anonymous

Replying to anonymous:

Hey, some problems with downloads from app.box.com, can anybody do a backup of usb-working wr3420 firmware? great tnx

try this
https://docs.google.com/file/d/0B5pPnrjVicSTUDJZekVobkxQdEk/edit?usp=sharing

comment:33 in reply to: ↑ 31 Changed 5 years ago by uduvgp@…

Replying to anonymous:

Hey, some problems with downloads from app.box.com, can anybody do a backup of usb-working wr3420 firmware? great tnx

And all files (in zip):
https://docs.google.com/file/d/0B5pPnrjVicSTVDRKNGtYaC1WRWc/edit?usp=sharing

comment:34 follow-up: Changed 5 years ago by anonymous

Any news on this problem?
Please, add patch to trunk!

comment:35 in reply to: ↑ 34 Changed 5 years ago by uduvgp@…

Replying to anonymous:

Any news on this problem?
Please, add patch to trunk!

You can find patches to AA 12.09 and trunk here (in last messages):
/ticket/12748.html

I tried patch to AA and had working USB-power and LED.
https://dev.openwrt.org/attachment/ticket/12748/mr3420v2_aa.patch

Trunk patch )
https://dev.openwrt.org/attachment/ticket/12748/mr3420v2_trunk.patch

comment:36 Changed 4 years ago by oguretsagressive@…

Hi, I agree with Dmytro that switching gpio4 to input mode (as patches above do) is swapping one problem with another. Isn't there a way to make it work in output mode, like in the official firmware? I'm ready to test on MR3420 v2.2.
For now I could tell that cat /sys/class/gpio/gpio4/value gives 0's and 1's randomly for me and writing gives no result. Writing to gpio11 turns usb led on/off though, so this one works fine. Firmware version: r37811.

comment:37 Changed 4 years ago by Dmytro <dioptimizer@…>

Sorry, no have access to Linux machine

...
	}, {
	/* the 3G LED is only present on the MR3420 v2 */
	.name		= "tp-link:green:3g",
	.gpio		= TL_MR3420V2_GPIO_LED_3G,
	.active_low	= 0,
	},
};  
...
...
  static void __init tl_ap123_setup(void)
{
	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);

	/* Disable JTAG, enabling GPIOs 0-3 */
	/* Configure OBS4 line, for GPIOs 4, 11, 14-17 */
	ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
				AR934X_GPIO_FUNC_CLK_OBS4_EN);

	/* config gpio15, 14, 11, 4, 16, 17 as normal gpio function */
	ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER, AR934X_GPIO_OUT_GPIO);
	ath79_gpio_output_select(11, AR934X_GPIO_OUT_GPIO);
	ath79_gpio_output_select(14, AR934X_GPIO_OUT_GPIO);
	ath79_gpio_output_select(15, AR934X_GPIO_OUT_GPIO);
	ath79_gpio_output_select(16, AR934X_GPIO_OUT_GPIO);
	ath79_gpio_output_select(17, AR934X_GPIO_OUT_GPIO);

	ath79_register_m25p80(&tl_wr841n_v8_flash_data);
...

Or try only this:

...
	}, {
	/* the 3G LED is only present on the MR3420 v2 */
	.name		= "tp-link:green:3g",
	.gpio		= TL_MR3420V2_GPIO_LED_3G,
	.active_low	= 0,
	},
};  
...
...
  static void __init tl_ap123_setup(void)
{
	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);

	/* config GPIO4 as normal gpio function */
	ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER, AR934X_GPIO_OUT_GPIO);

	ath79_register_m25p80(&tl_wr841n_v8_flash_data);
...

comment:38 Changed 4 years ago by anonymous

It works! Built firmware with "make" first, for no effect. Then with "make clean && make" and it worked. Used 1-st patch, with "ath79_gpio_function_setup". I think this is what solves the problem (latest trunk doesn't clear 6'th bit like original firmware, which does).
Would be better to leave "active_low = 1" by the way, cause after the patch my USB LED started to behave inversely - lights up when USB slot is empty and turns off when I plug something.
Thanks a lot!

comment:39 Changed 4 years ago by Dmytro <dioptimizer@…>

You can confirm for logs that you have it working?
I would also like to optimize the code. Try to remove all rows with ath79_gpio_output_select (after that, recompile) - need to find out whether you need to configure all these GPIOs.
After that, please check the buttons and LEDs:
USB LED (11), SYS LED (14), WPS LED (15), WPS button (16), Reset button (17)

comment:40 Changed 4 years ago by Dmytro <dioptimizer@…>

check - in the sense of whether you can change the direction and value of these gpios.

comment:41 Changed 4 years ago by oguretsagressive@…

Ok, let's start with a patch with all ath79_gpio_output_select removed:

root@OpenWrt:~# cat /sys/kernel/debug/gpio
GPIOs 0-22, ath79:
 gpio-4   (USB power           ) out lo
 gpio-11  (tp-link:green:3g    ) out hi
 gpio-12  (tp-link:green:lan4  ) out hi
 gpio-13  (tp-link:green:wlan  ) out lo
 gpio-14  (tp-link:green:system) out lo
 gpio-15  (tp-link:green:qss   ) out hi
 gpio-16  (WPS                 ) in  hi
 gpio-17  (Reset button        ) in  hi
 gpio-18  (tp-link:green:wan   ) out hi
 gpio-19  (tp-link:green:lan1  ) out hi
 gpio-20  (tp-link:green:lan2  ) out hi
 gpio-21  (tp-link:green:lan3  ) out hi

root@OpenWrt:~# lsusb
Bus 001 Device 001: ID 1d6b:0002

root@OpenWrt:~# echo out > /sys/class/gpio/gpio4/direction
-ash: can't create /sys/class/gpio/gpio4/direction: nonexistent directory

root@OpenWrt:~# ls /sys/class/gpio/gpio4/direction
ls: /sys/class/gpio/gpio4/direction: No such file or directory

root@OpenWrt:~# ls /sys/class/gpio/gpio4/
active_low  subsystem/  uevent      value

root@OpenWrt:~# cat /sys/class/gpio/gpio4/value
0
root@OpenWrt:~# echo 1 > /sys/class/gpio/gpio4/value
root@OpenWrt:~# cat /sys/class/gpio/gpio4/value
0

USB is not powering up (neither automatically nor manually), but random fluctuations of 0's and 1's on gpio4 have stopped.

Also, I cannot control gpio's 11,14,15,16 and 17 manually (neither with ath79_gpio_output_select's nor without them):

root@OpenWrt:~# ls /sys/class/gpio/
export     gpio4      gpiochip0  unexport
root@OpenWrt:~# echo 11 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# ls /sys/class/gpio/gpio11/
ls: /sys/class/gpio/gpio11/: No such file or directory
root@OpenWrt:~# echo 14 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 15 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 16 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 17 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# ls /sys/class/gpio/
export     gpio4      gpiochip0  unexport

Next, I'll add ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER, AR934X_GPIO_OUT_GPIO);:

root@OpenWrt:~# cat /sys/kernel/debug/gpio
GPIOs 0-22, ath79:
 gpio-4   (USB power           ) out hi
 gpio-11  (tp-link:green:3g    ) out lo
 gpio-12  (tp-link:green:lan4  ) out hi
 gpio-13  (tp-link:green:wlan  ) out lo
 gpio-14  (tp-link:green:system) out lo
 gpio-15  (tp-link:green:qss   ) out hi
 gpio-16  (WPS                 ) in  hi
 gpio-17  (Reset button        ) in  hi
 gpio-18  (tp-link:green:wan   ) out hi
 gpio-19  (tp-link:green:lan1  ) out hi
 gpio-20  (tp-link:green:lan2  ) out hi
 gpio-21  (tp-link:green:lan3  ) out hi

root@OpenWrt:~# lsusb
Bus 001 Device 004: ID 1a40:0101
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 005: ID 058f:6362

root@OpenWrt:~# ls /sys/class/gpio
export     gpio4      gpiochip0  unexport

root@OpenWrt:~# cat /sys/class/gpio/gpio4/value
1

A little extract from dmesg:

[    4.770000] usbcore: registered new interface driver usbfs
[    4.780000] usbcore: registered new interface driver hub
[    4.790000] usbcore: registered new device driver usb
[    5.300000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    5.310000] ehci-platform: EHCI generic platform driver
[    5.310000] ehci-platform ehci-platform: EHCI Host Controller
[    5.320000] ehci-platform ehci-platform: new USB bus registered, assigned bus number 1
[    5.330000] ehci-platform ehci-platform: irq 3, io mem 0x1b000000
[    5.360000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[    5.360000] hub 1-0:1.0: USB hub found
[    5.370000] hub 1-0:1.0: 1 port detected
[    5.380000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    5.430000] usbcore: registered new interface driver usb-storage
[    5.810000] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    5.960000] hub 1-1:1.0: USB hub found
[    5.960000] hub 1-1:1.0: 4 ports detected
[    6.250000] usb 1-1.1: new high-speed USB device number 3 using ehci-platform
[    6.360000] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[    6.370000] scsi0 : usb-storage 1-1.1:1.0
[    7.370000] scsi 0:0:0:0: Direct-Access     Generic  USB SD Reader    1.00 PQ: 0 ANSI: 0

After disconnecting usb device console output looks like this:

root@OpenWrt:~# lsusb
Bus 001 Device 001: ID 1d6b:0002

root@OpenWrt:~# cat /sys/kernel/debug/gpio
GPIOs 0-22, ath79:
 gpio-4   (USB power           ) out hi
 gpio-11  (tp-link:green:3g    ) out hi
 gpio-12  (tp-link:green:lan4  ) out hi
 gpio-13  (tp-link:green:wlan  ) out hi
 gpio-14  (tp-link:green:system) out lo
 gpio-15  (tp-link:green:qss   ) out hi
 gpio-16  (WPS                 ) in  hi
 gpio-17  (Reset button        ) in  hi
 gpio-18  (tp-link:green:wan   ) out hi
 gpio-19  (tp-link:green:lan1  ) out hi
 gpio-20  (tp-link:green:lan2  ) out hi
 gpio-21  (tp-link:green:lan3  ) out hi

USB device works just fine (I can mount and read the SD card):

root@OpenWrt:~# mount /dev/sda1 /mnt/
root@OpenWrt:~# ls /mnt
etc         fstab       lib         lost+found  mnt         usr
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  640.0K    224.0K    416.0K  35% /
/dev/root                 2.3M      2.3M         0 100% /rom
tmpfs                    14.2M    404.0K     13.8M   3% /tmp
/dev/mtdblock3          640.0K    224.0K    416.0K  35% /overlay
overlayfs:/overlay      640.0K    224.0K    416.0K  35% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               111.3M      4.9M     98.1M   5% /mnt

Filesystem might look strange, it's a 128MB card used previously as extroot for the router.

Adding the rest of ath79_gpio_output_select for gpios 11,14,15,16,17 doesn't seem to change anything. All LEDs behave identically and I still cannot control these gpios manually:

root@OpenWrt:~# ls /sys/class/gpio/
export     gpio4      gpiochip0  unexport
root@OpenWrt:~# echo 11 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 14 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 15 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 16 > /sys/class/gpio/export
ash: write error: Device or resource busy
root@OpenWrt:~# echo 17 > /sys/class/gpio/export
ash: write error: Device or resource busy

So, the minimal version of the code that worked for me is:

static void __init tl_ap123_setup(void)
{
	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);

	/* Disable JTAG, enabling GPIOs 0-4 */
	/* Configure OBS4 line, for GPIOs 4, 11, 14-17 */
	ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, AR934X_GPIO_FUNC_CLK_OBS4_EN);

	/* config gpio15, 14, 11, 4, 16, 17 as normal gpio function */
	ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER, AR934X_GPIO_OUT_GPIO);
					
	ath79_register_m25p80(&tl_wr841n_v8_flash_data);

comment:42 Changed 4 years ago by Slider

So, last version is correct and can be used for every day?
When it can be add to trunk builds?

comment:43 Changed 4 years ago by anonymous

Fixed: /changeset/37878.html
Please close this ticket.

comment:44 follow-up: Changed 4 years ago by florian

  • Resolution set to fixed
  • Status changed from new to closed

comment:45 in reply to: ↑ 44 Changed 3 years ago by tischd

Unfortunately turning USB power off (echo 0 > /sys/class/gpio/gpio4/value) still does not work in Barrier Breaker (r42625), at least for TL-MR3420 v2.3. Please see details at #19195!

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.