Subject: Re: ugen refusing writes
To: Chris Baird <>
From: Jasper Wallace <>
List: netbsd-users
Date: 02/14/2001 14:03:28
On Wed, 14 Feb 2001, Chris Baird wrote:

> System: NetBSD 1.5 "RELEASE"
> While attempting to get a USB scanner configured for SANE under NetBSD
> (I've already successfully done this with the same dual-boot system in
> Linux), I've come across the problem of all writes to /dev/ugen0.00
> returning ENODEV.

Yes, /dev/ugen0.00 is the control endpoint, so it won't let you do this.

> The usb attach information is thusly:
>         ugen0 at uhub0 port 1
>         ugen0: EPSON Perfection640  , rev 1.00/0.01, addr 2
> /dev/ugen0.00 would be the correct device file to use, correct? (It's
> the only one I can find that responds like it exists. I thought
> /dev/ugen0.02 would could have been it, but that's not the case.)

How are you choosing the device in the application? to work out which of the
/dev/ugen0.xx devices you have to use read/write to an endpoint requires a
couple of ioctls to the /dev/ugen0.00 device.

> "ktrace scanimage -L" reveals:
>   2480 scanimage NAMI  "/dev/ugen0.00"
>   2480 scanimage RET   open 5
>   2480 scanimage CALL  write(0x5,0xbfbfcee6,0x2)
>   2480 scanimage RET   write -1 errno 19 Operation not supported by device
>   2480 scanimage CALL  write(0x5,0xbfbfb714,0x2)
>   2480 scanimage RET   write -1 errno 19 Operation not supported by device
>   2480 scanimage CALL  __fstat13(0x2,0xbfbfb634)
>   2480 scanimage RET   __fstat13 0
>   2480 scanimage CALL  write(0x2,0xbfbfaffc,0x15)
>   2480 scanimage GIO   fd 2 wrote 21 bytes
>        "[epson] ident failed\n"
> Apparently this is the code responsible in /sys/dev/usb/ugen.c:ugen_do_write
> 	if (endpt == USB_CONTROL_ENDPOINT)
> 		return (ENODEV);

oh you noticed that too ;-)

> The ugen(4) man page seems to contradicts this:
>      If an endpoint address is used both for input and output the device can
>      be opened for both read or write.

The ugen stuff is a little wacky, i've been working with it for the last
couple of days and only recently worked out how to use it.

I think the best thing for you to try would be to subscribe to the usb-bsd
mailing lists - see:

Have you looked at the uscanner driver in -current?

I don't know how easy it would be to backport to 1.5...

> (Btw, an Epson Perfection 640U has vendor=0x4b8, product=0x10c in case anyone
> wants to update the usbdevs file.)

     "The aurochs was the great, black bull that was painted on cave
walls  alongside bison and mammoths  by tacky prehistoric minimalist
artists  who  had no  sense whatsoever of  modeling or perspective."
[see:]  [0x2ECA0975]