Brainwaves Raspberry Pi

Kodi on Raspberry Pi 3 running Arch Linux ARM

When setting up Kodi under Arch Linux ARM running on Raspberry Pi 3, I encountered this error, which crashed the graphical environment right from the start:

[drm:vc4_bo_create [vc4]] ERROR Failed to allocate from CMA:

After some searching, I ran into an issue thread, where it was advised to increase the CMA memory (as a workaround that seems to just be the actual fix). You need to add ‘cma=256M’ to the kernel boot parameters. But how do you do that?

# Run as root...

# dependencies
pacman -S uboot-tools

# modify the kernel boot parameters
cd /boot
vim boot.txt # append cma=256M to the line with boot params

Before this fix, I had only 64 MB of CMA. This wasn’t enough. To check that this worked:

if the cma parameter is present and /proc/meminfo

cat /proc/cmdline
# should contain cma=256M

cat /proc/meminfo | grep Cma
# should say CmaTotal: 262144 kB

Now Kodi finally starts!

…though there are still some problems with the graphics driver (video doesn’t play, random switching to the console and back).

As it turns out, using the AArch64 version of Arch Linux ARM for Kodi is not the best option. Switching to the ARMv7 version helped a lot, everything worked from the start.



Birdie: Alarm App for Linux Phones

Wouldn’t it be nice to have a way to be woken up by your phone in the morning? Well, any old Android phone can do that! That was not the case with Linux phones. Until Birdie came along. Let’s consider the options:

Gnome Clocks? Nope. The app needs to be running for the alarm to activate.

Cron? Nope. When the phone gets suspended to save power, it will miss the alarm.

Wake Mobile? Close, but nope. It has most of the technology that is needed, but the alarm sound is annoying and it is not convenient to use. To be fair, this was only a proof of concept app. Some people reportedly used it anyway.

Birdie? YES! This one brings the minimum of features that I consider are required for an alarm clock.

Birdie features

  • one recurring alarm for selected days
  • ON/OFF switch
  • pleasant alarm sound with gradually rising volume, starting from complete silence
  • stop / snooze buttons
  • configurable alarm sound
  • wakes the system from sleep
  • shows control buttons on the lock screen, without the need to log in

With this feature set, I can finally replace my Android phone as an alarm clock!



What is MPRIS?

This week I found out about MPRIS: Media Player Remote Interfacing Specification. It is a standardized D-Bus interface for exposing metadata and controlls from a music player. Thanks to MPRIS, other apps can integrate such a music player seamlessly, e.g. onto the computer lockscreen.

What else can you do with MPRIS? Stop or Snooze your alarm clock! That’s right, the alarm clock Birdie designed for Linux phones (PinePhone) now acts as a music player. Now you don’t have to unlock the phone to stop an alarm in the morning!



Building AArch64 Arch Linux packages on a x86_64 host

I was looking for a convenient way of easily building AArch64 (ARM64 / ARMv8-A) packages for Arch Linux ARM, namely for the PinePhone. One option is to cross-compile the packages, but maintaining a cross-compilation toolchain is a pain. I wanted the experience of compiling natively without the need to heat up the weak ARM CPU these devices have.

QEMU to the rescue! It is possible to run an emulated Arch Linux ARM on a non-ARM device. This way you can compile natively. And with armutils this whole process of building packages can be automated. All you need is to install a few AUR packages, create an AArch64 chroot and start building!


You’ll need qemu-user-static-bin, binfmt-qemu-static-all-arch and finally armutils-git, installed from AUR (e.g. via yay).

Creating a chroot

mkarmroot -u <YOUR-PATH>/aarch64/root base-devel

Building a package

Assuming <YOUR-PATH>/pkg contains the package PKGBUILD file:

cd <YOUR-PATH>/pkg
sudo makearmpkg -r ../aarch64 -- --noconfirm




Video Terminal Revival

Don’t you love old video terminals? I know I do! That’s why I spent the few last weeks playing around with various terminal-related technologies: composite video, CRT monitors, old keyboards and the VT100 standard. The result is a working physical VT100 emulator, built around a CRT TV, LK201 terminal keyboard and an ESP32.

Source code, instructions and photos: video-terminal-revival repository



Zbrojovka Brno Consul 262.9 adapted to USB

I obtained a vintage mechanical keyboard from 1988: Consul 262.9, made by Zbrojovka Brno. It features contactless Hall-effect switches (i.e. magnet sensors detect keypresses). It uses an XT protocol, so I had to create an adapter to make it usable for me. I could probably buy some cheap ready-made adapter, but where’s the fun in that?

Consul 262.9 contactless keyboard, Zbrojovka Brno k.p.

Time to bring out the Arduino Leonardo! This newer Arduino features a HID-USB support, so it acts as a keyboard when connected over USB. All that remains is to connect the Arduino’s GPIOs to the keyboard’s pins and write a mapping layer between the “XT-keys” and “USB-keys”. Fun fact: this actually makes the keyboard programmable!

Here is the repository with the source code: xt-keyboard-adapter



Sway Stickynotes

I love using workspaces when working on a computer. It neatly organizes your windows; commonly used apps are easy to find and project-related apps are grouped together. Workspaces became a must-have for me and Sway is my long-time favourite solution for everything.

One thing that I was missing in Sway was a way to have a brief note on every workspace. When working on a project (however small), I keep things together on a dedicated workspace. But after some time I tend to forget what the idea of the workspace was. I then need to figure it out based on the content. And sometimes projects get lost this way. Thankfully there is an easy fix now: Sway Stickynotes

With this small (and dirty) tool I can assign a short note to every workspace and change it easily.



NAS disk failure and lessons learned

I recently had a degraded RAID storage on my NAS. In other words, one of the disks failed and wouldn’t spin up again. Thankfully I am running a RAID1 configuration on two disks, so I only lost one copy of the data. After replacing the disk with a blank new one, the RAID was restored and once again my data is safe and happily redundant on the second disk.

The disk that failed on my was a Seagate NAS HDD 3TB and it lasted 5 years. Funny thing is that the SMART disk monitoring warned me of an imminent disk failure only after the disk had already failed. The NAS (Zyxel NAS542) was angrily beeping after detecting the RAID degradation.

Initially I chose RAID1 for exactly this scenario – when one of the disks fails, I can just buy a new one. No risk of data loss, because it is unlikely that both of the disks would fail at the same time. The second disk is even a different brand (Western Digital Red Plus (EFRX) 3TB), just to make sure. Also, with RAID1 I just need two disks, which is way cheaper than going for the more advanced RAID configurations which need at least 4 disks.

So after the Seagate disk failed, did I go and buy a Western Digital one, since that disk didn’t fail? No. I went for a new 3TB Seagate NAS disk instead. I don’t think there is anything wrong with the brand and I like the benefit of being able to reference the disks by the maker. It helps with identifying them, lowering the chance I accidentally wipe or throw away the wrong one.

In summary: RAID1 is great. Automatic redundancy is important. Keep your data safe!



Error mounting a CIFS storage

I was trying to mount several folders from my LAN NAS (Zyxel NAS542) to build an automated backup server and I kept bumping into this error:

$ sudo mount /mnt/nas/bagr
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

$ dmesg | tail
[426845.904201] CIFS: Attempting to mount //
[426845.914365] CIFS: VFS: \\\bagr validate protocol negotiate failed: -13
[426845.915581] CIFS: VFS: cifs_mount failed w/return code = -5

The other folders from the same server mounted just fine. Just this one kept failing.

Then when I ssh-ed into the NAS I found out that the directory had incorrectly set permissions:

# ls -all
drwxrwxr-x   15 works    works         4096 Jan  9 16:12 works
drwxrwx---   15 bagr     bagr          4096 Jan  9 16:12 bagr

For some reason the directory needs to have the “others” permissions set to read and execute so that the CIFS (SMB/Samba) may access that.

To fix this, I just did:

# chmod o+rx bagr

Done! Now the storage mounts successfully!



Exploring Desktop Notifications in Linux

I was looking into the realm of desktop notifications in Linux. How do I show custom notifications on my desktop? Will the same code work on my PinePhone?

Yes! Thanks to standardization, D-Bus, libnotify etc. this can be done. You need a server which shows the notifications and a client which submits the notifications. Naturally, ArchLinux Wiki has a great entry on this: Desktop notifications. It even provides example client source code for various languages.

Notifications Server

Some desktop environments provide their own server built-in, some do not. Luckily there are a bunch of standalone solutions available. Plus you can customize these to your liking.

I’m running SwayWM on my desktop, so I needed to install a standalone server. Dunst is a nice and minimalistic solution, though currently just for X11 (e.g. dwm). Finally, I chose mako – a Wayland-native daemon built for Sway. Fun sidenote: mako started as a “Gah! This is too hard to port” response to this Dunst issue to support Wayland.

On the PinePhone this was simple – Phosh already provides a notifications server. It shows notifications in the top pull-down panel, just like in other phone UIs.

Notifications Client

Running e.g. this Python code from the ArchLinux wiki is all you need!

import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
Notify.init("Hello world")
Hello ="Hello world", "This is an example notification.", "dialog-information")

Sharing the same tools, code and APIs between a desktop and a phone is just awesome.