April 1, 2013

setting up USB printer in Android/Linux chroot

I wanted to turn my Android tablet (an Asus Transformer TF101) into a little ad-hoc print server. Unfortunately, android apps for such purpose are either expensive, sucky or nonexistent (usually all three). So, I thought, since i have an openSUSE chroot up and running on the device, i can just install CUPS server and print happily through that.

This was not without trouble, because after installing it for the first time, it came up nicely, but refused to see the USB printer.

Here's how to fix it:

Step 1: Get a CUPS server that uses libusb. There is a known incompatibility between kernel support for USB printers and CUPS's userspace support - and since SUSE has kernel support turned on, userspace support is turned off. Well, it just so happens that Android has no kernel support and needs userspace support.
You can either compile a fixed version of CUPS yourself (just add BuildRequires: libusb-1_0-devel to the spec file), or install from my repository.

Step 2: Give yourself rights to the USB device in question. Look into /dev/bus/usb and make sure that the CUPS user can access the device file (for the simplest solution, chmod 666 /dev/bus/usb/*/* - beware though, this gives every user on the system access to all USB devices, so, you know. Exercise caution.)

Step 3: Start up the CUPS service. service cups start

Step 4: Head over to http://localhost:631/ in tablet's browser, set up your printer, allow remote administration, printer sharing, whatever you choose.

Step 5: Print!