Canon Printers and CUPS: ARM drivers availabile?

Re: Canon Printers and CUPS: ARM drivers availabile?

Wed Feb 22, 2017 5:17 pm

Update: The canon imageCLASS MF4570dn printer now prints from CUPS on the raspberry pi. I originally learned about this process from here: https://www.lhinderberger.de/pi/2016/01 … ivers.html and here http://orange314.com/Run_x86_code_on_OPI

First you need to have binfmt-support and qemu-i386 installed to run x86 drivers, binaries, etc:

Code: Select all

sudo apt-get install binfmt-support qemu-user

Enable the kernel to automatically hand x86 programs to qemu:

Code: Select all

sudo echo ':i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/usr/bin/qemu-i386-static:' > /proc/sys/fs/binfmt_misc/register

Then you’re going to create the default directory for the qemu i386 library files and link it to the other default directory for qemu i386 libraries:

Code: Select all

mkdir -p /etc/qemu-binfmt/i386
ln -s /etc/qemu-binfmt/i386 /usr/gnemul/qemu-i386

Next, you’ll install the 32-bit driver common and ufr2 deb files manually:

Code: Select all

ar x cndrvcups-common_3.70-1_i386.deb data.tar.xz && mkdir common-data && mv data.tar.xz common-data/data.tar.xz
ar x cndrvcups-common_3.70-1_i386.deb control.tar.xz && tar xvf control.tar.xz ./postinst && mv postinst common-data/postinst.sh && chmod 777 postinst.sh
ar x cndrvcups-ufr2-us_3.30-1_i386.deb data.tar.xz && mkdir ufr2-data && mv data.tar.xz ufr2-data/data.tar.xz 
ar x cndrvcups-ufr2-us_3.30-1_i386.deb control.tar.xz && tar xvf control.tar.xz ./postinst && mv postinst ufr2-data/postinst.sh && chmod 777 postinst.sh
sudo su
pushd common-data
tar xvC /etc/qemu-binfmt/i386 -f data.tar.xz ./lib ./usr/lib 
tar xvC / -f data.tar.xz ./usr/bin ./usr/include ./usr/share ./usr/lib/cups ./etc 
popd
pushd ufr2-data
tar xvC /etc/qemu-binfmt/i386 -f data.tar.xz ./lib ./usr/lib 
tar xvC / -f data.tar.xz ./usr/bin ./usr/include ./usr/share ./usr/lib/cups ./etc 
popd
./common-data/postinst.sh
./ufr2-data/postinst.sh

Now, the fun part – manually downloading and installing all the dependency libraries. Here’s how to extract one library manually to our default library folder:

Code: Select all

pushd /tmp && mkdir libraryname && cd libraryname
wget http://url-to-tar.gz-file
ar x tar.gz-file data.tar.xz --OR-- ar x tar.gz-file data.tar.gz
tar xvC /etc/qemu-binfmt/i386 -f data.tar.xz ./etc ./lib ./usr/lib --OR -- tar xvC /etc/qemu-binfmt/i386 -f data.tar.gz ./etc ./lib ./usr/lib
popd

Finally, since the proprietary cups filter pstoufr2cpca calls ghostscript with an x86 driver/shared library, we also need to download and install the x86 version of ghostscript and all of it’s library dependencies as well following the convention above. You may be wondering, “I have two different copies of the ghostscript program now. How do I tell pstoufr2cpca to use the x86 one instead of the arm one?” Not so lucky for us, pstoufr2cpca calls the ghostscript program by full path “/usr/bin/gs”. We’ll need to create a bash script that replaces “/usr/bin/gs” and allow the bash script to call the correct ghostscript program. Here’s the contents of the bash script that I made. I renamed the ghostscript programs to “gs-i386” and “gs-arm” and put them in /usr/bin. This script must also be given execute permission by using chmod.

Code: Select all

#!/bin/bash
PARENT_COMMAND=$(ps --no-headers -o command $PPID)
if [[ $PARENT_COMMAND == *"pstoufr2"* ]]; then
        /usr/bin/gs-i386 "$@"
else
        /usr/bin/gs-arm "$@"
fi

You can test the process that cups uses to print a test page by issuing the commands manually. The last command is the important command. If this runs successfully and pstoout.out contains binary code, your printer will print this document.

Code: Select all

export PPD=/usr/share/cups/model/CNCUPSMF4500ZS.ppd
/usr/lib/cups/filter/bannertopdf 1 me '' 1 '' < /usr/share/cups/data/testprint > bannertopdf.pdf
/usr/lib/cups/filter/pdftopdf 1 me '' 1 '' < bannertopdf.pdf > pdftopdf.pdf
/usr/lib/cups/filter/pdftops 1 me '' 1 '' < pdftopdf.pdf > pdftops.ps
/usr/lib/cups/filter/pstoufr2cpca 1 me '' 1 '' < pdftops.ps > pstoout.out

If this produces errors, you’ll need to check if qemu is running the cups filter, is the correct ghostscript program running, and do you have all the dependency x86 libraries installed, etc.

Canon Printers and CUPS: ARM drivers availabile? was last modified: March 27th, 2020 by Jovan Stosic

Nicholas II of Russia – Wikipedia

Nicholas II or Nikolai II Alexandrovich Romanov (18 May [O.S. 6 May] 1868 – 17 July 1918), known in the Russian Orthodox Church as Saint Nicholas the Passion-Bearer, was the last Emperor of Russia, ruling from 1 November 1894 until his forced abdication on 15 March 1917. His reign saw the fall of the Russian Empire from one of the foremost great powers of the world to economic and military collapse. His memory was reviled by Soviet historians as a weak and incompetent leader whose decisions led to military defeats and the deaths of millions of his subjects. By contrast Anglo-Russian historian Nikolai Tolstoy, leader of the International Monarchist League, says, “There were many bad things about the Tsar’s regime, but he inherited an autocracy and his acts are now being seen in perspective and in comparison to the terrible crimes committed by the Soviets.”

https://en.m.wikipedia.org/wiki/Nicholas_II_of_Russia

Nicholas II of Russia – Wikipedia was last modified: March 25th, 2020 by Jovan Stosic