Problem with Serial Gadget driver
We have an embedded device with an ARM9 processor running Linux 2.6.13 kernel. This device communicates with a PC via a USB connection. (PC is USB host, and ARM9 is USB device). We use the Serial Gadget driver (g_serial.ko) which makes it possible to communicate over usb via /dev/ttygserial.
I have a process that every second tries to open /dev/ttygserial. Until the device has been connected to a PC, open(/dev/ttygserial,…) returns with the error “device is not connected”. When the device is connected to a PC, and even if it is disconnected again, open(/dev/ttygserial,..) returns successfully.
I have another process continuously reading data over ttyS3.
My problem is that every time the first process fails to open /dev/ttygserial, data read over ttyS3 is damaged. So every second the data from ttyS3 is damaged, and there is CRC errors.
It seems like open(/dev/ttygserial,…) returns failure until some initialization has been done. Maybe the initialisation done by gs_setup(..) (located in drivers/usb/gadget/serial.c). gs_setup(..) is is not invoked until the USB cable is connected.
I hope somebody can help me out. I’ve worked on this problem for almost two weeks now.