Re: [linux-usb-devel] USB Gadget Serial Blocking Read Problem

2007-07-17 Thread David Brownell
On Friday 13 July 2007, Sagusti.Robert wrote:
 Hi,
 
 I'm running kernel 2.6.20 on an AT91RM9200 processor. I have
 the gadget serial driver loaded and I am successfully reading
 and writing data in and out the USB port to a windows terminal.
 In my user code, when I open the gadget driver port, I open it
 with the default blocking flag so that my user thread will
 sleep while waiting for data to come in. My problem is that
 when I pull the USB cable which causes a disconnect, the read()
 call never returns in my user code thereby locking the thread
 that it is called in.

Looks like gs_free_ports() only updates the write side,
not the read side ...


 I have turned on debugs in the driver's module and am I am
 monitoring the Gadget Driver in another thread by cat /proc/kmsg
 and can clearly see that the Gadget Driver function
 gs_disconnect(struct usb_gadget *gadget) is being called. The
 driver reacts fine to the connects and disconnects but the user
 mode read() function is the problem. I'm pretty new to driver
 development and I've been attempting to trace the problem
 through the tty driver and the line discipline to attempt
 to understand how things work. After 3 days, I'm gaining some
 understanding but I really could use some help. 
 
 I would think that lots of apps would have to handle the USB
 cord being yanked out. Does anyone have any insight into this?  

Just that this is clearly a bug in the serial gadget code.

The way gadget drivers are supposed to handle disconnect
events is to (cleanly) shut down all pending I/O ... and
it's not doing that except for write operations.

- Dave

 
 Thanks for reading.
 
 
 
 
 Robert P. Sagusti
 ENSCO Inc., APA Division
 5400 Port Royal Rd.
 Springfield, VA  22151
 (703) 321-4407
 [EMAIL PROTECTED]
 




-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget Serial - PXA-270 to WinXP

2006-09-27 Thread David Brownell
On Wednesday 27 September 2006 3:06 am, Thomi Aurel RUAG A wrote:
 Hi
 Im working on a Intel XScale PXA-270 Board with linux 2.6.17
 (linux-2.6.17-pcm027-3).

I hope you know that the pxa27x UDC code is still not working
very reliably.  Oddly enough, the hardware folk Intel tasked with
designing USB support on those PXA chips never seemed to understand
that configuration management is a job for software ... and that
they should just focus on fixing enough bugs to deliver robust
data transfer.  PXA 21x/25x/26x was bad enough; PXA 27x got worse.

 
 gs_set_config: cannot find endpoints
 udc: config change 09 fail -19?
 
 What does this message mean? Did i an error during configuration? Have i
 forgotten to configure endpoints (would this be necessary)? 

Configuring PXA 27x UDC hardware is a particular nightmare.  Yes,
there's all kind of special magic that _someone_ needs to do to work
around that truly awful hardware.  And from what I hear, nobody has
quite managed to figure out all the relevant magic...

- Dave


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-04 Thread Al Borchers
Joshua Wise wrote:
  We certainly should have a serial gadget.
 In progress. Progress is in the handhelds.org CVS repository, as 'char.c'.

I have also started writing a USB gadget serial device.
It has the usual tty driver interface so it will look
like a normal serial port to user space.  Looks like char.c
will only have a kernel interface--is that right???

This one supports multiple ports, like a multiport usb serial
device.  I will probably write a host side serial driver to
support the multiple ports--unless there is a good multiport
USB serial device to emulate.  Any suggestions on this?

Right now I am using Greg's generic usb serial driver,
but it is one port only.

I also plan to do software and maybe hardware flow control
and other serial features.  

-- Al


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Joshua Wise
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 I just use ssh over g_ether (2.4.19-rmk7-pxa2), it's less work for
 me to set up -- but then, I don't need to talk to Windows or such.

Right, but unfortunately this is with a very minimalistic kernel. (This is
actually part of the Linux As Bootloader project.) The kernel is compiled
without networking support, and has no actual userland. (All code is
contained in the kernel.) Is there a tutorial out there or a list of what I
need to do to get a really teeny driver up and going? g_zero seems to be
rather large for what it does...

 - Dave
~joshua

- --
Joshua Wise | www.joshuawise.com
GPG Key | 0xEA80E0B3
Quote   | lilo I akilled [EMAIL PROTECTED] by mistake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/U/NTPn9tWOqA4LMRAjmqAJwN5PW7WWr9+n88VED6F30GugpJ1gCeJOhB
dNpjOU4LuuXeuut5GnKinhM=
=aHlR
-END PGP SIGNATURE-



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread David Brownell
Joshua Wise wrote:

Is there a tutorial out there or a list of what I
need to do to get a really teeny driver up and going? g_zero seems to be
rather large for what it does...
No tutorial, at least not now -- beyond the overview in the
2.6 kerneldoc (Documentation/DocBook/gadget.pdf).  You'll
need to understand chunks of the USB spec too.  Provide the
usb_gadget_driver methods, and work up from there.
Actually I think g_zero is quite small for a driver that handles
several different kinds of hardware, supports two different
configurations, and passes the usb-if tests at both high and
full speeds ... more than you may be thinking!  :)
Try trimming things out of zero.c ... easier to prune out
things you don't need (like second config) than to come up
with a really minimal driver (like the one below) and then
morph it back into something that's useful and portable.
- Dave

#include linux/config.h
#include linux/module.h
#include linux/kernel.h
#include linux/delay.h
#include linux/ioport.h
#include linux/sched.h
#include linux/slab.h
#include linux/smp_lock.h
#include linux/errno.h
#include linux/init.h
#include linux/timer.h
#include linux/list.h
#include linux/interrupt.h
#include linux/uts.h
#include linux/version.h
#include linux/device.h
#include linux/moduleparam.h
#include asm/byteorder.h
#include asm/io.h
#include asm/irq.h
#include asm/system.h
#include asm/unaligned.h
#include linux/usb_ch9.h
#include linux/usb_gadget.h
/* This driver is OVERSIMPLIFIED and completely unrealistic,
 * because it doesn't support:
 *
 * - anything except enumeration to a nop configuration
 * - hardware other than the pxa2xx udc
 * - error checking/handling; fault logging; diagnostics; ...
 * - endpoints other then ep0
 * - string descriptors
 * - non-spotty usb-if conformance
 * - ... any useful functionality
 *
 * DO NOT BASE REAL DRIVERS ON THIS CODE.
 */
#define USB_BUFSIZ	256

struct simple_dev {
struct usb_request  *req;
};
/* these descriptors embed pxa-specific knowledge */
static const struct usb_device_descriptor
device_desc = {
.bLength =  sizeof device_desc,
.bDescriptorType =  USB_DT_DEVICE,
.bcdUSB =   __constant_cpu_to_le16 (0x0200),
.bDeviceClass = USB_CLASS_VENDOR_SPEC,
.bMaxPacketSize0 =  16,
.bNumConfigurations =   1,
};
static const struct usb_config_descriptor
the_config = {
.bLength =  sizeof the_config,
.bDescriptorType =  USB_DT_CONFIG,
.bNumInterfaces =   1,
.bConfigurationValue =  1,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
.bMaxPower =(100 + 1) / 2,
};
static const struct usb_interface_descriptor
the_intf = {
.bLength =  sizeof the_intf,
.bDescriptorType =  USB_DT_INTERFACE,
.bNumEndpoints =2,
.bInterfaceClass =  USB_CLASS_VENDOR_SPEC,
};
static int
config_buf (enum usb_device_speed speed,
u8 *buf, u8 type, unsigned index)
{
const unsigned  config_len = USB_DT_CONFIG_SIZE
+ USB_DT_INTERFACE_SIZE;
/* config */
memcpy (buf, the_config, USB_DT_CONFIG_SIZE);
buf [1] = type;
((struct usb_config_descriptor *) buf)-wTotalLength
= __constant_cpu_to_le16 (config_len);
buf += USB_DT_CONFIG_SIZE;
/* one interface */
memcpy (buf, the_intf, USB_DT_INTERFACE_SIZE);
buf += USB_DT_INTERFACE_SIZE;
	/* no endpoints */

return config_len;
}
static void simple_setup_complete (struct usb_ep *ep, struct usb_request *req)
{
}
static int
simple_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
{
struct simple_dev   *dev = get_gadget_data (gadget);
struct usb_request  *req = dev-req;
int value = -EOPNOTSUPP;
	/* this takes shortcuts and embeds pxa-specific knowledge */

	switch (ctrl-bRequest) {

case USB_REQ_GET_DESCRIPTOR:
switch (ctrl-wValue  8) {
case USB_DT_DEVICE:
value = min (ctrl-wLength, (u16) sizeof device_desc);
memcpy (req-buf, device_desc, value);
break;
case USB_DT_CONFIG:
value = config_buf (gadget-speed, req-buf,
ctrl-wValue  8,
ctrl-wValue  0xff);
if (value = 0)
value = min (ctrl-wLength, (u16) value);
break;
}
break;
/* our set_{config,interface} is a NOP;
 * pxa hw handles get_config and get_interface
 */
case USB_REQ_SET_CONFIGURATION:
case USB_REQ_SET_INTERFACE:
value = 0;
break;
}

RE: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Borchers, Al (C)(STP)
Greg mentioned a USB gadget serial device a few days ago
and it piqued my interest.

I am finishing a gadget and host driver that provides Unix style
pipes between a host and device over USB 2.0/1.1.  Not sure if
the company I am contracting with will be willing to release
it GPL or not (my guess is not).  However, I could take the
experience and write a gadget driver that looks like a known
serial device, or write both host and gadget side drivers.

What serial device did you want to emulate?  Do you have a spec
for the protocol?  Or were you thinking of both a host and gadget
driver?

One question--why not use CDCEther and g_ether?  They are already
written and give you all the features of TCP/IP--better than just
a serial port.

-- Al

 From: David Brownell [mailto:[EMAIL PROTECTED]
 Joshua Wise wrote:
 
 I'm working on porting Linux to the iPAQ h1910, and I need a way to get data 
 to the h1910, as it has no serial. I've been eyeing USB Gadget and wondering 
 if it provides anything like the usb-char that pxa2xx and sa11x0 drivers used 
 to provide (basically, something that can be accessed like a serial port on 
 both sides.)

 It'll be cool to see that working!

 Nothing like usb-char yet.  The idea's come up, but not yet a driver.

 I just use ssh over g_ether (2.4.19-rmk7-pxa2), it's less work for
 me to set up -- but then, I don't need to talk to Windows or such.



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Joshua Wise
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 02 September 2003 2:01 pm, Borchers, Al (C)(STP) wrote:
 I am finishing a gadget and host driver that provides Unix style
 pipes between a host and device over USB 2.0/1.1.  Not sure if
 the company I am contracting with will be willing to release
 it GPL or not (my guess is not).  However, I could take the
 experience and write a gadget driver that looks like a known
 serial device, or write both host and gadget side drivers.

Hrrm, you may be sorta hung there by NDAs and things like that (Thou Shalt Not 
Reimplement This Elsewhere). It may be more helpful to write a little 
document on your experiences...

 What serial device did you want to emulate?  Do you have a spec
 for the protocol?  Or were you thinking of both a host and gadget
 driver?
I'm thinking of having it emulate a serial port. This is for Linux As 
Bootloader, the next-generation iPAQ bootloader, and some new iPAQs do not 
have a serial port, so we need USB support.

 One question--why not use CDCEther and g_ether?  They are already
 written and give you all the features of TCP/IP--better than just
 a serial port.
Networking is not compiled into LAB. Too big.

 -- Al

Thanks,
~jwise

- -- 
Joshua Wise | www.joshuawise.com
GPG Key | 0xEA80E0B3
Quote   | lilo I akilled [EMAIL PROTECTED] by mistake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/VOnCPn9tWOqA4LMRApe8AJ43hOYUx1Yl0Kr3IZp+5OkMVYtT3gCeN1tg
ayvMwCBXw1qVnSFHEc6zo7s=
=N+G6
-END PGP SIGNATURE-



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


RE: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Borchers, Al (C)(STP)
From: Joshua Wise [mailto:[EMAIL PROTECTED]
 It may be more helpful to write a little 
 document on your experiences...

I started with zero.c and built up from there.  That is a great
starting place.  The code there is needed to handle the basic
enumeration duties a USB device is expected to do--you could
trim this down some, but you need enough for the host to enumerate
the device.

zero.c also shows an example of minimal data transfers on a bulk
endpoint.  That sounds like about what you need.

 I'm thinking of having it emulate a serial port.

To the kernel it will look like a serial port, and to the USB
host machine it will look like a serial device, but what serial
device should it look like--Keyspan, Belkin, ...?  You just have
to pick one to emulate--the choice depends on having a host side
driver and knowledge of the protocol.

 Networking is not compiled into LAB. Too big.

Right.  For your application g_ether is not appropriate, and for
your minimal needs emulating a serial device sounds appropriate.
Maybe that is where a gadget serial driver would come in handy,
or maybe with existing applications that would run on the device
side and expect a serial port, rather than networking.

-- Al


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread David Brownell
Joshua Wise wrote:
I'm thinking of having it emulate a serial port. This is for Linux As 
Bootloader, the next-generation iPAQ bootloader, and some new iPAQs do not 
have a serial port, so we need USB support.
What's the serial port used for ... command interpreter?
Or downloading files?

One question--why not use CDCEther and g_ether?  They are already
written and give you all the features of TCP/IP--better than just
a serial port.
Networking is not compiled into LAB. Too big.
But network boot protocols (UDP, DHCP, TFTP) were designed
to fit into much smaller ROMs than you're working with ... :)
BLOB has a mini-stack; and I've certainly seen it done with
standard kernel networking code.
And of course, PXA has enough endpoints that it's possible
to eventuall support BOTH models at the same time!
- Dave



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Joshua Wise
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 02 September 2003 6:06 pm, David Brownell wrote:
 What's the serial port used for ... command interpreter?
 Or downloading files?

Both. bootldr serial code which is ported to LAB has a generic 
readchar/writechar interface which is overridden by various other things. So 
yes, command interpreter, and ymodem to download files.

 But network boot protocols (UDP, DHCP, TFTP) were designed
 to fit into much smaller ROMs than you're working with ... :)
The kernel is already 430k; we need to get it sub-256k.

 BLOB has a mini-stack; and I've certainly seen it done with
 standard kernel networking code.
That, and ethernet over USB is just too much of a pain. Many of our users 
can't seem to handle it.

 And of course, PXA has enough endpoints that it's possible
 to eventuall support BOTH models at the same time!
However we need SA1100 compatibility also.

 - Dave
~jwise

- -- 
Joshua Wise | www.joshuawise.com
GPG Key | 0xEA80E0B3
Quote   | lilo I akilled [EMAIL PROTECTED] by mistake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/VRdePn9tWOqA4LMRAipNAJ4+0oejgLzMQPzRFvZdXPhGDtM+KwCeJ8Xk
kDB1wDMlY/k/fWndI2X5fpI=
=54cg
-END PGP SIGNATURE-



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Joshua Wise
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 The kernel is already 430k; we need to get it sub-256k.
Correction: 530k w/ ethernet gadget, networking, and TCP/IP. 380k w/g_zero. 
Also, luckily, the iPAQ h1900 has 512k of boot flash, but all other iPAQs 
have a boot sector of 256k.

 ~jwise
++~jwise;
- -- 
Joshua Wise | www.joshuawise.com
GPG Key | 0xEA80E0B3
Quote   | lilo I akilled [EMAIL PROTECTED] by mistake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/VR0RPn9tWOqA4LMRAmi2AJ9euNdVEHeSrMDdsZvlhMC0vDHPTQCffQUx
QCsI3d1xuTtgxBWCMPc79ZA=
=yTPX
-END PGP SIGNATURE-



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread David Brownell
Joshua Wise wrote:

The kernel is already 430k; we need to get it sub-256k.
Correction: 530k w/ ethernet gadget, networking, and TCP/IP. 380k w/g_zero. 
Also, luckily, the iPAQ h1900 has 512k of boot flash, but all other iPAQs 
have a boot sector of 256k.
That does seem excessive; you don't need TCP to do network
booting, just UDP.  A good example of where CONFIG_EMBEDDED
should be able to remove bells'n'whistles.
Yet I understand completely why you might not be wanting
to strip that extra code out yourself ... :)
We certainly should have a serial gadget.

- Dave



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-02 Thread Joshua Wise
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 That does seem excessive; you don't need TCP to do network
 booting, just UDP.  A good example of where CONFIG_EMBEDDED
 should be able to remove bells'n'whistles.
Gripe, whine, moan. :) Shoulda woulda coulda can't. Wonder if I can do some 
PF_RAW magic and fake it? 438k without TCP - networking is still DamnBig(tm). 
(oh, and I failed to mention, I'm compiling with MTD support also for the 
iPAQ's flash. it looks like a good candidate for stripping down, although I'm 
getting quite a bit offtopic here.)
  8622832641304   90796   162ac net/built-in.o
  985001112 136   99748   185a4 drivers/mtd/built-in.o

 Yet I understand completely why you might not be wanting
 to strip that extra code out yourself ... :)
Most of the 'big' bloat is in fs/. It's mostly distributed bloat, too, so that 
makes it ++harder to clean up... :(

 We certainly should have a serial gadget.
In progress. Progress is in the handhelds.org CVS repository, as 'char.c'.

 - Dave
~joshua

- -- 
Joshua Wise | www.joshuawise.com
GPG Key | 0xEA80E0B3
Quote   | lilo I akilled [EMAIL PROTECTED] by mistake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/VTbfPn9tWOqA4LMRAvT3AJ0c1D2IA9DYsi+jaTLShRbLeqUXhQCeMwoG
z16jUXb71cr8oUhdtr59pwo=
=Fadg
-END PGP SIGNATURE-



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] USB Gadget - serial?

2003-09-01 Thread David Brownell
Joshua Wise wrote:
I'm working on porting Linux to the iPAQ h1910, and I need a way to get data 
to the h1910, as it has no serial. I've been eyeing USB Gadget and wondering 
if it provides anything like the usb-char that pxa2xx and sa11x0 drivers used 
to provide (basically, something that can be accessed like a serial port on 
both sides.)
It'll be cool to see that working!

Nothing like usb-char yet.  The idea's come up, but not yet a driver.

I just use ssh over g_ether (2.4.19-rmk7-pxa2), it's less work for
me to set up -- but then, I don't need to talk to Windows or such.
- Dave



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel