Introduction: Network and AirPrint Support for Legacy Printer

I have a trusty old Brother HL-3040CN laser printer, and wanted to be able to print wirelessly from my laptop and phone. A previous attempt to use my router as a print-server failed because it didn't have drivers for this printer.

This printer is listed as not-supported by the OpenPrint list of printers.

In this instructable, I describe how I use a wifi-enabled Raspberry Pi as a print server, and run the Intel Linux drivers emulated. This includes support for Apple AirPrint.

Supplies

  • Raspberry Pi (the Zero W is ideal).
  • An SD card, at least 4GB, containing Raspberry Pi OS Lite.
  • A micro-USB male to USB type-B male cable. Or a micro-USB to type-A female adapter, and a normal USB printer cable.
  • A power supply for the Raspberry Pi.

Step 1: Install CUPS

Normally installing a print server is a case of running:

sudo apt-get install cups
sudo usermod -a -G lpadmin pi


You can verify that cups is running and what version you have by navigating to http://<ip-of-raspberry>:631/

AirPrint support was added to OpenPrinting CUPS 2.4.0 which, at time of writing, was newer than the version available from apt-get, so it was necessary to compile it from source:

sudo apt-get install autoconf build-essential libavahi-client-dev libgnutls28-dev libkrb5-dev \
    libnss-mdns libpam-dev libsystemd-dev libusb-1.0-0-dev zlib1g-dev
wget https://github.com/OpenPrinting/cups/releases/download/v2.4.0/cups-2.4.0-source.tar.gz
tar -xvf cups-2.4.0-source.tar.gz
cd cups-2.4.0/
./configure
make
sudo make install
sudo systemctl daemon-reload
sudo service cups restart

Step 2: Install Printer Drivers

Many printers have drivers included with CUPS. Others can be downloaded using apt-get, or from the manufacturer:

sudo apt-get install printer-driver-brlaser

OpenPrinting has a list of printers and suitable drivers: https://www.openprinting.org/printer/


The HL-3040CN is not supported by any of these methods. Brother provides Linux drivers for Intel machines (Raspberry uses an ARM processor). I was able to follow these instructions from DJAh to get these running successfully:

sudo apt install qemu-user-binfmt debootstrap
sudo mkdir -p /foreign/rootfs-i386
sudo debootstrap --foreign --arch=i386 stable /foreign/rootfs-i386/
sudo mkdir /etc/qemu-binfmt
sudo ln -s /foreign/rootfs-i386/usr /etc/qemu-binfmt/i386
wget https://download.brother.com/welcome/dlf006893/linux-brprinter-installer-2.2.3-1.gz
gunzip linux-brprinter-installer-2.2.3-1.gz
sudo mkdir -p /var/spool/lpd
sudo bash linux-brprinter-installer-2.2.3-1 HL-3040CN
sudo service cups restart

Print a test page when prompted.

If things aren't working you can view the logs at /var/log/cups/error_log

I needed to comment the line in /etc/ld.so.preload by adding a # at the start. I also needed to:

lpadmin -pBrother_HL-3040CN_series -o pdftops-renderer-default=gs
sudo apt-get install a2ps

Step 3: Setup the Printer in CUPS

Navigate to https://<ip-of-raspberry>:631/admin and proceed if warned that it's insecure.

Click "Add Printer" and enter your linux credentials (pi/raspberry by default)

Your printer should show up as a local printer. Select it and click "Continue".

Give it a suitable name and select "Share This Printer". Click "Continue".

On the next screen you should be able to select your make, and model. Click "Add Printer".

Print a test page.

Raspberry Pi Contest

Participated in the
Raspberry Pi Contest