13 August 2021

Raspberry Pi 4 Print Server: Part 3

Time for the final setup steps

General Setup

Changing the hostname:

  • hostnamectl set-hostname <new hostname>
Broadcasting the hostname:
  • sudo apt install samba
  • sudo apt install libnss-winbind
  • install wsdd
    • git clone
    • group: nogroup
    • /usr/local/bin/wsdd
    • cp etc/systemd/wsdd.service /etc/systemd/system/
    • sudo systemctl daemon-reload
    • sudo systemctl enable wsdd
    • sudo systemctl status wsdd
Controlling the fan and Power button:


Printer Setup

Installing CUPS and Printer Drivers for SCX-4623f

Unfortunately CUPS requires a user/pass combination and the default is for root, so I set a password for root
  • Run this on the Raspberry Pi:
    • sudo su -
    • passwd
Forward the CUPS UI to your laptop
  • Run this on your laptop
    • ssh -L 6631:localhost:631 ubuntu@192.168.1.XX
You can now open a browser and go to http://localhost:6631 on your laptop for adding the printer and checking "Share printers connected to this system" on the "Administration" tab. For the user use "root" and use the password that you set above. Optionally, you can check "Allow remote administration" to skip the ssh command in the future and go directly to http://192.168.1.XX:631

You should now be able to see the printer on your network!

Scanner Setup

Raspberry Pi Setup

  • Install sane
    • sudo apt install sane
  • Check for the scanner
    • sudo sane-find-scanner
    • sudo scanimage -L
    • cd /tmp
    • sudo -u saned scanimage -x 100 -y 100 -d xerox_mfp:libusb:XXX:XXX --format=png -p > image.png
    • if you hear it scanning than it works and proceed, if not add saned user to lp group and try again
      • sudo usermod -a -G lp saned
  • Have saned listen to local network
    • edit /etc/sane.d/net.conf
      • add the local network (eg. 192.168.1.0/24)
  • Configure saned socket to load (you do not need the saned service itself)
    • sudo systemctl start saned.socket
    • sudo systemctl enable saned.socket

Laptop Setup

  • install xsane
    • sudo apt install xsane
  • edit /etc/sane.d/net.conf
    • add the ip address of the Raspberry Pi (eg 192.168.1.XX)
Start xsane and happy scanning!

10 August 2021

Rasberry Pi 4 Print Server: Part 2

These are the steps that I went thru to update the firmware and get Ubuntu Server 20.04 LTS installed on my Raspberry Pi 4 2GB from my Chromebook

Prerequisites:

Firmware Update Steps:
  1. Download the latest firmware from: https://github.com/raspberrypi/rpi-eeprom/releases
  2. Insert your SD Card into your Chromebook
  3. Copy the Contents of the Zip file onto the SD Card
  4. Uses Files to eject your SD Card and then remove from Chromebook
  5. Boot your Raspberry Pi using the SD Card
Ubuntu Steps:

  1. Download 64-bit Ubuntu Server for Rasberry Pi from here: https://ubuntu.com/download/raspberry-pi
  2. In Files: Move it from Downloads to your Linux Files
  3. On the Linux Command Prompt run:
    • xz -d ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz
  4. In Files: Right click the IMG file and click Zip selection
  5. Insert your SD Card or USB Drive you want to use
  6. Write the image to your removable media:
    1. Open Chromebook Recovery Utility
    2. Click the Setting Wheel next to the close window button
    3. Click "Use local image"
    4. Use files to select the zip file you just created
    5. Wait for the progress bar to complete TWICE (once for unpacking, once for writing)
    6. Exit Chromebook Recovery Utility
  7. Ubuntu 20.04 preinstalled servers uses cloud-init on first boot, you can find out more here:
  8. Setup your WiFi
    1. Open /system-boot/network-config in a text editor
    2. Uncomment (remove the # from the front of the line) the wifis section and update it with your wireless network and password
    3. wifis:
        wlan0:
          dhcp4: true
          optional: true
          access-points:
            "YourWifiNameHere":
              password: "YourPasswordHere"

    4. Or for a fixed IP
    5. wifis:
        wlan0:
          addresses: [192.168.1.XX/24]
          gateway4: 192.168.1.1
          nameservers:
            addresses: [192.168.1.1]
          dhcp4: false
          optional: true
          access-points:
            "YourWifiNameHere":
              password: "YourPasswordHere"

    6. Save the File
  9. If you are using a SD Card, you are finished and can:
    1. Eject the removable media using the Files app
    2. Remove it from the laptop
If you are using a USB Flash Drive, follow these additional steps:
  1. Decompress vmlinux
    1. Share the system-boot partition with Linux
      • In the files app, right click it and click "Share with Linux"
    2. Open the terminal
      1. cd /mnt/chromeos/removable/system-boot
      2. zcat vmlinuz > vmlinux
  2. Update /system-boot/config.txt to have the pi4 section look like:
    • [pi4]
      max_framebuffers=2
      dtoverlay=vc4-fkms-v3d
      boot_delay
      kernel=vmlinux
      initramfs initrd.img followkernel
  3. Install a script that will do this after installing updates (currently this cannot be done on a Chromebook because the writable partition is mounted read-only --oh the irony--)
    1. Create a file on /system-boot (/system-boot/firmware if logged into the pi) called auto_decompress_kernel and paste the code that is at the end of the blog
    2. Create a file in /writable/etc/apt/apt.conf.d called 999_decompress_rpi_kernel and paste the following single line into it:
      • DPkg::Post-Invoke {"/bin/bash /boot/auto_decompress_kernel"; };
    3. Share the writable partition with Linux
      • In the files app, right click it and click "Share with Linux"
    4. Open the terminal
      1. cd /mnt/chromeos/removable/writable/etc/apt/apt.conf.d
      2. chmod +x 999_decompress_rpi_kernel
You can now install the SD card or USB drive into the Raspberry Pi and start it up. You will need to login and change the password and then reboot (sudo reboot now) before it will connect to WiFi


auto_decompress_kernel
#!/bin/bash -e

#Set Variables
BTPATH=/boot/firmware
CKPATH=$BTPATH/vmlinuz
DKPATH=$BTPATH/vmlinux

#Check if compression needs to be done.
if [ -e $BTPATH/check.md5 ]; then
    if md5sum --status --ignore-missing -c $BTPATH/check.md5; then
    echo -e "e[32mFiles have not changed, Decompression not needede[0m"
    exit 0
    else echo -e "e[31mHash failed, kernel will be compressede[0m"
    fi
fi

#Backup the old decompressed kernel
mv $DKPATH $DKPATH.bak

if [ ! $? == 0 ]; then
    echo -e "e[31mDECOMPRESSED KERNEL BACKUP FAILED!e[0m"
    exit 1
else    echo -e "e[32mDecompressed kernel backup was successfule[0m"
fi

#Decompress the new kernel
echo "Decompressing kernel: "$CKPATH".............."

zcat $CKPATH > $DKPATH

if [ ! $? == 0 ]; then
    echo -e "e[31mKERNEL FAILED TO DECOMPRESS!e[0m"
    exit 1
else
    echo -e "e[32mKernel Decompressed Succesfullye[0m"
fi

#Hash the new kernel for checking
md5sum $CKPATH $DKPATH > $BTPATH/check.md5

if [ ! $? == 0 ]; then
    echo -e "e[31mMD5 GENERATION FAILED!e[0m"
    else echo -e "e[32mMD5 generated Succesfullye[0m"
fi

#Exit
exit 0

Sources and Thanks to:


Raspberry Pi Print Server: Part 1

As I still have our perfectly functional Samsung SCX-4623f laser printer and scanner, but wanted to be able to place it away from my server. I looked at a few different options, but decided on a Raspberry Pi to be my best option. Below are the several options that I considered.

The Choices

IOGear GPSU21 or other print server

  • Price: $40-50
  • Does not list SCX-4623f as compatible
  • Requires Ethernet connection so not as flexible
  • Printer Only, No Scanner function

Raspberry Pi

  • Price: Varies based on options
  • Requires more time to setup
  • A learning experience/project
  • Wouldn't need to find new owner for existing printer

Repurposing an old laptop

  • Price: Free*
  • Not power or space efficient

Hooking a laptop up every time we want to print

  • Inconvenient
  • Can't print from phones

New Printer/Scanner with built-in wireless

  • Price: ~$200

Parts


Here are the parts that I went with:
  • Raspberry Pi 4 2GB ($30-35 at Microcenter)
    • Another option was the Raspberry Pi 3 B+ ($25-30 at Microcenter), but I wanted the faster processor and more memory
  • Raspberry Pi Power Supply ($7-10 at Microcenter)
  • GeeekPi Raspberry Pi 4 Aluminum Heatsinks 20PCS ($8 Amazon)
    • This is 5 sets of 4 different sized heatsinks, so i now have plenty of spares
  • Argon One v2 ($20-25 Amazon)
  • Samsung Fit 64GB USB ($11-12 Amazon)
Total price before tax: $82

Raspberry Pi 4 with 2GB of RAM because it was not much more than either the 1GB version or Raspberry Pi 3B.

You can get cheaper cases, but I liked the Argon the best. I considered many full coverage heatsink cases, but those left the GPIO pins and the sides of the board exposed and I didn't want the chance of those getting shorted or something getting in. There were other full aluminum housing, but I couldn't find any reviews about whether those affected the wifi range. So it was basically between the Argon One and Flirc. I chose the Argon over the FLIRC because it redirects all the connections to the back and has a fan with a controller.

Even though the Argon One has heatsinks for the CPU and RAM, it did not have any for the Ethernet, USB, or Power Chip. Since the Argon One applies the power thru the GPIO headers and not the USB C port on the Pi, I figured that the power chip would not need cooled. However, since I am unsure about how much of a load scanning might put on the USB chip, I wanted a heatsink for that. Several other brand of heatsinks that I looked at had questionable reviews about how strong the thermal adhesive was.

I went with a USB drive over a SD card because of the faster speed and increased reliability, but looking back I think I would change that. The USB boot feature of the Raspberry Pi and Ubuntu 20.04 aren't quite there.

Assembly

First take the top of the Argon and see the exposed underside of the GPIO pins along the back (top of pic)

I used electrical tape to cover the underside of the GPIO pins so my additional heatsinks will not accidentally short them

Install the Argon daughter board onto the Pi

I then placed the heatsinks on the ethernet and USB controller

Place the thermal pads on the Argon lid and then place the Pi and daughter board into the top of the Argon case

Use the short screws to keep them in place

Install the long screws and the rubber feet