A real Linux
distribution
for phones
and other mobile devices.
Alpha version. Calls don't work, etc. Only suitable for hackers.

Two years of postmarketOS

June 23, 2019 14 min. read

Our Journey Towards a Sustainable Mobile OS

Wouldn't it be great if you could take any obsolete smartphone from the past ten years and replace its outdated and insecure software with a maintained, modular free software stack? How about then using it as a Raspberry Pi-like device for your next tinkering project? With some constraints, postmarketOS makes this possible today for 139 booting devices. Every single package in the whole OS can be updated, with the only exceptions being the vendor's Linux kernel and firmware blobs (if you plan on using them). In a few cases, it is even possible to switch out the discontinued vendor kernel forks with the upstream kernel releases straight from Linus Torvalds.

We have made it easy for fellow hackers to install our Alpine Linux-based distribution on all kinds of mobile devices, to port new ones, and to change each and every piece of the operating system. Development can be done from any Linux distribution, with no requirements except for installing our lightweight pmbootstrap program. People use it on a daily basis to create amazing contributions.

Yet we are still at the beginning and full of potential to eventually breathe so much new life into these obsolete pocket computers, that they may one day become usable as actual phones again. We are here to stay, and we are celebrating two years of extending, improving and having fun with the platform and community that could potentially end the madness of planned obsolescence in the mobile phone market!

User Interfaces

Let's start our summary of what happened since the last update post with UI related news. Alpine developer @maxice8 packaged elogind in our upstream distribution, which means we can finally use a proper display manager. @PureTryOut created a patch to use lightdm instead of the previous approach of hacking /etc/inittab for autologin on TTY1 and kicking off a /etc/profile.d/ script that does a half-hearted job of setting up the session. Almost all UIs expect such a display manager, therefore we will have less compatibility problems moving forward.

Phosh

In fact, Purism's Phosh UI (for the upcoming Librem 5) did not work without elogind at all. But now that we have it, we can run Phosh on top of postmarketOS in QEMU. The initial patches for the port were merged at the beginning of this month.

Even though the patches have obviously not seen much testing at this point, @MartijnBraam has already managed to run it on the PinePhone devkit. The display resolution is clearly off, but touch input was reported to be working.

Plasma Mobile

We've gotten Plasma Mobile to run on both the Librem 5 (video) and PinePhone (video) devkits — with fully free software GPU drivers! Please note that the ports to these devices are still early days and that the sluggish performance is due to the GPU drivers still being in development.

As usually, @PureTryOut has been keeping the Plasma Mobile stack up-to-date with the latest versions. He also created a postmarketos-ui-plasma-mobile-extras package which effectively allows users to choose whether they want only the base installation, or a fully blown one with extra apps like a PDF reader, calendar and music player.

We like to upstream everything that makes sense, so with help from our Alpine friends, @PureTryOut got all of the KDE Frameworks 5 and Plasma desktop into Alpine and is maintaining them there from now on. The only packages we plan to keep specifically in postmarketOS are either mobile specific or development versions.

Unity 8

Speaking of upstreaming, @z3ntu contributed quite a few musl-specific patches back to Unity and UBports. After iterating over the next release, we were able to drop nine Mir patches in the postmarketOS port! The initial version of the Unity packaging is only available for x86_64 so far, because of cross compilation issues. That was a few months ago, and today there is only one package left that can not be cross compiled properly. For testing purposes, he compiled it natively and took a photo of Unity 8 starting up on the aarch64 PinePhone devkit.

Shelli

Besides giving a presentation on his current progress of porting the free software baseband firmware osmocom-bb to MediaTek devices, @unrznbl got his Shelli UI into postmarketOS. The essential piece is a Grafitti-inspired gesture recognition program that he started six years ago: it allows writing single letters at a time by drawing a rough shape of the letter across the whole screen. As you can see in the video, the gesture for tab (to use tab completion), is slashing from bottom left to top right, and "Enter" is the reverse gesture.

Now what does this strange input method have to offer in contrary to the usual on-screen-keyboard way of doing things? The radical difference that sets it apart from literally all other mobile UIs today is that it runs entirely on the TTY. Users get a minimalist environment with nothing but tiny and resource-efficient terminal applications. Certainly not for everyone, but there are folks who like to do the same on their PC and there are more use cases that can be explored from here, such as using Shelli as a fallback UI in case the graphical UI does not start up, or extending it with text-to-speech for blind people.

CoreApps

@rahmanshaber and the CuboCore team are the creators of a relatively young project called CoreApps. It provides several lightweight and touchscreen-friendly applications with a consistent look that work on low-end systems without hardware acceleration. The latter is a perfect match for postmarketOS, because most devices (especially right after the initial porting phase) do not have hardware-accelerated graphics working.

He created an initial port, and now most applications can be installed on postmarketOS. As of writing, the postmarketOS port is missing proper theming for CoreApps, which is why it looks a bit weird on the images below. For comparison, we have added a reference screenshot of how it should look once proper theming support is added.

Sway

Sway, the Wayland drop-in replacement for the i3 window manager, is already packaged in Alpine so it was a rather easy exercise for @Danct12 to make it available in the postmarketOS UI selection that is provided by pmbootstrap. He reminded us in the merge request that it needs hardware acceleration to work.

Mainlining

You may have noticed in previous blog posts that @opendata26 has been one of the driving forces in the mainline-related aspects of postmarketOS. Unfortunately he has been seemingly absent from the Internet for the last few months. We certainly miss him not only because of his great contributions, but because it was fun talking to him and he was always incredibly helpful towards anyone. From his username, and the way he answered questions, some newcomers would even be under the impression that they were chatting with an AI. We sincerely hope all is well with him!

Nevertheless, his absence does not mean all mainlining progress work as stopped. There is more motivation than ever in our community to get devices mainlined. So much actually, that we had to create a dedicated #postmarketOS-mainline channel.

Google (Samsung) Galaxy Nexus

For instance, there is a thrilling report from @drebrez about mainlining the Galaxy Nexus. Although the OMAP4460 SoC is supported in mainline Linux, actually booting it on the device made it panic and reboot instantly. By starting with only a stub for the device tree source, there was no way to get logs or other useful clues about the crash from the device. No USB, no serial and of course no working display or anything beyond that.

So he applied his best hacking skills and configured the kernel to wait forever when said panic occurs, and edited the code to do an emergency_restart() in one particular interesting location. After compiling and booting once more, the device would either hang forever, or reboot at once. That way he knew whether the code where he patched in the restart would get executed or not. A few hours later, he patiently narrowed down the troublemakers (mostly clock setup related).

When the offending code was commented out, the device would finally boot up to the initramfs (and of course crash there at some point). The above two paragraphs are just a simplified summary of what it took to get that first feeling of success in the mainlining endeavor. It should illustrate how many more mind-boggling problems had to be solved throughout the next months to get the following working: USB, MMC (internal flash storage), battery reporting and charging, volume and power keys, accelerometer, gyroscope, barometer and finally the display as you can see in the photo.

You are probably wondering what the video next to this paragraph is all about: it shows that even the earphone audio is working! (The video is muted by default, you can enable the audio manually or try this direct link). Also we have another video of the Galaxy Nexus booting into XFCE4 with the 5.1.0 based kernel. For anyone looking to mainline their own smartphone, reading the original issue is worthwhile: a lot of the steps that were taken are so well documented, that they could practically serve as blueprint for future mainline ports.

Google (LG) Nexus 5

While the mainlining tale just began for the Galaxy Nexus, the Nexus 5 (MSM8974 SoC) is on the other end of the spectrum. Pretty much everything besides audio has been working one year ago, with comparatively few small patches on top of the 4.17-rc3 kernel instead of the nearly two million lines of added code in the 3.4-based downstream kernel. But do not underestimate what it takes to resolve the remaining quirks, and to rebase and replace the remaining out-of-tree hacks up to the very last line with beautiful patches that integrate with the rest of the kernel source and are finally worth of getting accepted upstream. @masneyb is determined to get this task done for the Nexus 5. You can take a look at the crazy amount of patches he has gotten merged in this undertaking, together with a few patches that are still in review.

Thanks to these efforts, we can run postmarketOS on the Nexus 5 with a 5.2-rc3 based kernel (WIP merge request) that has less out-of-tree patches than ever before!

Ouya

We are publishing this blog post by coincidence one month before the online services of the Ouya Android gaming console get shut down. Once this happens, the once highly anticipated crowdfunding sensation will be as useful as a paper weight with the original software stack. However, it is possible to install postmarketOS on it. Moreover @ryang2678's patches allow running a slightly patched 5.0 mainline kernel and use the grate free software userspace driver to get accelerated graphics with its Tegra 3 SoC. The latter is not exactly stable so far, and audio support is still missing, but this is a nice foundation for expanding the lifetime of a gaming console that should surely be able to run a bunch of retro emulators for the next ten years.

More Mainlining

Rather than take up too much of your time with updates on device mainlining progress, we'll make the updates for the remaining phones a bit shorter. @cerg2010cerg2010 put a kernel close to 5.1.12 mainline on the Samsung Captivate Glide (Tegra SoC, photo). He reports, that the Midori browser works very well with latest grate drivers, even better than stock WebView from Android. Next up is @zhuowei, who put an incredible amount of work into his Google Pixel 3 XL (SDM845 SoC), to get from next to nothing all the way to penguins greeting him in the booting process.

Finally @Mis012 started mainlining his sm-a300fu (Samsung Galaxy A3 2015) and teamed up with @lambdadroid who is working on the similar sm-a500fu (both have a MSM8916 SoC).

Infrastructure

Sourcehut (sr.ht)

Bad infrastructure news first: we did not manage to move our binary package repository to sourcehut just yet. As outlined in the 600 days post, building on top of sourcehut will make maintaining the binary repo easier and more transparent. The whole thing will scale better and allow us to move towards a stable postmarketOS version. But we are still working on the postmarketOS specific part that will orchestrate the build jobs. In fact, we have a PHP based version that is about 90% feature complete, but has some hard to resolve bugs and no test cases. Long story short, we made the tough decision of starting over with a Python 3 version and with focus on testing from the beginning. Using the same programming language as pmbootstrap decreases friction for development, for writing tests, and increases the bus factor. If somebody is interested in helping us out, get in touch.

Crossdirect

In more pleasant announcements, cross-compiling in pmbootstrap was completely revamped with @zhuowei's crossdirect method. With this change there is no longer a need to run distccd on localhost anymore, which neatly resolves the distccd-behind-sshd performance bottleneck that had to be introduced earlier for security reasons.

Continuous Integration

The heart of postmarketOS development are the package build recipes in pmaports.git. In order to shorten code reviews, @ollieparanoid has once again improved the CI scripts. A new check makes sure that we always increase versions of modified packages. Sometimes we don't want to bump the version though, for example when we only enable another architecture. In that case, we can skip the new check with [ci:skip-vercheck] in the commit message. Similarly [ci:skip-build] allows skipping the test build (e.g. because we know it won't finish within the one hour timeout), while still running checksum verification and all other CI tests.

Pre-built Images / hwtest

@MartijnBraam has created images.postmarketos.org to host pre-built installations for the PinePhone, and we will probably add more devices in the future. He also wrote the terminal program hwtest, which tests a whole bunch of mobile hardware related components and reports the status back in an elegant overview. It allows, for example, quickly checking for regressions after a kernel upgrade and, as you have probably guessed, this makes it a perfect candidate for including in automated testing in the future.

GCC-4

One thing we have learned from the long list of ported devices is that some downstream kernels will only compile with certain GCC versions. Or, even worse, they may compile with a newer GCC but then they won't boot. The latter is of course a nightmare to resolve. @mberndt did it anyway and allowed his HTC Desire Z to be built with GCC-6 instead of GCC-4! To spare other porters from this pain, @drebrez added GCC-4 shortly afterwards. So now we have GCC-8 (in Alpine), GCC-6 and GCC-4.

Hybris

While on the subject of workarounds for vendor kernels, @asriel-danctnix, @Danct12 and @minlexx are trying to get optional Android driver support for their phones integrated into postmarketOS. They are targeting their Xiaomi Redmi 4X (first photo) and Samsung Galaxy S5 (second photo), and are of course streamlining the necessary libhybris packaging for all devices in the process, for example with the new hybris-base meta package. The photos show the libhybris test for GPU functionallity running successfully. Support for audio is being worked on by packaging pulseaudio-modules-droid from SailfishOS.

26 new booting devices (139 total)

Thanks to: everyone who ported these devices, see the contributors section in each device's wiki page.

Raw Numbers

Outro

Now that you're here, let's just assume that you have read this entire post and so we will reward you with an easter egg. @MartijnBraam created a dark mode for this very website, so if you configure your browser appropriately and open this page again, it will look entirely differently. Mind blown, right?

Another thing we did not want to miss out on is of course convergence. That is a fancy word people use to describe a consistent interface for both your desktop and your phone. Next to this paragraph is a prime example of how convergence should be done with postmarketOS.

With that critical piece of information out there, and with grateful thoughts towards everybody who contributed: let's get right into the next year of exciting postmarketOS development! \o/

Comments