GithubHelp home page GithubHelp logo

brother-in-arms's Introduction

Brother printer drivers for Raspberry Pi and other ARM devices

Why? The Brother provided Linux drivers have parts that are compiled for i386 and have no source code. Although there is an open source Brother Printer driver, it is not optimized for cheap printers with their small cache. It fails part way into a print on large images or busy pages.

So, how do we port the closed-source driver to another architecture? There are several methods:

  1. Run i386 code on ARM through an emulator. It works, but testing on RPi 4, the emulation layer overhead made printing terribly slow.
  2. Reverse engineer, recreate and recompile the code for ARM. This has only been done for rawtobr3 as far as I know. There is also an original source available for brcupsconfig4, but other necessary part are missing.
  3. Scavange and collect Brother's own ARM code into the full ARM install package. This is the approach taken here.

Quick start

Run the oh_brother.zsh script with the model of the printer that you have, like this ./oh_brother.zsh HL-4570CDW

If this script fails, you need to do the steps manually. Read below:

Background

Many Brother printers are designed for LPR and lack support for common page description languages (PDF, PCL, etc). They require a CUPS wrapper to translate the print options to their native protocol.

There are at least four Brother provided pre-compiled x86 32-bit binaries. Specifically:

  • /usr/local/Brother/Printer/HL2270DW/cupswrapper/brcupsconfig4 - wrapper that calls on brprintconflsr3 to set up /usr/share/Brother/inf on every print to pass the current options.
  • /usr/local/Brother/Printer/HL2270DW/lpd/rawtobr3 - converter for the job to a raster format. Seems to be model-agnostic. Called by /opt/brother/Printers/BrGenPrintML2/lpd/lpdfilter
  • /usr/local/Brother/Printer/HL2270DW/inf/brprintconflsr3 - translates job options to Brother format. Seems to be backward compatible. Called by /opt/brother/Printers/BrGenPrintML2/cupswrapper/lpdwrapper from brgenprintml2pdrv-4.0.0-1.i386.deb which is itself in the opt/brother/Printers/BrGenPrintML2/cupswrapper/brother-BrGenPrintML2-cups-en.ppd
  • /usr/local/Brother/Printer/HL2270DW/inf/braddprinter - adds alphanumeric printer model name to /usr/share/Brother/inf/brPrintList upon installation. This can be safely ignored.

Below is an example of how to create ARM packages for Brother HL2270DW, but it should work for other printers, both on ARM64 and ARM32 RPis. Substitute the proper packages for your printer. To find these packages:

Oh, yeah and next time just buy a printer that has Driverless printing or IPP Everywhere

Creating the ARM packages for HL2270-DW

Note: if you just want to install the precompiled packages grab them from this repo and run sudo apt install psutils cups; sudo dpkg -i hl2270dwlpr-2.1.0-1.armhf.deb cupswrapperHL2270DW-2.0.4-2.armhf.deb. Steps below show how to re-create them.

We'll be grabbing 2 native arm32 executables and compile one other. All the steps can be done on RPi or on x86 Doing it on x86 will require cross-compilation of brcupsconfig for armhf.

Repackage LPR drivers

Get the original i386 LPR driver, unpack the files and the control information

wget https://download.brother.com/welcome/dlf005893/hl2270dwlpr-2.1.0-1.i386.deb
dpkg -x hl2270dwlpr-2.1.0-1.i386.deb hl2270dwlpr-2.1.0-1.armhf.extracted
dpkg-deb -e hl2270dwlpr-2.1.0-1.i386.deb hl2270dwlpr-2.1.0-1.armhf.extracted/DEBIAN
sed -i 's/Architecture: i386/Architecture: armhf/' hl2270dwlpr-2.1.0-1.armhf.extracted/DEBIAN/control
echo true > hl2270dwlpr-2.1.0-1.armhf.extracted/usr/local/Brother/Printer/HL2270DW/inf/braddprinter

Grab the Brother ARM drivers from a generic armhf archive they provide and copy the ARM code into the unpacked folders. Note that HL2270 does not use brprintconflsr3.

wget http://download.brother.com/welcome/dlf103361/brgenprintml2pdrv-4.0.0-1.armhf.deb
dpkg -x brgenprintml2pdrv-4.0.0-1.armhf.deb brgenprintml2pdrv-4.0.0-1.armhf.extracted
# cp brgenprintml2pdrv-4.0.0-1.armhf.extracted/opt/brother/Printers/BrGenPrintML2/lpd/armv7l/brprintconflsr3 hl2270dwlpr-2.1.0-1.armhf.extracted/usr/local/Brother/Printer/HL2270DW/lpd
cp brgenprintml2pdrv-4.0.0-1.armhf.extracted/opt/brother/Printers/BrGenPrintML2/lpd/armv7l/rawtobr3 hl2270dwlpr-2.1.0-1.armhf.extracted/usr/local/Brother/Printer/HL2270DW/lpd

Now repackage it

cd hl2270dwlpr-2.1.0-1.armhf.extracted
find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums
cd ..
chmod 755 hl2270dwlpr-2.1.0-1.armhf.extracted/DEBIAN/p* hl2270dwlpr-2.1.0-1.armhf.extracted/usr/local/Brother/Printer/HL2270DW/inf/* hl2270dwlpr-2.1.0-1.armhf.extracted/usr/local/Brother/Printer/HL2270DW/lpd/*
dpkg-deb -b hl2270dwlpr-2.1.0-1.armhf.extracted hl2270dwlpr-2.1.0-1.armhf.deb

Repackage CUPS wrapper

Grab and extract the brcupsconfig4 sources

wget https://download.brother.com/welcome/dlf006733/brhl2270dwcups_src-2.0.4-2.tar.gz
tar zxvf brhl2270dwcups_src-2.0.4-2.tar.gz
cd brhl2270dwcups_src-2.0.4-2

Compile brcupsconfig4

gcc brcupsconfig3/brcupsconfig.c -o brcupsconfig4

If you are running these steps on the arm64 platform do cross complilation by first getting arm-linux-gnueabihf-gcc-9 via sudo apt install gcc-9-arm-linux-gnueabihf and then running arm-linux-gnueabihf-gcc-9 brcupsconfig3/brcupsconfig.c -o brcupsconfig4

Grab the original i386 CUPS wrapper and unpack it

wget https://download.brother.com/welcome/dlf005895/cupswrapperHL2270DW-2.0.4-2.i386.deb
dpkg -x cupswrapperHL2270DW-2.0.4-2.i386.deb cupswrapperHL2270DW-2.0.4-2.armhf.extracted
dpkg-deb -e cupswrapperHL2270DW-2.0.4-2.i386.deb cupswrapperHL2270DW-2.0.4-2.armhf.extracted/DEBIAN
sed -i 's/Architecture: i386/Architecture: armhf/' cupswrapperHL2270DW-2.0.4-2.armhf.extracted/DEBIAN/control

Copy the compiled code into the unpacked folder

cp brhl2270dwcups_src-2.0.4-2/brcupsconfig4 cupswrapperHL2270DW-2.0.4-2.armhf.extracted/usr/local/Brother/Printer/HL2270DW/cupswrapper

Repack it

cd cupswrapperHL2270DW-2.0.4-2.armhf.extracted
find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums
cd ..
chmod 755 cupswrapperHL2270DW-2.0.4-2.armhf.extracted/DEBIAN/p* cupswrapperHL2270DW-2.0.4-2.armhf.extracted/usr/local/Brother/Printer/HL2270DW/cupswrapper/*
dpkg-deb -b cupswrapperHL2270DW-2.0.4-2.armhf.extracted cupswrapperHL2270DW-2.0.4-2.armhf.deb

Installing

Note: if you are using RPi4 64 bit OS (AARCH64 aka ARM64) you need to install libc6:armhf. No need to do it on ARM32 aka AARCH32 aka armhf aka armv7l

sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install libc6:armhf

Install prereqs and install the drivers

sudo apt install psutils cups
sudo dpkg -i hl2270dwlpr-2.1.0-1.armhf.deb cupswrapperHL2270DW-2.0.4-2.armhf.deb

You may need to install other runtime dependencies such as a2ps, glibc-32bit, ghostscript

How to get the PPD and the filter

In case you're missing the printer defeniton you can extract it from the cupswrapper for from a Windows driver distribution using the official brother method

Top extract extract the filter and the PPD file directly from the cupswrapper run this:

sed -e '0,/cat <<!ENDOFWFILTER! >/d' -e '/^!ENDOFWFILTER!/,$d' './cupswrapperHL2270DW-2.0.4' -e 's|\\||g' > ./brlpdwrapperHL2270DW
sed -e '0,/cat <<ENDOFPPDFILE >/d'   -e '/^ENDOFPPDFILE/,$d'   './cupswrapperHL2270DW-2.0.4'              > ./HL2270DW.ppd

How to install on an x86 platform

Either use the driver installer, which is just a bash script that downloads the debs, or download the debs manually and install

curl -o - https://download.brother.com/welcome/dlf006893/linux-brprinter-installer-2.2.2-1.gz | gunzip > linux-brprinter-installer-2.2.2-1
echo -e "HL2270-DW\ny\nn" | sudo bash linux-brprinter-installer-2.2.2-1
(HL2270-DW as "model name", then y to continue, "no" for "Will you specify the DeviceURI?" choose "No" for USB connection or "Yes" for network connection.

or manually download debs and configure them.

References

brother-in-arms's People

Contributors

alexivkin avatar northisup avatar the-alchemist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

brother-in-arms's Issues

Emulation & Deadlink & No .c file

* Run i386 code on ARM [through an emulator](https://wiki.alphaframe.net/doku.php?id=raspberry_pi:brotherh1110). However, if you are using RPi the emulation layer will make it terribly slow.


Speaking of emulation of x86 in raspberry pi
Does anybody tried https://forums.raspberrypi.com//viewtopic.php?f=28&t=203755#p1677249 ?


I tried script in this repo for my printer DCP-1601, but it doesn't work, because there is no .c file in .deb
i386 cups wrapper
i386 lpr

Alternate solution for some printers - extract a PPD from the Windows BR-Script driver

https://help.brother-usa.com/app/answers/detail/a_id/164936/~/how-to-create-a-brother-ppd-file-for-installation---linux

I'm pretty sure this is just the USB solution for printers that otherwise support driverless printing, but I was tired of my HL-L3210CW running out of memory printing large pictures (I assume it was attempting to scale the images on the printer), so I set up an rpi print server for it. After fiddling with other solutions I stumbled over this and it might be nice to direct other fools like me to this option.

Does not work for MFC-L9570CDW

When I run
$ sudo zsh oh_brother.zsh MFC-L9570CDW
I get the error
dpkg-deb: error: 'mfcl9570cdwlpr-1.5.0-0.i386.deb' is not a Debian format archive

Running on a Raspberry Pi Zero 2 W on Debian Bookworm

Cannot create package for MFC-J6720DW

Dear @alexivkin,

I tried to create a package for my Brother MFC-J6720DW printer, but I am not able to. I am getting the following error message:

oh_brother.zsh: Zeile 6: ${${ZERO:-${0:#ZSH_ARGZERO}}:-${(%):-%N}}: Falsche Substitution.

Also doing it step by step I am not able to create them.

Can you help me for this, or can you create it for me?
I am enclosing the .deb files
Deb.zip

Thank you

ADadlDudlDa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.