Engineering and technology notes

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.

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

Mily Balakirev – Wikipedia

Mily Alexeyevich Balakirev (Russian: Милий Алексеевич Балакирев, IPA: [ˈmʲilʲɪj ɐlʲɪkˈsʲeɪvʲɪtɕ bɐˈɫakʲɪrʲɪf]; 2 January 1837 [O.S. 21 December 1836] – 29 May [O.S. 16 May] 1910) was a Russian composer, pianist, and conductor known today primarily for his work promoting musical nationalism and his encouragement of more famous Russian composers, notably Pyotr Ilyich Tchaikovsky. He began his career as a pivotal figure, extending the fusion of traditional folk music and experimental classical music practices begun by composer Mikhail Glinka. In the process, Balakirev developed musical patterns that could express overt nationalistic feeling. After a nervous breakdown and consequent sabbatical, he returned to classical music but did not wield the same level of influence as before.

In conjunction with critic and fellow nationalist Vladimir Stasov, in the late 1850s and early 1860s Balakirev brought together the composers now known as The Five (a.k.a., The Mighty Handful) – the others were Alexander Borodin, César Cui, Modest Mussorgsky and Nikolai Rimsky-Korsakov. For several years, Balakirev was the only professional musician of the group; the others were amateurs limited in musical education. He imparted to them his musical beliefs, which continued to underlie their thinking long after he left the group in 1871, and encouraged their compositional efforts. While his methods could be dictatorial, the results of his influence were several works which established these composers’ reputations individually and as a group. He performed a similar function for Tchaikovsky at two points in the latter’s career – in 1868–69 with the fantasy-overture Romeo and Juliet and in 1882–85 with the Manfred Symphony.

As a composer, Balakirev finished major works many years after he had started them; he began his First Symphony in 1864 but completed it in 1897. The exception to this was his oriental fantasy Islamey for solo piano, which he composed quickly and remains popular among virtuosos. Often, the musical ideas normally associated with Rimsky-Korsakov or Borodin originated in Balakirev’s compositions, which Balakirev played at informal gatherings of The Five. However, his slow pace in completing works for the public deprived him of credit for his inventiveness, and pieces that would have enjoyed success had they been completed in the 1860s and 1870s made a much smaller impact.

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