Subject: USB scanners on NetBSD4?
To: None <current-users@NetBSD.org>
From: Paul Ripke <stix@stix.id.au>
List: current-users
Date: 06/07/2007 14:50:37
Hi,

I just dug my old Canon CanoScan N 650U out and tried to use it on
NetBSD 4.0_BETA2 i386. It hangs using either of libusb or
/dev/uscanner0 in the same way. Last time I successfully used it was
around NetBSD 2.x, I believe.

With SANE_DEBUG_PLUSTEK=255 and SANE_DEBUG_SANEI_USB=255 and using
libusb, scanimage reports:

...
[plustek] usbDev_open(libusb:,0x04A9-0x2206) - 0x8057040
[sanei_usb] sanei_usb_open: trying to open device `libusb:/dev/usb1:/dev/ugen0'
[sanei_usb] sanei_usb_open: configuration nr: 0
[sanei_usb] sanei_usb_open:     interface nr: 0
[sanei_usb] sanei_usb_open:   alt_setting nr: 0
[sanei_usb] sanei_usb_open: endpoint nr: 0
[sanei_usb] sanei_usb_open: direction: 128
[sanei_usb] sanei_usb_open: address: 1 transfertype: 3
[sanei_usb] sanei_usb_open: found interrupt-in endpoint (address 0x01)
[sanei_usb] sanei_usb_open: endpoint nr: 1
[sanei_usb] sanei_usb_open: direction: 128
[sanei_usb] sanei_usb_open: address: 2 transfertype: 2
[sanei_usb] sanei_usb_open: found bulk-in endpoint (address 0x02)
[sanei_usb] sanei_usb_open: endpoint nr: 2
[sanei_usb] sanei_usb_open: direction: 0
[sanei_usb] sanei_usb_open: address: 3 transfertype: 2
[sanei_usb] sanei_usb_open: found bulk-out endpoint (address 0x03)
[sanei_usb] sanei_usb_open: opened usb device `libusb:/dev/usb1:/dev/ugen0' (*dn=0)
[sanei_usb] sanei_usb_get_vendor_product: device 0: vendorID: 0x04a9, productID: 0x2206
[plustek] Vendor ID=0x04A9, Product ID=0x2206
[plustek] usbio_DetectLM983x
[sanei_usb] sanei_usb_write_bulk: trying to write 4 bytes
[sanei_usb] 0000: 01 69 00 01                                     .i..............
[sanei_usb] sanei_usb_write_bulk: wanted 4 bytes, wrote 4 bytes
[sanei_usb] sanei_usb_read_bulk: trying to read 1 bytes
USB error: error reading from bulk endpoint /dev/ugen0.02: Connection timed out
[sanei_usb] sanei_usb_read_bulk: read failed: Connection timed out
USB error: usb_clear_halt called, unimplemented on BSD
[plustek]  * could not read version register!
[sanei_usb] sanei_usb_close: closing device 0

And during the hang time, scanimage is stuck waiting on ugenrb.
With usbdebug=255 set, the kernel reports:

Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: start transfer 1 bytes
Jun  5 18:54:57 hactar /netbsd: usbd_transfer: xfer=0xc1ce1b00, flags=4, pipe=0xc2021080, running=0
Jun  5 18:54:57 hactar /netbsd: usbd_dump_queue: pipe=0xc2021080
Jun  5 18:54:57 hactar /netbsd: usb_allocmem: use frag=0xcb7a9e00 size=1
Jun  5 18:54:57 hactar /netbsd: usb_insert_transfer: pipe=0xc2021080 running=0 timeout=30000
Jun  5 18:54:57 hactar /netbsd: usb_schedsoftintr: polling=0
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: pipe=0xc2021080 xfer=0xc1ce1b00 status=0 actlen=1
Jun  5 18:54:57 hactar /netbsd: usb_freemem: frag=0xcb7a9e00
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: repeat=0 new head=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_start_next: pipe=0xc2021080, xfer=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: transferred 1
Jun  5 18:54:57 hactar /netbsd: usbd_free_xfer: 0xc1ce1b00
Jun  5 18:54:57 hactar /netbsd: usbd_alloc_xfer() = 0xc1ce1b00
Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: start transfer 4 bytes
Jun  5 18:54:57 hactar /netbsd: usbd_transfer: xfer=0xc1ce1b00, flags=0, pipe=0xc1d2a800, running=0
Jun  5 18:54:57 hactar /netbsd: usbd_dump_queue: pipe=0xc1d2a800
Jun  5 18:54:57 hactar /netbsd: usb_allocmem: use frag=0xcb7a9e00 size=4
Jun  5 18:54:57 hactar /netbsd: usb_insert_transfer: pipe=0xc1d2a800 running=0 timeout=0
Jun  5 18:54:57 hactar /netbsd: usb_schedsoftintr: polling=0
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: pipe=0xc1d2a800 xfer=0xc1ce1b00 status=0 actlen=4
Jun  5 18:54:57 hactar /netbsd: usb_freemem: frag=0xcb7a9e00
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: repeat=0 new head=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_start_next: pipe=0xc1d2a800, xfer=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: transferred 4
Jun  5 18:54:57 hactar /netbsd: usbd_free_xfer: 0xc1ce1b00
Jun  5 18:54:57 hactar /netbsd: usbd_alloc_xfer() = 0xc1ce1b00
Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: start transfer 1 bytes
Jun  5 18:54:57 hactar /netbsd: usbd_transfer: xfer=0xc1ce1b00, flags=4, pipe=0xc2021080, running=0
Jun  5 18:54:57 hactar /netbsd: usbd_dump_queue: pipe=0xc2021080
Jun  5 18:54:57 hactar /netbsd: usb_allocmem: use frag=0xcb7a9e00 size=1
Jun  5 18:54:57 hactar /netbsd: usb_insert_transfer: pipe=0xc2021080 running=0 timeout=30000
Jun  5 18:54:57 hactar /netbsd: usb_schedsoftintr: polling=0
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: pipe=0xc2021080 xfer=0xc1ce1b00 status=0 actlen=1
Jun  5 18:54:57 hactar /netbsd: usb_freemem: frag=0xcb7a9e00
Jun  5 18:54:57 hactar /netbsd: usb_transfer_complete: repeat=0 new head=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_start_next: pipe=0xc2021080, xfer=0x0
Jun  5 18:54:57 hactar /netbsd: usbd_bulk_transfer: transferred 1
Jun  5 18:54:57 hactar /netbsd: usbd_free_xfer: 0xc1ce1b00
Jun  5 18:54:57 hactar /netbsd: usbd_ar_pipe: pipe=0xc2021080
Jun  5 18:54:57 hactar /netbsd: usbd_dump_queue: pipe=0xc2021080
Jun  5 18:54:57 hactar /netbsd: usbd_ar_pipe: pipe=0xc1d2a800
Jun  5 18:54:57 hactar /netbsd: usbd_dump_queue: pipe=0xc1d2a800
Jun  5 18:55:39 hactar /netbsd: usb_event_thread: woke up

Which seems to indicate that from the USB stacks POV, the read was
successful. Anyone know what might be going on here?

-- 
Paul Ripke