Sunday, December 28, 2014

Safer and more friendly Brother printer drivers

It is a cleaner way to intall Brother printer drivers for both 32bit and 64bit system (with of without multilib).

Below I describe a way to install Brother driver without obsolete closed-source apps. Ultimately you need only one app from Brother package: br<printer model>filter, where <printer model> is yours printer model, eg mfcj6510dw.

Preparation

mfcj6510dwcupswrapper-3.0.0-1.i386.deb

We only need opt/brother/Printers/<printer model>/cupswrapper/brother_<printer model>_printer_en.ppd file (eg. brother_mfcj6510dw_printer_en.ppd).

You should replace line at the begining of file (in this example, printer model is mfcj6510dw):

*cupsFilter: "application/vnd.cups-postscript 0 brlpdwrappermfcj6510dw"``

Change it to:

*cupsFilter: "application/vnd.cups-postscript 0 /opt/brother/bin/filter_mfcj6510dw"
mfcj6510dwlpr-3.0.0-1.i386.deb

From opt/brother/Printers/<printer model> you need:

  • lpd/br<printer model>filter => move to /opt/brother/Printers/<model>/filter

  • lpd/psconvertij2 => move to /opt/nbrother/bin/

  • inf/ - whole folder contents excluding setupPrintcapij => move to /opt/brother/Printers/<model>/inf/

Directory structure

/opt/brother
├── bin
│   ├── filter
│   ├── filter_mfcj6510dw -> filter
│   └── psconvertij2
├── lib
│   ├── ld-linux.so.2
│   ├── libc.so.6
│   └── libm.so.6
├── lib32 -> lib
├── opt
│   └── brother -> ..
└── Printers
    └── mfcj6510dw
        ├── filter
        └── inf
            ├── brmfcj6510dwfunc
            ├── brmfcj6510dwrc
            ├── ImagingArea
            ├── lut
            │   ├── BRPRI10IA.BCM
            │   ├── BRPRI10IB.BCM
            │   ├── BRPRI10IC.BCM
            │   ├── BRPRI10ID.BCM
            │   ├── BRPRI10IE.BCM
            │   ├── BRPRI10IF.BCM
            │   ├── BRPRI10IG.BCM
            │   ├── BRPRI10IH.BCM
            │   └── BRPRI10II.BCM
            └── paperinfij2

Installation

[x86] For 64bit and 32bit systems [x64] For 64bit systems without multilib

  • kernel - enable ia32 [x64]

  • sudo [x64]

  • chroot [x64]

  • libs [x64]

  • script [x86] [x64]

kernel - ia32 [x64]

Brother's driver is a 32bit application so you need to enable IA32 support in kernel.

Executable file formats / Emulations, IA32 Emulation
sudo [x64]

Sudo installation is needed for running in chroot. I tried to do it with setuid app but CUPS requires appropriate filter permissions (which is essentially Brother driver).

chroot [x64]

As in Directory structure, paths lib, lib32 and opt/brother are required for running chroot.

libs [x64]

To see which libs are needed on 32bit machine run ldd <ścieżka do filtra>:

glorpen@example ../brother $ ldd brmfcj6510dwfilter
    linux-gate.so.1 (0xf779f000)
    libm.so.6 => /lib32/libm.so.6 (0xf7719000)
    libc.so.6 => /lib32/libc.so.6 (0xf756b000)
    /lib/ld-linux.so.2 (0xf77a1000)

Copy given files to destination dir in chroot.

script [x86] [x64]

Create /opt/brother/bin/filter:

#!/bin/sh

DIR="/opt/brother"

PRINTER="$(echo $0 | sed -e 's/.*_//')"

BRCONV="${DIR}/Printers/${PRINTER}/filter"

if [[ -d /usr/lib64  && ! -d /usr/lib32 ]];
then
    BRCONV="/usr/bin/sudo /usr/bin/chroot --userspec=``id -u``:``id -g`` /opt/brother ${BRCONV}"
fi

PSCONV="${DIR}/bin/psconvertij2"

FILE_RC="${DIR}/Printers/${PRINTER}/inf/br${PRINTER}rc"
FILE_PAPERINF="${DIR}/Printers/${PRINTER}/inf/paperinfij2"
FILE_IMAGINGAREA="${DIR}/Printers/${PRINTER}/inf/ImagingArea"

cat | "${PSCONV}" "${FILE_PAPERINF}" "${FILE_RC}" "${FILE_IMAGINGAREA}" | ${BRCONV} -pi "${FILE_PAPERINF}" -rc "${FILE_RC}"

exit $?

Make it executable:

chmod a+x /opt/brother/bin/filter

Next, create symlink filter_mfcj6510dw -> filter

PPD file prepared earlier should point to created by us filter_mfcj6510dw.

CUPS

During printer configuration select our PPD file, that's all, after completing wizard printer should be ready to use.

If printed pages have it top cut off you may edit /opt/brother/Printers/<model>/inf/br<model>dwrc and change line from PaperType=Letter to PaperType=A4.