Getting Started with the Pinephone UBports CE

I recently received my Pinephone from Pine64, which is a low-cost open-hardware Linux-capable smartphone.

After playing around with the initial UBports operating system that came with the phone, I decided that it really wasn't for me. One of the more interesting alternative operating systems that is available for this particular module, and one that an upcoming Community Edition phone batch will be flashed with, is postmarketOS. This is an Alpine Linux-based operating system, which is capable of running a couple different graphical user interfaces, or GUIs.

The initial instructions for installing postmarketOS tends to be based around the use of an installer on your host computer, called pmbootstrap. Now, I hold the conceit that I'm a fairly technical user, but I had some issues with getting that installer to do what I wanted it to do, particuarly with regards to getting data written to a microSD card into a bootable state.

That's when I realized that there were already pre-built versions of the software that I was interested available here, with different options available for firmware and GUIs. This was exactly what I was looking for, because the process of installing a bootable pre-built image on an SD card is about as simple as can be. After downloading the image that I was interestd in (in this case, the phosh GUI with the crust firmware, which is supposed to produce some seriously increased battery life), I popped a 16 GB microSD card into the adapter, plugged it into my computer, opened up Balena Etcher (which you'll probably be familiar with if you've ever worked with a Raspberry Pi or other single-board computer), and flashed the SD card.

After that was done, it became a simple matter of adding the microSD card to the Pinephone's slot under the back case, and turning it on.

I did run into a few issues after that, however. First, since the image is already built, we start off having to use all of the system defaults for everything. This is particularly important for gaining superuser access, which lets you do things like install new packages or access the phone remotely over SSH.

On some installations, this is very standard--the default user is root, and the password is something like password or totally blank. Early today, I actually ran into the same problem while installing a version of Debian onto a Beaglebone Black (another small SBC), which ended up having a default username of root and a default password of temppwd. It took me a little time to find, but as it turns out, the information was actually listed in the table at the top the page where I'd downloaded the system image earlier. whoops!

In this case, the username:password combination is: demo:147147.

From there, I was able to gain SSH access to the phone from my dev machine. This is important, because even though it's nice to have a phone with a rooted terminal in it, a phone is still a phone, and doing serious development work isn't it's strong suit. That's not a commentary on the Pinephone--when I've had Termux installed on Android phones, I found it to be a pain as well. I'm not an expert at putting together GUIs, but I'm sure that for me, a large use case here will be building more complex scripts on my dev machine, testing them on the phone, and then tying those programs to a short alias in the phone's .bashrc file, which will let me easily run them from the phone's terminal.

Now, one small issue did come up after this. As I mentioned earlier, the postmarketOS image was flashed onto a 16 GB SD card. However, while trying to install g++ onto the phone itself, I came across an error that simply stated that I'd run out of room. Now, Alpine Linux takes up very little space, and additions like phosh don't add much more--the image we installed was less than 2GB in size. How was I running out of room already? I started off by navigating to the root directory, and running the $ du -sh . command, which should tell us the total size of all the files that we have in the operating system. Sure enough, well under 2 GB.

Next, I ran the $ df -h command, which should produce a human-readable value of the size of our disk. 1.2 GB. Uh-oh. That's not right.

It turns out, when the image was initially flashed to the SD card, the partition that was created for the operating system wasn't expanded to take up any extra room--it simply took up the minimum amount needed to the OS and boot partitions. This is a fairly easy fix. I just pulled out the SD card (after safely powering down, of course), and re-inserted it into my dev machine, which is running Ubuntu 18.04. Navigating to the "Disks" menu presents an option, where I'm able to select the SD card, then select the partition with the operating system on it (not the boot partition!), and use the "Resize..." command to expand the size of the partition that the OS is assigned to. After re-installing it in the phone and powering it back up, I now had access to all 16 GB and was able to run the $ sudo apk add g++ command to add the toolchain.