Archlinux on PinePhone [Part 1]

In this part I'm trying to make a phone out of PinePhone BraveHeart Edition running Arch Linux ARM.

In the previous part I've got a bare-bones system running with SSH access.

A phone with a terminal is cool but I don't even have a keyboard to interact with it. There are plenty of desktop environments and window managers to solve this problem but just a few are built with a phone in mind. Gnome is a good example. Starting from version 3 it's much more touch-friendly but I'd say it's more tabled oriented. It's not my daily driver but I've grown to love this DE and there is a mobile-first shell for it - phosh by Purism.

Phosh is developed for Purism's Debian based PureOS. It's also well supported by PostmarketOS based on Alpine Linux which is much closer to Arch Linux than Debian due to APKBUILD being similar to PKGBUILD. I'm going to use the postmarketOS implementation/packaging of phosh as a reference.

The disappointing thing is the lack of Phosh and its dependencies in the main repos. Let's take a quick look at what is available at Dreemurrs Embedded Labs repo:

$ pacman -Sl pine64
pine64 danctnix-usb-tethering 0.1-0 [installed]
pine64 linux-pine64 5.5.0-2 [installed]
pine64 linux-pine64-headers 5.5.0-2 [installed]
pine64 mesa-git 20.1.0_devel.120770.bc5724faf40-1 [installed]
pine64 qt5-es2-base 5.14.1-1
pine64 qt5-es2-declarative 5.14.1-1
pine64 qt5-es2-multimedia 5.14.1-1
pine64 qt5-es2-wayland 5.14.1-1
pine64 qt5-es2-xcb-private-headers 5.14.1-1
pine64 rtl8723bt-firmware 20190223.28ad358-1 [installed]
pine64 tinymembench-git 0.4.r13.ga2cf6d7-1
pine64 uboot-pinephone v2020.01_megous-1 [installed]

No phosh but we have git version of mesa which is what postmarketOS is using with its phosh PinePhone build. Danct12 wrote that Phosh UI is coming to this repo. I think there is nothing wrong with trying to get Phosh running myself.

It means I'm going to AUR. One thing about it: I try not to use AUR helpers because I have more than one machine and compiling stuff on every one of them seems like a waste of time and resources. The solution is running my small repos. The cool thing is it also helps some of my friends and close ones to save some time. Right now for PinePhone users, there are two interesting ones:

  • PinePhone - PinePhone/mobile-specific stuff goes to
  • General - used to be AUR builds and my own projects for x86_64 but now aarch64 is slowly getting to the same pace

It's subject to change because I hope that PinePhone stuff is going to appear in Dreemurrs Embedded Labs repo and Arch main repo. Or my repos can just get merged.

AUR search for phosh gave a positive result. I see phosh with up-to-date version! Checking PKGBUILD reveals that there is no aarch64 architecture but other ARMs are present. Arch Linux ARM build system adds all necessary ARM architectures to upstream's (regular Arch Linux) PKGBUILDs automatically. But since other ARM variants are already there why not to ask to add one more =] As for now I'm passing the -A flag to the makepkg to ignore a missing architecture (more info in man). Done!

Now cloning it to the PinePhone and trying to build. First things first - missing dependencies: feedbackd and phoc are available only in AUR. Moving to build them first.

Right about now I would like to mention that Arch Linux doesn't support partial upgrades. This is the thing I'm well aware of and still, it was able to bite me. While building the feedbackd I've encountered an issue of missing libffi even though I was building it with makepkg -s which installs all available dependencies (libffi is not one of this package dependencies but it sure should be installed because it's at least required by vim). An easy thing to fix: search for it pacman -Ss libffi, install it pacman -S libffi. I'm not sure what it was exactly, probably an update for glibc and libffi or some other important underlying bits. Versions of underlying components got mismatched. I, being unaware of this, was still trying to build the feedbackd and fighting build errors. I decide to reboot. BOOM! a kernel panic at boot!

The previous version of libffi is not available in the pacman cache. I'm not aware of archive for Arch Linux ARM. My little panic. After all, it's always possible to nuke and pave this system but it means losing some part of a challenge spirit.

Luckily in pacman cache of one of my RaspberryPis was a suitable version of libffi ( instead of Copy to sdcard. Downgrad in a qemu powered arch-chroot. Boot on PP. It's working!

At this point, I'm starting to guess that my feedbackd dependency play got in the middle of an upgrade. Upgrading everything and rebooting got feedbackd to build just fine.

No problems with phoc apart from a failing test. It has to be started and requires EGL to be tested which is not a state I can get during build right now or at all. Passing --nocheck to makepkg solves the problem.

Good time to add some phone related apps to repo:

It's time to start all of it! PostmarketOS uses lightdm for this. Installing and configuring it by creating /usr/share/lightdm/lightdm.conf.d/20-autologin.conf:


Configuring groups like in this guide

alarm user used in this example is the default one for Arch Linux ARM installation. It's highly recommended to change it. I use another one. Do it.

Firing it with systemctl start lightdm. I've got couple service failures due to misconfiguration but /var/log/lightdm/lightdm.log pointed them out. Clean service start! The terminal blinker stopped!

Wait! There is no video. journalctl says there is a core dump by phoc:

Stack trace of thread 36003:
#0  0x0000ffff86d3bab8 raise ( + 0x36ab8)
#1  0x0000ffff871877e8 g_log_default_handler ( + 0x667e8)
#2  0x0000ffff87187a6c g_logv ( + 0x66a6c)
#3  0x0000ffff87187cb8 g_log ( + 0x66cb8)
#4  0x0000ffff8741a5dc n/a ( + 0x1295dc)
#5  0x0000ffff87295278 n/a ( + 0x1d278)
#6  0x0000ffff8729736c g_object_new_valist ( + 0x1f36c)
#7  0x0000ffff87297634 g_object_new ( + 0x1f634)
#8  0x0000aaaac996dbb8 n/a (phoc + 0xfbb8)
#9  0x0000ffff87294ed4 n/a ( + 0x1ced4)
#10 0x0000ffff87296c78 g_object_new_with_properties ( + 0x1ec78)
#11 0x0000ffff87297668 g_object_new ( + 0x1f668)
#12 0x0000aaaac9969b88 n/a (phoc + 0xbb88)
#13 0x0000aaaac99686d0 n/a (phoc + 0xa6d0)
#14 0x0000aaaac9967e80 n/a (phoc + 0x9e80)
#15 0x0000ffff86d2912c __libc_start_main ( + 0x2412c)
#16 0x0000aaaac9967fc8 n/a (phoc + 0x9fc8)
#17 0x0000aaaac9967fc8 n/a (phoc + 0x9fc8)

Well, that's all I got energy for today. Going to be back soon!

P.S. Resources I find useful to monitor: