md
Installing the DCP-7040 Scanner in Ubuntu 17.10
January 15, 2018
Updated: January 25, 2018
-- Installation de Ubuntu 18.04.1 - Imprimante multifonction Brother DCP-7040->
Numérisation avec l'imprimante multifonction Brother DCP-7040 dans Mint 20.1 ou Ubuntu 20.04->

This is a happy day! I finally managed to get the scanner of the Brother DCP-7040 working in Ubuntu 17.10. Way back in 2016, when migrating to Linux, I had chosen to install Ubuntu 14.04 LTS. While 16.04 was available, it would not do for one reason: I could not get the scanner installed correctly in the newer version. Last November, when Ubuntu had to be reinstalled because of a "little mishap" that was entirely my fault, I crossed my fingers hoping that the scanner would work in Ubuntu 17.10. It didn't. But now it does! Impatient to find out how? Skip ahead.

Two nights ago, as I was falling asleep I had the brilliant idea to use my remaining Raspberry Pi Model B as a printer/scanner server. Hopefully, it would be possible to get around the problem of setting up the scanner in a Debian system. Some reading on the Web yesterday sort of convinced me that it looked feasible, there were lots of links to instructions although they were for the most part about 3 or 4 years old. Today, I tackled the problem seriously. It took a while to find the old Raspberry Pi. Then I decided to install DietPi on the SD card. I even installed Samba with the distribution utility, which is needed to connect a Windows system to a print server on Linux. That took quite a while, DietPi is very lean, so that many, many dependencies had to be installed. But that is ok, it was all done automatically and DietPi is so much nicer for setting up a headless server, supporting ssh out of the box and WiFi with just a simple edit of a configuration file on the boot partition of the SD card.

Then reality crashed in: I did not have drivers for the printer/scanner. A search of the Support and Downloads page for the DCP-7040 on the Brother web site turned up source code for the printer.

There was no mention of the scanner to be found in the archive. Even if it were possible to compile the source on the ARM architecture, I would be no further ahead, the scanner would not be available. Turns out that looking through the source code was a good thing.

As can be seen on the screen capture, there was a Christmas gift from the manufacturer, a new version of the driver installer. So I downloaded it. Before using it, I tried to undo everything I had done back in November trying to install the scanner. First I used the uninstall scripts that had been created by the installer.

michel@hp:~/Downloads/DCP-7040/tmp/$ sudo ./uninstaller_DCP7040 michel@hp:~/Downloads/DCP-7040/tmp/$ sudo ./uninstaller_brscan-skey michel@hp:~/Downloads/DCP-7040/tmp/$ sudo ./uninstaller_brscan3

Two lines

# Brother scanners ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="01e9", ENV{libsane_matched}="yes"
added to the file /lib/udev/rules.d/60-libsane1.rules were removed. Finally, I deleted the file /etc/udev/rules.d/60-brother-libsane-type1.rules

As you can see, I was trying to apply various Scanner Setting for normal user fixes found on the Brother site. These have to do with file permissions and udev rules. Such a fix had been necessary to get the scanner working in Ubuntu 14.04.

Once I rebooted, the system was hopefully back to its initial state as far as printing and scanning is concerned. I followed the installation instructions provided by Brother when I downloaded the new installer. It is a bash script, so all I had to do was to execute it as a superuser after extracting it from the archive.

michel@hp:~/Téléchargements/Devices/DCP-7040$ sudo su root@hp:/home/michel/Téléchargements/Devices/DCP-7040# bash linux-brprinter-installer-2.2.0-1 Input model name ->DCP-7040 You are going to install following packages. brdcp7040lpr-2.0.2-1.i386.deb cupswrapperDCP7040-2.0.2-1.i386.deb brscan3-0.2.13-1.amd64.deb brscan-skey-0.2.4-1.amd64.deb

At each step, I answered "y(es)" when asked if the package was to be installed. However when asked for the URI, I answered "n(o)"

Will you specify the Device URI? [Y/n] ->no

because the printer is a USB device without network capabilities.

The test print page printed without problems, but simple-scan could not find the scanner. I rebooted to make sure, and then ascertained that both lsusb and sane-find-scanner found the USB connection to the device. However scanimage -L could not find the scanner. The same thing happened when I tried as root and this time the penny dropped. The problem was probably not related to file permissions and udev rules. The problem is that SANE is not finding the Brother library. It was reading Elder Geek's answer in the ask ubuntu forum on the topic of "Simple Scan cannot find scanner" that I put the pieces together. There was a link to a list of files in the labesane-dev package and looking at it, I realized that /usr/lib/x86_64-linux-gnu/sane/ did not contain a shared library from Brother; there was no file named libsane-brotherxxxx.so in the directory. I remembered seeing something like that in the source code, so I looked at it again and found the correct name libsane-brother3.so.xxx so that it was a simple matter to locate the file with find. It turns out that the Brother installation program had put it in /usr/lib64/sane all by its lonesome. Thinking that there might be a reason for that choice, I decided to put a symbolic link to the library in the /usr/lib/x86_64-linux-gnu/sane/ directory instead of moving it.

With a bit more fiddling with the configuration of SANE as explained by Elder Geek and in the Ubuntu Community Help Wiki page entitled SANE - Installing a scanner that isn't auto-detected everything finally worked.

Completing the Installation of the Scanner in Ubuntu 17.10

To cut to the chase, after installing the newest driver from Brother, three things had to be done to complete the installation of the scanner.

  1. Verify that brother3 is in the file /etc/sane.d/dll.conf. I found the line at the end of the file, so I moved to its "rightful" alphabetical position in the list but I am pretty sure that it is not necessary. If you do need to modify that file, it will have to be done as a "superuser" as in michel@hp:~$ sudo nano /etc/sane.d/dll.conf

    I think that step is what is entailed by configuring the "front end" of SANE.

  2. Create a file named brother3.conf in the /etc/sane.d directory which contains the USB vendor and product ID of the printer/scanner. #Brother DCP-7040 usb 0x04f9 0x01e9

    The directory belongs to root so the file must be created using the sudo prefix. However, it turned out that I did not even have to create the file, it was there but named brother3_conf_attempt. Given its date, I assume it was created the first time I installed the drivers from Brother. So all I had to do was

    michel@hp:~$ sudo mv /etc/sane.d/brother3_conf_attempt /etc/sane.d/brother3.conf

    This is what is called configuring the "back end" of SANE.

  3. Finally, add the symbolic link to the Brother SANE library.
    michel@hp:~$ sudo ln -s /usr/lib64/sane/libsane-brother3.so.1.0.7 /usr/lib/x86_64-linux-gnu/sane/libsane-brother3.so.1

Checking with scanimage was gratifying:

michel@hp:~$ scanimage -L device `brother3:bus2;dev3' is a Brother DCP-7040 USB scanner

From there, it was obvious that Simple Scan would work when I found the scanner in its preferences. The final test was to reboot and check that everything still worked. And it did.

Others had found the solution before me. And it looks like all that is really needed after installation is adding the symbolic link. I can use the scanner without a brother3.conf file in the /etc/sane.d/ directory. But I decided to put it back, it looks prettier.

References:

16.04 and Brother DCP-7040 scanner on ask ubuntu,
Brother scanner not detected in ubuntu 16.04 on ubuntu forums.
Update: January 25, 2018

This is just an ad hoc solution. There is probably a correct way of fixing the installation, but to paraphrase Rhett Buttler, "I frankly don't give a damn". I do not want to spend any more time on this vexing problem; the solution works for me, perhaps it will work for others.

So now, I may not have a printer/scanner server, but I am happy that the scanner connected to my Ubuntu box works.

-- Installation de Ubuntu 18.04.1 - Imprimante multifonction Brother DCP-7040->
Numérisation avec l'imprimante multifonction Brother DCP-7040 dans Mint 20.1 ou Ubuntu 20.04->