Jump to content

Canon printer drivers (cnijfilter)


Recommended Posts

Canon provides source code for cups driver, but with some proprietary binary libs.

This libs available only for x86. No way for direct compiling cnijfilter for ARM (and other architectures). :(

 

But we have qemu! We can transparently run x86 executables on any other host architectures.

 

Easy steps to run cnijfilter on ARM (or any other arch):
- Build https://github.com/endlessm/cnijfilter-common for x86

- Copy all needed x86 libs using recursive ldd. And copy it to /usr/lib/bjlib/

- Patch all executables: set interpreter to /usr/lib/bjlib/x86/ld-linux.so.2 and rpath to /usr/lib/bjlib/

- Install these patched packages to ARM system

- Install qemu-user and qemu-user-binfmt (or qemu-arm-static)

 

You do not need to do this manually. I have implemented an automated build system: https://github.com/Azq2/cnijfilter-arm-build

 

All you need is any x86 machine to do the build.

 

How to use

1. On any x86 machine:

 

# Install dependencies
sudo apt install debootstrap git util-linux

# Get build system
git clone https://github.com/Azq2/cnijfilter-arm-build

# Start building
cd cnijfilter-arm-build
sudo ./build.sh build

# Get .deb packages
ls -lah ./result/full
ls -lah ./result/light

 

After build we have two variants of packages: full and light

 

Item Full Light

PPD files

+ +

CUPS filters

+ +

CUPS backends

+ -
lgmon + -

canon-maintenance

+ -
cngpij + -
cngpijmnt + -
cnijlgmon2 + -
cnijnetprn + -
cnijnpr + -
docs + -

 

In most cases, a light package is completely sufficient:

- We don't need canon usb backend, because cups have builtin USB support

- We don't need canon network backend, because cups have builtin BJNP support (package cups-backend-bjnp)

- Other canon maintenance utils are useless (in my opinion)

 

2. Copy .deb from result/light or result/full to your ARM machine.

 

3. On your ARM machine:

 

# Install dependencies
sudo apt install qemu-user qemu-user-binfmt # or sudo apt install qemu-user-static

# Install common for all printers package
sudo dpkg -i cnijfilter-common.deb

# Install printer-specific package
# Choose right package for your printer! e400series only for reference!
sudo dpkg -i cnijfilter-e400series.deb

 

4. Done. You can now configure CUPS.

 

Security with apparmor (optional)

 

CUPS filters don't need any specific permissions.

 

Create file /etc/apparmor.d/cnijfilter-filters with contents:

 

#include <tunables/global>

/usr/bin/bjfilter* {
	#include <abstractions/base>
	@{PROC}/sys/vm/mmap_min_addr r,
}

/usr/bin/cif[a-z]*[0-9d]* {
	#include <abstractions/base>
	@{PROC}/sys/vm/mmap_min_addr r,
}

/usr/lib/cups/filter/{cmdtocanonij,pstocanonbj,pstocanonij} {
	#include <abstractions/base>
	@{PROC}/sys/vm/mmap_min_addr r,
}

 

Then restart apparmor:

 

sudo systemctl reload apparmor
sudo aa-enforce cnijfilter-filters

 

Note: this minimal file full coverage all executables in light package. For full package you need write additional rules by yourself.

Link to comment
Share on other sites

Great work.

 

Currently still running building, so i dont know if it will work.

building for a while now & ill leave it for the night 😴.

 

Just a suggestion, I see that my terminal is showing its building for all canon printer models. (see screenshot)

In the future it would be nice if a specific model can be chosen instead of all model, to save time.

 

Goodnight.

Clipboard01.png

Link to comment
Share on other sites

Nice, I see that your strating from the build of https://github.com/endlessm/cnijfilter-common that has not been maintained since 3 years now.
Unfortunately for me it doesn't support yet my pixma G5550.  However Canon distribute new sources for the cnijfilter (https://www.canon-europe.com/support/consumer/products/printers/pixma/g-series/pixma-g550.html?type=drivers&detailId=tcm:13-2160851&os=all&language=en&productTcmUri=tcm:13-2080172).
Any suggestion how I can adapt your build to use directly Canon sources ? (or directly 64bits binaries)  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines