MacJL
Posts: 7
Joined: Thu Aug 02, 2012 9:40 am

Re: FTDI USB Serial Hangs [Solved]

Thu Aug 09, 2012 12:14 pm

I've done some other tests :
The raspberry hangs easily when you do a 4 or 5 times the commande 'stty -F /dev/ttyUSB0'.
It hangs on every USB to Serial Adapter I tried : Old FTDI, newer FTDI, PL2303...

Does someone has an other ARM based computer to see if it's a Linux ARM kernel bug, or a Raspberry one?

IRQ
Posts: 35
Joined: Thu Aug 09, 2012 4:56 pm

Re: FTDI USB Serial Hangs [Solved]

Thu Aug 09, 2012 5:35 pm

Don't know if this helps but...

I have another ARM based HW using kernel 2.6.18.6 and running Debian Lenny and on that one my USB <> serial adapters using the older FT8U232AM works without issues but when plugging the same into RasPi using kernel 3.1.9 and running Debian Squeeze I get the same hang issue like everyone else as soon as I try to write to it (i.e ls > /dev/ttyUSB0).

If I can provide any info/logs just let me know since I'm also looking for a solution to be able to use them on RasPi!

secretagent
Posts: 36
Joined: Wed Mar 07, 2012 10:09 am

Re: FTDI USB Serial Hangs [Solved]

Fri Aug 10, 2012 2:57 pm

The problem is definitely with the DWC_otg driver (the driver for the Pi's USB hardware). It looks like sometimes the channel gets halted without the reason being known, so the driver doesn't know what to do with it and as a result doesn't do anything, which apparently causes the hanging.

I tried forcing it to release the channel in this case which does prevent the hanging but causes some other problems and it is only a band-aid anyway. Ideally we need to find the reason the channel gets halted in the first place. (I think it may have something to do with the split transactions but not sure at this point).

I will keep looking into it as time permits and will post here if there is more progress. I can also provide the modified kernel at some point so that we can see if it behaves the same way for others as it does for me (things may be different with different chips).

MathieuMD
Posts: 2
Joined: Fri Aug 10, 2012 9:05 pm

Re: FTDI USB Serial Hangs [Solved]

Fri Aug 10, 2012 9:28 pm

I have the same problem. On my Ubuntu 12.04 box it works perfectly, but not on the Raspberry Pi (though contrary to most of you, R-Pi crashed only once -- the first time -- but not since).

The commands (like `echo -e '\xff\x01\x01' > /dev/ttyUSB0`) are received by the relay board (the "TX" LED flash just like when it works with Ubuntu) but the relays don't changes.

The only difference I can see between the two machines is the kernel module version of ftdio_sio, which is more recent on Ubuntu (see logs below). May it be the reason?

Ubuntu
uname -a
Linux inspiron 3.2.0-27-generic-pae #43-Ubuntu SMP Fri Jul 6 15:06:05 UTC 2012 i686 i686 i386 GNU/Linux
tail -f /var/log/syslog
When connected:
Aug 10 23:06:21 inspiron kernel: [18699.631131] usb 2-1.5.2: new full-speed USB device number 30 using ehci_hcd
Aug 10 23:06:21 inspiron mtp-probe: checking bus 2, device 30: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5.2"
Aug 10 23:06:21 inspiron kernel: [18699.732132] ftdi_sio 2-1.5.2:1.0: FTDI USB Serial Device converter detected
Aug 10 23:06:21 inspiron kernel: [18699.732182] usb 2-1.5.2: Detected FT232RL
Aug 10 23:06:21 inspiron kernel: [18699.732185] usb 2-1.5.2: Number of endpoints 2
Aug 10 23:06:21 inspiron kernel: [18699.732188] usb 2-1.5.2: Endpoint 1 MaxPacketSize 64
Aug 10 23:06:21 inspiron kernel: [18699.732190] usb 2-1.5.2: Endpoint 2 MaxPacketSize 64
Aug 10 23:06:21 inspiron kernel: [18699.732193] usb 2-1.5.2: Setting MaxPacketSize 64
Aug 10 23:06:21 inspiron kernel: [18699.734715] usb 2-1.5.2: FTDI USB Serial Device converter now attached to ttyUSB0
Aug 10 23:06:21 inspiron mtp-probe: bus: 2, device: 30 was not an MTP device
Aug 10 23:06:21 inspiron gpsd.hotplug: add /dev/ttyUSB0
Aug 10 23:06:21 inspiron gpsdctl: gpsd_control(action=add, arg=/dev/ttyUSB0)
Aug 10 23:06:21 inspiron gpsdctl: reached a running gpsd
When disconnected:
Aug 10 23:06:27 inspiron kernel: [18705.573623] usb 2-1.5.2: USB disconnect, device number 30
Aug 10 23:06:27 inspiron kernel: [18705.573826] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
Aug 10 23:06:27 inspiron kernel: [18705.573842] ftdi_sio 2-1.5.2:1.0: device disconnected
Raspberry Pi
uname -a
Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l GNU/Linux
tail -f /var/log/syslog
When connected:
Aug 10 23:06:42 raspberrypi kernel: [ 2143.018581] usb 1-1.2: new full speed USB device number 13 using dwc_otg
Aug 10 23:06:42 raspberrypi kernel: [ 2143.126788] usb 1-1.2: New USB device found, idVendor=0403, idProduct=6001
Aug 10 23:06:42 raspberrypi kernel: [ 2143.126826] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 10 23:06:42 raspberrypi kernel: [ 2143.126858] usb 1-1.2: Product: FT232R USB UART
Aug 10 23:06:42 raspberrypi kernel: [ 2143.126876] usb 1-1.2: Manufacturer: FTDI
Aug 10 23:06:42 raspberrypi kernel: [ 2143.126892] usb 1-1.2: SerialNumber: AH01IAGC
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140109] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140347] usb 1-1.2: Detected FT232RL
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140372] usb 1-1.2: Number of endpoints 2
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140391] usb 1-1.2: Endpoint 1 MaxPacketSize 64
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140408] usb 1-1.2: Endpoint 2 MaxPacketSize 64
Aug 10 23:06:42 raspberrypi kernel: [ 2143.140425] usb 1-1.2: Setting MaxPacketSize 64
Aug 10 23:06:42 raspberrypi kernel: [ 2143.141676] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
When disconnected:
Aug 10 23:06:48 raspberrypi kernel: [ 2148.923346] usb 1-1.2: USB disconnect, device number 13
Aug 10 23:06:48 raspberrypi kernel: [ 2148.924172] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
Aug 10 23:06:48 raspberrypi kernel: [ 2148.924295] ftdi_sio 1-1.2:1.0: device disconnected
I use this relay: USB 4 Relay Board - RS232 Serial controlled, PCB (link)

Ste123
Posts: 19
Joined: Sat Aug 11, 2012 7:10 am

Re: FTDI USB Serial Hangs

Sat Aug 11, 2012 7:28 am

I need some help please. I have a KMTronic 2-channel USB relay which I cant get working at all.

On a stock 'wheezy' (freshy flashed from stock) I am getting no responses from 'echo -e '\xFF\x01\x01' > /dev/ttyUSB0' at all. I dont think it is power related because I have the pi and this device both plugged into a USB Hub with a 2.5A PSU.

This image seems to have ftdi_sio 1-1.3.4.2:1.0, see below.

Should I go looking for the source for ftdi_sio for the later version and compile and install it?

Which TX light are you seeing blink? On the PI or on the USB device? My KMTronic device only has a power light and lights for the relays.

The relay works fine connected to my Win7 PC.

Code: Select all

[email protected] ~ $ stty -F /dev/ttyUSB0
speed 9600 baud; line = 0;
-brkint -imaxbel

Code: Select all

Bus 001 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

Code: Select all

[  226.574559] usb 1-1.3.4.2: new full speed USB device number 7 using dwc_otg
[  226.682261] usb 1-1.3.4.2: New USB device found, idVendor=0403, idProduct=6001
[  226.682309] usb 1-1.3.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  226.682331] usb 1-1.3.4.2: Product: FT232R USB UART
[  226.682348] usb 1-1.3.4.2: Manufacturer: FTDI
[  226.682363] usb 1-1.3.4.2: SerialNumber: A100TWNX
[  226.696677] ftdi_sio 1-1.3.4.2:1.0: FTDI USB Serial Device converter detected
[  226.696905] usb 1-1.3.4.2: Detected FT232RL
[  226.696929] usb 1-1.3.4.2: Number of endpoints 2
[  226.696947] usb 1-1.3.4.2: Endpoint 1 MaxPacketSize 64
[  226.696966] usb 1-1.3.4.2: Endpoint 2 MaxPacketSize 64
[  226.696983] usb 1-1.3.4.2: Setting MaxPacketSize 64
[  226.698216] usb 1-1.3.4.2: FTDI USB Serial Device converter now attached to ttyUSB0
Thanks, I am really keen to get this working. Im new to linux, but I was a UNIX software developer in the past so have some skills - just not for interfacing to hardware!

Stephen

Ste123
Posts: 19
Joined: Sat Aug 11, 2012 7:10 am

Re: FTDI USB Serial Hangs

Sat Aug 11, 2012 7:59 pm

Update

I got the latest kernal compiled using http://elinux.org/RPi_Kernel_Compilation and updated the firmware http://hexxeh.net/?p=328117855

It now seems more stable, and I am not getting lockups - infact had none.

BUT, it is still not working. Maybe I need to update to 3.2 Linux

Code: Select all

Linux rpi1 3.1.9+ #1 PREEMPT Sat Aug 11 18:01:14 UTC 2012 armv6l GNU/Linux

Code: Select all

[   73.949109] usb 1-1.3.4.3: new full speed USB device number 8 using dwc_otg
[   74.057074] usb 1-1.3.4.3: New USB device found, idVendor=0403, idProduct=6001
[   74.057109] usb 1-1.3.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   74.057129] usb 1-1.3.4.3: Product: FT232R USB UART
[   74.057144] usb 1-1.3.4.3: Manufacturer: FTDI
[   74.057159] usb 1-1.3.4.3: SerialNumber: A100TWNX
[   74.137031] usbcore: registered new interface driver usbserial
[   74.140098] USB Serial support registered for generic
[   74.141325] usbcore: registered new interface driver usbserial_generic
[   74.141359] usbserial: USB Serial Driver core
[   74.155392] USB Serial support registered for FTDI USB Serial Device
[   74.156246] ftdi_sio 1-1.3.4.3:1.0: FTDI USB Serial Device converter detected
[   74.156498] usb 1-1.3.4.3: Detected FT232RL
[   74.156523] usb 1-1.3.4.3: Number of endpoints 2
[   74.156540] usb 1-1.3.4.3: Endpoint 1 MaxPacketSize 64
[   74.156568] usb 1-1.3.4.3: Endpoint 2 MaxPacketSize 64
[   74.156585] usb 1-1.3.4.3: Setting MaxPacketSize 64
[   74.164648] usb 1-1.3.4.3: FTDI USB Serial Device converter now attached to ttyUSB0
[   74.166941] usbcore: registered new interface driver ftdi_sio
[   74.166975] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
Any suggestions?

irp
Posts: 10
Joined: Sun Aug 12, 2012 1:30 pm

Re: FTDI USB Serial Hangs

Sun Aug 12, 2012 4:46 pm

Can't help suggestion wise, but can add my voice to the chorus I'm afraid. I have a FTDI USB<->RS485 adapter, with an FT232R in it....Usual locking up after trying to access the device. The odd echo blah >/dev/ttyUSB0 works fine, but too many operations and it hangs...


Iain

psmedley
Posts: 10
Joined: Mon Aug 13, 2012 9:08 am

Re: FTDI USB Serial Hangs

Mon Aug 13, 2012 9:11 am

Me too unfortunately. I have an FTDI Usb-Serial adapter that is working fine on an Arm based Qnap device that's running Debian Squeeze, but when I use the same device with my Raspberry Pi, the Pi locks solid within a minute or two.

I am currently running the Pi from the USB port of the Qnap, but it is rock solid stable EXCEPT when used with the USB-Serial adapter.

I will try it with a USB plug pack, as I read a poor power supply can cause stability issues, but I still suspect the USB stack is the problem.

MathieuMD
Posts: 2
Joined: Fri Aug 10, 2012 9:05 pm

Re: FTDI USB Serial Hangs

Mon Aug 13, 2012 7:50 pm

I made a progress: now my Pi is able to switch the relays' state :) ... until it crash! :(

A colleague at work suggested that maybe the default serial settings were not right, and that the output strings was not properly encoded and received by the relay board. Indeed, it seems he was right.

According to my relay-board maker doc, communication parameters are: 8-bits data, 1 stop, no parity, and 9600 baud.
stty -F /dev/ttyUSB0 sane
stty -F /dev/ttyUSB0 9600 -evenp -parity -cstopb
But it doesn't work every times, and often I have to repeatedly run these commands until it finally works... and/or crash.

Now I can say I have the same problem as most of you: the Pi crash; sometimes at the first echo sent, sometimes several echo later, but it always eventually crash when dealing with this USB-Serial driver. It even crashed once when I was simply "stty -F /dev/ttyUSB0 9600".

No kernel panic or debug message on the console, nothing to help debug.

As it works on Ubuntu with ftdi_sio version 1.5.2, maybe its worth to recompile the kernel. Anybody tried?

Ste123, the TX light which blink is the one on the 4 relays board of KMtronic. Did your newly compiled kernel work with above stty settings?

irp
Posts: 10
Joined: Sun Aug 12, 2012 1:30 pm

Re: FTDI USB Serial Hangs

Tue Aug 14, 2012 6:26 am

Ubuntu doesn't run on the Pi as far as I'm aware (at least no recent version). Do you mean Ubuntu on the PC ? or Are you running 9.04 ?

If the former, indeed, there is no problem on the PC platform, and in fact I understand there is no issue on other ARM platforms, the issue is Pi (or USB Controller at least) specific

If the latter, bare in mind, a lot of folks suspect an issue with the USB Controller Chip driver, rather than the FTDI driver itself, so if anyone tries, downgrading both chunks of code might be a good idea

secretagent
Posts: 36
Joined: Wed Mar 07, 2012 10:09 am

Re: FTDI USB Serial Hangs

Tue Aug 14, 2012 9:39 am

irp wrote:Ubuntu doesn't run on the Pi as far as I'm aware (at least no recent version). Do you mean Ubuntu on the PC ? or Are you running 9.04 ?

If the former, indeed, there is no problem on the PC platform, and in fact I understand there is no issue on other ARM platforms, the issue is Pi (or USB Controller at least) specific

If the latter, bare in mind, a lot of folks suspect an issue with the USB Controller Chip driver, rather than the FTDI driver itself, so if anyone tries, downgrading both chunks of code might be a good idea
Yes, the problem is with the USB driver of the Pi, not with the ftdi driver on ARM. See my previous post in this thread. I will file an issue on github with my findings so far. I've used the exact same adapter on different ARM Linux boards with even older FTDI drivers and it works solid.

Ste123
Posts: 19
Joined: Sat Aug 11, 2012 7:10 am

Re: FTDI USB Serial Hangs

Wed Aug 15, 2012 6:44 pm

I finally got it working late on sunday and then promptly blatted my SD card, so only today have I been able to spend some time looking at it again.

I gave up on the echo '\x....' > /dev/ttyUSB0 route as this does not work for me. Eventually I trawled the net and found a bit of C code to turn on and off my relays.

Code: Select all

/* This program is distributed under the GPL, version 2 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef __WIN32__
#define sleep(x) Sleep(x)
#endif
#include <ftdi.h>

int main(int argc, char **argv)
{
    struct ftdi_context *ftdi;
    int f,i;
    unsigned char buf[3];
    int retval = 0;

    if ((ftdi = ftdi_new()) == 0)
    {
        fprintf(stderr, "ftdi_new failed\n");
        return EXIT_FAILURE;
    }

    f = ftdi_usb_open(ftdi, 0x0403, 0x6001);

    if (f < 0 && f != -5)
    {
        fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi));
        retval = 1;
        goto done;
    }

    printf("ftdi open succeeded: %d\n",f);
/*
    printf("enabling bitbang mode\n");
    ftdi_set_bitmode(ftdi, 0xFF, BITMODE_BITBANG);

    sleep(3);
*/
    buf[0] = 0xff;
    buf[1] = 0x1;
    buf[2] = 0x1;
    printf("turning everything on\n");
    f = ftdi_write_data(ftdi, buf, 3);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }

    sleep(3);

    buf[0] = 0xFF;
    buf[0] = 0xff;
    buf[1] = 0x2;
    buf[2] = 0x1;
    printf("turning everything on\n");
    f = ftdi_write_data(ftdi, buf, 3);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }

    sleep(3);

    buf[0] = 0xFF;
    buf[1] = 0x1;
    buf[2] = 0x0;
    printf("turning everything off\n");
    f = ftdi_write_data(ftdi, buf, 3);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }


    sleep(3);

    buf[0] = 0xFF;
    buf[1] = 0x2;
    buf[2] = 0x0;
    printf("turning everything off\n");
    f = ftdi_write_data(ftdi, buf, 3);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }


    printf("\n");

    printf("disabling bitbang mode\n");
    ftdi_disable_bitbang(ftdi);

    ftdi_usb_close(ftdi);
done:
    ftdi_free(ftdi);

    return retval;
}
Compiled with

Code: Select all

gcc -o runme ./usbrnd.c -lftdi
I have a permissions issue and have to run as root, but I suspect my new user is not set up correctly.

Seems to do the job. I am soak testing with a cron job turning the relays off/on randomly. It seems rock solid but I will need to leave it overnight. I am using the 1-wire kernel. With the latest firmware.

dennyfmn
Posts: 33
Joined: Thu Aug 16, 2012 1:36 pm
Location: Minnesota/California USA

Re: FTDI USB Serial Hangs

Thu Aug 16, 2012 2:35 pm

I too am having problems with a device with an embedded FTDI USB to serial interface. I am trying to get Mr House, a home automation application, running with Insteon devices on the Raspberry Pi. Insteon is somewhat similar to X10 but much more robust. The components are readily available through Amazon/Smarthome. You use a device called a Power Line Modem (PLM) talk to the devices from your computer. I am using a model 2413U PLM that shows up like this on the latest Raspbian image from the Raspberry Pi Foundation downloads:

Code: Select all

[email protected]:~# lsusb | grep FT232
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
The driver versions are:

Code: Select all

[email protected]:~# dmesg | grep ftdi_sio
[   12.850741] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[   13.477687] usbcore: registered new interface driver ftdi_sio
[   13.485830] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
I have tested the PLM on three hosts, a Debian i386 Squeeze system, the Raspberry Pi Debian Squeeze image, and the Raspbian Wheezy image. The PLM runs for many hours without hanging on the Debian i386 Squeeze system, but hangs on both the Pi images, faster with the Raspbian image.

The Debian i386 Squeeze system is using:

Code: Select all

strings /lib/modules/2.6.32-5-686/kernel/drivers/usb/serial/ftdi_sio.ko | grep 'Serial Converters Driver'
ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver
I have been using a utility called plmtools-imeter to test the PLM on all the platforms.

http://traces.cs.umass.edu/index.php/Smart/Tools


I wrote a looping script that turns a lamp on/off every three seconds. It runs for hours on Debian i386, but hangs within minutes on Raspbian. The "insteon" wrapper for the plmsend utility sets up the command and passes args to plmsend which sends the command, then prints the responses. Insteon is a two way protocol. Here is the script and some sample output. I manually stopped it with ^C before it hung.

Code: Select all

cat toggle_appliance0.sh
#!/bin/bash

while true
do
  echo -n "`date '+%Y%m%d%H%M%S'` `date '+%s'` " ; insteon $1 appliance0 on
  if [ "$1x" != "x" ]; then
    echo
  fi
  sleep 3
  echo -n "`date '+%Y%m%d%H%M%S'` `date '+%s'` " ; insteon $1 appliance0 off
  if [ "$1x" != "x" ]; then
    echo
  fi
  sleep 3
done

./toggle_appliance0.sh
20120816091002 1345126202 02501D85D31CF5182711FF
20120816091006 1345126206 02501D85D31CF518271300
20120816091010 1345126210 02501D85D31CF5182711FF
20120816091014 1345126214 02501D85D31CF518271300
^C
The first two fields are the time in two formats, the second one is seconds since Jan 1, which makes it easy to tell how long it runs before it hangs. The third field is the response from the PLM. The last byte FF means the lamp is on, 00 means the lamp is off.

There is one way of running plmtools-imeter on the Pi that does not seem to hang. There are instructions in the README for decoupling the sending and receiving processes for the PLM. In one Putty session you run the insteon script in quiet mode, and in another Putty session you run plmcat with the verbose argument. The first session sends the commands, the second sessions displays the outputs. Here is some sample output that I manually stopped after two cycles:

Code: Select all

(first session)
./toggle_appliance0.sh -q
20120816092104 1345126864
20120816092108 1345126868
20120816092112 1345126872
20120816092116 1345126876
^C

(second session)
plmcat -v /dev/ttyUSB0
02621D85D30311FF06              (ack, on, arg FF)
02501D85D31CF5182711FF          (standard msg, on, arg FF)
02621D85D303130006              (ack, off, arg 00)
02501D85D31CF518271300          (standard msg, off, arg 00)
02621D85D30311FF06              (ack, on, arg FF)
02501D85D31CF5182711FF          (standard msg, on, arg FF)
02621D85D303130006              (ack, off, arg 00)
02501D85D31CF518271300          (standard msg, off, arg 00)
^C
I does seem like a driver issue on the Raspberry Pi platform. I'm hoping that this information may help sort out what the problem is.

I would be happy to test updated versions.

BTW, the Mr House application is written in Perl, and seems to run fine on the Pi. If I can get the Insteon stuff to be stable, the Pi would make a great platform for home automation.

Many Thanks...

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

Re: FTDI USB Serial Hangs

Mon Aug 20, 2012 3:10 am

Here's the cross link back to the other forum posting.

Please try with the new microscheduler option and new 3.2 kernel. Combined they fixed a few of my usb issues and for the slow-high speed mix issue it at least makes it possible to isolate the misbehaving devices. It's usually 2 not ALL the devices that are acting up. The new code seems to reset the offending devices upon usage but as soon as you stop using the bad device.. IE ftdi adapter on high speed hub in my case, then the usb resets go away but you are not hung anymore.

I had to move my low speed (pl2303) usb serial adapter to the main rpi port then the odd stuff went away and I can send 115200 8n1 commands for hours on end now.

http://www.raspberrypi.org/phpBB3/viewt ... 45#p154045

zakapatul
Posts: 3
Joined: Thu Aug 02, 2012 9:12 am

Re: FTDI USB Serial Hangs

Mon Aug 20, 2012 8:16 am

Very good news :)
Is there anyone having a link to a simple guide to upgrade raspbian kernel to 3.2+ ?

christation
Posts: 1
Joined: Sun Aug 19, 2012 3:08 pm

Re: FTDI USB Serial Hangs

Mon Aug 20, 2012 10:52 am

You can use rpi-update which can be found here https://github.com/Hexxeh/rpi-update

Follow installation instruction and run

Code: Select all

sudo rpi-update
This should update to 3.2.27+

After I did a reboot the kernel version is:

Code: Select all

Linux raspberrypi 3.2.27+ #24 PREEMPT Sun Aug 19 21:28:36 BST 2012 armv6l GNU/Linux
Now how do we enable the microscheduler? I added the "dwc_otg.microframe_schedule=1" to /boot/cmdline.txt which now reads:

Code: Select all

p[email protected] ~ $ cat /boot/cmdline.txt
dwc_otg.microframe_schedule=1 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Note: All the options are on a single line

The problem does not go away the rpi still hangs. I use an FT232BM.

Cheers
Christos

gonesurfing
Posts: 7
Joined: Wed Aug 22, 2012 1:13 am

Re: FTDI USB Serial Hangs

Wed Aug 22, 2012 1:20 am

I'm having similar troubles with an FTDI converter accessing an xbee module. I can't access /dev/ttyUSB0 with cat, tail, or any perl script. However, I found that not only will screen access the device, but after running it I can access it with any normal method including cat.

I need to be able to run a perl script at startup that access ttyUSB, so I am currently looking for some sort of workaround using screen. Possibly, something similar to launching screen with a non-recognized command that will take control of the port and allow normal access.

relevant dmesg output below.

Code: Select all

 5.957681] ftdi_sio 1-1.3:1.0: FTDI USB Serial Device converter detected
[    6.271705] usb 1-1.3: Detected FT232RL
[    6.357296] usb 1-1.3: Number of endpoints 2
[    6.364055] usb 1-1.3: Endpoint 1 MaxPacketSize 64
[    6.484717] usb 1-1.3: Endpoint 2 MaxPacketSize 64
[    6.567253] usb 1-1.3: Setting MaxPacketSize 64
[    6.695408] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
[    6.787454] usbcore: registered new interface driver ftdi_sio
[    6.795483] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver

ryanferg
Posts: 1
Joined: Tue Aug 21, 2012 6:15 am

Re: FTDI USB Serial Hangs

Wed Aug 22, 2012 4:21 am

gonesurfing wrote:I'm having similar troubles with an FTDI converter accessing an xbee module. I can't access /dev/ttyUSB0 with cat, tail, or any perl script. However, I found that not only will screen access the device, but after running it I can access it with any normal method including cat.

I need to be able to run a perl script at startup that access ttyUSB, so I am currently looking for some sort of workaround using screen. Possibly, something similar to launching screen with a non-recognized command that will take control of the port and allow normal access.

relevant dmesg output below.

Code: Select all

 5.957681] ftdi_sio 1-1.3:1.0: FTDI USB Serial Device converter detected
[    6.271705] usb 1-1.3: Detected FT232RL
[    6.357296] usb 1-1.3: Number of endpoints 2
[    6.364055] usb 1-1.3: Endpoint 1 MaxPacketSize 64
[    6.484717] usb 1-1.3: Endpoint 2 MaxPacketSize 64
[    6.567253] usb 1-1.3: Setting MaxPacketSize 64
[    6.695408] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
[    6.787454] usbcore: registered new interface driver ftdi_sio
[    6.795483] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
I'm using an Arduino thats sending messages over FTDI serial. In order to be able to use cat/printf/etc, I have to run

Code: Select all

stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Found that here: http://arduino.cc/playground/Interfacing/LinuxTTY

Looks like that stty is doing whatever opening screen does (also, minicom should work for initiating the serial communications). Cheers.

dennyfmn
Posts: 33
Joined: Thu Aug 16, 2012 1:36 pm
Location: Minnesota/California USA

Re: FTDI USB Serial Hangs

Wed Aug 22, 2012 1:55 pm

Updating to the kernel mentioned above and activating the microframe scheduler did not resolve my issue.

My looping test with the Smarthome Insteon PLM (Power Line Modem) with embedded Future Technology Devices International, Ltd FT232 USB-Serial (UART) hung after 662 seconds.

Code: Select all

[email protected]:~# uname -a
Linux raspbian 3.2.27+ #54 PREEMPT Wed Aug 22 13:22:32 BST 2012 armv6l GNU/Linux

Had added to /boot/cmdline.txt before rebooting
dwc_otg.microframe_schedule=1 
Thanks...

Freemann
Posts: 10
Joined: Wed Jun 27, 2012 8:20 pm

Re: FTDI USB Serial Hangs

Thu Aug 23, 2012 8:22 am

I'm experiencing the same problems.
I have 2 converters with different chipsets (Prolific PL2303 and ch340T).

The pl2303 i use for reading the Smart Meter in our home and the ch340T i use to read/monitor our PV-solar inverter.

Both converters let the Rasp hang randomly within max. 1 min.

The PL2303 has a constantly open/active/inverted/high request pin, so its constantly "listening" on the port. The CH340T connects several times a second to request the inverters state/generated power/and so on.

And as mentioned before in the topic, this works normally on a i586 (Atom proc) with the most recent Ubuntu version.

At this point i'm so done with the Rasp.
USB-keyboards won't work properly (key-hanging, not responding keys)
A lot of USB-Wiseless dongles aren't supported of let the kernel/rasp crash
USB-converters (rs232,rs485, etc) let the rasp hang,
etc....

The whole USB-stack is one big mess.

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

Re: FTDI USB Serial Hangs

Fri Aug 24, 2012 1:18 am

I know this isn't much of a full fix, but I can say that at least for the PL2303 device connected to a USR 56k modem, attaching the PL2303 via USBIP works 100% awesome and with no lag or anything.

I just posted my complete test bed in the other forum post on "USB elephant in the room". I know this won't help everyone but if you have access to another linux machine with usbip in order for that machine to HOST your usb periphs, the raspi works surprisingly well and solid with the howto found elsewhere. I had to download the linux src tree and compile the kernel modules needed for the latest rev USBIP src to compile and work. BUT once you get it working, and you can "attach" to the other machine it presents the remote usb devices to the raspi just like local devices and it WORKS.

So far only my bluetooth dongle and the DreamCheeky missile launcher wouldn't work remotely attached, but they wouldn't work remotely attached to any of my other intel ubuntu instances either. BUT webcam, mouse, trackball, keyboard, pl2303 converter all worked very well!

Give it a shot. It might work. This also may highlight yet more hardware/firmware issues now since the virtual hub inserted into the usb stack seems to solve the situation. I was amazed to say the least. Also keep in mind this "fix" however does come at the cost of high cpu usuage during large rapid usb data bursts since it's all ethernet packets and the software I bet still could be optimized.

Kramnik
Posts: 1
Joined: Fri Aug 24, 2012 1:33 pm

Re: FTDI USB Serial Hangs

Fri Aug 24, 2012 1:44 pm

Please take this issue seriously, the obvious way to connect the rasp to any peripheral (at least for me) is by means of the many cheap USB2everything converters around.
I have spend a couple of days figuring out why my rasp hangs, when accessing my PV-inverter via my USB to RS485 inverter. Due to this post, I have now ported all my software to an old PC running centos, everything is running stable now, but this was definetly not the goal with my project.

psmedley
Posts: 10
Joined: Mon Aug 13, 2012 9:08 am

Re: FTDI USB Serial Hangs

Fri Aug 24, 2012 11:53 pm

Hi guys,

Since updating to:

Linux raspberrypi 3.2.27+ #60 PREEMPT Thu Aug 23 15:33:51 BST 2012 armv6l GNU/Linux

this morning, my solar monitoring has run for about 13 minutes without a hang - previously I was lucky to last a minute...

Very early days, but will report back again later today, but looking promising!!

psmedley
Posts: 10
Joined: Mon Aug 13, 2012 9:08 am

Re: FTDI USB Serial Hangs

Sat Aug 25, 2012 12:03 am

yup, spoke too soon - I got about 15 minutes before the hang, so an improvement, but not completely fixed :(

jromang
Posts: 2
Joined: Fri Jan 06, 2012 12:01 pm

Re: FTDI USB Serial Hangs

Sat Aug 25, 2012 11:45 am

Same problem here with an FTDI adapter and the default raspbian image : my raspberry pi hangs :(

Return to “Interfacing (DSI, CSI, I2C, etc.)”