Epson Stylus Photo P50 on Linux

Well, after many years of service my HP 720c is being retired. It basically refuses to detect any non-HP ink cartridges. While before it happily used compatible cartridges it recently stopped, and the HP ones are just too expensive.

I toyed with getting a laser printer, but when I think about it, I just don't print documents that often anymore. I either print photo's (taken with DSLR), labels or colour reference diagrams/manuals. I also don't print that much (usually a small burst of printing, then nothing for months). A colour laser printer would not be worth it unless I really print a lot, which I don't.

As such I decided to go with another inkjet. I was originally unsure about the P50 because Epsons have the print heads built into the printer (as opposed to HP, which had them in the cartridges). This means that if the head clogs up (which can happen after months of unuse) it may be impossible to clean out again. This is how my original Epson stylus colour went to the bin (all those years ago). To be honest I am still unsure about Epson, but they were recommended by a friend, and I last used one 10+ years ago, so I figure I'd give them a try (there must have been some improvement in tech since then, right?).

On the flip side, the cartridges can be cheaper (no need for print head as well), and compatible cartridges should be easier to get hold of.

Another reason I went with the P50 is because it is supported by CISS (Continuous Ink Supply System) which means that if I ever end up printing a lot, I can start buying ink by the litre, which should be a lot cheaper!  It also supports printing on CD's, which is pretty cool. I hope it works on Linux...

We shall see how this works out =)

Officially Epson does not support Linux, but it does provide links to what you need to get in order to use it.
What you need

What you need

The Epson, like most consumer inkjets, does not have a PCL interpreter built in. It only supports raster images (i.e. raw data sent over the connection). This makes it both slower (as you have to send the raw data across) and more CPU intensive for the host (as it needs to convert the PCL to raster).

As my previous inkjet was a HP, I didn't need to convert to raster. So the first thing that threw me with the epson is that it would not print after installation. If you have this problem, then scroll down to the "Troubleshooting" section to see the problems I came across, and my fixes.

For the purporse of this howto, I will be assuming a Debian OS. The machine I'm running the print server on (Kronos) is a Debian box. The commands here should work for all debian-based distributions, including Ubuntu.

The software you need to get this working is:

A simple aptitude command should suffice for the above:

aptitude install cups ghostscript-cups lsb 

That should pull in all needed dependencies. As for the epson driver, download the version that fits your arch:

epson-inkjet-printer-stylus-photo-t50-series_1.0.0-1lsb3.2_i386.deb

epson-inkjet-printer-stylus-photo-t50-series_1.0.0-1lsb3.2_amd64.deb


As you can see from above, as of 2012 there is only drivers for x86. No arm, no other architecture. Take this into account if you want to make use of the rasberry pi, or other embedded system as a print server. My server is x86 compatible (VIA CPU) so I should be ok.

For those of you with ARM systems, who are quite advanced with linux and hacking, you might want to consider qemu. It can run programs individually as a different arch, so you could try hacking the driver to execute the binary blobs with qemu. It would be slower, but it should work :)

If you do try this and it works, drop me a line and we'll add the information here. With the rise of non-x86 archs in the home, I'm sure this would be of interest to more and more people :) UPDATE:  Looks like someone got it working, by compiling the source of the driver! See: www.raspberrypi.org/phpBB3/viewtopic.php for more info.

For my usage, I went with the i386 driver, downloaded it to my current directory and executed:

dpkg -i ./epson-inkjet-printer-stylus-photo-t50-series_1.0.0-1lsb3.2_i386.deb

And that is that, it should have installed without a problem. If it complains about missing dependencies, then you'll have to install them using aptitude. Im my case I didn't need to do more than the above mentioned, but your system may be different.

Setting up the printer

At this point it like setting up any printer. Follow the CUPS step by step instructions for adding the printer. When it comes to setting up the driver, select:

"Epson Stylus Photo P50 Series - epson-inkjet-printer 1.0.0-1lsb3.2 (Seiko Epson Corporation LSB 3.2)"

CUPS is nice enough to autoselect the generic epson stylus colour driver, but this will limit you to 300dpi, so don't use it!

Troubleshooting

The above was easy enough to do, and I got my printer setup within the hour (including all the research time). Now that I've written this article for you it should have taken even less time! :)

Now I did have some issues with the printer.

Problem 1

First when I checked CUPS, I got the following error returned:

CUPS: client-error-document-format-not-supported.

Turns out that the issue with Epson not supporting PCL was the problem. You need to tell CUPS to accept raw input. Normally you send CUPS PCL data, and it will set it up and send it to the printer. With the P50, you have to first parse the data, convert it to a binary format, and send it raw across. This requires some changes to your cups configs:

After this the error went away, but I still could not print! This time I didn't get anything. No error reports, nothing! Everything worked, the printer showed up on cups, and on all my networked PC's, and it would accept jobs. Just nothing came out the printer!

Problem 2

Checking the error logs, I saw the following problems:

I [11/Mar/2012:21:39:05 +0000] [Job ???] Request file type is application/vnd.cups-banner.
E [11/Mar/2012:21:39:05 +0000] Returning IPP client-error-document-format-not-supported for Print-Job (ipp://localhost:631/printers/Epson_Stylus_Photo_P50) from localhost

and
I [11/Mar/2012:21:55:32 +0000] [Job ???] Request file type is application/pdf.
E [11/Mar/2012:21:55:33 +0000] Returning IPP client-error-document-format-not-supported for Print-Job (ipp://localhost:631/printers/Epson_Stylus_Photo_P50) from localhost

This was rather odd, and while searching around, I came across the samba documentation on cups. Nice of them to include the filter chain. This allowed me to manually step through the commands needed to print a document. When I got to running the "pstoraster" command, I got "command not found". Bingo! I was missing the command to convert to raster. As I didn't need it before (due to HP supporting PCL) I never installed it.

simply installing ghostscript-cups and it all worked for me! :)   If you do have this command, and it is still not working, keep stepping through the process manually. Eventually you'll hit whatever is breaking it for you. Good luck! :)

Annoyingly, CUPS doesn't report when the programs you execute don't exist, or don't work. Come on guys! How hard would it be to check the return codes and print something out on the error log? It would have saved me a couple of hours of digging round!

 

Problem 3

I found a problem with printing, which is quite annoying. I can print from some programs (e.g GIMP/evince/cups test page)  just fine. However printing from firefox, or any other program, just prints gibberish, or I get an error "epson_inkjet_printer_filter failed".

The problem I've seen so far is that there are multiple possible situations, all of them revolving around CUPS being upgraded to 1.4. Apparently everything worked fine on cups 1.3, but since the upgrade this has broken.

Some references:

os.sugi.web.id/tag/epson/

bbs.archlinux.org/viewtopic.php

From what I can see, it could be something to do with the client programs, and what library they use. Especially see this bug report: bugs.launchpad.net/inkscape/+bug/964726.

If it is a client-side bug, then there isn't much we can do about the situation :( 

For the time being I end up writing everything to bitmap or printing to PDF, opening that in evince/gimp (the only two programs that can print properly) and print it. A pain in the backside, but hopefully a fix will come out soon :/

One option that might be open to you, is to share the printer as a windows share/samba printer. Windows Samba printing using its own interim raw format that everything is converted to, when being sent to cups. So then this should work ok.

However, for the above you'd have to install the epson drivers on every machine you want to print from (just like windows) and there would be no auto-detection of printers. You'll have to manually add it as an smb printer to your local samba install.

 I have so far not found a solution to this problem. Please let me know if you get any success...

Completion

And that is that, I am happily printing now :)   Printer prints at all resolutions (although annoyingly it does not specify resolutions, but gives you "Draft, Text, Tex+Images",etc.... options, which are useless for me really, but I can get by.  It prints on all my linux boxes (sorry no windows here, if you want to print from windows you'll have to jump through some more hoops. The samba documentation above should be able to help you) without needing to do anything on them. It is all autodectected.

I still have not tried printing on CD's, but will give it a go when I have a need. See below section!

As for the ink, I will look at how long the ink lasts for me, and work it out as a monthly running cost. That way I can see if I should get original ink cartridges, compatible ones, or go for the CISS system.

Printing on CD's

Well, I bought a printer that can print directly to CD's, so why not actually use it for that! Well, turns out that it does work, it is just fiddly.

Basically, most Linux software, like inkscape, GIMP, etc... are too intellingent. When you select that you want to print on a CD they give you a nice 12cm x 12cm area to work in.

All is good until you try to print. When you do, the printer driver will crash, and you'll need to restart cups.

It took many hours of debugging and testing before I worked out what the problem was.  The problem was that when set up in "CD" mode, the Epson driver does not recognise custom page sizes.

So you can print any page size you want (even 12x12cm) in normal mode, but not in CD mode! Horribly silly in my opinion. In fact it is worse, the driver will segfault and requires a restart of the cups server. You've been warned! After trial and error I found out you have to set the page to A4 when in CD mode, and then the printer will print the first 12x12cm of the A4 page, starting at the origin (0,0) at the top-left of the page.

I have made a quick SVG template for inkscape, which you can just open and edit for printing CD's on Linux. I've included the standard 12cm CD, as well as guides for smaller credit card sized CD's I had.

I have found a quite awesome piece of software for linux called glabels. I have written a template for CD printing using glables. Download the template and use it when creating CD's. It seems to work fine with me, and should work ok for you as well. Let me know if it all works.

The printable CD's I use have printable area all the way to the spindle, so I had to make changes to the Epson settings to the minimum inner diameter (26mm). Still too much (the CD inner is 24mm) but not much I can do about that.

You can download the label template here: Epson P50 CD Template

Any updates/comments you do, or want to contribute more CD templates for the P50, get in contact :)

 

Getting ink levels from the P50

This turned out to be hit and miss, there is a utility, called "ink"  (surprise!), which can be found at http://ink.sourceforge.net/.

The utility is rather temperamental, in the sense that sometimes it works, sometimes it doesn't. Sometimes you have to run it multiple times before it gives you a response. Usually you will get an error along these lines:

Unknown IEEE 1284.4 error number 69
Could not read from printer.
Could not get ink level.
Not the most descriptive error. I've emailed the developer and we'll see if he can work out a fix for it. For the moment I wrote a quick hack of a script that just keeps trying, then writes out the ink levels if it succeeds.
 
The code:
 
#!/bin/bash
TRIES=30 #how many times to try before giving up

while true; do
        ink -p usb > /tmp/ink
        if [[ $? == 0 ]]; then
                echo Updated: `date`
                perl -e "print '='x80;"
                echo ""
                cat /tmp/ink
                rm /tmp/ink
                break
        else
                TRIES=$(( $TRIES - 1 ))
                #sleep for random amount
                sleep $(( $RANDOM / 1000 ))
        fi

        if [[ $TRIES == 0 ]]; then
                echo "Failed to update, tries exceeded"
                break
        fi
done

And this (eventually) gives you the following output:

Updated: Sat Aug 11 00:00:01 BST 2012
================================================================================
ink 0.5.1 (c) 2010 Markus Heinz

EPSON Epson Stylus Photo P50

Yellow:                        21%
Photoblack:                    80%
Light Cyan:                    94%
Light Magenta:                 94%
Magenta:                       64%
Cyan:                          63%

In my case, I write this file to my webserver on Kronos, so I can visit the web page whenever I want to check the status of the ink. The script runs daily from cron (I don't print enough to need it more often), but I can run the script manually to get the ink printed out if needed.

  

 Epson P50 on PowerPC G4 Mac running Linux

Well, the above worked, up until I decided to update the distro in order to fix an annoying bug in the DNS/DHCP server. I fixed that bug, but I messed up the printer. It would only print from PDF's, printing from anything else resulted in garbage being printed  (This has been fixed now!). Not to mention that poking holes in the firewall in order to get it to share to the network properly, plus a bunch of other gotcha's, made me decide to give it a dedicated server. 

I've had an old powerPC G4 mac mini that used to run Gentoo (for my Uni project). Well, I decided to have a go at modding it, I overclocked it to 1.42GHz (from its original 1.25) and added 1GB of RAM (I kept the 40GB IDE drive, primarily because I had no larger IDE drive available). I installed debian on it, cups, gutenprint, etc... as usual (I just selected "Print server" on the list during installation.

Lo and behold, I plug the printer in, it is found, added and already has a compatible driver! Not only that, but this driver is far better than the Official Epson one, the features/tweaks possible alone is impressive. I've not even had a chance to look through it properly for all the stuff you can do. 

I don't know why it all just worked on the mac, I always thought the "it just works" was primarily due to OSX ;)   In reality, I think it has to do with the OS distro version. This is Debian Wheezy, cups version 1.5. Try loading the same versions, and it should all work for you as well :)

This also means that we now have a cross platform driver, so you can use PPC/ARM/etc... for your print server with the P50 :)

Checking ink levels

We don't have a version of libinklevel for PPC in debian, so just go ahead and compile one. You will need to have the essential tools for building, and the libieee1284-dev package (for parallel port access, despite the mac's not having such a port). libtool is there to make your life easier later on.

aptitude install build-essential libieee1284-3-dev libtool

Then download the latest version from their website, and pretty much follow their instructions, up until the end. Once you ran "make install"  it should be installed and you're ready for the next bit.

Now, you have the required libraries, however you still need a program to read the ink and display it. I like the "ink" command line program, (http://ink.sourceforge.net/) so I'll be using that. 

I had some errors while compiling ink on ppc, specifically errors to do with "rpl_malloc". You need to export the following variables to get it to compile:

export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
./configure
make
make install

Once done, run ldconfig to reload the libraries and you're good to go. Note that we still have the issues with "ink" sometimes not working, so you'll still need the script I used above for reliable ink level output. 

Problems

Garbage being (sometimes) printed

This was an annoying problem to pin down. Test pages worked, printing from PDF's (Evince) and ps files worked, printing from other applications didn't. It was just print pages and pages of garbage. 

Turns out that when you first configure debian, you will be given an option of handling "raw" jobs. Either to process them anyway, or send them directly to the printer unmodified. I must have set it to always process at some point (probably during the update).

Always set this to "yes", because what seems to happen is when I connect remotely to the printer, the driver loads and does the processing client side, then sends the finished raw format to the server. I've not seen this done before, and I suspect that is how I can set all the fancy Graphics/CD options locally, and have it just work. 

It also explains why the PDF/PS files worked, it would force process them, realise it was PDF/PS, and convert it to raster. Converting raw data to raw data will not work ;)

Printer works, but not all programs/computers can see it

 This wasn't too bad.  Normally you'll not have to do this, but I fiddled with the config at some point in the past and messed things up. 

  1. Make sure your server is set to share the printers on the network. 
  2. Make sure either:
    1. You have cups server + client installed locally, and set to "show printers from other systems".
      1. Also make sure your /etc/cups/client.conf has "ServerName localhost:631" in it (and no other ServerName lines)
    2. You only have cups client installed locally, in which case your /etc/cups/client.conf will have a ServerName pointing to your cups server

I already have a cups server on every machine (also this allows for auto-detection of available printers), so I went with making sure my client.conf has the localhost:631 as ServerName.