micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Raspbian usb printer server using p910nd

Fri Nov 09, 2012 2:22 pm

Hi all,
i've been messing around to get server printer functionality on raspbian using p910nd. Cups is a terrible overhead, and this small server is perfect for our tiny pi. My printer is a usb one, and I found that raspbian has no usblp.ko module, so no usb printer support in stock kernel (I'm using version 3.2.27+). Thus, kernel compilation is needed. To save time for those with the same kernel version and trusting me enough, here is the compiled module usblp.ko:

Code: Select all

sudo wget http://dl.dropbox.com/u/5684427/archives/usblp.ko -o /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
sudo depmod -a
I haven't tested this method, but should work.
A great resource of information on kernel compile for rasberrypi is: http://elinux.org/Rpi_kernel_compilation#Common
Compiling in rpi is a bit of a crazy idea, evenmore because configuring a crosscompiling environment is a matter of minutes. Those are the steps I used to compile usblp module (in a amd64 squeeze host):

1- Add emdebian repository to /etc/apt/sources.list:

Code: Select all

deb http://www.emdebian.org/debian squeeze main
2-Update package database and install emdebian signed keys:

Code: Select all

sudo apt-get update
sudo apt-get install emdebian-archive-keyring
3-Install the appropiate build environment

Code: Select all

sudo apt-get install git g++-4.4-arm-linux-gnueabi make ncurses-dev
4-Get latest kernel sources (takes quite some time)

Code: Select all

cd (It will download to user's home directory)
git clone --depth 1 git://github.com/raspberrypi/linux.git
5-From the pi, get kernel configuration and copy to build server

Code: Select all

sudo zcat /proc/config.gz > config
scp config USER@SERVER:BUILDIR/.config
Where USER and SERVER refers to the build server and BUILDIR is the path where you downloaded kernel sources (following the example, just "linux"). It can be done the other way around (scp'ing from the build server), depending on the accessibility of each machine.

6-Configure kernel compilation

Code: Select all

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
7- In kernel menuconfig, you have to select usb printer driver. It can be found under:

Code: Select all

Device Drivers--->USB Support--->USB Printer support
It is recommended to compile it as a module

8- Do the actual compilation

Code: Select all

make -j 6 ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k
The -j parameter set the concurrency level in compilation (how many parallel threads). It provides a dramatic decrease in compilation time. My machine is a 4-core one, so 6 is a reasonable number threads.

9- Install modules in local /tmp directory

Code: Select all

mkdir /tmp/modules
make ARCH=arm modules_install INSTALL_MOD_PATH=/tmp
10- Create a tar archive:

Code: Select all

cd /tmp/lib/modules/
tar cJf - * > ~/mod.tar
11- From raspberrypi, back up old modules, copy and extract modules tar file

Code: Select all

cd /lib/modules
sudo mv 3.2.27+ 3.2.27+.bk
sudo scp USER@SERVER:mod.tar ./
sudo tar xJf mod.tar
sudo chown -R root:root 3.2.27+
sudo rm mod.tar
12 - From raspberrypi, backup old kernel and install new one

Code: Select all

sudo mv /boot/kernel.img /boot/kernel.img.bk
sudo scp USER@SERVER:linux/arch/arm/boot/Image /boot/kernel.img
13 - Reboot raspberrypi

Code: Select all

sudo reboot
14 - Test module loading

Code: Select all

sudo modprobe usblp
You should see the following in last dmesg line:

Code: Select all

usbcore: registered new interface driver usblp
With the printer already attached to usb port, also a line similar to this:

Code: Select all

usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x04E8 pid 0x3301
That means everything went fine and usb printer support is now enabled! Now, lets do the real printing service configuration.

15 - Install p910nd server

Code: Select all

sudo apt-get install p910nd
16 - Edit p910nd config file, /etc/default/p910nd, With the following options

Code: Select all

P910ND_OPTS="-f /dev/usb/lp0"
P910ND_START=1
17 - Restart p910nd server

Code: Select all

sudo service p910nd restart
Now, printer should be ready to accept jobs.

18 - To access the network printer from a linux client, you need to configure CUPS to use raspberripy printer.
For that, access the url http://localhost:631 from the client computer. There click on “Administration”, and then “Add Printer”. You will prompted for password authentication. In network printers, select “AppSocket/HP JetDirect”. Fill the address text input with the following:

Code: Select all

socket://raspberrypi:9100
Where “raspberrypi” is either raspberripy ip address in you LAN, or its hostname (if configured /etc/hosts in your local client or in your router). If you don't know the IP of raspberrypi, issue ifconfig command to find out. Click next, choose a descriptive name for the printer, click next again, and finally choose the appropiate CUPS driver or pdd file for your printer and you're done! CUPS may prompt you some default options for your printer model, and then you can test if everything worked printing a test page.

19 - For windows clients, see openwrt wiki for detailled instructions:
http://wiki.openwrt.org/doc/howto/p910n ... 000xpvista
That's all. I hope you find it usefull.
Cheers.

ellepdesk
Posts: 1
Joined: Tue Nov 27, 2012 8:56 pm

Re: Raspbian usb printer server using p910nd

Tue Nov 27, 2012 8:59 pm

Small fix: wget -o saves the logfile, you'll want to use wget -O to save tha data

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Sat Dec 01, 2012 2:52 pm

Thanks for the postm i'd like to try it. I've had no end of trouble with CUPS feezing with my Canon MP800.

So if I were to use your pre-compiled core, after I get it, so I skip to step 12?

John

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Sat Dec 01, 2012 5:10 pm

Hi,
if you download the module linked in the first post, and running the same kernel version (3.2.27+), you can go directly to step 14.
Small fix: wget -o saves the logfile, you'll want to use wget -O to save tha data
Oops! You're right, thanks. It's a pity I cannot edit the post to fix it.

Cheers

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Mon Dec 03, 2012 1:02 am

Hello micerinos

No luck, I did the following

pi@raspberrypi ~ $ sudo wget http://dl.dropbox.com/u/5684427/archives/usblp.ko -o /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko

pi@raspberrypi ~ $ sudo depmod -a
ERROR: failed to load symbols from /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko: Exec format errorpi@raspberrypi ~ $ sudo modprobe usblp
ERROR: could not insert 'usblp': Exec format error

I tried re-booting too but I get the same error.

I checked that /lib/modules/3.2.27+ exists and it does.

Any tips?

John

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Mon Dec 03, 2012 4:21 pm

Hi Ewlie,
Could you please post the output of the following commands?
uname -a
dmesg | tail (after trying to load module usblp.ko)
modinfo /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko

Thanks.

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Tue Dec 04, 2012 6:00 am

Hi micerinos

Thanks for your help. Here is the log. I connected with SSH and sent the commands in that way.
I checked that /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko does exist at that location.

Thanks

Code: Select all

pi@raspberrypi ~ $
login as: pi
pi@pineapple's password:
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 29 22:02:41 2012 from 192.168.1.4
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
pi@raspberrypi ~ $ dmesg | tail
[    9.868060] bcm2835 ALSA chip created!
[    9.881321] bcm2835 ALSA chip created!
[    9.894693] bcm2835 ALSA chip created!
[    9.907916] bcm2835 ALSA chip created!
[    9.921059] bcm2835 ALSA chip created!
[    9.934524] bcm2835 ALSA chip created!
[   18.385576] bcm2835-cpufreq: switching to governor ondemand
[   18.385600] bcm2835-cpufreq: switching to governor ondemand
[   20.456620] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SS
[   84.730370] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
pi@raspberrypi ~ $ sudo wget http://dl.dropbox.com/u/5684427/archives/usblp.ko -o /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
pi@raspberrypi ~ $ sudo depmod -a
ERROR: failed to load symbols from /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko: Exec format error
pi@raspberrypi ~ $ dmesg | tail
[    9.868060] bcm2835 ALSA chip created!
[    9.881321] bcm2835 ALSA chip created!
[    9.894693] bcm2835 ALSA chip created!
[    9.907916] bcm2835 ALSA chip created!
[    9.921059] bcm2835 ALSA chip created!
[    9.934524] bcm2835 ALSA chip created!
[   18.385576] bcm2835-cpufreq: switching to governor ondemand
[   18.385600] bcm2835-cpufreq: switching to governor ondemand
[   20.456620] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SS
[   84.730370] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
pi@raspberrypi ~ $ modinfo /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
filename:       /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
ERROR: could not get modinfo from 'usblp': Exec format error

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Tue Dec 04, 2012 9:43 am

I see,
as ellepdesk pointed out before, you have to replace -o with -O in wget. Right now you're saving the log with the name usblp.ko, but not the module.

Cheers

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Wed Dec 05, 2012 3:11 am

Thanks!

Here is a complete log for anyone else who wants to do the same thing.

I've just been able to setup the printer in windows and hopefully soon on the mac.

Code: Select all

pi@raspberrypi ~ $ sudo wget http://dl.dropbox.com/u/5684427/archives/usblp.ko -O /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
--2012-12-05 10:53:57--  http://dl.dropbox.com/u/5684427/archives/usblp.ko
Resolving dl.dropbox.com (dl.dropbox.com)... 184.73.159.129, 107.20.162.164, 23.23.132.187, ...
Connecting to dl.dropbox.com (dl.dropbox.com)|184.73.159.129|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20737 (20K) [application/octet-stream]
Saving to: `/lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko'

100%[===================================================================================>] 20,737      31.5K/s   in 0.6s

2012-12-05 10:53:59 (31.5 KB/s) - `/lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko' saved [20737/20737]

pi@raspberrypi ~ $ sudo depmod -a
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
pi@raspberrypi ~ $ dmesg | tail
[  282.022959] usb 1-1.3: Manufacturer: Canon
[  282.022972] usb 1-1.3: SerialNumber: 11867B
[  282.037606] scsi0 : usb-storage 1-1.3:1.2
[  282.174902] usblp0: USB Bidirectional printer dev 9 if 1 alt 0 proto 2 vid 0x04A9 pid 0x170D
[  282.175052] usbcore: registered new interface driver usblp
[  283.032444] scsi 0:0:0:0: Direct-Access     Canon    MP800Storage     0106 PQ: 0 ANSI: 2
[  283.041839] sd 0:0:0:0: [sda] Attached SCSI removable disk
[  325.207405] usb 1-1.2: USB disconnect, device number 4
[  325.207435] usb 1-1.2.1: USB disconnect, device number 7
[  325.225645] usb 1-1.2.3: USB disconnect, device number 8
pi@raspberrypi ~ $ modinfo /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
filename:       /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko
license:        GPL
description:    USB Printer Device Class driver
author:         Michael Gee, Pavel Machek, Vojtech Pavlik, Randy Dunlap, Pete Zaitcev, David Paschal
srcversion:     EDA6416251AF7A5D79B44E5
alias:          usb:v04B8p0202d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v*p*d*dc*dsc*dp*ic07isc01ip03*
alias:          usb:v*p*d*dc*dsc*dp*ic07isc01ip02*
alias:          usb:v*p*d*dc*dsc*dp*ic07isc01ip01*
alias:          usb:v*p*d*dc07dsc01dp03ic*isc*ip*
alias:          usb:v*p*d*dc07dsc01dp02ic*isc*ip*
alias:          usb:v*p*d*dc07dsc01dp01ic*isc*ip*
depends:
intree:         Y
vermagic:       3.2.27+ preempt mod_unload modversions ARMv6
parm:           proto_bias:Favourite protocol number (int)
pi@raspberrypi ~ $ sudo modprobe usblp
pi@raspberrypi ~ $ sudo apt-get install p910nd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bc cups-client cups-filters cups-ppdc dc fonts-droid foomatic-db-compressed-ppds foomatic-db-engine foomatic-filters
  ghostscript ghostscript-cups gir1.2-glib-2.0 gsfonts hpijs hplip-data libart-2.0-2 libcupscgi1 libcupsdriver1
  libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libescpr1 libgirepository-1.0-1 libgs9 libgs9-common
  libgutenprint2 libhpmud0 libijs-0.35 libpaper-utils libpaper1 libperl5.14 libpoppler19 libsane-hpaio libsensors4 libslp1
  libsnmp-base libsnmp15 mscompress poppler-data poppler-utils printer-driver-all printer-driver-c2050 printer-driver-c2esp
  printer-driver-cjet printer-driver-escpr printer-driver-foo2zjs printer-driver-hpijs printer-driver-m2300w
  printer-driver-min12xxw printer-driver-pnm2ppa printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi
  python-dbus python-dbus-dev python-gi python-gobject-2 python-imaging python-pexpect python-renderpm python-reportlab
  python-reportlab-accel ssl-cert
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  p910nd
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 15.2 kB of archives.
After this operation, 76.8 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main p910nd armhf 0.95-1 [15.2 kB]
Fetched 15.2 kB in 1s (8,640 B/s)
Selecting previously unselected package p910nd.
(Reading database ... 63374 files and directories currently installed.)
Unpacking p910nd (from .../p910nd_0.95-1_armhf.deb) ...
Processing triggers for man-db ...
Setting up p910nd (0.95-1) ...
[warn] Not starting p910nd daemon. Please edit /etc/default/p910nd first. ... (warning).
pi@raspberrypi ~ $ sudo nano /etc/default/p910nd
pi@raspberrypi ~ $ sudo service p910nd restart
[ ok ] Restarting network print daemon: p910nd.
pi@raspberrypi ~ $

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Wed Dec 05, 2012 3:53 am

I'm not quite celebrating. It does not work on OSX :-(

I found a reference where it indicated you need guttenprint drivers, which i tried also but no luck. The http://mwolske.wordpress.com/2010/11/03 ... -printers/

iMac says it cant communicate with the printer.
as address I tried the IP with and without the port , ie 192.168.1.49:9100

It must be something on the mac end.

Thanks for your help

John

ewlie
Posts: 12
Joined: Tue Sep 25, 2012 1:31 pm

Re: Raspbian usb printer server using p910nd

Wed Dec 05, 2012 4:05 am

I take that back. It's now working with normal and gutten print MP800 drivers.
I had to restart the p910nd service. I think I had been messing with it too much.

Thanks very much for your help. :D :)

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Wed Dec 05, 2012 7:38 pm

Glad you managed to make it work.
Enjoy your rasprinterserver! :)

pjtewkesbury
Posts: 2
Joined: Thu Dec 20, 2012 8:04 pm

Re: Raspbian usb printer server using p910nd

Thu Dec 20, 2012 8:11 pm

Hi,

I an trying to download the p910nd driver that you have compiled, but the command

sudo wget http://dl.dropbox.com/u/5684427/archives/usblp.ko -O /lib/modules/3.2.27+/kernel/drivers/usb/class/usblp.ko

keeps giving the following error

--2012-12-20 20:10:07-- http://dl.dropbox.com/u/5684427/archives/usblp.ko
Resolving dl.dropbox.com (dl.dropbox.com)... 23.21.218.127
Connecting to dl.dropbox.com (dl.dropbox.com)|23.21.218.127|:80... connected.
HTTP request sent, awaiting response... 404 NOT FOUND
2012-12-20 20:10:07 ERROR 404: NOT FOUND.

Is the download still OK?

Thanks for posting.

Peter

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Fri Dec 21, 2012 10:23 am

Hi,
sorry, I reorganized my public folder. Here is a new link for the file:

http://dl.dropbox.com/u/5684427/misc/usblp.ko

cep33920
Posts: 2
Joined: Thu Jan 31, 2013 9:37 pm

Re: Raspbian usb printer server using p910nd

Thu Jan 31, 2013 9:40 pm

Nice tuto !
If someone need same module for 3.6.11+ kernel email me ( i'm a noob on online file sharing...)

webwizard
Posts: 5
Joined: Sat Mar 16, 2013 11:10 pm

Re: Raspbian usb printer server using p910nd

Sat Mar 16, 2013 11:19 pm

cep33920 wrote:Nice tuto !
If someone need same module for 3.6.11+ kernel email me ( i'm a noob on online file sharing...)
Yep, I'd like to have the module for 3.6.11+. May you upload it as an attachment ?

setijo
Posts: 1
Joined: Tue Apr 23, 2013 9:03 am

Re: Raspbian usb printer server using p910nd

Tue Apr 23, 2013 9:06 am

If someone need same module for 3.6.11+ kernel
email me / save to dropbox

amccloud
Posts: 2
Joined: Sun Apr 28, 2013 5:46 pm

Re: Raspbian usb printer server using p910nd

Sun Apr 28, 2013 5:49 pm

I would also like the 3.6.11+ usblp kernal module.

Can share the file with https://letscrate.com/


totaluser
Posts: 9
Joined: Sat Dec 01, 2012 9:52 pm

Re: Raspbian usb printer server using p910nd

Wed May 01, 2013 8:57 am

amccloud wrote:Here it is for 3.6.11+

https://www.dropbox.com/s/fh60hnk7umx8rlw/usblp.ko
thank you very much
you saved me from recompiling it myself

andrum99
Posts: 373
Joined: Fri Jul 20, 2012 2:41 pm

Re: Raspbian usb printer server using p910nd

Sun Jun 02, 2013 12:53 pm

amccloud wrote:Here it is for 3.6.11+

https://www.dropbox.com/s/fh60hnk7umx8rlw/usblp.ko
Big thanks from me too! In case anyone else is struggling with a printer that uses foo2zjs, I have written up the procedure for getting it working on my blog:

http://andrum99.blogspot.co.uk/2013/06/ ... inter.html

Cheers

Andrew.

el_jefe
Posts: 2
Joined: Mon Jun 10, 2013 2:08 pm

Re: Raspbian usb printer server using p910nd

Mon Jun 10, 2013 2:24 pm

Thank you very much!

zia_7575
Posts: 11
Joined: Thu Oct 18, 2012 6:39 am

Re: Raspbian usb printer server using p910nd

Wed Jan 22, 2014 2:55 pm

Hey everyone,

I am unable to download the usblp.ko for 3.6.11+ from dropbox. I am very thankful, if anyone shares the file with me.
Meanwhile, I tried to recompile the kernel and driver by myself. Everything goes smooth but usblp.ko is not present in modules/.... /usb/class folder. Can anyone help me with this ?

micerinos
Posts: 74
Joined: Fri Nov 09, 2012 11:15 am
Location: Madrid, Spain

Re: Raspbian usb printer server using p910nd

Wed Jan 22, 2014 5:43 pm

Hi,

it seems that this problem was solved by kernel packagers last June. See:

https://github.com/raspberrypi/linux/issues/253

I can't help you with the file you mention, but newer versions of raspbian bundle the usblp module, thus solving this automatically. Also, you could try upgrading the kernel and firmware files (with rpi-config or raspi-config, I can't remember exactly). This should keep untouched all your not-kernel-related customizations to raspbian.

Hope it helps

praj
Posts: 1
Joined: Fri Oct 16, 2015 5:45 am

Re: Raspbian usb printer server using p910nd

Fri Oct 16, 2015 5:47 am

Is it possible to create a own filter with this?

Return to “Advanced users”

Who is online

Users browsing this forum: DougieLawson, SlowBro and 28 guests