November 25, 2007

New Sane scanner driver for Canon Pixma MP610 !


Good news, Canon MP610 is now fully operational, scanner ready under Linux !

Successfully added some modifications to the sane pixma library (home page here), to get the MP610 scanner start dozing off ... using utilities like scan, scanimage, or Xsane and hopefully many other sane frontends ... You can take a look at a 300 dpi scan, produced using Xsane / Ubuntu.

Using Canon's 'Doze driver, I snooped those little USB packets traveling between the MP610 and the computer, and discovered ... several new USB messages added by Canon, which significantly changes the protocol from previous Pixma MPs. The rest was a matter of adding this new stuff (or what I've understood it was !) into the libsane-pixma driver ... and here it is.


Several "thingies" appeared also in this Pixma driver, presumably affecting others MPs ... Fixed the I/O error bug when scanning a full page under Xsane ... Hope this new version can help also other older Canon MP users, as I bet they should fall on it also. Looks like most functions seems to be OK for now.

Of course, let me know if you discover any bugs too. Presumably, it is still in a "beta" state.

Important Note: this first MP610 driver version is currently a clone of "what the 'Doze Canon driver does on USB", and gets the same functionalities. That is to say, It scans - only for the moment I hope - up to 600 dpi. The point is that I don't know how to scan - under 'Doze - at upper resolutions ! If someone can explain how to scan at 4800 dpi using 'Doze, I'll greatly appreciate to upgrade the sane driver to do the same !

So here is now the complete stuff. As it is not yet "officialy" integrated into the libsane-pixma library, I've added the letter "u" at the end, for "unofficial". I'll take contact with the libsane-pixma maintainer to request an add-on and probably a new libsane-pixma version package.

Procedure:

Please go to this page of the blog, to install the latest Sane git version of the pixma backend.

This old procedure here below is not to be used anymore, but I've left it here just for reference only.
Please use the pixma backend that is now included either in the 1.0.20 Sane version, or Sane git version.
  • Get the full new package that includes MP610: mp150-0.14.0u.tar.bz2, and untar it :
    $ tar xvjf mp150-0.14.0u.tar.bz2

  • Or you can get only the MP610.0.14.0u.patch file (patch over the latest official libsane-pixma 0.13.1). To use this patch file only, download it and the libsane-pixma 0.13.1 library, untar, navigate into its main directory, and apply the patch:
    $ patch -p1 < path_to_MP610.0.14.0u.patch
Then, the installation procedure is the same (from the full package or from the patch), go into the main directory where you have you new driver files:
  1. Compile:
    $ make

    or better, if you want to optimize size (1/3 size!) and speed:
    $ make NDEBUG=yes

  2. Test
    From here, you can use the classic "scan" utility provided with the package. See the pixma home page for details on it. Example:
    $ ./scan -x 10 -y 15 -w 51 -h 25 -1 -d 20 -W pixmascan.pnm

  3. Install for Xsane, Kooka, ...
    To install for use with sane, you need to copy the libsane-pixma.so file freshly compiled, to replace you current one coming with the sane library (latest one is 1.0.18). Keep a backup of your current one.
    So you need first to locate your sane libsane-pixma.so currently installed, depending on your distribution.
    For instance, Mandriva and Ubuntu places it at: /usr/lib/sane/libsane-pixma.so.1.0.18
    Simply rename: /usr/lib/sane/libsane-pixma.so.1.0.18 to: /usr/lib/sane/libsane-pixma.so.1.0.18.old
    And copy your new: libsane-pixma.so to: /usr/lib/sane/libsane-pixma.so.1.0.18

    The statements are:
    # mv /usr/lib/sane/libsane-pixma.so.1.0.18 /usr/lib/sane/libsane-pixma.so.1.0.18.old
    # cp libsane-pixma.so /usr/lib/sane/libsane-pixma.so.1.0.18


  4. Try it with scanimage, Xsane, Kooka, ...
    You're almost finished.
    Under root, you can try to run scanimage -L (sane command line scan utility) for instance.
    To use Xsane, or Kooka with your non-root user account, read now next section ...
Setting permissions to access the scanner:

Now that you've installed your new scanner, maybe you've noticed that you can only use it ... as a root user !

This behavior may vary between Linux distributions.
The MP610 is detected by udev, the universal linux hotplug device manager, as a usb device, with a unique MP610 usb address: 04a9:1725

According to your distribution's udev rules settings, udev and some scripts may add this device to a particular group, change its permissions, so that non root users can use it. If no udev rules exist, the device belongs to root, with generally too restrictive permissions for non-root users, to access it.

Here are 2 examples, on Mandriva, and Ubuntu, to adjust the udev rules, groups and permissions, to make the MP610 usable by non-root users:

On Ubuntu
As Ubuntu do not create any udev rule for it, MP610 will default to the root group, with too restrictive permissions so that non-root users won't be able to access it.

Ubuntu sets by default all users to belong to a particular group named "scanner".

So the easiest way is to tell udev to make the MP610 belong to the scanner group too.

Modify the file:
/etc/udev/rules.d/45-libsane.rules

And simply add the 2 following lines in it:
# Canon PIXMA MP610
SYSFS{idVendor}=="04a9", SYSFS{idProduct}=="1725", MODE="664", GROUP="scanner"

To have udev take into account this new change, simply... unplug the MP610 USB cable, wait a few seconds, and plug it back.
Or issue the command:
$ sudo udevcontrol reload_rules

On Mandriva
udev and some Mandriva scripts automatically add the MP610 into the "usb" group. This way, a normal user can access the scanner if he belongs to the "usb" group too. <user> can be added to the "usb" group, either with the mcc, or the following command line:
# adduser -G usb <user>

Check that <user> is added correctly to the "usb" group:
$ groups
<user>
<user> : <user> usb

Other distros ...
Based on those 2 examples, you'll need either to set:
  • your udev rules and groups, so that:
    • udev changes MP610 group to a non root group (modify the file /etc/udev/rules.d/xx-libsane.rules as with Ubuntu)
    • your normal user belongs to the same group (see for Mandriva, above).

  • or wider permissions for MP610 or all usb devices, but this is less "secure", (r+w for everyone to all USB devices).
    For enabling all usb devices to be accessed by anyone, add a udev rule like:
    SUBSYSTEM=="usb_device", MODE="0666"

    or to open access to MP610 only:
    SYSFS{idVendor}=="04a9", SYSFS{idProduct}=="1725", MODE="666"
Remember that any change to a udev rule needs to be taken into account. For that, simply unplug and replug the USB cable, or run the command, under root:
# udevcontrol reload_rules

Good scans, and fell free to report any comment!

34 comments:

jbernardo said...

Thanks! I got it to find the scanner for root only, though. I am using kubuntu 7.10.
I'll google for it tomorrow...
And when I have some time I'll check for high res scanning in windows, I can do another capture of 4800 and 9600 dpi scanning as I did of 75 dpi.

Nicolas said...

Ok, if it works for root, then having it to work for a normal user account should be just a matter of permissions and groups. Check that your user account belongs to group "scanner".

jbernardo said...

I'll check it and /dev/sg* permissions. I just booted into windows, and found you can go up to 1200 dpi if you enable the "Use the scanner driver" checkbox and the choose the advanced settings in the scangear application. You can also type in the dpi value in the scangear app, but I don't know if it is obeyed for values above 1200. It does complain that scanning can only be done for values of 21000x30000 pixels or less of output.

Anonymous said...

Had the same problem as jbs.

sudo chmod a+w /dev/bus/usb/$Bus/$Device

fixed it. To find out $Bus and $Device use

lsusb

and look for Canon Inc.

Nicolas said...

Yes, this is one way yo do it. But the disadvantage is that it will be lost on next reboot.

Another solution (proposed by jbs on ubuntuforums) is to add, in the udev rules, a line corresponding to the MP610:

in file (on Ubuntu): /etc/udev/rules.d/45-libsane.rules

Add the 2 lines:

# Canon PIXMA MP610
SYSFS{idVendor}=="04a9", SYSFS{idProduct}=="1725", MODE="664", GROUP="scanner"

This line tells udev to automatically add the MP610 into group "scanner" when plugged in. As normal users, in Ubuntu, belong to group "scanner" (by default), they will be able to use the MP610.

Nota: on other distros, this file may have another name like this: xx-libsane.rules

Complete thread is at: http://ubuntuforums.org/showthread.php?t=620671

I'll add a few words on that in this post for newcomers. Thanks.

Anonymous said...

Hi,

I have used your MP610 extension to bring MP520 Support for sane. It seems to protocol is the same.
The only thing I have done is to add some view lines so the MP520 is detected by your libary.
Die device-ID is pixma:04A91724_116906.

So thanks for the good work!

Bye
Thomas

Nicolas said...

Hi Thomas,

This info looks very interesting!

In fact, I was not sure about MP520 protocol, although released by Canon at the same time with MP610.
In the doubt, I left MP520 as a Generation 2 scanner, as I could not do any testing ...

This means that Sane support for MP520 can be easily added to the pixma driver too.

Could you post or mail your modifications (I suppose in file pixma_mp150.c) to have it work ? I propose to add then MP520 support on this blog too.

Did you get also high dpi scanning (1200 and 2400 for MP520) working also ?

Thanks for your feedback!

Ionut Scutaru said...

Hi,
Do you know if it's possible to use the scanner if the printer is attached to a windows machine ? I'm currently having the printer shared in windows and printing works just fine.. However, I was wondering if I can scan documents using samba as well..

Thank you.

Nicolas said...

Hi,

Unfortunately, Windows uses Twain to drive the scanners, and, AFAIK, Twain cannot be used as a Windows share.

The reverse is however possible, and works fine. With a scanner and printer attached to a Linux server, you can use Samba/Cups to share the printer with Windows boxes, and saned to share the scanner. Windows boxes can for instance access the scanner using Xsane-Win32, a ported version of Xsane on Windows.

Nicolas

Anonymous said...

Thank you so much! It works great. In my Ubuntu 8.04 there was no sane udev file. Instead I had /etc/udev/rules.d/80-canon_mfp.rules where my MP210 was already mentioned. I added the "GROUP" statement and it worked perfectly (not shure if I had to modify 80-canon_mfp.rules, try it without edit).

Anonymous said...

Nicholos - This is Mike, from the MX700. I upgraded to Ubuntu 8.04 and downloaded the latest version of your Pixma driver. The "make" command doesn't work - I get error output. I remember when we did this before that I had to download and install some package from Ubuntu to get this to work, but can't remember what it was. Could you remind me?

Anonymous said...

Does anyone know if this driver works for the MP390?

Nicolas said...

I would say: probably.
The backend has been designed taking into account the MP390. man page says that this model is supported, and should work in most cases.

The best is to try it, if you get any issues, please post them to the sane-dev mailing list. Also, if you can get a USB snoop under Windows, that will be of great help to fix any issues with this scanner.

=w= said...

Using your instructions got the scanner for my MP470 to work. Thank You!

But now the printer has quick working! Anything in your instructions that could be interfering?

Nicolas said...

A bit strange, there's nothing related between scanner (Sane) and printer (Cups).

Did you try to delete and reinstall the printer ?

Nicolas

kayou_77 said...

I am under Ubuntu Hardy
My scanner MP610 is not recognized. (but the printer, yes).

I followed your method and wher Imake the test, I get this message :


./scan -x 10 -y 15 -w 51 -h 25 -1 -d 20 -W pixmascan.pnm
[pixma-0.13.1] Scanning devices under /dev/bus/usb
No supported scanner found!


What do you think is wrong ?

Nicolas said...

Did you install Sane CVS version, or are you running Hardy's 1.0.19 ? In the latter case, MP610 is not supported in 1.0.19

Nicolas

Séamas said...

Does this support the mp470?

Thanks.

Séamas said...

Never mind, I saw the message. Sorry.

kayou_77 said...

Thanks Nicolos,

My UBUNTU version is

Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Codename: hardy

I will install this week-end Sane CVS version and tell you if any change

Nicolas said...

Yes, MP470 is supported in Sane CVS version.

Nicolas

J. Pablo Fernández said...
This comment has been removed by the author.
J. Pablo Fernández said...

Is this working/going to work out-of-the box in Ubuntu Intrepid?

Nicolas said...

This will be going to work out of the box for any Linux distribution as soon as the new Sane package 1.1.0 will be released.

Unfortunately, I don't have an answer to that question, as it was originally scheduled for last summer.

But you could ask the Sane-dev mailing list for that.

In the meantime, there are still new enhancements in the CVS version for different PIXMA models (TPU, ADF), the next one, coming soon, will be a major step as the backend will implement Canon's BJNP protocol to scan over the network.

Nicolas

Unknown said...

We also found that printing with CUPS stopped working after following these instructions - this was because the udev rules cause /dev/usb/lp0 to be owned by root.scanner instead of root.lp. We changed the udev rules to make the group "lp" and permissions "666", but obviously that means that any user on your system can access the printer / scanner, which may not be what you want. I guess you could leave the rules as suggested in this post and make lpadmin a member of the group scanner as well, but I haven't tested that.

Anyway, I hope that helps if anyone's got the same problem.

Random Man said...

Thank you for the tutorial. Had no idea there was a Cannon Asia section. I usually go to the Cannon UK since they provide drivers for some of the printers too. Wonder why the US section does not provide them?

Anonymous said...

Great blog!
I wouldn't have bought Canons mx310 if I had not found this tutorial beforehand. And I probably could not figure it out myself. Thanks!

Anonymous said...

PS: Running Ubuntu 8.04 it was especially helpful to hear that I have to get the CVS sane first, as the one provided with Ubuntu would not work. Cheers!

Anonymous said...

Hello,
I am a total newbie, running Ubuntu 8.10. I have a Canon Pixma MX310 all-in-one. I got the printer to work, but not the scanner. Can anyone explain to me in English how to get it to work?
Thanks!!!!

weierj80 said...

Hi, I really hope someone can help me with this. I've gotten my pixma (610M) set up perfect and I'm really happy with the results (using canon scangear wizard along with some customizations I made to the PPD files). I set this up a while ago and stupidly did not document the process (third time I've been through all this). I'm wondering if someone could tell me where I would look for the PPD files for the printer and the scanner in Ubuntu 8.04? I'd like to just copy them before I install 9.04 from scratch on this machine. Any help would be appreciated.

computer said...

I could not find ppd files for CANON PIXMA IP 1300 so I could not configure the printer in Debian.Please help me.

Anonymous said...

Just spent a helluva lot of time trying to get Canon Pixma MP630 installed into Ubuntu 10.4 64b.

May I just say, Linux will never get anywhere until and unless one can simply install a driver and peace!

Most of the "instructions" I have encountered are useless, as they presume everyone is a geek/technically just as educated/knowledgeable/experienced as they are!!

God forbid somebody wrote it all properly!! They may look "lame" and "beneath contempt" to the "community of like-minded geeky fellows", writing it all up for "lamers"...

Imagine going to the doctors and being given something but left to your own devices to use it, from trying to dosage it to where to apply it, what to look for in terms of symptoms if it is improving or worsening etc.

I'm sorry but if every seventh step in this procedure is written down and if it is impossible to locate some files on a Linux PC, with those "instructions" - it's causing most of us to waste our precious time, time we would spend with our kids [the abuse I got from the wife for trying to do this is... oh, well...]...

My hobby is Sat TV. You should see how I write "intros/how to's", after reading which EVERYBODY CAN DO IT for themselves!!!

That is in the spirit of Open Source and sharing the knowledge/experiences.

All else is a lot of wan*ing, trying to imagine a good looking girl you'll never "get"... because you're wan*ing all the time and sitting behind a PC... So, no wonder... all that resentment towards those who are not doing the same nonsensical experience...

Now, this is not in the interest of the manufacturers either, of course!!! It is pretty "lame" and inexcusably pathetic to write something complex and them give almost NO INFO how to get it installed in Linux. Canon, this is really contemptible! And NOT economically justifiable!!! It would have taken a guy maybe 2-3 hours to do it. So, honestly...

weierj80 said...

I've been working with the Canon Pixma 620 and 600 with Ubuntu for a while now. This blog has been instrumental in assisting with configuring these devices. However I do have to say now that 10.04 is out and after spending two days attempting to install and configure either of the printers...it's a major hassle. My suggestion if your new to GNU/Linux, you should just buy a cheap HP (Universal driver just works in my experience). Canon has been slacking off for going on 3 years now, producing drivers for GNU/Linux that are not available in the US (only on the Asia site), and I will admit are extremely difficult to configure for newbies. I consider myself fairly experienced with Ubuntu at this point, yet still I'm unable to get these printers to operate correctly under 10.04 even after reinstalling the OS between each attempt (4 times but who's counting). I love my Pixmas, and it's a shame that it's such a struggle getting them configured every time a new release comes out. I'm not about to admit defeat just yet. I'll keep busting my knuckles on it till it works, and try to post back with instructions. However, lashing out at those who aspire to help as the last "Anonymous" commenter did is not just rude, and disingenuous, it's also rather foolish. If you haven't the time to focus on making your devices work, or learning to understand the underlining principals of a GNU/Linux system, there are at least two other options your welcome to pursue (Windows,or Apple). The point of community driven support is to educate and assist, not act as a punching bag for the frustrated. I for one really appreciate the work the author of this blog has done to assist the owners of these devices. In reality the responsibility to support the PIXMA series should belong to Canon, but that has not been the case. I guess I'd just like to point out that if your experiencing difficulty with your GNU/Linux distribution, locate the forum for the distro, and ask for help. Provide a link to the instructions here and see what happens. Many experienced people are out there willing to help.

...and if your wife or partner gets on your case about it, just remember "many hands make lite work" (and and extra set of eyes looking for a solution is never a bad thing either).

Nicolas said...

Hi all !

Being a bit busy those days, so could not participate as I would expect with the blog.

Anyway, I see lots of discussions coming to Ubuntu 10.04.

After installing it recently, I experienced also the problem with the Canon driver.

First point, the Canon common package version to install, which, as I explained in an article in this blog, must be at least 3.00 (latest is 3.20). You can download it for instance from the Canon Asia site at the MP648 page.

The second point is due to the debian packages supplied by Canon, which specifies dependancies that are now incorrect for Ubuntu 10.04, namely libcupsys2 which is now renamed to libcups2 in 10.04

So installing the Canon printer specific package will fail.

From there, 2 solutions:

1) the easiest is to force installation of the printer package using the dpkg with the --force-depends option. Drawback is that apt-get will always try to remove it after, so you won't be able to install anything else unless you remove and reinstall it each time ;-(

2) second (which works fine) is to modify the Canon Debian package to correct the libcups2 dependency. This is just a change in a text file (control) in the Debian archive, but not obvious for a newbie. I have done the exercise for MP610 package, so I can send it by email if you ask to me. There exist some tutos on the web to do that, here are the main steps:

- Download (but do not install !) the Canon printer specific .deb from Canon web site. For instance, the file is named for MP610:
cnijfilter-mp610series_2.80-1_i386.deb
- Right click this .deb archive, and select extract here (you must have libtools installed, so that file-roller can open a deb archive)
- Change slightly the folder name, for instance, put 2.90 as version instead of 2.80, or 3.10 instead of 3.00 ...
- Enter this folder.
- Right click successively the 2 archives control.tar.gz and data.tar.gz, and select extract here.
- Remove the 2 archives control.tar.gz and data.tar.gz, but do keep the 2 new folders created named: control and data
- Rename the control folder into: DEBIAN
- Enter this DEBIAN folder, and gedit the file named: control . Change the libcupsys2 dependency into libcups2 . You can also remove this dependency if you prefer.
- Return up to the the top folder (where the Canon debian package sits), and rebuild a new modified .deb package:
dpkg-deb -b "new folder name" . This will create a new .deb package taking the name of that folder.
- install this new debian package as usual, by double clicking it.

Last: remember to reinstall your printer after in Ubuntu (as explained in this blog), with the printer setup dialog, taking the cnijusb driver as URI (and not the default one installed by Ubuntu)

As usual, hope it helps!
Nicolas