On Thu, 13 May 2004, Patrick Boettcher wrote:
> Hello list,
>
> I'm currently working on a driver for a USB-DVB device (VP-7041). This
> device needs to be initialized by a firmware. Peter Schildmann wrote a
> user-level (libusb) programm to load the firmware to the device. I wanted
> to convert this small program to kernelspace. Everything works like
> expected so far, except that the the firmware does not want to go to the
> device:
>
> Peters programm does the following to load the firmware:
>
> /* init stuff */
> for(i = 0; i < s.st_size; i += 22) {
> b = &firmware[i];
> addr = ((u_int16_t) b[3]) | ((u_int16_t) b[4] << 8);
>
> ret = usb_control_msg(usb, USB_TYPE_VENDOR, 0xa0, addr, 0x0,
> &b[6], b[1], 500);
>
> if (ret != b[1]) {
> fprintf(stderr, "Firmware download failed\n");
> exit(1);
> }
> }
>
> This works.
>
> I wrote this part like this:
>
> for(i = 0; i < fw->size; i += 22) {
> b = &fw->data[i];
> addr = ((__u16) b[3]) | ((__u16) b[4] << 8);
>
> retval = usb_control_msg(dev, usb_sndctrlpipe(dev,0),
> 0xa0, USB_TYPE_VENDOR,addr, 0x0, &b[6],
> b[1], (50000 * HZ + 999) / 1000);
>
> if (retval != b[1]) {
> err("Error while transferring firmware (transferred size: "
> "%d, block size: %d)",retval,b[1]);
> break;
> }
> }
>
> When running this code following messages appear in syslog:
>
> kernel: uhci_hcd 0000:00:1d.1: host system error, PCI problems?
> kernel: uhci_hcd 0000:00:1d.1: host controller halted, very bad!
> kernel: usb 2-1: control timeout on ep0out
>
> Not good at all I think...
>
> I think the problem is the usb_sndctrlpipe, I would appreciate if someone
> could point me in the right direction.
No, your use of usb_sndctrlpipe is correct.
However without seeing more of the context, it's impossible to say whether
your use of fw and b is correct. This sort of error might occur if you
pass an invalid address, for example. Also, you have the kernel trusting
the value in b[1]; you should check to make sure it's in the correct
range.
(Also, the timeout value can be expressed more simply as "5*HZ".)
Alan Stern
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users