From: Bryan O'Donoghue Date: Mon, 21 May 2007 00:11:58 +0100 Subject: [U-Boot-Users] PXA27x usbtty start up sequence In-Reply-To: <20070520222342.GD30191@enneenne.com> References: <20070512231906.GG11070@enneenne.com> <20070513132536.6ab397df@localhost.localdomain> <20070518171521.GA4199@enneenne.com> <20070520145436.180807c6@localhost.localdomain> <20070520160702.GB3887@enneenne.com> <20070520224017.1e50894c@localhost.localdomain> <20070520222342.GD30191@enneenne.com> Message-ID: <20070521001158.6056ad5d@localhost.localdomain> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 21 May 2007 00:23:42 +0200 Rodolfo Giometti wrote: > The problem is that the defice __is__ into configured state (USB > cable is connected and /dev/ttyUSB0 is running) but nobody has > opened the serial line (no minicom/kermit running). > > So, I suppose, the above modification is useless... No, no, unless I'm *really* forgetting my USB enumeration behavior, a device shouldn't go into the configured state unless and until the host does a SET_CONFIGURATION, so the modification would be right since without the USB cable connected the device should be in the DEFAULT state, not the CONFIGURED state. usb_20.pdf page - 240 Figure 9.1 see ? > Mmm... I see... I supposed to get no control request once device is > connected... > > Currently I use a timeout of 2ms but I suppose I should decrease it, > shouldn't I? :-o Possibly... I don't think I'd take issue with the specific timeout but, you *can* get a control request at *any* time... including 50% of the way through a DATA IN transfer to the host... there's nothing in the USB specification which precludes control requests on EP0 at *any* time... You'd probably "get away" with it if you limited your hardware to functioning only with g_serial but, where would be the fun in doing just g_serial ? > Ok, what do you suggest to do? I'm a bit confused... :) Possibly the simple solution is #1: Fix it so SET_CONFIGURATION is the only thing to move the device into the configured state. #2: Either you or I should write a patch then which looks like this. /* Not tested */ static void __usbtty_puts (const char *str, int len) { int maxlen = usbtty_output.totalsize; int space, n; /* break str into chunks < buffer size, if needed */ while (len > 0 && device_instance->device_state == STATE_CONFIGURED) { usbtty_poll (); space = maxlen - usbtty_output.size; /* Empty buffer here, if needed, to ensure space... */ if (space) { write_buffer (&usbtty_output); n = MIN (space, MIN (len, maxlen)); buf_push (&usbtty_output, str, n); str += n; len -= n; } } } I think... that *should* work. Happy Monday. Bryan