Tuesday, March 5, 2013

[Tutorial] Apple AirPrint on TomatoUSB Router


In this tutorial, I'm going to show you how to setup Apple AirPrint Server on a router running TomatoUSB firmware. This will allow you to print from your iOS device (iPhone, iPod, iPad) to your non-AirPrint-enabled printer through your router. If you're familiar with AirPrint Activator or FingerPrint, this solution is similar, except you don't have to keep your power hungry MAC/PC running 24/7.

Before I start, I want to give special thanks to @davygravy on the TomatoUSB.org forum. He was the one that ultimately made this all possible by compiling, re-compiling and fixing all the required packages.

Another thing, if you're familiar with my Tutorial on Apple AirPlay on TomatoUSB Router, these two tutorials (currently) are not compatible with each other. Meaning, you either go with AirPrint or AirPlay on your TomatoUSB Router, NOT BOTH. This is because the AirPrint tutorial uses Entware and this tutorial uses Optware, which isn't compatible with each other. Hopefully we're get this issue resolved in the near future.

Note: this tutorial is a work in progress (but working). I'll be updating and flushing out the details as time permits. Please excuse the typos and bad grammar.

YMMV (Your Mileage May Vary) depending on your Printer model.

What you'll need:

  1. Router with TomatoUSB installed*
  2. USB Flash Drive >1GB (will be completely wiped)
  3. USB or Wireless/Network Printer
* If you're looking for a recommendation on a router for this project,  please check this post - [Tutorial] Apple AirPlay on TomatoUSB Router. You can pick up a router as low as $24.

Outline of Steps:

  1. Partition and Format USB Flash Drive*
  2. Install Optware
  3. Download and Install Required Packages
  4. Start CUPS and Configure Printer(s)
  5. Generate AirPrint Service File
  6. Startup DBus, Avahi and CUPS
  7. Test Print
  8. Configure the router so that everything works after a reboot
  9. CloudPrint (Bonus Content)

*Note that your USB Flash Drive will be completely wiped clean.


1) Partition and Format USB Drive:

Plug in your USB drive and connect to your router via SSH (Putty) and execute the following commands:

#Partition your usb flash drive 
umount /dev/sda1
fdisk /dev/sda

Type in the following commands to create a primary partition on your USB Flash drive
# p # list current partitions
# o # to delete all partitions
# n # new partition
# p # primary partition
# 1 (one) # first partition
# <enter> # default start block
# <enter> # default end block #use the whole flash drive
# w # write new partition to disk


#format newly created partition
#label disk as 'optware' case sensitive
umount /dev/sda1
mke2fs -j -L optware /dev/sda1

#mount partition as /opt

mount /dev/sda1 /opt

#Make sure /opt is properly mounted on a reboot.
echo "LABEL=optware /opt ext2 defaults 1 1" >> /etc/fstab
nvram setfile2nvram /etc/fstab
nvram commit


2) Install Optware

#Install Optware from scratch. 
#Assumes drive is formated and mounted as /opt already
cd /tmp
wget http://tomatousb.org/local--files/tut:optware-installation/optware-install.sh -O - | tr -d '\r' > /tmp/optware-install.sh
chmod +x /tmp/optware-install.sh
sh /tmp/optware-install.sh

3) Download and Install Required Packages

#create a folder to store packages

mkdir -p /opt/ipkgs
cd /opt/ipkgs

#download packages. 

#cut/paste this whole section
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/dbus_1.2.16-2_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/cups_1.5.4-1_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/poppler_0.12.4-1_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/py26-cups_1.9.62-1_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/ghostscript_8.71-3_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/hplip_3.11.7-1_mipsel.ipk
wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/gutenprint_5.2.9-1_mipsel.ipk

wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/cups-driver-gutenprint_5.2.9-1_mipsel.ipk

#install packages. this may take awhile. 

#cut/paste this whole section
ipkg install /opt/ipkgs/dbus_1.2.16-2_mipsel.ipk
ipkg install /opt/ipkgs/cups_1.5.4-1_mipsel.ipk
ipkg install /opt/ipkgs/poppler_0.12.4-1_mipsel.ipk

ipkg install /opt/ipkgs/py26-cups_1.9.62-1_mipsel.ipk
ipkg install /opt/ipkgs/ghostscript_8.71-3_mipsel.ipk
ipkg install /opt/ipkgs/gutenprint_5.2.9-1_mipsel.ipk
ipkg install /opt/ipkgs/cups-driver-gutenprint_5.2.9-1_mipsel.ipk

#install hplip if you have a HP printer
#ipkg install /opt/ipkgs/hplip_3.11.7-1_mipsel.ipk


#install splix for Samsung printers
#ipkg install splix

#Color profiles for Samsung (untested)
#cd /opt/share/cups/model/samsung
#wget http://splix.ap2c.org/samsung_cms.tar.bz2
#tar xvjf samsung_cms.tar.bz2
#rm samsung_cms.tar.bz2



4) Start CUPS and Configure Printer(s)

#start cups
cupsd

Now open up your web browser and go to http://<RouterIPAddress>:631/admin (http://192.168.1.1:631/admin).

Click on "Manage Printers"->"hp990c"
Administration->Delete Printer (this printer was accidentally included)
If you're prompted for authentication, enter in root and your password.

Go back to Administration->Add Printer

In my case, I am using a Brother HL-2270DW which has built in wireless and supports various printing options - socket, ipp, http, etc. I'm going to use socket (AppSocket/HP JetDirect) which is the same option you would select if you had your USB printer directly connected to your router. Make sure you enable "USB Printer Support" in the Tomato GUI if you're using a USB attached printer.

For my wireless printer, the Connection address I'm using is "socket://<PrinterIPAddress>:9100" ( for the record "ipp://<PrinterIPAddress>/pcl_p1" would also work).

For a USB attached printer, the Connection address would be: "socket://<RouterIPAddress>:9100" (i.e., socket://192.168.1.1:9100)

Name your printer. Check the "Share This Printer" checkbox (not totally sure if this is required, but for now check it to be safe).

Select the Make/Model of your Printer. Basically you are selecting the drivers to use. For my Brother HL-2270DW, I went with "Generic"->"Generic PCL 6/PCL XL Printer".

Click Add Printer.

Set your Default Options.

Print a test page. Maintenance->Print Test Page.

Printing a test page needs to work. If not, you can not continue. Not all printers will work. Try different drivers (or a different printer).

5) Generate AirPrint Service File

Back in your SSH console session, execute the following:

#Stop CUPS
killall cupsd

#create some needed mime types for AirPrint and iOS6
echo "image/urf urf string(0,UNIRAST<00>)" > /opt/share/cups/mime/airprint.types


echo "image/urf application/pdf 100 pdftoraster" > /opt/share/cups/mime/airprint.convs

#Start CUPS
cupsd

#make airprint folder

mkdir -p /opt/airprint
cd /opt/airprint

#install wget-ssl (for https)
ipkg install wget-ssl

#Download airprint-generate.py
#this is all one line
/opt/bin/wget --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py

#set the script to be executable
chmod 755 ./airprint-generate.py

#Generate airprint service file
cd /opt/etc/avahi/services
python2.6 /opt/airprint/airprint-generate.py

#There should be a
#AirPrint-<PrinterName>.service file listed
ls

#Stop CUPS
killall cupsd


6) Startup DBus, Avahi (aka Bonjour) and CUPS

#Required for Avahi and dbus
#Ignore the warning
adduser avahi
addgroup netdev

#delete orphan pid files in case they exist
rm /opt/var/run/dbus/pid

rm /opt/var/run/avahi-daemon/pid

#start dbus before avahi
/opt/etc/init.d/S20dbus start

#start avahi (aka bonjour)
avahi-daemon -D

#Start CUPS
cupsd

#verify that your printer is being advertise
avahi-browse --terminate --resolve _ipp._tcp



7) Test Print

From your iPhone/iPad/iPod, do a test print.

8) Configure the router so that everything works after a reboot

Go to USB and NAS -> USB Support (http://192.168.1.1/nas-usb.asp).
In the "Run after mounting" section add the following:


#Required for avahi and dbus
adduser avahi
addgroup netdev

#delete orphan pid files in case they exist
rm /opt/var/run/dbus/pid

rm /opt/var/run/avahi-daemon/pid

#start dbus before avahi
/opt/etc/init.d/S20dbus start

#start avahi (aka bonjour)

avahi-daemon -D

#Start CUPS
cupsd


In the "Run before unmounting" section add the following:

#run before unmounting
killall cupsd
avahi-daemon -k
/opt/etc/init.d/S20dbus stop


You're done. Enjoy!

9) Google CloudPrint (Bonus Content - Work In Progress)

ipkg install git
cd /opt

git clone git://github.com/armooo/cloudprint

cd /opt/cloudprint
python2.6 setup.py build
python2.6 setup.py install

#Run once to create credential files
#give it about a minute to start up
/opt/local/bin/cloudprint

#enter your google account email and password
#Google username:
#Password:

#test print from your Chrome browser
#Control+C to close cloudprint

#copy your cloudprint authentication files to /opt
cp /tmp/home/root/.cloudprintauth /opt/cloudprint
cp /tmp/home/root/.cloudprintsaslauth /opt/cloudprint


To have cloudprint start automatically on reboot. Go to USB and NAS -> USB Support (http://192.168.1.1/nas-usb.asp). In the "Run after mounting" section add the following:

#copy back cloudprint authentication files to /tmp
cp /opt/cloudprint/.cloudprintauth /tmp/home/root/ 
cp /opt/cloudprint/.cloudprintsaslauth /tmp/home/root/
/opt/local/bin/cloudprint &

In the "Run before unmounting" section add the following:

killall cloudprint

Cloudprint is very fragile. If you're having start-up or printing issues try the following steps.

- Clear your Google CloudPrint Print Queue - https://www.google.com/cloudprint/#jobs
- Delete your stored credential and reboot and start over.

One more thing regarding CloudPrint, my recommendation is to set up a new Google Account dedicated just for CloudPrint. Use this account for the above cloudprint login, and then share your printer(s) with your main account. I'm a little paranoid of having my email authentication stored on my router (even though its hashed or whatever).

If you get AirPrint working with your printer, please leave a comment with your printer model and drivers used. This will help other users. Thanks

Please leave a comment with any questions or feedback. Thanks


[Update 4/9/2013] Please check out my PogoPlug Tutorial below. A PogoPlug running Arch Linux ARM is the perfect companion to your TomatoUSB Router. I highly recommend that you run AirPlay/AirPrint on the PogoPlug versus your TomatoUSB router.

[Tutorial] - PogoPlug E02 with Arch Linux ARM - NAS (Samba4), AirPlay, AirPrint, Google CloudPrint

83 comments :

  1. Hi,

    When I go to download the packages, I am getting the error.

    onnecting to dl.dropbox.com (107.21.253.161:80)
    wget: can't open 'dbus_1.2.16-2_mipsel.ipk': Read-only file system

    any idea why??

    Thanks.

    ReplyDelete
    Replies
    1. Brett, doesn't sound like you are in the right directory.

      Note the following two commands before the wget.

      #create a folder to store packages
      mkdir /opt/ipkgs
      cd /opt/ipkgs

      You should be downloading to /opt/ipkgs

      Delete
  2. Hi,

    So, I definitely went through the steps again. Everything was as is, yet it didn't download...same error. I tried removing and recreating the dir, and then I decided to check the wget parameters. For whatever reason when I executed the mkdir/cd commands it just wouldn't do it. No errors, it seemed to change, but didnt. I used the -P flag and manually stated the dir and that seemed to work.

    ReplyDelete
    Replies
    1. Strange. You shouldn't need the -p option since the /opt directory should already exist. I went ahead and updated the tutorial and added the -p, since it doesn't hurt anything to use it. Thanks for letting me know.

      Delete
  3. Hi again,

    I am now stuck in the CUPS config. It will not accept the credentials to add/delete a printer. I have tried 2 browsers and cleared the cache/stored data/pw's etc. Any idea whats going on?

    Thanks,
    Brett

    ReplyDelete
    Replies
    1. No idea. The username (root) and password should be the same as what you used to access the Tomato GUI via your web browser and SSH. I'll upload a full ssh console output in the next couple of days so you can compare. I might even make a YouTube video of the process. Please keep me updated on your progress. Thanks

      Delete
    2. You probably have SSH login via password disabled.

      Delete
  4. Hi,

    So, I have not ideas as to how to move forward. I dont know why it will not accept the user name as root, and my router password. Ive tried changing the password as well in the router. stuck at this cups page :/

    Bret

    ReplyDelete
    Replies
    1. Hey Brett,

      Sorry to hear you're still not able to get AirPrint working. I experienced this exact issue on my journey to getting AirPrint working. Never was able to resolve it and just blame it on a bad build of CUPS.

      I can't say for certain what causing your issue, but I do know that the tutorial works if you start from step 1. Did you start from step 1 or did you already have a pre-existing optware installation?

      If you started from step 1, try restoring the default configuration and starting fresh. Erase all data in NVRAM memory (thorough) @ http://192.168.1.1/admin-config.asp

      Hang in there, we'll figure it out.

      You can also contact me via email .

      Delete
  5. When I run the line
    avahi-browse --terminate --resolve _ipp._tcp
    there is no output at all.
    I can print test page from the cups interface but iPad doesnt detect the printer.

    ReplyDelete
    Replies
    1. Sorry, there was a run-on command in step 5 (Generate AirPrint Service File), which I just fixed. Please re-do step 5 and verify that a AirPrint-.service file exist in the /opt/etc/avahi/services folder. Please keep me updated. Thanks.

      Delete
    2. .service file exists!
      ipad detects printer too.
      Printer queue is however stuck saying

      " processing since
      Thu Mar 14 21:41:48 2013
      "Processing page 1...""

      Delete
    3. When I manually deleted the job the file printed succesfully. :S

      Delete
    4. Maybe trying giving it a little more time? Not sure.

      Delete
    5. cancelling the job doesnt help anymore. it just remains stuck at processing page 1

      Delete
    6. no longer prints at all
      just says "pending since
      Fri Mar 15 00:09:39 2013 "

      Delete
    7. I fixed the problem by changing the generic driver to hp driver for my printer model !
      Still prints agonizingly slowly. Hope to fix that too.

      Delete
    8. Thanks for the update. This is good to know for other users that may experienced this issue.

      Delete
  6. Hi,

    I am giving this a go again starting from scratch. Although, everything up to the CUPS server worked, I am trying a different machine using putty instead of my Mac's terminal interface....I will update you with my results.

    Brett

    ReplyDelete
  7. Hi,

    I believe I have everything worked out. One thing I that was left unmentioned is that it seems you need to have either a usb hub or two usb ports for this to work, am I correct? unplugging the flash drive to plug in the printer loses all of the software...

    ReplyDelete
    Replies
    1. Hey Bret, glad to hear you got it working. Yeah, you can't unplug the flash drive :). If you have a regular usb attached printer, yes, you will need a router with two usb ports or a usb hub. In my case, I'm printing to a wireless network printer, so I would only need one usb port for the flash drive. -Qui

      Delete
  8. Hi,
    I have a samsung clx-3180 printer. I followed the instructions, but unable to print the Test page. During installation, I did not get any error during installation. When I do a test print, my printer give print success sound without printing any pages. What could be wrong? Any help will be appreciated.

    thanks
    Ajay

    ReplyDelete
    Replies
    1. Hi Ajay,

      What print drivers are you using? From what I understand, Samsung use proprietary printing language. Try installing splix (ipkg install splix) and using a driver that closely matches your printer (clx-3160). Let me know if you get further. YMMV regarding printers.

      Qui

      Delete
    2. When I run ipkg install splix, I get error - package not found. Where do I need to download it? How to download it? thanks

      Delete
    3. Hi,
      I got this package installed, but now when I do a test print, I am getting message ""SpliX Cannot open CMS file /opt/share/cups/model/samsung/cms/CLX-3160cms (2)" and nothing is getting printed. Any idea?

      thanks

      Delete
    4. Ajay,

      Take a look at this http://www.openprinting.org/driver/splix/. Sounds like you need some "color profiles". Not sure how/where you would get them. My suggestion is to try a black/white driver. Color at this point is probably not possible.

      Qui

      Delete
    5. "Color printers needs color profile files to get better results. These
      files are provided by your printer manufacturer and you have to install them
      manually. To do that, download the linux official drivers and locate the "cms"
      directory." - So it sounds like you can try to download and extract these color profiles from the official linux driver and place them in the /opt/share/cups/model/samsung/cms/CLX-3160cms folder. Worth a shot.

      Delete
    6. I think you might be in luck. Try the following set of commands:

      cd /opt/share/cups/model/samsung
      wget http://splix.ap2c.org/samsung_cms.tar.bz2
      tar xvjf samsung_cms.tar.bz2
      rm samsung_cms.tar.bz2

      Delete
    7. Thanks Qui. I got the error message taken care of. But no test page yet. In the status page, it says Printing is successful, but nothing is printed from the printer. Is it possible that CLX-3160 is not compatible with CLX-3180?

      thanks
      Ajay

      Delete
    8. Yes. Try a different driver (B/W only).

      Delete
    9. Qui,
      I tried all the driver, but test page is not getting printed. In the CUPS admin screen, it says Successful but nothing is printing. Any idea?
      thanks
      Ajay

      Delete
  9. Hi,
    Excelent tutorial. Thanks!
    Only difficulty i have when printing pages with rasters from iOS is:
    /opt/lib/cups/filter/pstoraster failed
    Befor that I can see something like this in the cups log:
    width = 4800, height = 6639
    PageSize = [ 595 841 ], HWResolution = [ 600 600 ]
    Which seems strange, as I only try to print from iOS's Notes.
    In the router's log:
    prnt/hpcups/HPCupsFilter.cpp 511: cupsRasterOpen failed, fd = 0

    ReplyDelete
    Replies
    1. Did you test page print okay? What's your printer model and what driver have you tried? Try a different driver.

      Delete
  10. Test page went okay. The printer is a multifunction device HP Deskjet F300 Series and the driver się from hplip, the hpcups version. Other drivers don't work at all.
    My router is ASUS RT-N16 with Tomatousb 1.28 with optware of course.

    As I said printing simple text or simple webpages from iOS works well, the problem occurs while trying to print put of Notes or something with big images or background. Maybe a problem with memory or rescaling?

    ReplyDelete
    Replies
    1. I think I might have this exact printer at home somewhere. Not sure if it has any ink, but if I have some time this weekend I'll give it a test.

      Delete
    2. Hi,
      Any chance on testing this? :)
      I've done some trials. For this particular printer there are two drivers: hpcups and hpijs. The hpijs doesn't work at all (error on testpage print). The hpcups works while printing test page from cups webpage, but doesn't work while printing from iOS.
      Bottom lines I'm still stuck with this error.

      Delete
  11. thanks for the tutorial. I have ASUS RT-N16. Followed your instructions. I am able to print test page, but can't start google cloud print:

    Tomato v1.28.9054 MIPSR2-beta K26 USB Ext
    root@router:/tmp/home/root# /opt/local/bin/cloudprint
    Traceback (most recent call last):
    File "/opt/local/bin/cloudprint", line 8, in
    load_entry_point('cloudprint==0.9', 'console_scripts', 'cloudprint')()
    File "build/bdist.linux-mips/egg/cloudprint/cloudprint.py", line 418, in main
    RuntimeError: failed to connect to server

    Any suggestion?

    ReplyDelete
    Replies
    1. Hello Soleen,

      Line 418 - cups_connection = cups.Connection()

      Doesn't sound like you have CUPS running.

      Qui

      Delete
    2. Hi Qui,

      It worked! I restarted cupsd and cloudprint started fine! Thanks again for the great tutorial!

      Delete
  12. I got Airprint working but I can only print in B/W !! How do I print in color? I have an HP printer

    ReplyDelete
    Replies
    1. Try a different driver and let us know if you get it working :)

      Delete
  13. Hi Qui, thanks for this tutorial.
    Everything seemed to work out ok and I started cupsd, but when i visit the CUPS admin page, it get Internal Server Error.
    I can visit the CUPS homepage fine, just not any of the tabs, like admin, printers, etc.
    Have you seen this before?
    (i did not start from a clean install, as I had tomato set up already, with transmission already running)

    ReplyDelete
    Replies
    1. @schmichael,

      Hard to say what the issue is. Might be easier if you started from a clean install and re-configure transmission (backup your transmission config).

      If you go this route I would recommend running Shibby's AIO TomatoUSB version, which is what I'm using on my Asus RT-N16 acting as my primary router and has Transmission client built right into the firmware with a nice Web Interface to config it.

      http://tomato.groov.pl/download/K26/build5x-108-EN/tomato-K26USB-1.28.RT-MIPSR2-108-AIO.trx

      Delete
  14. Hi everyone,
    I've followed the instructions to get CUPS working with my Brother HL-2140 printer to work on my RT-N16, but I'm getting stuck at the test page part.

    I've tried several drivers, including the generic ones for PCL 5e and those for Brother alternatives. Most of those drivers start the printer for a few seconds, but then nothing actually prints. I've also tried using the PPD from OpenPrinting.org (www.openprinting.org/printer/Brother/Brother-HL-2140).

    In the process of trying to get the PPD driver working, I've also had to install foomatic-rip (using hpijs package) and perl, which installed fine. Now I'm running into a situation where the print job renderer (KID4) is logging the following error:

    D [05/Jan/2010:09:07:06 -0800] [Job 3] sh: gs: command not found

    Some Google searching (http://mybookworld.wikidot.com/forum/t-144918/cups-problems) revealed the following solution (#3 on the reply post):

    3) Also, gs was not linked in /usr/bin, since I found the following in the logs:
    D [05/Jan/2010:09:07:06 -0800] [Job 3] sh: gs: command not found
    So I created the missing link to gs in the /usr/bin
    #ln -s /opt/bin/gs /usr/bin/

    However, I cannot create the symlink in /usr/bin/ because it's read only.

    Anybody know a solution for creating this symlink for gs in /usr/bin/? Thanks in advance.

    ReplyDelete
    Replies
    1. Sorry for the late reply. Tomato's file system is read only. Did you ever get the HL-2140 working? Most likely its the drivers. I'm surprise the generic PCL drivers are not working. I don't think the foomatic-rip included in hpijs package is compatible with all the other packages..

      Delete
  15. I get a 404 for one of the files :

    wget http://dl.dropbox.com/u/42238/TomatoUSB/Optware/gutenprint_5.2.9-1_mipsel.ipkwget
    Connecting to dl.dropbox.com (54.243.118.43:80)
    wget: server returned error: HTTP/1.1 404 NOT FOUND

    I'm not sure if it will be required, but I'm guessing it will.
    I copy and pasted the link, I don't think I missed a character ?

    ReplyDelete
  16. I found the problem. The wget from the next line is appended : http://dl.dropbox.com/u/42238/TomatoUSB/Optware/gutenprint_5.2.9-1_mipsel.ipkwget

    Should be :

    http://dl.dropbox.com/u/42238/TomatoUSB/Optware/gutenprint_5.2.9-1_mipsel.ipk wget

    ReplyDelete
  17. Is it necessary to have a flash drive greater than 1GB? I have multiple 1GB drives lying around unused. Will those work?

    ReplyDelete
    Replies
    1. Maybe. I'm not sure if everything will fit. Give it a try.

      Delete
  18. I had some trouble printing a test page for a Canon MX870 printer, until I found the following link:
    http://forums.linuxmint.com/viewtopic.php?f=51&t=28486

    I believe the necessary command lines were:

    cd /opt/ipkgs
    ipkg install optware-devel
    ipkg install buildroot
    ipkg install cups-dev
    wget http://downloads.sourceforge.net/project/cups-bjnp/cups-bjnp/1.2.1/cups-bjnp-1.2.1.tar.gz
    gunzip cups-bjnp-1.2.1.tar.gz
    tar -xvf cups-bjnp-1.2.1.tar
    cd cups-bjnp-1.2.1
    ./configure
    make install

    Then go back to "http://:631/admin".
    Add printer, choosing ipp and address bjnp://

    ReplyDelete
    Replies
    1. Yeah!! This^^ helps!
      Now i can print a test page with my Canon MP640...

      Thx

      Delete
  19. Awesome guide. Got everything to work. However, printing is unbelievably slow. Any log files I should be looking at?

    ReplyDelete
    Replies
    1. I changed default options in the server to a lower DPI and the speed got better. This is only when printing from iOS because you can't set printer options and it uses defaults.

      Printer: Canon MP180

      Delete
    2. Thanks for the feedback. Glad you got it working. Did you have compile and install the cups-bjnp package to get your Canon MP180 to work?

      Yeah, these routers with their MIPS processors are very slow. If you want a little more speed/power, consider picking up a PogoPlug.

      Delete
  20. I can print a test page from CUPS and my ipad sees the printer. However, it won't print anything. The CUPS page shows no indication of receiving a job either.

    Is there something I'm missing? Thank you so much for this tutorial.

    ReplyDelete
    Replies
    1. Not sure. Check the CUPS logs to see if the AirPrint job even makes it to CUPS. What model printer? Just curious.

      Delete
    2. If I wait, a double sided option appears. Turning double sided off gets the job to CUPS and it does print.

      Also, I'm using a Brother HL4150cdn with a brother 4050 cups driver.

      Delete
    3. Glad to hear you got it working. Yeah, I don't think duplexing works.

      Delete
  21. Hello,
    I have a HP Laserjet m1136 printer. I tried all the drivers and even the generic ones, but the test page does not print. I get this error : "/opt/lib/cups/filter/hpcups failed". Any help?

    ReplyDelete
    Replies
    1. Sorry, sounds like a driver issue. My only recommendation would be to try a different printer.

      Delete
  22. Is there a way to add the foo2qpdl driver to tomato?

    ReplyDelete
  23. I got

    wget: bad address 'ipkg.nslu2-linux.org'

    is that ok??

    ReplyDelete
    Replies
    1. Full log:

      root@tomatoRAF:/tmp# sh /tmp/optware-install.sh
      Checking system config ...
      Using 171.97.62.1 as the default gateway.
      Using the following nameserver(s):
      nameserver 127.0.0.1
      Installing package uclibc-opt_0.9.28-13_mipsel.ipk ...
      Some newer versions of DD-WRT does not show download progress bar,
      so just be patient - or check STATUS -> BANDWIDTH tab for download
      activity in your routers Web-GUI, and then still wait a minute or two.
      wget: bad address 'ipkg.nslu2-linux.org'
      tar: can't open '/tmp/uclibc-opt_0.9.28-13_mipsel.ipk': No such file or directory
      tar: can't open '/tmp/control.tar.gz': No such file or directory
      tar: can't open '/tmp/data.tar.gz': No such file or directory
      Installing package ipkg-opt_0.99.163-10_mipsel.ipk ...
      Some newer versions of DD-WRT does not show download progress bar,
      so just be patient - or check STATUS -> BANDWIDTH tab for download
      activity in your routers Web-GUI, and then still wait a minute or two.
      wget: bad address 'ipkg.nslu2-linux.org'
      tar: can't open '/tmp/ipkg-opt_0.99.163-10_mipsel.ipk': No such file or directory
      tar: can't open '/tmp/control.tar.gz': No such file or directory
      tar: can't open '/tmp/data.tar.gz': No such file or directory
      /tmp/optware-install.sh: line 102: /opt/sbin/ldconfig: not found
      /tmp/optware-install.sh: line 103: /opt/bin/ipkg: not found
      /tmp/optware-install.sh: line 104: /opt/bin/ipkg: not found
      /tmp/optware-install.sh: line 105: /opt/bin/ipkg: not found

      Delete
    2. Solved!!

      Changed DNS to 8.8.8.8 and 8.8.4.4

      Delete
  24. Hi,
    I followed it to letter and got the print page as well from CUPS.
    The Airprint*.service xml has also been created and I can see it publishes as below
    --------------------------------------------------------------------------------------
    root@Tomato:/opt/etc/avahi/services# avahi-browse --terminate --resolve _ipp._tcp
    + br0 IPv4 AirPrint Epson-NX420 @ Tomato _ipp._tcp local
    = br0 IPv4 AirPrint Epson-NX420 @ Tomato _ipp._tcp local
    hostname = [Tomato.local]
    address = [192.168.2.1]
    port = [631]
    txt = ["pdl=application/octet-stream,application/pdf,application/postscript,application/vnd.cups-raster,image/gif,image/jpeg,image/png,image/tiff,text/html,text/plain,application/vnd.cups-banner,application/vnd.cups-command,application/vnd.cups-pdf" "printer-type=0x80900c" "printer-state=3" "product=(GPL Ghostscript)" "note=Epson inkjet printer NX420" "rp=printers/Epson-
    NX420" "URF=none" "Transparent=T" "qtotal=1" "txtvers=1"]
    --------------------------------------------------------------------------------------
    However my Iphone( IOS7 ) nor ipod(IOS6) are not abel to find the printer.
    what should be done.

    ReplyDelete
    Replies
    1. FYI.. I did this on Belkin Share N300 router

      Delete
    2. Not sure why you're not seeing the printer. Can I assume this is your only router?

      Delete
    3. Anything other information you may be leaving out that is relevant? Did you really follow the tutorial exactly from start to finish? Running Shibby's version of TomatoUSB, etc?

      Just so we're clear, I meant to ask if this was your only router on your network. I noticed the IP of the router is set to 192.168.2.1, which isn't the default so I had to ask.

      Have you completed step 8 and rebooted?

      Delete
    4. Yes, i followed it word by word. and Yes I have only 1 router. I can still print well from CUPS.
      have tried Rebooting Router( and veryfied using "avahi-browse --terminate --resolve _ipp._tcp") and iphone5.
      still no luck. Yes my router is set to 192.168.2.1, should i try to default it to 192.168.1.1

      Delete
    5. I was playing with it while reading - http://ubuntuforums.org/showthread.php?t=2060594 and then rebooted the router and voila, it got up.. can see it in my Iphone now..( Not sure if i made any significant change, so ur instructions are stil golden)
      its different story that each job fails with this error "/opt/lib/cups/filter/pstoraster failed". looking in cups folder I do not see any pstoraster at all :-)

      Delete
  25. This comment has been removed by the author.

    ReplyDelete
  26. Hi Qui
    While I can start cloudprint manually from a telnet session but I'm having trouble to get it to start automatically after the router reboots, power flash etc. I tried this script in USB NAS script as suggested but cloudprint does not start. I can see cupsd and ahavi but no cloudprint with ps|tail and no log files record either. I tried to move the script to admin firewall but that does not work either.

    My startup script reads
    #Required for avahi and dbus
    adduser avahi
    addgroup netdev

    #delete orphan pid files in case they exist
    rm /opt/var/run/dbus/pid
    rm /opt/var/run/avahi-daemon/pid

    #start dbus before avahi
    /opt/etc/init.d/S20dbus start

    #start avahi (aka bonjour)
    avahi-daemon -D

    #Start CUPS
    cupsd
    copy back cloudprint authentication files to /tmp
    cp /opt/cloudprint/.cloudprintauth /tmp/home/root/
    cp /opt/cloudprint/.cloudprintauth.sasl /tmp/home/root/
    /opt/local/bin/cloudprint &

    Please help.
    Frank Hull
    PS you need to correct a typo in your tutorial to read /opt/cloudprint/.cloudprintauth.sasl /tmp/home/root/

    ReplyDelete
    Replies
    1. Sorry for the support late reply. This is for future readers I guess.

      Cloudprint is started via the following line: "/opt/local/bin/cloudprint &". Simply as that. Double check that it runs correctly from the command line would be a good start.

      Delete
  27. Hi Qui,
    Thank you for your tutorial, im getting an error is step 4, in adding a new printer, after im filling the Name, Description and Location, im getting the bellow error:


    Add Printer HP_LaserJet1200 Error

    Unable to get list of printer drivers:

    Internal Server Error

    Add Printer HP_LaserJet1200 Error

    Unable to get list of printer drivers:

    Internal Server Error

    Any idea how to resolve this issue ?

    Regards
    Ahmed

    ReplyDelete
    Replies
    1. i am having the same problem as Ahmed, but with epson tx121 printer.
      any insight on this?

      Thanks, mufti

      Delete
    2. I reinstall gutenprint and cups-driver-gutenprint, and now I can select my printer driver.
      But I am still unable to print a test page.. :(

      Delete
    3. Try a different driver or printer.

      Delete
    4. Hi Qui, I have tried various driver but could not get it working. However, I did some search at Gutenprint site and found that my printer driver is available on version 5.2.10. I just don't know where to find the ipk file or how to compile the source file on tomato. Any advise?

      Delete
  28. Hello, Can I install only google cloudprint without installing avahi and cups? I don't need to print from IOS devices. thanks

    ReplyDelete
    Replies
    1. No. The only part you can skip is the generation of the AirPrint service file. :)

      Delete