Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Hang on serial port open

Thu Jul 05, 2012 1:15 pm

Hello all. I'm following on from my post here, but I'm not sure if that thread is the right place to continue my discussion.

Initially I was having problems with a Java program hanging the Pi (the TinyOS serial forwarder program specifically). This requires a fair bit of setup on the part of anyone who wants to check. However, I have now found a much simpler and easier-to-reproduce way to get the same result:

Code: Select all

[email protected]:~$ python
>>> import serial
>>> s = serial.Serial('/dev/ttyUSB0')
### Immediately hangs here, no kernel panic shown, just stops responding and disappears from the network ###
The device plugged in is a TelosB sensor node, but there's nothing fancy. It just presents as a USB to serial adapter.

Has anyone else had similar issues with accessing serial devices? Is there any way I can provide more/better information?

User avatar
guidol
Posts: 69
Joined: Tue Jul 03, 2012 9:21 am
Location: Mudanya, Turkey

Re: Hang on serial port open

Thu Jul 05, 2012 1:26 pm

Did you check the same operation with a active hub betweeen the raspberry and the "serial port"?
If your power supply doesnt have enough current for the RPi and the serial port at the usb the RPi could
go in "hang"-mode :)

As a option try to check if USBtty0 is the only "serial port" in your /dev directory.

Could you test the serial port of your device on the raspberry successfully without python?
Like with a echo-command to /dev/USBtty0 ?

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Thu Jul 05, 2012 1:49 pm

guidol wrote:Did you check the same operation with a active hub betweeen the raspberry and the "serial port"?
If your power supply doesnt have enough current for the RPi and the serial port at the usb the RPi could
go in "hang"-mode :)
The max current draw of the node is under 30mA IFAIK, and in the mode I'm using it should be significantly less, so I doubt that is the issue. I'm using the most stable supply I've found (and I've tested a few that I have here) - 0.7A stated output, with 5.05v measured across TP1 and TP2. I've tried with no peripherals or display attached, going in via SSH, with the same result. Also tried with a 2A supply (though only giving 4.69v across the test points) with the same result.
guidol wrote:As a option try to check if USBtty0 is the only "serial port" in your /dev directory.
I have /dev/tty[0..63], /dev/ttyUSB0 (the node), and /dev/ttyAMA0 (which I believe is provided by the Pi).
guidol wrote:Could you test the serial port of your device on the raspberry successfully without python?
Like with a echo-command to /dev/USBtty0 ?
"cat /dev/ttyUSB0" also hangs in the same way.


Edit:
Just to be clear - the node is plugged in prior to powered the Pi up, and enumerates correctly during boot (at least as far as the messages displayed show me).

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Thu Jul 05, 2012 8:53 pm

I've noticed that stevewardell reports hanging with a USB<-> serial adapter as well near the (current) bottom of this thread: http://www.raspberrypi.org/phpBB3/viewtopic.php?p=90223

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Tue Jul 17, 2012 5:15 pm

I'm going to need to work on this over the next couple of days, so hopefully I'll find something (it's blocking on a project at the moment). If anyone has any additional advice/suggestions I'd be happy to hear them.

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Wed Jul 18, 2012 11:46 pm

Just a small update. I switched to the Raspbian image and the hang is still there. The only difference is I now have to use sudo to be able to open ttyUSB0.

Just for completeness on the connection - the node has the usual FTDI chip and the generic driver is loaded on the Pi.

greypower
Posts: 92
Joined: Sat Jan 07, 2012 10:00 am

Re: Hang on serial port open

Thu Jul 19, 2012 10:26 am

@kemp

I don't know if you have solved your problem, but the following may help -

See section 4. of this document for details : http://www.picaxe.com/docs/axe027.pdf

It worked for me using a cable with an embedded FTDI chip.

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Thu Jul 19, 2012 7:04 pm

Thanks for the tip. I don't think it will work in this case though as the driver already recognises the device and creates the /dev/ttyUSB0 entry. Unless a different driver should be loaded instead of the generic one, but AFAIK the generic one has been used everywhere else (x86 and so on though, this is the first ARM version of Debian I've used).

Lucleonhart
Posts: 6
Joined: Fri Jun 01, 2012 6:45 am

Re: Hang on serial port open

Mon Aug 06, 2012 2:44 pm

Are there any news to this topic?
I cannot communicate using any serial port adapter i tried. Just as mentioned above, the system stops responding and nothing happens anymore.

I tried with python, system tools and a mono program...

Help! :)

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Thu Aug 09, 2012 4:06 am

I am having this same issue with a ftdi usb to serial cable as well. Sometimes mine "hangs" but the hang I've linked back to the USB stack resetting over and over the base USB driver not being able to restart properly.

The odd part is if I use a wvdial script and it bursts the commands to a modem it works then drops with no dialtone which is correct since I'm not connected to pstn. BUT as long as the script is active the Caps Lock light blinks slowly over and over and the Microsoft usb mouse blinks every now and then. When I check back to dmseg I get.

ERROR:: dwc_otg_hcd_urb_enqueue:518: DWC OTG HCD URB Enqueue failed adding QTD. Error status -4008
INFO:: periodic_channel_avialable: Total channels: 8, Periodic: 6, Non-periodic: 2
INFO:: schedule_periodic: No host channel available for periodic transfer

Those repeat over and over. If I catch and kill in time while the keyboard is still active I can sometimes recover after stopping communications to /dev/ttyUSB0

I'm running raspbian image with the latest kernel as of 8/9/2012

It's not supposed to be this hard for simple USB-SERIAL attachment is it?

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Thu Aug 09, 2012 6:11 am

Did some more testing tonight on the ftdi/pl2303 adapter and the raspi.

Good news and bad news.

Good news - I got it working perfectly by attaching it directly to the raspi USB port.
Bad news - lime many other items, if you access it through a powered hub, it tries to reset the device over and over. I do NOT get this behavior when using the same powered usb hub on the usb front port of a Dell 1800 server running Ubuntu 12.04 - This odd usb phenomenon ONLY happens when the device is plugged into the raspi via the powered hub.

I've noticed this with a few devices already and it is very frustrating.

My test setup was plugging in and dmesg validation that it found the serial cable pl2303 device. I then validated that root and pi were added to the dialout group and chmod 777 the /dev/ttyUSB0 entry

rebooted and logged in as root.

ran

cu 9600 -l /dev/ttyUSB0

use "~." to exit...

I sent several AT commands to a standard USR 56k modem.

When setup on the hub, it gets "stuck" resetting the devices on the hub when it tries to reset a low-speed device...

Any ideas? This has to be something with the local raspi USB implementation since again a regular PC usb with ubuntu 12.04 and the same powered hub and adapter works just fine using the same pl2303 module.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Hang on serial port open

Thu Aug 09, 2012 7:57 am

In another threat on this forum People reported the following behavour:
FT232BM not working
FT8U232AM not working
FT232R working
So, it might be intersting tu run lsusb and see what ftdi usb device is emulated.
While it could be due to the known Pi usb issues, I rather think there is a problem in the arm compiled driver for the older chipsets.
I tested a prolific PL2303 as well. Connected directly to the Pi, it worked. Connected to a self powered usb hub, it enumerated fine, but I couldn't query it. It didn't make the Pi hang like the older ftdi chipsets do.
A good test would be to connect one of the older ftdi devices to another arm linux board like the beagle to find out if all arm based linux boards are having issues with it.

I recompiled the kernel with other dot config settings, and with that kernel the prolific seems to work behind an usb hub as well. I hope to post this kernel today for people who are willing to test it. It's not my work, the other config comes from rpifreeze. So all complains should come to me and all the thanks should go to him. This kernel doesn't fix the issues with the older ftdi chipsets.
So, if you have a non working ftdi device, please post how it shows up in lsusb.

dmesg | grep tty is what I use to show the name of the usb serial port
stty -F /dev/ttyUSB0 -a should show the default settings of the port

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Fri Aug 10, 2012 4:03 am

After remembering the issues with the Raspi and low speed usb devices and combinations I was able to get my pl2303 device working direct on the usb port AND on the powered usb hub (CyberPower)

In my case I am thinking it is back to the bug with the USB mixed speed setups...

In my previous tests I had an Apple USB Keyboard (slow speed), and the Microsoft IntilliEye USB mouse (slow speed) connected to the keyboard. The keyboard attached to the powered hub and the pl2303, and a 2.5" ide/usb 2.0 drive attached. In that case the pl2303 refused to work correctly.

I'm am now successfully running with the keyboard (slow) attached to the pi, and the hub attached to the pi, and the mouse (slow), usb hd (high speed), and pl2303 (high speed) hooked to the powered hub.

This follows with a previous poster in another thread that mentions that you attaching things to downstream slow hubs (ie in the keyboard) AND having other devices on the power high speed endpoints might cause issues... Since I had the mouse on the keyboard, that must have activated the extra channel???? Which caused enqueue issues?

I'll definitely give the alternate kernel a try! Thanks!

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Tue Aug 14, 2012 12:08 pm

Great detective work :) I've been away for the last couple of weeks, but I'm hoping I can apply some of what you've found to my own situation.

In my case, I've tried it with and without other devices (Logitech wireless dongle when working locally, or nothing attached when working via SSH) and the hang occurs in both cases. It looks like my device is emulating the FT232BM which you note as not working.

lsusb gives me:

Code: Select all

Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
The system logs contain:

Code: Select all

[    5.873934] usb 1-1.2: new full speed USB device number 4 using dwc_otg
[    6.004425] usb 1-1.2: New USB device found, idVendor=0403, idProduct=6001
[    6.014406] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    6.029743] usb 1-1.2: Product: MTM-CM5000MSP
[    6.040065] usb 1-1.2: Manufacturer: FTDI
[    6.049901] usb 1-1.2: SerialNumber: MFU8H5NZ
[   23.410793] usbcore: registered new interface driver usbserial
[   23.544051] USB Serial support registered for generic
[   23.551922] usbcore: registered new interface driver usbserial_generic
[   23.873868] usbserial: USB Serial Driver core
[   24.050017] USB Serial support registered for FTDI USB Serial Device
[   24.428840] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[   24.644116] usb 1-1.2: Detected FT232BM
[   24.650471] usb 1-1.2: Number of endpoints 2
[   24.739234] usb 1-1.2: Endpoint 1 MaxPacketSize 64
[   24.818942] usb 1-1.2: Endpoint 2 MaxPacketSize 64
[   24.917810] usb 1-1.2: Setting MaxPacketSize 64
[   24.984416] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
[   25.078823] usbcore: registered new interface driver ftdi_sio
[   25.156950] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Sat Aug 18, 2012 8:44 pm

More info here: http://www.raspberrypi.org/phpBB3/viewt ... =44&t=8010

Don't know how I missed that thread before, but it looks like some good investigation happened there.

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Mon Aug 20, 2012 2:55 am

If you haven't already downloaded and installed via rpi-update or manually grab the new 3.2 kernel and activate the new microscheduler code. It does fix SOME issues and might fix your hang. It doesn't fix the multiple low speed devices on hub issue, but it does highlight WHICH devices are having conflicts since at least in my case the dmesg errors list the two devices that are having fits while in use.

in /boot/cmdline/txt add dwc_otg.microframe_schedule=1

It does seem to fix the usb enqueue issue too!

In my case it was the PL2303 serial usb and the low speed Logictech mouse or IntelliEye mouse. The fix for me now is to simply move the PL2303 serial dongle to the main raspi usb port, and until I add another slow speed device, things should be quite happy.

The new kernel fixes some minor CIFS timing/protocol issues too I reported a while back as well.

Hope this helps some!

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Mon Aug 20, 2012 12:02 pm

Thanks, I'll check that out ASAP. Are there any drawbacks to the microscheduler?

Apologies if I'm going over old territory, I must have missed where the new kernel/microscheduler was discussed.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Hang on serial port open

Mon Aug 20, 2012 12:18 pm

It was announced in the Elephant Thread on Sunday 19 august. (yesterday) by Dom.
I guess we can't blame you for missing it.

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Mon Aug 20, 2012 4:04 pm

Thanks, seen it now. I'll let you guys know if it solves my problem (and, hopefully, therefore for the other older chips too).

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Mon Aug 20, 2012 5:46 pm

Unfortunately that doesn't seem to solve the problem, it still hangs opening the port. This is with latest firmware via rpi-update and with the microscheduler turned on:

Code: Select all

[email protected]:/home/kemp# uname -a
Linux raspberrypi 3.2.27+ #24 PREEMPT Sun Aug 19 21:28:36 BST 2012 armv6l GNU/Linux

[email protected]:/home/kemp# /opt/vc/bin/vcgencmd version
Aug 17 2012 23:48:54 
Copyright (c) 2012 Broadcom
version 332044 (release)

[email protected] ~ $ cat /proc/cmdline 
dma.dmachans=0x3c bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x2 bcm2708.serial=0x5b12c3e8 smsc95xx.macaddr=B8:27:EB:12:C3:E8 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait dwc_otg.microframe_schedule=1

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Tue Aug 21, 2012 4:49 am

I haven't tried the rest of these exotics yet with the new kernel but here's all of the "usb" options I could find all in one place.

dwc_otg.microframe_schedule=1, sdhci-bcm2708.missing_status=0,
sdhci-bcm2708.sync_after_dma=0 dwc_otg.speed=1

I THINK this slows the buss down to low speed? or is it highspeed only? As well as the microframe and then the dma change that may help and status update changes...

They go in /boot/cmdline.txt as usual.

I'll post shortly how the others help or not since I've noticed even last night that I still get flakey keyboard usb repeats depending on how I connect the low speed devices... I wish this was an easy one to figure out!

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: Hang on serial port open

Fri Sep 07, 2012 2:35 pm

For what its worth, I get this too on a usb to serial (pl2303). As soon as I open the port, the mouse responsiveness becomes sluggish - which agrees to the high v low speed usb conflict.

Waiting humbly for a resolution :)

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Fri Sep 07, 2012 5:25 pm

It seems to me like we have two distinct issues here:

1) Buggy drivers for the older USB-serial chips on peripherals (me, Lucleonhart, and some people on the other thread I linked)
2) The low speed/high speed conflict (ppuskari and dauhee)

The latter is being solved (has been solved?) on the elephant thread, while the former doesn't seem to be going anywhere currently.

ppuskari
Posts: 38
Joined: Sat Jul 07, 2012 4:04 am

Re: Hang on serial port open

Sat Sep 08, 2012 4:03 am

Okay, I finally have working pl2303, ibm usb keyboard (low power passive 2 port hub), ethernet (onboard), cheap webcam, mVox usb mic/speaker, Prolific chipset usb hd case with 2.5" ide drive, and logitech trackball with a 4 port powered hub, all working great!!!!

If it helps anyone I'm using the latest rpi-update kernel #114 3.2.27+

dwc_otg.microframe_schedule=1 sdhci-bcm2708.enable_llm=1 sdhci-bcm2708.sync_after_dma=0 dwc_otg.fiq_fix_enable=1

I mentioned earlier the one for speed setting and it was the one that made my pi basically crippled...

my lsusb -t output is like this.

Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
Port 1: Dev 2, If 0, Class=hub, Driver=hub/3p, 480M
Port 1: Dev 3, If 0, Class=vend., Driver=sms95xx, 480M
Port 2: Dev 4, If 0, Class=vend., Driver=pl2303, 12M
Port 3: Dev 5, If 0, Class=hub, Driver=hub/4p, 480M
Port1: Dev 6, If 0, Class=stor., Driver=usb-storage, 480M
Port2: Dev 7, If 0, Class=audio, Driver=snd-usb-audio, 12M
Port2: Dev 7, If 1, Class=audio, Driver=snd-usb-audio, 12M
Port2: Dev 7, If 2, Class=audio, Driver=snd-usb-audio, 12M
Port3: Dev 8, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
Port3: Dev 8, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
Port4: Dev 9, If 0, Class=hub, Driver=hub/3p, 12M
Port 1: Dev 10, If 0, Class=HID, Driver=usbhid, 12M
Port 1: Dev 10, If 1, Class=HID, Driver=usbhid, 12M
Port 3: Dev 11, If 0, class=HID, Drier=usbhid, 1.5M

That gives:

Pi:
Local Pi 3p hub
Ethernet
PL2303
4 Port Powered High speed hub
USB HD
mVox speaker/mic (has 3 sub ids)
webcam (has 2 sub ids)
IBM enhanced multimedia keyboard with 2 p hub
keyboard
multimedia keys part
Logitech trackball

Make what you will of the high/low speed device issue, but this combination works great now especially with the llm enable and fiq options above. the pl2303 will still spit out >40k interrupts/sec but that is a known issue.

The main pi has a high speed and full speed mix, but the powered hub has the full, high, and the one low speed device on it.

Hope this might help someone figure their usb chain out using one of these adapters.

Kemp
Posts: 29
Joined: Tue Jul 03, 2012 12:56 pm

Re: Hang on serial port open

Fri Sep 21, 2012 9:49 pm

It works perfectly for me now with the latest updates and the dwc_otg.speed=1 option (with the BM variant). I didn't look into this option before as I only saw it mentioned in relation to devices of different speeds conflicting and this device is the only one I have plugged in.

Perhaps we are saved?

Return to “Troubleshooting”