The Brother HL-5150D is a USB black and white laser printer for use in small offices or at home. It works in Linux using CUPS and Brother's lpr driver and cupswrapper.
Before we start...
Brother-provided PPD file
Brother does provide a PPD file for this printer, so in theory installation should be a breeze using Cups' built-in printer installation wizard. However, Brother printers installed that way often don't work correctly, in particular they tend to misalign the printed content on the page, leading to margins being too small or too wide or text being cut off. This is due to the driver being buggy with regards to paper size and who knows what else. The method described below leads to a fully working printer.
The steps below work for 64bit systems.
Setting up the Kernel
If you use Cups 1.3.x, you need USB Printer Support enabled in your kernel. Cups 1.4.x brings its own kernel module, so if you use that version, remove USB Printer Support from your kernel to avoid conflicts.
Installing required packages
- You'll need to install net-print/cups on your system if you haven't done that already. For more information on that subject please refer to the article CUPS.
- You'll need app-arch/rpm2targz to unpack the downloaded .rpm files.
- On an amd64 non-multilib system, you need app-emulation/emul-linux-x86-compat. (Quick check: if you already have /lib32/libc.so.6 you should be good to go.)
Downloading and extracting the driver
- Go to http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html#HL-5150D and download both rpm packages.
- 'cd' to wherever you saved the files, convert them to .tar.gz and extract them (the filenames might look a little different depending on printer model and version updates):
Performing necessary changes
You'll need to adapt the scripts surrounding the drivers a litte to make them work. Open usr/local/Brother/cupswrapper/cupswrapperHL5150D-1.0.2 in your favorite editor.
- Change all occurrences of /etc/init.d/cups to /etc/init.d/cupsd (there should be 6 of them).
- If you're on a 64bit system, change all occurrences of /usr/lib/ to /usr/lib32/ (I've counted 4).
- On recent Cups versions (probably 1.4.x, I'm not sure), you'll need to change the connection identifier for your printer. At the bottom of the file, you'll see a line lpadmin -p HL5150D -E -v usb:/dev/usb/lp0 -m brhl5150d_cups.ppd. To find out what to change it to:
- Start /etc/init.d/cupsd if it's not already running
- Turn on your printer
- Open your browser and go to http://localhost:631
- Begin adding a printer ("Administration" -> "Add Printer"), choose your connected printer
- On the second screen, look out for the field labeled "Connection:". Copy its contents. Cancel the printer addition process.
- Put this string into the script, replacing usb:/dev/usb/lp0, so that the line looks like this:
lpadmin -p HL5150D -E -v usb://Brother/HL-5150D%20series?serial=XXXXXXXXX -m brhl5150d_cups.ppd
- The driver defaults to A4 paper. If you're in North America you'll probably want to change that. Open usr/local/Brother/inf/brHL5150Drc and change PaperType=A4 to:
Installing the drivers
Now it's time to copy the driver to your system.
You'll also need to set a few symlinks to make Cups happy:
Then you can install the printer. Run:
No further setup inside Cups is necessary. Go print yourself a test page.
The instructions above are based on these sources, which unfortunately are both outdated/incomplete: