OpenWrt Forum Archive

Topic: Tp-link Tl-wr703n GPIO via tx/rx

The content of this topic has been archived on 24 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Serial is onboard, seems like quite tiny pins but it is there...
(seen from pictues available)

Is it possible to unbind those pins from serial console and use them as GPIO pins?

My idea is to use 703n as an 1-wire host and I don't want to use usb/1-wire dongle.

janisalnis wrote:

First, check that GPIO was supported:

Next step is to export control files of each pin.
found C code for WR703N:
#define TL_WR703N_GPIO_LED_SYSTEM       27
#define TL_WR703N_GPIO_BTN_RESET        11
#define TL_WR703N_GPIO_USB_POWER        8

Above are listed "used" GPIO pins.
But as prosessor IS eqiped with number of GPIO's (32 pcs?)
And also (most probably?) tx/rx lines are one of those.

My goal is to indentify rx line GPIO number.

I hope that that GPIO number colud be indentifyed by using gpioclt to control lines - and detect change in voltage level in rx-pin.
Unfortunately soldering pads in 703n are so small that I need better equipment to acces those pins...

Also it is not clear if rx-pin of serial connection can be used without re-compiling kernel.
As been such n00b what source coed should I check if I want to see how rx is handled vie kernel ?
(I trust that tx is "own" by kernel as it's main purpose is to print info to console)

janisalnis wrote:

Next tried to adopt 1-wire bus code for  GPIO pin that works well on routers WRT160NL: … AZQS5K.txt

It did not work out on rx pin nr 9. W1 bus appeared at /sys/devices  but sensors did not appear. 
nano /etc/modules.d/55-w1-gpio-custom
w1-gpio-custom bus0=0,9,0
It did not work on reset button ether. W1 bus did not appear at all.

I gave up. Waste of time. Will use Arduino for 1 wire temprature sensors and switches. Then do not need to open the box and solder any whires at all.

Did you have pull-up reistor ?
I think 4,7kOhm is good for it...

Did you also check GPIO for tx pin?

janisalnis wrote:

Probably it is because pins are used by serial port. I do not know how to disable serial port function.

Is it possible to remove console from kernel by removing "console=ttyATH0,115200" from Makefile? (target/linux/ar71xx/image/Makefile)

Example define as LED:

add C code for WR703N as example this or this in mach-tl-wr703n.c:

#define TL_WR703N_GPIO_LED_SYSTEM       27
#define TL_WR703N_GPIO_LED_TX       9
#define TL_WR703N_GPIO_LED_RX     10

also add to static struct gpio_led Function:

static struct gpio_led tl_wr703n_leds_gpio[] __initdata = {    
                    .name           = "tp-link:blue:system",    
                    .gpio           = TL_WR703N_GPIO_LED_SYSTEM,    
                    .active_low     = 1,    
                    .name           = "tp-link:blue:tx",    
                    .gpio           = TL_WR703N_GPIO_LED_TX,    
                    .active_low     = 1,    
                    .name           = "tp-link:blue:rx",    
                    .gpio           = TL_WR703N_GPIO_LED_RX,    
                    .active_low     = 1,    

Then after build:
When you use rmmod leds_gpio, you also unlock this gpios used as tx and rx.

(Last edited by Dioptimizer on 24 Feb 2012, 21:48)

janisalnis wrote:

Probably it is because pins are used by serial port. I do not know how to disable serial port function.


#ttyS0::askfirst:/bin/ash --login


option 'conloglevel' '3'
option 'kconloglevel' '3'

If you want to free the serial port completely, you must modify the kernel command line and recompile the firmware. I think it's also possible to disable the serial output of U-Boot by changing several variables.


What happens if I edit /linux/ar71xx/config-3.2

193 CONFIG_SERIAL_AR933X=y -> n

I tested following:
make kernel_menuconfig -> disable onboard serial (ttyATH0)
ttyATH0 diapears from /dev but 1w is sitll not working (I tested rx-pin TP_in)

On my test I took +5V from USB connector (and connected USB gnd and TP_gnd together)
And I had aprox 5 kOhm pullup to +5V

Any ideas ? (I must still check how voltages are on 1w bus)

EDIT: How I can check if serials is still some how live (and controlling my GPIO-pin(s))?

(Last edited by metsberg on 5 Mar 2012, 11:37)

I checked with an scope and it shows that pin remains pulled up.
Is it possible that not all of the GPIO-lines support "open collector"-mode?

Have anyone had any succes with tp-link wr703n's GPIO traffic?
(especially with 1-wire devices)

I managed to get 1w bus up and running in wr703n using system led's gpio pin.
I even left led untouched so it is possible to monitor 1w traffic.

I had 5 kOhm pull-up to USB +5V in 1w bus.
Atleast one 1w temperature sensor is working for now - I need to complete HW by adding a connector and do some more testing.

Is there any knolidge how other 1w devices can be accessed through 1w-master-gpio?
I want to measure high temperatures via li-ion battery monitor chip and I have not seen any drivers for those...

greatest for your job!! I have a question:
can I use the USB port as GPIO ?

I'm intersting to use the 5+ and GND to power on/off a led.

Can you help me?

WillyLord wrote:

I'm intersting to use the 5+ and GND to power on/off a led.

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

echo 1 > /sys/class/gpio/gpio8/value

This should power off and on the usb port. Maybe this is what you want.

OK! Later I'll try this trigger. Thanks

You need to remove them unless you want the gpio pulled to ground.

janisalnis wrote:

there is no transistor that can control USB 5V power line. So I doubt that for WR703N it is possible with GPIO8 to control USB power .

U6 is an USB power switch, see …

So GPIO8 can actually control the "3G" USB power supply.

Unfortunately, it is turned on forever by default in the current Linux firmware just before launching the USB driver sad

The only way to get it back is by recompiling the kernel yourself, then you should be able to control it as you wish.

The discussion might have continued from here.