Bug 207939 - print/cups: Removal of LIBUSB option breaks some printer types
Summary: print/cups: Removal of LIBUSB option breaks some printer types
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-13 01:38 UTC by russo
Modified: 2016-03-21 05:07 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (tijl)


Attachments
patch-usb-dbg (1.22 KB, patch)
2016-03-18 09:34 UTC, Tijl Coosemans
no flags Details | Diff
ktrace of cups usb backend process, showing failure (87.18 KB, text/plain)
2016-03-19 17:11 UTC, russo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description russo 2016-03-13 01:38:05 UTC
With the most recent update of print/cups, the old LIBUSB option was removed, and LIBUSB is always turned on (and the file %%DATADIR%%/usb/org.cups.usb-quirks
 unconditionally installed per pkg-plist).

This is a major problem for a small class of USB printers such as the HP LJ 1020, which will not work if cups is built with LIBUSB.  The problem is that the usb driver attempts to detach the kernel driver using libusb_detach_kernel_driver, which fails.  The result is an endless "Waiting for printer to become available" error.

I was able to force cups to be built without LIBUSB by hacking the print/cups/Makefile to add the "--diable-libusb" option to CONFIGURE_ARGS and removing the %%DATADIR%%/usb/org.cups.usb-quirks line from pkg-plist.

This is obviously NOT the solution for the port, but it WAS the solution to the problem of getting my printer working again after the upgrade to cups 2.1.3 this afternoon.  I only got the solution by googling like crazy, watching ktraces of the usb: process that was screwing up, and finally finding an article saying "Just build the port with LIBUSB off."  It was then that I realized that there was no longer such an option, and that it had been removed yesterday.  I must have had it selected for all previous builds of cups.

Would the port maintainer please re-insert the LIBUSB option so that oddball uses of cups with printers that have this problem can actually print?
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-14 12:14:17 UTC
The call to libusb_detach_kernel_driver fails because the process doesn't have the required privileges.  Detaching of ulpt(4) isn't needed on FreeBSD though so I've committed a patch that removes this call.  Please try updating to cups-2.1.3_1 and see if that fixes your problem.
Comment 2 rhs 2016-03-14 13:00:38 UTC
I too had exactly the same dilema with Epson R300 printer after upgrading my packages yesterday. Firstly package upgrade failed at which point I pkg delete cups and then pkg install cups. This resulted in no usb printers and "Waiting for printer to become available" error. Portsnap fetch update followed by portmaster print/cups also failed. It was not until I found this bug post and hacked my Makefile and pkg-plist as described in preceding post by "russo" that my printer finally returned. This hack is in the cups-2.1.3 makefile. So now are you saying these changes have been committed to cups-2.1.3_1? Should simply cd to /usr/ports/print/cups and portmaster not automatically upgrade? Why did portsnap fetch upgrade not grab cups-2.1.3_1. I did that at Monday, March 14, 2016 08:03 AM.

Sorry if I sound frustrated but I am. Cups is a pain to update and its not the first time this kind of thing has happened.

Richard Susgin
freebsd -version 10.2-RELEASE-p13
uname -a 10.2-RELEASE-p9 FreeBSD 10.2-RELEASE-p9 #0: Thu Jan 14 01:32:46 UTC 2016     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-14 14:20:54 UTC
cups 2.1.3_1 was committed in ports r411055 (2016-03-14 11:40:58 UTC).  It can take some time for portsnap to catch up but it should be there now.

Cups can indeed be a pain.  There were 15 open bugs for it.  One of the reasons for that was that there were too many components and options that all had to be aligned to make it work and they weren't maintained by anyone.  The update cut down on these so there's only one method to access USB printers now (libusb) and only one to access Zeroconf network printers (Avahi).  Neither libusb nor Avahi were the default before but both are the recommended methods and are the ones supported by other ports that depend on cups.  It's unfortunate that the switch to libusb didn't go smoothly, but this problem only happens when you have ulpt in your kernel or loaded as a kernel module which isn't the default.  Of course, I should have known that many users of cups use ulpt.  But anyway, it should all work now.
Comment 4 James French 2016-03-17 11:55:17 UTC
2.1.3_1 is still causing issues for me. As an aside, the ulpt is available in the GENERIC kernel as a module and is autoloading as soon as quickly as I can unload it. I'm not entirely sure what's causing that as I can't find any reference to it. 

In any case, before I went to the effort of rebuilding a kernel without the module built, I forcibly unloaded it by moving ulpt.ko out of the way and issuing a kldunload. After restarting cups and verifying that it definitely wasn't loaded, still no go. 

Disabling libusb and rebuilding the port gets it going right away with the module loaded or not.
Comment 5 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-17 13:14:23 UTC
Can you provide some more information:

What kind of printer do you have?

What is the output of these commands:

ls -l /dev/ulpt* /dev/usb/*
pkg info -x cups foo
Comment 6 russo 2016-03-17 14:34:09 UTC
Sorry for the delay in  my response, I went  on travel right after my initial report.

Disabling ulpt is apparently impossible.  I do not have ulpt in my GENERIC kernel, and have tried to rebuild the kernel many times with "WITHOUT_MODULES=ulpt" or "WITHOUT_MODULES=usb/ulpt" in /etc/make.conf --- only to have the ulpt kernel module built anyway.  Looking at the Makefile in the 
/usr/src/sys/modules directory, it is not at all clear that the WITHOUT_MODULES option even works to disable modules under the usb tree --- you could disable all the usb modules but not an individual one.

I even tried unplugging the printer, kldunloading the ulpt module, and then moving ulpt out of the way.  It caused a hang elsewhere because the module couldn't load. 

As James French mentions in comment 4, ulpt autoloads as soon as the printer is plugged in (or on boot, if the printer is plugged in already).

My printer is HPLJ 1020,   usbconfig shows:
ugen3.2: <HP LaserJet 1020 Hewlett-Packard> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (98mA)

Because the printer needs to be loaded with firmware before it prints, I need a devd.conf rule to send that data to the printer when it's detected.  The rule is:

attach 100 {
match "vendor" "0x03f0";
match "product" "0x2b17";
action "sleep 10; cat /usr/local/share/foo2zjs/firmware/sihp1020.dl > /dev/$device-name";
};

(the sleep was for debugging some time ago, never took it out).

The device name this rule always gets is ulpt0.


As for the output you asked for:

> ls -l /dev/ulpt* /dev/usb/*
crw-rw----  1 root  cups      0xa1 Mar 12 18:28 /dev/ulpt0
crw-------  1 root  operator  0x40 Mar 12 17:47 /dev/usb/0.1.0
crw-------  1 root  operator  0x60 Mar 12 17:47 /dev/usb/0.1.1
crw-------  1 root  operator  0x4e Mar 12 17:47 /dev/usb/1.1.0
crw-------  1 root  operator  0x5f Mar 12 17:47 /dev/usb/1.1.1
crw-------  1 root  operator  0x50 Mar 12 17:47 /dev/usb/2.1.0
crw-------  1 root  operator  0x5e Mar 12 17:47 /dev/usb/2.1.1
crw-------  1 root  operator  0x6a Mar 12 17:47 /dev/usb/2.2.0
crw-------  1 root  operator  0x6c Mar 12 17:47 /dev/usb/2.2.1
crw-------  1 root  operator  0x6d Mar 12 17:47 /dev/usb/2.2.2
crw-------  1 root  operator  0x77 Mar 12 17:47 /dev/usb/2.3.0
crw-------  1 root  operator  0x79 Mar 12 17:47 /dev/usb/2.3.1
crw-------  1 root  operator  0x7a Mar 12 17:47 /dev/usb/2.3.2
crw-------  1 root  operator  0x52 Mar 12 17:47 /dev/usb/3.1.0
crw-------  1 root  operator  0x63 Mar 12 17:47 /dev/usb/3.1.1
crw-rw----  1 root  cups      0x70 Mar 12 17:47 /dev/usb/3.2.0
crw-------  1 root  operator  0x73 Mar 12 17:47 /dev/usb/3.2.1
crw-------  1 root  operator  0x54 Mar 12 17:47 /dev/usb/4.1.0
crw-------  1 root  operator  0x62 Mar 12 17:47 /dev/usb/4.1.1
crw-rw----  1 root  uucp      0xa5 Mar 12 17:48 /dev/usb/4.2.0
crw-------  1 root  operator  0xa7 Mar 12 17:48 /dev/usb/4.2.1
crw-rw-r--  1 uucp  wheel     0x74 Mar 12 17:47 /dev/usb/4.3.0
crw-------  1 root  operator  0x76 Mar 12 17:47 /dev/usb/4.3.1
crw-------  1 root  operator  0x56 Mar 12 17:47 /dev/usb/5.1.0
crw-------  1 root  operator  0x61 Mar 12 17:47 /dev/usb/5.1.1
crw-------  1 root  operator  0x6e Mar 12 17:47 /dev/usb/5.2.0
crw-------  1 root  operator  0x72 Mar 12 17:47 /dev/usb/5.2.1
crw-------  1 root  operator  0x84 Mar 12 17:47 /dev/usb/5.3.0
crw-------  1 root  operator  0x88 Mar 12 17:47 /dev/usb/5.3.1
crw-------  1 root  operator  0x58 Mar 12 17:47 /dev/usb/6.1.0
crw-------  1 root  operator  0x66 Mar 12 17:47 /dev/usb/6.1.1
crw-------  1 root  operator  0x5a Mar 12 17:47 /dev/usb/7.1.0
crw-------  1 root  operator  0x65 Mar 12 17:47 /dev/usb/7.1.1
crw-------  1 root  operator  0x5c Mar 12 17:47 /dev/usb/8.1.0
crw-------  1 root  operator  0x64 Mar 12 17:47 /dev/usb/8.1.1

> pkg info -x cups foo
cups-2.1.3
cups-filters-1.8.2_1
cups-pdf-2.6.1_3
linux-c6-cups-libs-1.4.2_4
foo2zjs-20150511_2
foomatic-db-20160226_1

The printer is on /dev/usb/3.2.0, and that is correctly set to ownership by cups.  The other usb devices need to be set as they are for other uses.

And for the record, uname -a says:
FreeBSD bogodyn.org 10.2-STABLE FreeBSD 10.2-STABLE #3 r287165: Sat Mar 12 17:34:03 MST 2016     russo@bogodyn.org:/usr/obj/usr/src/sys/GENERIC  amd64
Comment 7 James French 2016-03-17 15:07:27 UTC
Mine is a Brother HL-1110:
ugen0.4: <HL-1110 series Brother> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (2mA)

> ls -l /dev/ulpt* /dev/usb/*
crw-rw----  1 root  cups  0x6c 17 Mar 20:43 /dev/ulpt0
crw-rw----  1 root  cups  0x7e 17 Mar 20:43 /dev/usb/0.4.0

(Cups is in a jail, but this was working previously, have some spare hardware and poudriere built packages so can probably test out of the jail if that becomes critical).

> pkg info -x cups foo

cups-2.1.3_1
cups-filters-1.8.2_2
foomatic-db-20160226_1
Comment 8 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-17 15:43:59 UTC
(In reply to russo from comment #6)
>> pkg info -x cups foo
> cups-2.1.3

Can you try cups-2.1.3_1?
Comment 9 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-17 15:45:50 UTC
(In reply to James French from comment #7)
Where did you obtain the PPD for this printer?  Did you download something from http://support.brother.com/g/b/downloadlist.aspx?c=eu_ot&lang=en&prod=hl1110_us_eu_as&os=127
Comment 10 rhs 2016-03-17 16:20:36 UTC
Tried latest update with same results. Ended up deleting pkg and reinstalling hacked ports version cause I really need my printers. Below is condition after pkg upgrade. 


# pkg info cups
cups-2.1.3_1
Name           : cups
Version        : 2.1.3_1
Installed on   : Wed Mar 16 08:09:34 2016 EDT
Origin         : print/cups
Architecture   : freebsd:10:x86:64 
Prefix         : /usr/local
Categories     : print
Licenses       : LGPL20 and GPLv2
Maintainer     : tijl@FreeBSD.org
WWW            : https://cups.org/
Comment        : Common UNIX Printing System
Options        :
        AVAHI          : on
        DBUS           : on
        DOCS           : on
        IPPTOOL        : off
        LIBPAPER       : on
        NLS            : on
        X11            : off
Shared Libs required:
        libavahi-client.so.3
        libdbus-1.so.3
        libgnutls.so.28
        libpaper.so.1
        libavahi-common.so.3
Shared Libs provided:
        libcupscgi.so.1
        libcupsppdc.so.1
        libcupsimage.so.2
        libcups.so.2
        libcupsmime.so.1
Annotations    :
        cpe            : cpe:2.3:a:apple:cups:2.1.3:::::freebsd10:x64:1
Flat size      : 5.87MiB
Description    :
CUPS is a standards-based, open source printing system.  It uses the Internet
Printing Protocol (IPP) to support printing to local and network printers.

# pkg info -x cups foo
cups-2.1.3_1     
cups-filters-1.8.2_2
cups-pdf-2.6.1_3
gutenprint-cups-5.2.10_2
linux-c6-cups-libs-1.4.2_4
foomatic-db-20160226_1
foomatic-db-engine-4.0.12_1,2
gutenprint-foomatic-5.2.10_2

# ls -l /dev/ulpt* /dev/usb/*
crw-rw----  1 root  cups      0x66 Mar 17 10:49 /dev/ulpt0
crw-------  1 root  operator  0x58 Mar 16 12:31 /dev/usb/0.1.0
crw-------  1 root  operator  0x5d Mar 16 12:31 /dev/usb/0.1.1
crw-------  1 root  operator  0x88 Mar 16 12:31 /dev/usb/0.2.0
crw-------  1 root  operator  0x8c Mar 16 12:31 /dev/usb/0.2.1
crw-------  1 root  operator  0x90 Mar 16 12:31 /dev/usb/0.3.0
crw-------  1 root  operator  0x92 Mar 16 12:31 /dev/usb/0.3.1
crw-rw----  1 root  cups      0x9c Mar 16 12:31 /dev/usb/0.4.0
crw-------  1 root  operator  0xa2 Mar 16 12:31 /dev/usb/0.4.1
crw-------  1 root  operator  0xa3 Mar 16 12:31 /dev/usb/0.4.2
crw-------  1 root  operator  0xa4 Mar 16 12:31 /dev/usb/0.4.4
crw-------  1 root  operator  0xa5 Mar 16 12:31 /dev/usb/0.4.5
crw-rw----  1 root  cups      0xa8 Mar 16 12:31 /dev/usb/0.5.0
crw-rw----  1 root  cups      0xaa Mar 16 12:31 /dev/usb/0.5.1
crw-------  1 root  operator  0xab Mar 16 12:31 /dev/usb/0.6.0
crw-------  1 root  operator  0xad Mar 16 12:31 /dev/usb/0.6.1
crw-------  1 root  operator  0xae Mar 16 12:31 /dev/usb/0.6.7
crw-------  1 root  operator  0xb7 Mar 17 07:20 /dev/usb/0.7.0
crw-------  1 root  operator  0xbb Mar 17 07:20 /dev/usb/0.7.1
crw-------  1 root  operator  0xbc Mar 17 07:20 /dev/usb/0.7.2
crw-------  1 root  operator  0xbd Mar 17 07:20 /dev/usb/0.7.3
crw-------  1 root  operator  0x5a Mar 16 12:31 /dev/usb/1.1.0
crw-------  1 root  operator  0x5c Mar 16 12:31 /dev/usb/1.1.1
crw-------  1 root  operator  0x8a Mar 16 12:31 /dev/usb/1.2.0
crw-------  1 root  operator  0x8d Mar 16 12:31 /dev/usb/1.2.1
crw-------  1 root  operator  0x8e Mar 16 12:31 /dev/usb/1.3.0
crw-------  1 root  operator  0x93 Mar 16 12:31 /dev/usb/1.3.1
crw-------  1 root  operator  0x94 Mar 16 12:31 /dev/usb/1.3.2
crw-------  1 root  operator  0x95 Mar 16 12:31 /dev/usb/1.3.3
crw-------  1 root  operator  0x96 Mar 16 12:31 /dev/usb/1.3.4
crw-------  1 root  operator  0x97 Mar 16 12:31 /dev/usb/1.4.0
crw-------  1 root  operator  0x99 Mar 16 12:31 /dev/usb/1.4.1
crw-------  1 root  operator  0x9a Mar 16 12:31 /dev/usb/1.4.2
crw-------  1 root  operator  0x9b Mar 16 12:31 /dev/usb/1.4.3
Comment 11 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-17 17:20:41 UTC
(In reply to rhs from comment #10)
Can you post the output of these commands when using the unmodified port:

lpinfo -l -v
grep URI /usr/local/etc/cups/printers.conf
Comment 12 russo 2016-03-17 22:58:21 UTC
I can try the latest revision, but not immediately.  Domestic tranquility is not served by making changes to the household printing set-up.  Wife needs printing working now, And the cats don't like it much when I scream.

It might be as late as this weekend before I can test out this change.  Since others are saying it doesn't help them, I'm not expecting it'll work much better for me.
Comment 13 russo 2016-03-17 23:01:17 UTC
(In reply to Tijl Coosemans from comment #9)
I know you didn't ask where I got my PPD for the HPLJ, but for the record I got it out of the foo2zjs package.
Comment 14 James French 2016-03-18 01:35:15 UTC
(In reply to Tijl Coosemans from comment #9)

Yeah, the PPD is from Brother's Linux drivers - which comprise an lpwrapper script with Linux binary blobs making the setup somewhat of a hack job (the whole reason I'm running it in a jail, trying to keep my main install clean from that sort of silliness). It was all working okay with Linux emulation switched on, but CUPS loses sight of the printer entirely with libusb enabled.

Come to think of it though, I'm not sure that I've tried modifying the existing print queue in situ. I'm fairly certain that I've only deleted the printer and tried adding it again at which point CUPS never detects it and nothing shows up in lpinfo.

Will put an un-hacked cups package back on the system when I get home tonight and see if I can modify the existing printer with any success with the 2.1.3_1 patches.

More info in 8 hours or so.
Comment 15 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-18 09:34:54 UTC
Created attachment 168365 [details]
patch-usb-dbg

This patch adds some printfs to help debug usb problems.  Please put it in /usr/ports/print/cups/files, then rebuild and reinstall cups.  Next change "LogLevel warn" in /usr/local/etc/cups/cupsd.conf into "LogLevel debug" and restart cupsd by running "service cupsd restart".  Try to setup the printer and print a test page and then email me /var/log/cups/error_log.
Comment 16 James French 2016-03-18 11:41:57 UTC
Log emailed through.
Comment 17 rhs 2016-03-18 12:54:53 UTC
In response to comment 11:

# lpinfo -l -v
Device: uri = http
        class = network
        info = Internet Printing Protocol (http)
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = https
        class = network
        info = Internet Printing Protocol (https)
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = ipp
        class = network
        info = Internet Printing Protocol (ipp)
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = ipps
        class = network
        info = Internet Printing Protocol (ipps)
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = lpd
        class = network
        info = LPD/LPR Host or Printer
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = socket
        class = network
        info = AppSocket/HP JetDirect
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = usb:/dev/ulpt0
        class = direct
        info = USB Printer #1
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = usb:/dev/unlpt0
        class = direct
        info = USB Printer #1 (no reset)
        make-and-model = Unknown
        device-id = 
        location = 
Device: uri = cups-pdf:/
        class = file
        info = CUPS-PDF
        make-and-model = Virtual PDF Printer
        device-id = MFG:Generic;MDL:CUPS-PDF Printer;DES:Generic CUPS-PDF Printer;CLS:PRINTER;CMD:POSTSCRIPT;
        location = 
Device: uri = beh
        class = network
        info = Backend Error Handler
        make-and-model = Unknown
        device-id = 
        location =

# grep URI /usr/local/etc/cups/printers.conf
DeviceURI usb:/dev/ulpt0
DeviceURI usb:/dev/ulpt0
DeviceURI cups-pdf:/

Hmm, my lpr printer is not showing up in cups gui right now where as it used too. Its never been configured but I use it to print certain types of PDF's out of 'xpdf' that do not print or display using 'okular' as of about 6mnths ago. Its still working though. Nice command lpinfo -l -v, thanks for that!! My laser-jet died so I've been using an intravenously fed Epson for everything else. I can also assure you that there are x2 configured and working printers on ulpt0 right now. Thanks for all the help.
Comment 18 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-18 13:23:47 UTC
(In reply to rhs from comment #17)
That's the output for the modified port right?  With an unmodified port I'd expect to see /dev/ugen where it says /dev/ulpt now.
Comment 19 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-18 13:27:34 UTC
Just for the record: The problem reported by James French was solved by giving the jail access to /dev/usbctl.

So that leaves russo and rhs.  Can you take a look at comment #15?
Comment 20 rhs 2016-03-18 15:54:34 UTC
In response to comment #18

I have this right now:

# pkg info cups
cups-2.1.3_1
Name           : cups
Version        : 2.1.3_1
Installed on   : Wed Mar 16 08:09:34 2016 EDT
Origin         : print/cups
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : print
Licenses       : LGPL20 and GPLv2
Maintainer     : tijl@FreeBSD.org
WWW            : https://cups.org/
Comment        : Common UNIX Printing System
Options        :
        AVAHI          : on
        DBUS           : on
        DOCS           : on
        IPPTOOL        : off
        LIBPAPER       : on
        NLS            : on
        X11            : off
Shared Libs required:
        libavahi-client.so.3
        libdbus-1.so.3
        libgnutls.so.28
        libpaper.so.1
        libavahi-common.so.3
Shared Libs provided:
        libcupscgi.so.1
        libcupsppdc.so.1
        libcupsimage.so.2
        libcups.so.2
        libcupsmime.so.1
Annotations    :
        cpe            : cpe:2.3:a:apple:cups:2.1.3:::::freebsd10:x64:1
Flat size      : 5.87MiB
Description    :
CUPS is a standards-based, open source printing system.  It uses the Internet
Printing Protocol (IPP) to support printing to local and network printers.

WWW: https://cups.org/

So once again its really hard to figure out what portmaster has done, as follows; previous 'pkg install cups-2.1.3_1' did not render a usable printer, so I 'pkg delete -f cups' and then cd /usr/ports/print/cups and issue a 'portmaster'. I just check the port and the modified cups-2.3.1 is still there. I can only assume that portmaster has built the package for 2.3.1_1 using the modified 2.3.1 makefile (because printers started working again) which was still in the port. I have not used ports ever on this build save for this exception and one other which is also still unresolved for obvious reasons. I really dont know what portmaster has done cause I do not use it but did in the past. I'm gonna delete the port and the package. Start all over and build from ports using a fresh 2.3.1_1 and a simple 'make install clean'. Then if that does not render a printer I will add your patch and do some logging. Thanks again!
Comment 21 rhs 2016-03-19 13:12:50 UTC
My mistake. Wrong path in 'devfs.rules'. It seems that my teenager needed my scanner and did not plug it back into same location. New package installed and working 100%. This is really embarrassing. What would we do without families? This really exemplifies the need to return to basics before assuming the worst.

Thanks
Rick




# usbconfig -d 0.4 dump_device_desc <<<where it is
ugen0.4: <USB2.0 MFPHi-Speed EPSON> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0200 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x04b8 
  idProduct = 0x0803 
  bcdDevice = 0x0100 
  iManufacturer = 0x0001  <EPSON>
  iProduct = 0x0002  <USB2.0 MFP(Hi-Speed)>
  iSerialNumber = 0x0003  <M13130305140344520>
  bNumConfigurations = 0x0001

# more /etc/devfs.rules
[system=10]
add path 'usb/0.5.*' mode 0660 group cups <<<where it was
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
add path 'usb*' mode 0660 group cups
add path 'ugen*' mode 0660 group cups
add path 'da*' mode 0660 group operator
add path 'usb*' mode 0770 group cups
Comment 22 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-19 15:19:30 UTC
(In reply to rhs from comment #21)
Ok.  Note that cups now installs a devd file (/usr/local/etc/devd/cups.conf) that changes permissions of USB printers so you should not need those devfs rules.
Comment 23 russo 2016-03-19 17:11:33 UTC
Created attachment 168392 [details]
ktrace of cups usb backend process, showing failure
Comment 24 russo 2016-03-19 17:19:13 UTC
Got around to trying the new version, and I'm sorry to report that there's no joy here.

The unmodified port simply put the printer into the endless "Waiting for printer to become ready" cycle again.

My steps:

   - remove the files I  modified from the port directory
   - svn update in the cups directory to get back the original version
   - rebuild (portupgrade -f cups)
   - commented out my own devd rule to send the printer firmware, and
     put it in /usr/local/etc/devd/foo2zjs.conf instead (the one they had 
     for the HPLJ1020 was commented out, and needed a slight modification to
     work when uncommented)
   - let the cups.conf in /usr/local/etc/devd take care of the device permissions rather than my own devfs.rules
   - restart daemon:  /usr/local/etc/rc.d/cupsd restart
   - try to print
   - See "Waiting for printer to become ready" in the web interface.
   - do a ktrace on the usb: process, and obtained the attached ktrace.


I then re-did my original hack, adding "--disable-libusb" and removing the 
%%USB%%%%DATADIR%%/usb/org.cups.usb-quirks
line from pkg-plist, and my printer works again.

I tried setting USB="@comment" in the makefile instead of removing the one line, and found that it also commented out the "backend/usb" line, which caused cupsd to stop my printer queue and refuse even to try printing --- apparently, the backend/usb is still needed even when libusb is disabled?

Anyhow, the removal of the "libusb_detach_kernel_driver" call is not enough to make the HPLJ 1020 work, and disabling libusb is the only path forward that I have so far.

Summarizing information asked for previously:

> ls -l /dev/ugen3.2 
lrw-rw----  1 root  cups  9 Mar 19 04:56 /dev/ugen3.2@ -> usb/3.2.0
> ls -l /dev/usb/3.2.0 
crw-rw----  1 root  cups  0xb2 Mar 19 04:56 /dev/usb/3.2.0
> ls -l /dev/ulpt0 
crw-rw----  1 root  cups  0x99 Mar 19 11:06 /dev/ulpt0
> sudo pkg info -x cups foo
cups-2.1.3_1
cups-filters-1.8.2_2
cups-pdf-2.6.1_3
linux-c6-cups-libs-1.4.2_4
foo2zjs-20150511_2
foomatic-db-20160226_1
Comment 25 rhs 2016-03-19 22:32:57 UTC
In response to comment 21:

My exact steps were: 1)- after some checking corrected /etc/devfs.rules.
2) De-install ('make deinstall') the port, then manually delete the port and then delete the pkg using 'pkg delete -f cups'.
3) 'pkg clean -a'
4) 'portsnap fetch update'
5) cd /usr/ports/print/cups
   'make install clean'<<<<-it is 2.3.1_1

It works perfectly. I have since renamed /etc/devfs.rules to /etc/devfs.rules.ng and 'service cupsd restart' and printed via lpr and usb printers and both are working. I guess I have made another incorrect assumption on the actual original cause of the problem. I'm actually hesitant to try and install the package because the port is working well, and just wish to leave it at that. I really hope that installing the port just ends up building the package as is my understanding of how ports are supposed to work on a system using pkgng only! I have really tried to stay away from ports and as I have said this is one of two exceptions in over a year. As a side note I have noticed that 'devd' is doing a much better job of sorting out hardware. It is obvious when comparing 'dmesg' from over a year ago to now.
Thanks much.
Comment 26 russo 2016-03-19 22:50:14 UTC
Per comment 15 I have patched cups, and emailed the error_log for two attempts to print, both failing with "Waiting for printer to become available" loops.
Comment 27 Tijl Coosemans freebsd_committer freebsd_triage 2016-03-20 10:28:43 UTC
(In reply to russo from comment #26)
From the logs it appears the device URI that is autodetected is usb://HP/LaserJet%201020?serial=FN0VY3Q.  It may be easier to go to http://localhost:631/printers, click on your printer and then select "Modify Printer" from the Administration drop-down.  Cups will list all available printers then and you should be able to select the right URI.
Comment 28 russo 2016-03-20 15:05:51 UTC
(In reply to Tijl Coosemans from comment #27)
And we have a winner.

Using the Modify Printer method and picking the recognized printer URI instead of specifying something in /dev was the trick, and it worked on the first try with the unmodified port.

Thank you.
Comment 29 commit-hook freebsd_committer freebsd_triage 2016-03-20 16:08:29 UTC
A commit references this bug:

Author: tijl
Date: Sun Mar 20 16:07:48 UTC 2016
New revision: 411457
URL: https://svnweb.freebsd.org/changeset/ports/411457

Log:
  - Add more information about USB printers to the 20160311 cups entry.
  - Clarify the 20160311 HPLIP entry a bit.

  PR:		207939

Changes:
  head/UPDATING
Comment 30 Jonathan Chen 2016-03-21 05:03:34 UTC
Um. This does not work for me. When I click on modify printers, I do *NOT* get a drop down with my printer listed.

This is *still* not fixed.
Comment 31 Jonathan Chen 2016-03-21 05:07:33 UTC
(In reply to Jonathan Chen from comment #30)
Hmm. Did a full reboot, and the second time around the printer was listed.