Building Raspberry Pi Alpine Linux drivers (splix) for Samsung SCX-3205

(Executive summary: Some prebuilt packages also available at my site http://alpine.asuka.fi/v3.12/community/ )

Remember my old war horse, the Samsung SCX-3205 black & white printer/scanner? I recently moved in to a house. My girlfriend did not want printer near TV (with my ESXi shoebox) anymore, so I had to invent something else.

I had old Raspberry Pi 2 Model B v. 1.1 around, so I thought I should hook it up with the printer. Unfortunately I ended up compiling the necessary drivers myself because Alpine Linux did not have anything relevant. (I don’t blame them, this is quite outdated and rare.)

BTW Some Prebuilt packages are available at

http://alpine.asuka.fi/

Trying stock CUPS

The first thing I tried of course was to check out how the thing performs with stock CUPS. So, I installed cups package with apk:

apk add cups

I found from Internet a PPD file I think I had used earlier, so I tried the configuration with it:

When printing test pages, this came up:

So lots of errors. I rerun stuff and these errors jump out:

Samsung_SCX-3200_Series: File \"/usr/lib/cups/filter/rastertoqpdl\" not available: No such file or directory

CreateProfile failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files

CreateDevice failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files

First error hints that there is something very essential missing from the system. Other errors could be dependent.

QPDL is some kind of printer command language used for some Samsung printers. And seems to be, also for my SCX-3205.

Spying old installation for info

Luckily I had the old ESXi printserver Debian installation running. I fired a shell to take a look. /usr/lib/cups/filter/rastertoqpdl was indeed in place:

root@printserver:~# ls -la /usr/lib/cups/filter/rastertoqpdl
-rwxr-xr-x 1 root root 67768 Feb 10 2018 /usr/lib/cups/filter/rastertoqpdl

So, time to see what package provides the specific file:

root@printserver:~# dpkg -S /usr/lib/cups/filter/rastertoqpdl
printer-driver-splix: /usr/lib/cups/filter/rastertoqpdl

Interesting. Time to see full package info:

So, the driver is something called Splix driver from http://splix.ap2c.org/ with download links pointing to https://sourceforge.net/projects/splix/files/ . Cool. Lets get explicit list of dependencies:

root@printserver:~# apt-cache depends printer-driver-splix
printer-driver-splix
Depends: libc6
Depends: libcups2
Depends: libcupsimage2
Depends: libgcc1
Depends: libjbig0
Depends: libstdc++6
Depends: cups
Depends: cups-client
Depends: cups-filters
Breaks: <splix>
Replaces: <splix>

And lets check all the files the package provides:

root@printserver:~# dpkg-query -L printer-driver-splix
/.
/usr
/usr/lib
/usr/lib/cups
/usr/lib/cups/filter
/usr/lib/cups/filter/pstoqpdl
/usr/lib/cups/filter/rastertoqpdl
/usr/share
/usr/share/cups
/usr/share/cups/drv
/usr/share/cups/drv/splix-dell.drv
/usr/share/cups/drv/splix-lexmark.drv
/usr/share/cups/drv/splix-samsung.drv
/usr/share/cups/drv/splix-toshiba.drv
/usr/share/cups/drv/splix-xerox.drv
/usr/share/cups/ppd-updaters
/usr/share/cups/ppd-updaters/splix.ppd-updater
/usr/share/doc
/usr/share/doc/printer-driver-splix
/usr/share/doc/printer-driver-splix/changelog.Debian.gz
/usr/share/doc/printer-driver-splix/changelog.gz
/usr/share/doc/printer-driver-splix/copyright

So, this is probably partially the info we need in setting the necessary things up.

What the flaming f…

I figured out from the Debian packages that cups-filters were needed. I installed those with apk

apk add cups-filters

And I got forward. I also compiled the Splix driver 2.0.0 source from https://sourceforge.net/projects/splix/files/ (how? I’ll tell later).

I got forward now. Strangely, I saw first the error message which made no sense. It said “SpliX Invalid PPD file version: SpliX V. 2.0.0 but the PPD file is designed for SpliX V. 2.0.0”. Seriously, WTF?

I added quick debug print, recompiled and checked what happens. And take a look:

You see?  The system was comparing “SpliX V. 2.0.0” and “2.0.0”. Of course it does not work.

Confusions alleviated

I took a look at Splix source codes. Specificly comparing last official release 2.0.0 and latest SVN commits. And guess what did I see:

So actually, there had been silly change or feature in the system which now caused problems.

Next I took a look at PPD file to see what they contain in general:

So there is lots of meta information and settings (also the “2.0.0”). Also there are directives to tell how to process the input picture for the printer with filters. In this case the filter program “rastertoqpdl” was needed. This explained one of our initial errors. Splix 2.0.0 installed the correct filter program.

I figured out that I should ditch the PPD file I found from internet and install the exactly latest revision of the Splix driver to the local CUPS system and then reconfigure the driver.

The Alpine Linux build system

To build my packages (earlier and now) I read about Alpine Linux build system. In a way it is pretty straightforward. This tutorial got me going: https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package .

The system is almost the same for all architectures (but for “read-only mode” installations, like in Raspberry, one needs to issue “lbu commit -d” when needed.

For building one needs also so-called APKBUILD file. I was able to create my own and it is listed below and also as a Gihub gist here: https://gist.github.com/usvi/28ceec3a3c48f9677831afab0ddc8df8

or raw: https://gist.githubusercontent.com/usvi/28ceec3a3c48f9677831afab0ddc8df8/raw/f201c7a6ab0dd98391484abefe9287a9fee849f4/APKBUILD

# Contributor: Aurelien Crock
# Contributor: Till Kamppeter
# Maintainer: Janne Paalijarvi <jpaalija@gmail.remove.com>
pkgname=splix pkgver=2.0.0
pkgrel=2
pkgdesc="Samsung printers CUPS support files" url="http://splix.ap2c.org/"
arch="all"
license="GPL"
depends="cups cups-filters"
makedepends="cups-dev"
#install=""
#subpackages="$pkgname-dev $pkgname-doc" source="http://deb.debian.org/debian/pool/main/s/splix/splix_2.0.0+svn315.orig.tar.gz http://deb.debian.org/debian/pool/main/s/splix/splix_2.0.0+svn315-7.debian.tar.xz" builddir="$srcdir"/splix-2.0.0+svn315.orig 

prepare() {
  patch -d "$srcdir"/splix-2.0.0+svn315.orig -p1 < ../debian/patches/0001-Fix-alignment-problem-on-armel.patch
  patch -d "$srcdir"/splix-2.0.0+svn315.orig -p1 < ../debian/patches/0002-Set-IFS-when-looping-over-the-file-to-avoid-letting-.patch
  patch -d "$srcdir"/splix-2.0.0+svn315.orig -p1 < ../debian/patches/0003-Fix-the-aready-already-typo.patch
  # Omit 4th core debianisms patch
  patch -d "$srcdir"/splix-2.0.0+svn315.orig -p1 < ../debian/patches/0005-Use-compilers-passed-to-make.patch
  default_prepare
}

build() {
  # Replace with proper build command(s)
  make DISABLE_JBIG=1
}

check() {
  # Replace with proper check command(s)
  :
}

package() {
  # Replace with proper package command(s)
  make DESTDIR="$pkgdir" install
} 

sha512sums="3ea4cee4f24c44dacdc3d474e1b8c0bed016d6673f2a84a1b33b45d7746897a7511725f830748a90de7be0a6ae5f29a7364ab60f1683398c435af2cf46d84be7 splix_2.0.0+svn315.orig.tar.gz 451aa91f9d7d0e33e0bbc6e397143cdc02b66aa0d84cbfd0e2af22a2cea13bf5ad15582905f16e0708552d4746f12c6698ff5464f74194a81c2753fa655fb31a splix_2.0.0+svn315-7.debian.tar.xz"

Some important notes:

  1. Because it is practically impossible to download the actual source from SourceForge in a script like this (insane, right?), I’m using Debian source package
  2. I’m applying only selected patches from the source package
  3. I’m not splitting the package into sub-packages because in this case I don’t think it makes much sense
  4. JBIG library is explicitly disabled as I did not want to add complicating dependencies

Installing the build system

Installing the build system needs to be done step-by-step just as stated below. Otherwise you run into problems.

First, allow community repo from /etc/apk/repositories:

Perform apk update to fetch pkg indexes:

Make new user, add it to abuild group, install sudo and edit the sudoers file with visudo command:

Btw, if you are in Raspberry Pi “read-only” installation, remember to add home directory to save paths with something like “lbu add /home/user”.

Add “user ALL=(ALL) ALL” line to sudoers file:

Check IP address with ifconfig so we can ssh in with Putty:

Create necessary directories:

sudo mkdir -p /var/cache/distfiles
sudo chgrp abuild /var/cache/distfiles
sudo chmod g+w /var/cache/distfiles

Create build keys with “abuild-keygen -a -i”

Building the actual package

Now that everything is in place, we can start to build the actual package.

First, create build directory. I used /tmp/build . Dunno if good, but seemed to work. Then in that directory download the APKBUILD file (in raw mode):

In the directory, issue “abuild -r”. As you can see the build starts by making some checks and installing dependencies:

More dependecies being installed:

The actual build process running. Old C++ code barely complies with all the new checks and nags in place:

After raw build the system maks further checks:

Then finally the package is complete. In the absolute final step the system removes temporary packages required for building:

Done done done. Package appears in ~/packages/tmp/<arch>/splix-2.0.0-r2.apk (at least during time of writing):

Installing the package

I made also small mirror of packages I built. It is at http://alpine.asuka.fi/v3.12/community/ . They are unsigned, so you need the –allow-untrusted options for apk add if you dare to install them:

But if you have keys on your own machine / if you followed this guide, you can install with sudo:

As you can see, all dependency packages got automatically installed:

Quite a lot. But it works with this selection. At least after a couple of tweaks.

Finishing touches

As this blog post was mostly about building the necessary package, I’m not going to go through of how to configure CUPS completely. But couple of pointers. Enable the service on startup with:

sudo rc-service cupsd start
sudo rc-update add cupsd

And next a stupid hack. Because the mdev functionality does not work that great (at least in 3.12), we need to make the following. In /etc/mdev.conf change:

Specifically the line to add is

SUBSYSTEM=usb;.* root:lp 0660

Position matters, so keep it there.

This hack makes all USB devices to be owned by lp group. Stupid but mdev is bugged somehow and it is next to impossible to single out just the printer we need.

NOW RUN lbu commit -d IF YOU ARE IN RASPBERRY “READ-ONLY” INSTALLATION.

AND IN ANYCASE NEXT REBOOT THE SYSTEM.

Finally find a way to access http://localhost:631/   to configure the printer. OR if you want to allow external configuration access, edit /etc/cups/cupsd.conf to have “Allow all” to Location stanzas “/” and “/admin”.

Thoughts

After another sleepless night adventure the print server is up and running on Raspberry Pi 4 Model B 2GB (aarch64). There is/was huge CPU load from GhostScript when rendering the pages for printing. Raspberry Pi 2 Model B nearly chokes on it on one core making printing slow. RPi 4 seems to be more up to the task in terms of speed. That mdev hack needs to be looked at at some point. This should not be needed for :lp ownership.

If you had any luck with my help or want to point something out, please comment below.

4 Replies to “Building Raspberry Pi Alpine Linux drivers (splix) for Samsung SCX-3205”

  1. Trying to get my scx-3405 to work with my pi zero w print server. Can these steps be applied to rasbian os?

    Thanks In advance

    1. In general:

      I think that if Raspbian is Debian-based, it should already have proper packages. My first proper system was running ok this printer stuff in amd64 Debian on PC.

      But SCX-3405 … I don’t know. Try?

Leave a Reply

Your email address will not be published. Required fields are marked *