skysurfer.media

streamer-base


strategy

So, its my second time around installing Arch Linux on a Raspberry PI and regretfully I didn’t keep any notes, so this time I’m documenting the process. The first time around there was confusion about the difference between the RPI 3B and the 3B+ which led to mismatched libraries when trying to build an exotic driver… but it worked! I was able to successfully build and install Webcamoid on a Raspberry Pi, including its custom video driver and all effects. Even recording was working. But then there were glitches and random crashes from issues with the kernel and as I kept rebuilding, reinstalling, and deleting things, I realized the main issue and simply deleted *everything* to start over. Unfortunately, this meant I lost some custom configs I wish I’d backed up. That’s the first part of the new strategy. I’ll also be able to better share the configurations and final images. But although I’m sharing this publicly, this document assumes some basic Linux knowledge and is not meant to be a tutorial, just install notes.

images

The starting point for any RPI 3 is the following link, but it leads to installation directions for ArmV7. Printed on my board is Raspberry Pi v1.2 – 2015, so the right image to start with is the aarch64, not the 32-bit version. This is important, as it’s one of the only differences between the 3B and the 3B+ and its critical for video hardware acceleration. This document only covers 64-bit installation on the RPI 3B+ although the same instructions should apply to the RPI 4 and 5, and the basic install process should be the same for the 32-bit version.

starting point:
https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3

use for RPI 2 or 3 (32-bit):
http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz

use for RPI 3B+ (64-bit):
http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz

I’m starting with a 512G MicroSD card but 32G should be more than enough. 64G or larger will allow lots of room for saving video files. The USB Disk driver is not necessary as some tutorials recommend when using the MIcroSD slot and USB is really just one Bus that shares 4 ports so the USB should be used *only* for the webcam. Onboard video should also be fine. For the camera, I’m using a Logitech C930e that should be able to stream 1080p and has the added benefit of a built in microphone. Any v4l compliant camera should work.

basic install

Partition the MicroSD with 2 partitions :

/boot – must be big enough for Grub. Some tutorials do not recommend enough. 300M should be sufficient – I used 512M to be sure. Make this Partition Type VFAT or it won’t boot. mkfs.vfat

/root – use the rest of the space for /root and make this Partition Type EXT4 – there is no valid reason to use a swap partition on fixed media. If its necessary for software because of a lack of memory (1G), a swap file is more appropriate. mkfs.ext4

There are different ways to unpack and install the image to the sdcard. I mount the formatted card’s /root partition on /mnt/root and then mkdir /root/boot and mount the /boot partition there. After mounting the partitons, I unpack the image into ~/ and ‘cp -a * /mnt/root’ — this can be done more poetically with a one-liner but making backups of an installed image is the reverse of this so versioned backups can be made the same manner. ‘cp -a /mnt/root/* ~/<backup-version> — in the end, I’ll have a few prebuilt filesystems to choose from, one basic, one with build tools, and one enhanced with added binaries and such. There is no plan to make a mega image with tons of useless extras, though variations can easily be made or restored this way.

Important: After installing the filesystem, a change needs to be made for Grub to be able to boot. If this is not done, you will be dropped to an emergency shell because the second partition will not be found. There are a couple of ways to do this. The RPI 4 directions on the Arch Linux site say to use ‘sed -i ‘s/mmcblk0/mmcblk1/g’ root/etc/fstab’ in the root mount and that the RPI 3 doesn’t require this. If you’re installing the RPI 3B+, you *should* be able to just boot to a prompt at this point without any further steps. But I have also read that you have to edit /etc/fstab manually to use the UUID of the /root partition. This didn’t work for me out of the box the second time around, though, and I think it’s probably better to just edit /mnt/boot/boot.txt to reflect the actual UUID of the /root partition since its not going to change. Use blkid to get partition information and remember to run mkscr in the /boot folder – and now you should be able to put the MicroSD card into the RPI and boot to the login prompt.

post install steps

The default user:pass is alarm:alarm for ArchLinuxARM.

The first thing you’ll see is an annoying blinking cursor.

alarm: printf '\033[?12l' ## does not work as it does in some terminals, so...
alarm: su root ## default password is: root
root: echo 0 > /sys/class/graphics/fbcon/cursor_blink

Blinking stops.

Now to fix a condition resulting from a big screen and a small font.

root: setfont -d ## doubles the consolefont size, or...
root: setfont /usr/share/kbd/consolefonts/solar24x32.psfu.gz

Note that these fonts are not in the default location and standard font config tools have not been installed. Several fonts are available at boot. It is possible to rebuild the kernel to use a specific font and size at the console level but this way is a flexible option that can be easily adjusted for different screens.

The RPI 3b+ requires a power supply of 2.5 amps – many power supplies are only 2.1 amps which is sufficient for most things, but can throw errors:
hwmon hwmon1: Undervotage detected!
hwmon hwmon1: Voltage normalised

Although these errors can usually be safely be ignored, they interrupt the terminal so I turn them off:

root: dmesg -n 1 ## disables output to stdout

I also prefer the look of an old green or amber monochrome monitor:

root: tput setaf 2 ## green, or...
root: tput setaf 3 ## amber

For color to be persistent, changing the PS1 variable is better, though. And while we’re at it, we can make the prompt simpler or fancier:

root: export PS1='\[\e[32m\]\u: ' ## makes prompt <user>: green
root: export PS1='\[\e[33m\]\u: ' ## makes prompt <user>: amber

This must be changed in /etc/bash.bashrc to be permanent for root and ~/.bashrc for the regular user. There is a lot of information about possible variables and fancy prompts elsewhere online.

Now lets make the rest into a script so I won’t have to enter all of these commands every time I boot up the RPI:

root: nano /etc/streamer-startup
echo 0 > /sys/class/graphics/fbcon/cursor_blink;
setfont /usr/share/kbd/consolefonts/solar24x32.psfu.gz;
dmesg -n 1;

Remember to make the script executable:

root: chmod a+x /etc/streamer-startup

And then let’s make this into a systemd service:

root: nano /etc/systemd/system/streamer-startup.service
[Unit]
Description=run streamer-startup script
[Service]
Type =oneshot
RemainAfterExit=yes
ExecStart=/etc/streamer-startup
[Install]
WantedBy=multi-user.target
root: systemctl daemon-reload
root: systemctl enable streamer-startup

A reboot will now bring up a readable prompt with any personal customization. This is an unorthodox way of setting things up but avoids the use of xinit, .profile, and so on… so it’s universal with or without a graphical environment. There are many ways to start a script on boot, but this keeps userspace changes in one place and can be easily disabled or edited.

Also, to enable sound and video, edit /boot/config.txt to include:
enable_uart=1
dtparam=audio=on
dtoverlay=vc4-kms-v3d
hdmi_enable_4kp60=1

update and upgrade

Ok, so now we need an internet connection to update and install the base system. The Arch Linux instructions assume you have an ethernet port to plug into but this is not the case for me since I’m doing all this on a broadband hotspot, and unfortunately the base install does not configure a wireless device by default. This is the other difference between the RPI 3B and the 3B+ — the main processor and the wireless adapter are the only two differences. These notes are only guaranteed to apply to the RPI 3B+ but the necessary changes may also be valid on other RPIs.

There are two problems with this adapter and Arch Linux. The first problem is that it remains in a down state since it isn’t recognized, easy fix.

root: cd /etc/systemd/system/network/
root: cp en.network wl.network
root: sed -i 's/en/wl/g' wl.network
root: systemctl daemon-reload
root: systemctl restart systemd-networkd

Now wlan0 will show up as ‘Configuring…’, basically waiting for the wireless program to connect it to the WAN – no problem, except that the program we want hasn’t been installed.

That was the second problem with my particular device, that it would not connect to a WPA hotspot no matter what I tried. The issue is with wpa_supplicant which is included as the default and is configured to use udev — this may or may not work for a USB adapter, but had problems with the onboard adapter and a cell phone hotspot. The solution is to upgrade to iwd which is far more up to date. It uses iw and ip so the problematic iwconfig along with wpa_supplicant are not necessary. Also unnecessary are netctl, netcfg, netcfg-auto, and wifi-menu… so much simpler to keep only networkctl and install iwd. There’s no need to install the bulky gnome network-manger, either, as some forums suggest. To achieve this, I had to open up an unencrypted hotspot – no password, no need for wpa_supplicant.

root: systemctl enable dhcpcd
root: systemctl start dhcpcd
root: iw wlan0 connect "<hotspot>" ## important that the hotspot name is in quotes

Once connected to the internet:

root: ping 4.2.2.2 ## make sure there's a connection
root: pacman-key --init && pacman-key --populate
root: pacman -Rns wpa_supplicant wireless_tools netctl
root: pacman -Syyu linux-aarch-headers ## use linux-rpi-headers for 32-bit
root: reboot

Reconnect to the hotspot.

Edit /etc/mkinitcpio.conf and remove ‘microcode’ from the HOOKS section

root: pacman -S most htop iwd ffmpeg-rpi vlc-rpi v4l-utils v4l2loopback-dkms v4l2loopback-utils i2c-tools

When prompted for a jack provider, choose pipewire-jack — this will be useful later.

root: hostnamectl set-hostname streamer
root: systemctl enable iwd
root: systemctl start iwd

Refer to https://wiki.archlinux.org/title/Iwd for more complete instructions on using iwd from the command line and managing connections.
Systemd-networkd and dhcpcd handle assigning an IP address to the interface automatically so the basic routine for connecting to a hotspot is:

root: iwctl station wlan0 scan
root: iwctl station wlan0 get-networks
root: iwctl station wlan0 connect "<hotspot>"

If there’s a password required, you will be prompted and WPA works fine. However, I’m only able to connect on 2.4ghz despite the capabilities of the card. 5ghz networks are not showing up for some reason.
I’m not bothering to troubleshoot this at this time.

On reboot, the wifi connection is now persistent…
This is an ideal stopping point to make the base image.

backup procedure

root: pacman -Scc  ## to empty the package cache

And the whole filesystem is only 3.3G so far!
Logout and move the MicroSD card back to the main OS.
Mount partitions just like when I installed:

root: mount -t ext4 /dev/sdX2 /mnt/root
root: mount -t vfat /dev/sdX1 /mnt/root/boot

In the folder where I keep images, ArchLinuxARM-rpi-aarch64-latest is no longer the latest, but we’ll stick with the convention.

root: mkdir ~/ArchLinuxARM-rpi-aarch64-20251220-streamer-base
root: cp -a /mnt/root/* ~/ArchLinuxARM-rpi-aarch64-20251220-streamer-base
root: tar czf ArchLinuxARM-rpi-aarch64-20251220-streamer-base.tar.gz ~/ArchLinuxARM-rpi-aarch64-20251220-streamer-base

Notes:
When copying the files, the system stalls on a file in /var/log/journal/<session>
Removing this directory was the solution. I have no idea what the problem is with the file but the system hangs on copying if the journal isn’t removed first.
During boot, there’s a quick yellow-colored warning that flies by on the screen… I’ve poured over dmesg and can’t figure out what it is. Maybe it’s related but I’ll assume it can be safely ignored.
Two errors persist – one is about adding hdmi_enable_4kp60 to /boot/config.txt but this does not make the error go away. The second error may be related – unable to find drm device by node – however, drminfo shows everything is good and the module is loaded and running without a problem. Kernel messages look like vc4 hardware acceleration is functional, so if there are any configuration issues they won’t likely surface until a graphical interface is installed.
ffmpeg-rpi and vlc-rpi are built to use hardware acceleration. Along with v4l2, this should be sufficient to start a camera stream from the command line.
most and htop are personal preferences, as is the font choice.

This image can be found at http://skysurfer.media/share