OpenWrt Forum Archive

Topic: Using a pl2303 usb-serial adapter with WR703N for serial console log

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

I have simple application for a WR703N as a linux I can ssh into, run minicom and connect to a serial port from another server to monitor it.

1) I'm planning on using it in a far away server room. If I use minicom to write logs to /tmp,  am I likely to corrupt flash and break the device after a few months?

2) serial port hangs:
I used openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin and a simple PL2303 based serial adapter:

usbserial              23792  1 pl2303
usbcore                99104  6 pl2303,usbserial,ohci_hcd,ledtrig_usbdev,ehci_hcd

root@OpenWrt:~# uname -r
3.3.8
[   10.000000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[   10.120000] usb 1-1: new full-speed USB device number 2 using ehci-platform
[   10.180000] usbcore: registered new interface driver usbserial
[   10.180000] USB Serial support registered for generic
[   10.280000] usbcore: registered new interface driver usbserial_generic
[   10.290000] usbserial: USB Serial Driver core
[   10.320000] USB Serial support registered for pl2303
[   10.320000] pl2303 1-1:1.0: pl2303 converter detected
[   10.340000] usb 1-1: pl2303 converter now attached to ttyUSB0
[   10.340000] usbcore: registered new interface driver pl2303
[   10.350000] pl2303: Prolific PL2303 USB to serial adaptor driver


It works fine with minicom or screen talking to /dev/ttyUSB0, unfortunately the serial connection hangs if I stay connected more than a few minutes.

Two ways to fix it are:
1) reboot the router (no power cycle, just reboot over ssh ok)
2) unplug the serial adapter, plug it back in, connect on ttyUSB1 and the connection resumes.

If I don't leave minicom running, and quit it. I can reconnect later just fine. It seems that it's just leaving the serial port open that causes the usb driver to flake and hang.
I've done this before on other machines, including other routers and have not experienced problems.

Any idea if there is a hardware issue with the WR703N that is causing this? Or is it just a bad kernel/build?

Thanks,
Marc

1) /tmp is ram, not flash, so if you lose power, you lose your logs.  You might want a small usb hub so you can attach both your serial drive and a flash drive.  But if you do log to flash, I don't see that you would destroy the device in the short run.  Even if you are offloading daily and erasing, I would think you would have years of writing before the device would become unuseable.

2) Don't know.  I've connected for weeks with a CP2102 serial dongle (ttl).  I assume your PL2303 has a DB9 connector, so is RS232 logic levels.  I've had these successfully connected for long periods of times to other openWrt devices, but not to a WR703N, so haven't seen this issue.

(Last edited by lizby on 29 Nov 2012, 21:05)

Thanks for the reply.

1) sorry, I forgot I can't log to /tmp, I can't fill tmpfs with kernel boot logs and crash the router, I'll have to log to flash. I'm just hopefuly that the flash will be good enough to support normal logging (yes, I know about reasonable flash wear, just making sure that one doesn't have worse flash than an average device)

2) I found the problem in another thread. There is a problem with USB support on that device for slower speed devices
https://forum.openwrt.org/viewtopic.php … 56&p=4 post 84 gives the details.
apparently using the right kind of passive hub is a workaround for that issue which seems to be due to the high speed USB chip that is used in the device.

Thanks for your answer, Marc

Hi Marc,

I investigated in the other thread on the AR9331 USB problem: there is definitively an issue with Low-Speed and Full-Speed devices, that may cause the USB connection to crash after a few minutes to one hour.

I confirm that the only known workaround is to insert a hub in-between.

As for logging to flash, the TL-WR703N Flash capacity is rather limited (4MB total), so I suggest you to use a small 2x USB HS hub + microSD combo like this (the microSD connector is located inside the USB connector on the right):
http://www.pearl.de/images/large/px5294_2_2.jpg

Available from here (in French) or here (in German).

But even on microSD, you have to use the right  FS (NOT vfat, use ext4 if possible, it is at least a 2x performance boost over plain ext2) and tune it to avoid unnecessary Flash wear by using "lazy" write options. Among these, here are some hints:

  1. noatime to avoid writing last access time back to disk (!!!)

  2. commit to set the commit period, default is 5s, you can probably increase it to 120s if you can afford to lose this amount of log in case of a crash

  3. data=writeback to specify the journaling method to use

Just using the first two tricks will reduce the Flash wear by a 60 factor, so your disk will have a life expectancy increased from 6 months to 30 years under constant write...

Thanks squonk, since I'm putting a hub anyway, adding a hub+microsd is not a bad idea, thanks for the tip.

Make sure to use a usb serial adapter with a FTDI chipset. This usb serial support info might help you select the right adapter before you buy next time

Magneto wrote:

Make sure to use a usb serial adapter with a FTDI chipset. This usb serial support info might help you select the right adapter before you buy next time

No!

Actually, the TL-WR703N I/O level is 2.5V +/-10%, and PL2303 handles better these low voltages compared to FTDI chips, which would require a pull-up resistor on TX to 3.3V.

(Last edited by Squonk on 27 Jan 2013, 23:15)

I have successfully used usb/serial dongles with PL2303 and CP2102 chips with the WR703N.

I see two threads here that conflict.

One is about USB serial ports and the other is about the internal serial port on the WR703N.

@lizby, are the USB dongles connected directly to the WE703N or thru an hub ?

@squonk, does the internal serial port work with a telnet session ?

Regarding USB serial ports, all TTL UART to USB converters I know of are either Low-Speed or (most of them) Full-Speed, none are High-Speed because 480 Mbps is not required for a serial link anyway. So you almost certainly fall onto the AR9331 non High-Speed problem, unless you connect it to a High-Speed hub in between and not directly to the TL-WR703N USB connector.

Then, regarding the internal serial port, using a PL2303 or CP2102 cheap adapter like a Nokia CA42 cable clone is better than using an FTDI based solution because of the voltage level problem I mentioned.

And no, you can't get a telnet session over serial, but you have access to a serial U-Boot/Linux console using either a serial terminal emulator or "screen" on the PC side.

The discussion might have continued from here.