Ask HN: How do I write a Linux driver for my 15 year old photo printer?
254 points| pushedx | 3 years ago
It looks like someone out there maintains 32 bit drivers for this printer, but I'd like low-hassle native support for my 64-bit install.
https://askubuntu.com/questions/1324015/how-to-install-print...
Where do I get started with this? What's the toolchain for sniffing USB data and that sort of thing?
[+] [-] fuckstick|3 years ago|reply
What you’re asking for probably won’t be low hassle compared to just running the 32 bit usermode “driver” - which should run fine on a 64 bit system with some packaging help.
Ask yourself, are you trying to use the damn printer or you want a possibly educational rabbit hole to go down. Even if you sniff the USB (you can simply use pcap/wireshark) what are you expecting to see? It will likely be Canons proprietary raster and control format. Reversing that from the bus alone will be an enormous amount of work. I’ve written proprietary “WinPrinter” printer drivers with the spec in hand and it’s still not trivial.
[+] [-] jrockway|3 years ago|reply
That said, sniffing and replaying packets might get you pretty far. You should be able to do basic things like making the windows driver eject a piece of paper, and then doing that from Linux.
[+] [-] rroot|3 years ago|reply
What we have here is an enthusiastic hacker wanting to go down the rabbit hole of writing a hardware driver. That's no easy task (like you point out), and answers like this are not helpful at all.
The answer is discouraging and seem to only sow doubt in OPs mind. Let him find out how hard it is. May I remind that this website is called "Hacker News".
Let the voting suggest the venue for the question - it hit the front page of hacker news.
[+] [-] AshamedCaptain|3 years ago|reply
[+] [-] dopamean|3 years ago|reply
[+] [-] matheusmoreira|3 years ago|reply
What would your advice be if we assume that was what the author wanted? I had a lot of fun reverse engineering my laptop's keyboard LEDs and I'd love another rabbit hole to go down into...
[+] [-] a-dub|3 years ago|reply
last i played with this, i had to hack up scapy to handle the windows usb packet capture format. (windows and linux usb packet captures are/were in different formats, unfortunately)
when you're on windows you should print a bunch of images and then try and train a transformers neural network to predict the packets from the images alone.
if you got this to work, it would be cool.
[+] [-] yyyk|3 years ago|reply
It would be easiest to see if there's a PPD for closely related printer* - most manufacturers reuse components and/or evolve them incrementally - and start modifying stuff from there. There's a decent chance it would already work for basic functionality, and that you'll be able to improve it by trial and error. If you are lucky, you may be able to get a decent driver without even needing to bother with USB sniffing.
* e.g. A similar Canon printer by model name.
[+] [-] pessimizer|3 years ago|reply
Are 15 year old photo printers modern?
[+] [-] zamalek|3 years ago|reply
[+] [-] btdmaster|3 years ago|reply
If you read https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=cnijf..., you should be able to compile the 32-bit driver yourself and try and port stuff from there, but note that only parts of the driver are GPL2 and some are proprietary, and it's not entirely obvious which is which (though, from the looks of it, the prebuilt libraries are proprietary and everything with Makefile.am and autogen.sh is GPL2)
[+] [-] frankjr|3 years ago|reply
They are Bash scripts.
[+] [-] mmastrac|3 years ago|reply
https://www.qemu.org/docs/master/user/main.html
[+] [-] kelnos|3 years ago|reply
[+] [-] chpatrick|3 years ago|reply
It supports Pixma ip2000, so maybe it's not a huge change.
This describes how to add a new printer: http://gimp-print.sourceforge.net/reference-html/c199.html
[+] [-] chpatrick|3 years ago|reply
https://github.com/endlessm/cnijfilter-common/blob/0c5cfbf85...
[+] [-] nixcraft|3 years ago|reply
[+] [-] kristopolous|3 years ago|reply
While on the other hand, contemporary accounts date it to a Xerox 9700 printer at MIT in 1980.
I don't know. You could say in the 1980s the printer story sounded too absurd so they emphasized the clash of Titans aspect or you could say that we really like provincial origin stories these days so this "a simple motivated man with a great idea" framework is more appealing
This kind of stuff is fascinating; how history is narrated differently throughout time
For people uninitiated, the idea is materially, only discrete events happen. Stories are the narrative sense making humans project on them.
[+] [-] pessimizer|3 years ago|reply
[+] [-] quickthrower2|3 years ago|reply
[+] [-] unknown|3 years ago|reply
[deleted]
[+] [-] antegamisou|3 years ago|reply
https://lwn.net/Kernel/LDD3/
Don't mind the document's age, the principles have largely remained unchanged. Besides, it's probably a better fit since you're targeting a device from 2007
I understand this may be kind of non-specific to what you were expecting, but it's the most rewarding way of achieving what you want and coming up much faster with a driver for an obscure device next time.
[+] [-] fuckstick|3 years ago|reply
[+] [-] sireat|3 years ago|reply
I do remember having a bit of trouble finding the most recent source code for the book at the time (which was 12 years ago).
[+] [-] lagrange77|3 years ago|reply
You can use Wireshark for that part.
https://wiki.wireshark.org/CaptureSetup/USB
[+] [-] rroot|3 years ago|reply
I once had to ditch a perfectly functioning scanner (HP), due to out-of-date drivers and no linux support. I now do my best to always buy hardware that I know is well supported on Linux.
For example, some CanoScan scanners are completely supported by Sane, see http://www.sane-project.org/lists/sane-mfgs-cvs.html
[+] [-] jherskovic|3 years ago|reply
[1] https://www.hamrick.com/
[+] [-] jandrese|3 years ago|reply
[+] [-] brudgers|3 years ago|reply
I bought Turboprint. https://www.turboprint.info/
To me, it is the shortcut that will save endless searching for something that doesn't exist.
My free all Linux based solution was driverless printing, but it has limitations.
My non-Linux exclusive solution was an old Thinkpad running windows and SD card sneakernet. That was the simplest thing that might work so I tried it first.
Good luck.
[1] Well mostly solved it...I mean it solved all the important issues with a color managed workflow. At the scale of color managed workflows, $50 is about rounding error on X-rite gear...or even Datacolor gear. Never mind if you price your time.
[+] [-] torstenvl|3 years ago|reply
[+] [-] hapless|3 years ago|reply
[+] [-] tpmx|3 years ago|reply
https://www.canon-europe.com/support/consumer_products/produ...
[+] [-] raverbashing|3 years ago|reply
(not sure if the kernel USB API is the same, that might be a tricky part)
[+] [-] worthless-trash|3 years ago|reply
The actual source is available, http://ppa.launchpad.net/thierry-f/fork-michael-gruz/ubuntu/... http://ppa.launchpad.net/thierry-f/fork-michael-gruz/ubuntu/...
etc..
The packages are compiled for x86-64.
What am i missing, no reversing required ?
[+] [-] lallysingh|3 years ago|reply
[+] [-] digitallyfree|3 years ago|reply
Now writing or reversing a Linux driver for the printer though can be a fun project but I personally wouldn't buy this driver just so I can use the printer.
[+] [-] triggercut|3 years ago|reply
https://news.ycombinator.com/item?id=32714806
[+] [-] Comevius|3 years ago|reply
You only need cnijfilter-4.10, pstocanonij and 312/libs_bin32, which are the 32-bit proprietary libraries used to communicate with your printer. Those are the ones you would want to replace.
[+] [-] hapless|3 years ago|reply
The proprietary drivers are just faster/fancier.
[+] [-] bgorman|3 years ago|reply
[+] [-] lifeisstillgood|3 years ago|reply
The site is Hacker News, so we need a bit more low level hackery here, and a few less insights into ideal product management style.
[+] [-] MisterTea|3 years ago|reply
You first have to figure out which language your printer speaks. If it speaks a common language like postscript (basis for PDF) or PCL (printer command language) then you might be able to use a generic driver or one from a similar printer. If it is proprietary you will need to reverse engineer it by installing the printer in a native environment along with tools to sniff/log the communications send some test prints with magic data and figure out the command language that way.
Given that your printer already has a 32 bit driver it stands to reason you could have a look at the 386 source and see what fails to build on an amd64 machine. Then correct that and you have a driver.
[+] [-] userbinator|3 years ago|reply
The main problem is that the format is not documented, and there may also be a layer of compression.
[+] [-] unknown|3 years ago|reply
[deleted]