Hi there. As the title suggests, I'll explain how I converted my old Canon MF4450 printer, which doesn't have a network port, into a shared network printer in my home network using a Raspberry Pi4. This is actually quite easy to do. I actually wanted to explain the steps I took and the difficulties I encountered while doing this. Therefore, I first want to discuss the design before the real configuration.
Note: In the rest of this article, I will use the abbreviation RPi instead of Raspberry Pi.
The first thing is selecting the platform. As I mentioned in the title, I worked with RPi4, or I had to work with it, to be more precise. I also have a RPi 1B at home, and it's actually more than sufficient just for this task in terms of hardware. If this machine will be a dedicated print server, an 8 GB SD card (half of it just for operating system) is just fine as storage. And since RPi 1B has no onboard WiFi adapter, a WiFi dongle is also needed. I'm using a 128 GB SD card on RPi 4, because I run other services on it, but it is also mostly empty. RPi 4 has an onboard WiFi, so no additional hardware is required for wireless networking.
Using an RPi 4 solely for this task is clearly wasting resources, but here's what happened to me with RPi 1:
Selecting OS Distro
For print server, I first planned to use RPi 1B. This has a 32-bit CPU. 32-bit version of Raspberry Pi OS (formerly Raspbian) can be downloaded from the official website. This is a Debian-based distro. I opted for the lite version of it, even though RPi 1 is able to launch GUI, it is beyond usable slow. Apart from that, I also evaluated Alpine RPi, DietPi and piCore, but only found DietPi somewhat useful. It is also Debian-based and gave me the impression of being a customized version of RPi OS. However, DietPi configuration script requires a working internet connection during the very first boot. I'll address this issue later.
RPi4 is 64-bit. For this, I downloaded the 64-bit version of RPi OS from its official website. I also downloaded Manjaro ARM, Ubuntu and Fedora IOT, but I didn't have much time to use the first two. Fedora IOT's approach is quite different from both classic Fedora and other distributions. It uses a script called ignition for the initial configuration, which is similar to cloud-init, but based on JSON. RPi OS, on the other hand, is configured using a classic startup script.
WiFi Config on Raspberry Pi 1
I had a TP-Link AC600 WiFi dongle to use with my RPi 1, and I realized that this stick is not recognized automatically, because the driver for this chipset (Realtek rtl8821au) is missing in RPi OS as well as Dietpi. There is a driver for this chipset, openly developed on github, but you still need internet to download it. Therefore, I had to connect the RPi initially via cable. As I mentioned earlier, DietPi cannot be initially configured without internet. This creates a chicken-egg problem. Alternative: Download the github repo directly to the SD card on the computer.
In the meantime, I ordered TP-Link's TL-WM725N model (rtl8188eu chipset). Its driver is shipped with RPi OS and the card is recognized automatically. While my order was on its way, I compiled the driver I downloaded from github. gcc, make and bc is prerequisites and it gets compiled with a simple install-driver.sh script and installed via DKMS, but due to the RPi 1's CPU speed, compilation takes about 4-5 hours. I also didn't like having to install extra packages, that I'll be only using once or twice, especially on a distribution like DietPi, which is supposed to be optimized for being small.
Printer Config on Raspberry Pi 1
The second problem I had with the RPi1 (after WiFi), was that there is no official 32-bit ARM driver for Canon MF4450. If you have a different model printer, that works perfectly on RPi 1, feel free to skip this section.
I downloaded the printer driver from Canon's official website. According to their website, Linux ARM is supported. The fire (linux-UFRII-drv-v620-m17n-20.tar.gz) contains .deb and .rpm files for ARM64, x86 and x84 platforms but no ARM32. Therefore, I decided to compile the source code in the Sources directory. But this means installing a bunch of packages again, which will be only used for compilation. Moreover, spoiler alert: I couldn't succeed after compiling the driver (if you're not curious about the process, you can skip this part, too). To compile the driver, you'd need to install a total of 11 prerequisite packages.
After installing these, I ran allgen.sh script in the cnrdrvcups-common-6.20 and cnrdrvcups-lb-6.20 directories in sequence, to compile the code and copied the files with make install. When compiling cnrdrvcups-lb-6.20 on DietPi, a pointer conversion error occurs. Therefore, CFLAGS variable needs to include -fpermissive flag. To do this, I added the following case to the case structure in allgen.sh :
_machine_type="MACHINETYPE=armv6"
_cflags="CFLAGS=-fpermissive"
;;
After setting all these up, I did not get any errors from compilation and neither did I from CUPS while sending print jobs, but even the local print jobs did not reach the printer. I haven't solved the problem yet, but I still have some cards up my sleeve. If I can solve this issue later, it could be a future blog post. TL;DR: Due to both the WiFi issue -even if it's resolved now- and the printer driver, I decided not to waste time with RPi 1B and to focus on RPi 4 instead.
Configuration Steps
In this section, I based my work on the "Raspberry Pi Print Server" article. I won't go into details of RPi 4 setup. After writing the image file to the SD card and booting it up, a wizard asks for details such as username, WiFi settings and prepares the system accordingly. If SSH isn't enabled yet, enable it with following command:
Then I installed the packages, mentioned in the article:
Frankly, hplip and printer-driver-gutenprint packages didn't work for me. According to the article, they contain drivers for many printers, including Canon, but apparently the MF4450 model isn't there. cups-bsd is just a dependency of Canon driver.
CUPS is configured through a web UI, and the user must be in the lpadmin group or be root, to configure it. Following commands add the current user to this group and grant external access to CUPS:
cupsctl --remote-any
sudo systemctl restart cups
After this step, you should be able to access CUPS webUI via http://<machineIP>:631/ from a computer on your network. If not, the host firewall may be running. In this case, you can disable it by running sudo ufw disable or allow the port to the network. If it's still not working, check whether there is a process listening on that port and whether CUPS is running.
If everything is fine so far, I need to install the printer driver.
Printer Config on Raspberry Pi 4
To install the printer on RPi 4, I used the same driver package, I used for RPi 1. After connecting the printer, I installed the .deb file in ARM64/Debian directory, using following command.
There is one big detail here: If a window manager is running, a window will pop up (see the image right) on the desktop during the installation. If you're installing it via SSH, it may seem like the installation is frozen, yet the installer is waiting for input via GUI. Therefore, a monitor should be connected during the installation. The installer finds the connected printer automatically. In next step, you select the printer model and the installation is complete.
After spending hours compiling in various ways on RPi 1, I couldn't reach this point, where I got to in about ten minutes with RPi 4. Now, I went back to service configuration.
samba, which I installed above, is necessary to share the printer with Windows clients. I didn't need to make any change in cups.conf. Since I won't be creating any Windows share, I commented out the [homes] section in smb.conf. In the [printers] and [print$] sections, I set guest ok = yes. I checked for errors using testparm -s command and loaded the new settings with systemctl reload smbd command.
These steps are slightly different in DietPi. First, it's recommended to install CUPS and samba using dietpi-software command. Second, DietPi has a customized smb.conf. You should copy the default [printers] and [print$] sections from smb.conf.example file.
CUPS and the driver are independent of eachother. Even if the driver isn't installed, CUPS can find the printer, display it in the web interface and add it without any issue. To do this, I first clicked 'Administration' from the upper bar. A SSL certificate warning should appear in the browser, because Administration page is served with HTTPS and you're getting redirected to HTTPS now. I skipped it and logged in with the user I added to lpadmin. When I clicked "Find New Printers", it automatically found the printer. After I clicked "Add This Printer", a page appeared, asking me what alias to give it to. The only thing important is to select "Share This Printer" here. If the driver is already installed, Canon's model list appears on the next page. You can still go further without installing the driver, by providing the PPD file for the printer. The correct file for Canon MF4450 printer is CNRCUPSMF4400ZK.ppd. And I can extract this file from any .deb or .rpm file in the driver package. In Fedora, this can be achieved with
command. PPD files are definition files, that contain the specs of printers. They're platform and distribution independent. The driver selection page looks very similar to the one in the image below, but since I had already added the printer, I have included an image of "Modify Printer" page.
When I click on this printer, "Printer and Queue Settings" page opens (on the left). Here, I'll check whether I have loaded the correct PPD file. Default paper size is different (A4 vs Letter) in European and American versions of the same PPD file. If I accidentally load the US version, the print job is delivered to the printer with Letter sized paper, and an annoying warning appears during printing. As it can be seen from the screenshot, the settings are correct here. If Letter appears in these settings, you should select 'Set Default Options' from 'Administration' menu
... and change the paper size to A4 on the page that appears next.
Finally, I took a test printout on this interface via Maintenance -> Print Test Page.
If this gets printed correctly and without problems, the printer is installed. When I tried this for the first time, just input the PPD file without installing the driver, there was no printer activity, and when I clicked the 'Show All Jobs' button, it was showing an error with rastertoufr2. This mean, the driver has/could not been installed correctly. This file should be normally located at /usr/lib/cups/filter/rastertoufr2. At this point, there is no way around installing the driver. However, it is the PPD file, specifies that this file must be called. Perhaps something can be still done by changing corresponding line in PPD file.
And finally, one last magic touch: Debian shuts down the wireless network card, when it hasn't detected any activity for a long time. To prevent this, you need to run
command. So, the printer is now online on the local network.
Installing the Printer to Windows and Linux Clients
Installing a network printer to clients is quite easy. Moreover, I must admit, that it's easier in Windows than Fedora. This procedure is probably similar in other Linux distros, but I have Fedora and I'll focus on that.
To add a printer in Fedora, open System Settings -> Printers, click on '+ Add' button above. The network printer is found quickly. When I clicked on 'Select Recommended Driver' here (below), IPP Everywhere gets selected.
I continued by selecting this, and the form on the right image appeared. I continued without changing anything here. Queue name must be a unique name. Description and Location can be changed as desired, if the defaults are not descriptive enough.
Since there is no other printer installed in my system, 'Default printer' option isn't important. If everything is OK, click 'Add' to add the printer, and it should appear in the printers list.
A test job can be sent, by clicking on this printer and then 'Print Test Page' button in the window.
In Windows (v10 ve v11), when you select printers from settings or type "Printers" on the Start Menu, a form appears with an 'Add a printer or scanner' entry and 'Add device' button next to it. The printer gets listed automatically, when you click on this button. There is another 'Add device' button, next to the newly found printer. When you click it, the printer is installed automatically, but this step may take 1-2 minutes. The drivers are probably being downloaded from the internet during this time.















