Setting up Brother HL-5250DN printer with OpenBSD

This document describes how to set up a Brother HL-5250DN printer with OpenBSD

Before reading this document further, please note that the rest of it was created using some GPL licensed documentation and code. Anything you use, or download from this page, is considered being used under the GPL license, version 2 or higher, along with this license file. If you disagree to any of the terms of the license, please close this page now.

Prerequisites

I connected the printer into my home network using ethernet interface. The printer does also support USB and LPT connection, and it should be possible to connect it using either of those ways, but the further instructions have specific to TCP/IP connectivity and LPD application protocols.

I used CUPS instead of LPD. CUPS seems to be a little more flexible then LPD, and also allows for better compatibility when printing from the network, however, my other systems connect to the printer using IPP/LPD/SAMBA, rather than using OpenBSD box as the print server.

The instructions may be specific to OpenBSD 4.1, for example you may not be able to find certain packages for earlier versions of OpenBSD, or some path locations may change.

For OpenBSD, you will need to install a few packages. I reference the version numbers that I have, your experience may differ. If you have packages of earlier versions, you may have to upgrade for some functionality to work.

These packages depend on a lot of others, you may have to pull quite a lot of dependencies in.

Related configuration

You will need to enable the Linux binary execution first. Edit the /etc/sysctl.conf file, uncomment the line with kern.emul.linux option, and make sure it's value is 1. Now, if you were on windows, or Solaris, you would have needed to reboot, but on OpenBSD you merely execute:

# sysctl -w kern.emul.linux=1
kern.emul.linux: 0 -> 1
#

If you haven't installed any RPM packages, you will need to initialize the RPM database first. This is what you need to do:

# mkdir -p /var/db/rpm
# rpm --initdb
#

If you haven't used CUPS before, you need to figure out how to enable it first. It is some time confusing. Supposedly, it's enough to execute the /usr/local/sbin/cups-enable script, and add the /usr/local/sbin/cupsd into the /etc/rc.local script. Then you should be able to access CUPS at https://localhost:631. I had problems with this, though I needed to access the web server from another system, so I had to modify the config files, and actually change some permission on the directories.

Now, you need to supply the printer with it's IP address. The printer can use BOOTP, RARP or DHCP protocols to obtain it's IP address. It can also use static IP address, and will fall back to one of the private network IP addresses if failed to auto-configure. The procedures on how to set up a static address, along with the examples for the auto-configuraion exaples can be found on the Brother web site. Specifically in the "Network User's Guide". You should really download this document from their web site, in case it's been updated, or if you prefer a different language.

I personally used DHCP, so my /etc/dhcpd.conf looks something like:

shared-network PAWEL {
    option domain-name "whoops";
    option domain-name-servers 192.168.xxx.xxx;
    option time-offset -28800;
    option ntp-servers 192.168.xxx.xxx;

    subnet 192.168.xxx.xxx netmask 255.255.xxx.xxx {
        option subnet-mask 255.255.xxx.xxx;
        option routers 192.168.xxx.xxx;

# skipped
        host printer   { hardware ethernet 00:80:77:xx:xx:xx;
                        fixed-address 192.168.xxx.xxx;
                        option host-name "printer"; }
    }
}

I actually had troubles finding what the ethernet address of the printer is, so I just turned it on without configuring DHCP, and looked at the /var/log/daemon. The dhcp server complained about the unknown ethernet address, so you can see what it is:

Oct 10 13:55:46 openbsd dhcpd: DHCPDISCOVER from 00:80:77:xx:xx:xx via sk0
Oct 10 13:55:46 openbsd dhcpd: no free leases on subnet PAWEL
As an undisclosed contributor pointed out, you can alternatively find the ethernet address by printing the settings. To print the settings, press the "Go" button 3 times within two seconds. The ethernet address will be printed near the top of the 3rd page of the 3-page printout.

The only last thing I had to do, is to set the Samba domain name on the printer, so it becomes discoverable. The best way is to use telnet:

# telnet printer
Welcome. Type , enter a password at # prompt

# 
Brother NC-6400h Command Console
<... skipped ...>
Enter username>
Local> set netbi dom sambadom
Local> in
You should type EXIT.

Local> exit
Connection closed by foreign host.
#
I'm not sure, but there should be a way to tell the printer what it's Samba domain name should be. Probably via combination of DHCP and WINS. If you know how to do that, please let me know.

The default password is access. It is a good idea to change the default password, and also disable web server access and IPP. If you retain IPP, it will advertise, and your CUPS server will want to add this printer as IPP destination, and you should probably avoid that.

"Installing" the software

I deliberately enclosed the word "installing" into the quotes, as it's really a mix of installing packages, copying the files to the right places, and using your favorite text editors to edit files.

Installing LPD drivers

You really should download the packages from Brother web site. Some of the package files have been modified, however, but you may want to modify the files yourself. I will explain where the files were obtained from in every single case. All download links in the rest of this document point to my website. The web site has a special page that is dedicated to Brother Linux drivers.

So let's install the DL-5250DN LPD drivers. Download LPD RPM package. Install the package using the following command:

# rpm -i --nodeps --noscripts --force --ignoreos brhl5250dnlpr-2.0.1-1.i386.rpm
#

The installer may babble about not being able to find files, but it should install the package successfully.

If you know a better way to extract the contents from RPM, please let me know. I played around trying to use cpio without much success.
You can see what have been installed by executing
# rpm -ql brhl5250dnlpr
/usr/bin/brprintconfiglpr2
/usr/bin/brprintconflsr2
/usr/lib/libbrcomplpr2.so
/usr/local/Brother
/usr/local/Brother/inf
/usr/local/Brother/inf/brHL5250DNfunc
/usr/local/Brother/inf/brHL5250DNrc
/usr/local/Brother/inf/braddprinter
/usr/local/Brother/inf/paperinf
/usr/local/Brother/inf/setupPrintcap
/usr/local/Brother/lpd
/usr/local/Brother/lpd/filterHL5250DN
/usr/local/Brother/lpd/psconvert2
/usr/local/Brother/lpd/rawtobr2
/var/spool/lpd/HL5250DN
#

All the fuss is about the rawtobr2 binary, and the brcomplpr2 library. You may want to move the library where it belongs better:

# mv /usr/lib/libbrcomplpr2.so /emul/linux/lib/
# ldd /usr/local/Brother/lpd/rawtobr2
/usr/local/Brother/lpd/rawtobr2:
	libbrcomplpr2.so => /lib/libbrcomplpr2.so (0x49895000)
	libc.so.6 => /lib/libc.so.6 (0x4c906000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x569dc000)
# /emul/linux/usr/bin/ldd /usr/local/Brother/lpd/rawtobr2
	libbrcomplpr2.so => /lib/libbrcomplpr2.so (0x4d8e8000)
	libc.so.6 => /lib/libc.so.6 (0x56eee000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x539e8000)

The ldd is to check that the binary will be executable.

Installing PPD file

The PPD file is the definition of the printer. Like a driver of sorts. It is used heavily by the IPP negotiations, and is also used internally by CUPS to determine what filters need to be executed. It may be used by any other filters in the chain, when the document find it's way from the your application to the printer. The PPD file is the part of the install script in the Brother CUPS package, I cut and pasted it from the script. Download my version here. The difference are : different defaults, so the "Letter" is the default page size, and duplex mode is on, and the toner saver is on. Also, some empty space strings replaced with empty strings. Put the PPD file into the /usr/local/share/cups/model directory.

Anytime you want to change the contents of the PPD file, you have to change this file. And then use the CUPS web interface, or run lpadmin, to update the PPD file CUPS stores in the /etc/cups/ppd directory. Don't modify files in the /etc/cups/ppd directory, unless it's some selection change, as they will be overwritten with the file from the model directory.

Installing CUPS filter script

The filter script is also embedded into the installation script, so I also had to cut it out. The script needed to be modified to use the proper location of psnup, and CUPS directories. Download the script here and place it into /usr/local/libexec/cups/filter directory.

Configuring the LPD driver

The LPD driver uses somewhat elaborate an unnessary configuration. The parameters are stored in the /usr/local/Brother/inf directory. I simply edited the /usr/local/Brother/inf/brHL5250DNrc file to change the paper size, toner saver and duplex mode. If I have more time, I'll try to modify, it is at all possible, the mechanism of reading the config file. Right now the drivers simply make the rc file world writable, which is not really good, and may lead to possible root exploits.

Installing the printer

The last thing to do is to install printer with CUPS. One way is to use it's web interface. This becomes simple, you should see the new printer definition in the list, and use 'LPD' for the protocol. My answers were:

Namelp
Locationhome
DescriptionHL-5250DN
 
DeviceLPD/LPR Host or Printer
 
Device URIlpd://printer.dns/binary_p1
 
MakeBrother
 
ModelBrother HL5250DN for CUPS(en)

You then way want to configure this printer as default, to avoid having to specify the destiantion every time you execute a printer command.

Another way is to use command line. If you don't know CUPS, I would recommend to read the manual pages to see what does what. Here are the commands I used:

# /usr/local/sbin/lpadmin -p lp -m HL5250DN.ppd \
-v 'lpd://printer.dns/binary_p1' -L home -D HL-5250DN
# /usr/local/sbin/cupsenable lp

That's it !
by Pawel S. Veselov, 2007
[Back] [Or press "BACK" button on your cool browser ;)]
This page was accessed
 times.
Traffic load: