my tildelog

a blog about tildes

Building postmarketOS for my Raspberry Pi 3B+

June 12, 2018 — sebboh

I've been following postmarketOS for a while. I intend to install it on my NEC Terrain.

The project really speaks my language:

It is 2018. Pick an average PC from 2008 and install a minimal Linux based operating system. You will be able to do basic computing tasks (e.g. surfing the web, reading e-mails, listening to music, chatting) just like on an expensive modern PC. You will even get security updates, so your old computer is protected, just like a new one.

On the current mobile landscape you get none of that. Even expensive phones only have few years of support. As time progresses, your phone becomes slower and slower, and the newest features will not work on it anymore. But postmarketOS builds upon a real Linux distribution, which has no reason to drop support for old devices at all and (assuming that you choose the right software) keeps the resource usage at a constant minimum instead of increasing it with every release. There's no reason to restrict features (such as full disk encryption) to newer devices either. We want to be able to use our devices until they break!

But, pmOS does not yet support the NEC Terrain. I'll have to port it. I've never ported anything before.

I have a strategy. I'll install pmOS on a supported device, first. The only supported device I already own is the Raspberry Pi 3B+. (Other models are also supported.)

sebboh⬢truth:~$ cd ~/src
sebboh⬢truth:~/src$ git clone https://github.com/postmarketOS/pmbootstrap
Cloning into 'pmbootstrap'...
remote: Counting objects: 16129, done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 16129 (delta 28), reused 61 (delta 13), pack-reused 16024
Receiving objects: 100% (16129/16129), 13.33 MiB | 2.32 MiB/s, done.
Resolving deltas: 100% (9923/9923), done.
sebboh⬢truth:~$

A user called yangxuan8282 has been making improvements, but they aren't merged into master yet. So, I'll pull them into my local workspace.

sebboh⬢truth:~/src/pmbootstrap$ git remote add yangxuan8282 git@github.com:yangxuan8282/pmbootstrap.git
sebboh⬢truth:~/src/pmbootstrap$ git fetch yangxuan8282
remote: Counting objects: 42, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 42 (delta 25), reused 28 (delta 25), pack-reused 14
Unpacking objects: 100% (42/42), done.
From github.com:yangxuan8282/pmbootstrap
 * [new branch]      check-dtbtool-qcdt                              -> yangxuan8282/check-dtbtool-qcdt
 * [new branch]      device-archos-a80                               -> yangxuan8282/device-archos-a80
 * [new branch]      device-asus-p024                                -> yangxuan8282/device-asus-p024
 * [new branch]      device-asus-tf300t                              -> yangxuan8282/device-asus-tf300t
 * [new branch]      device-htc-dlx                                  -> yangxuan8282/device-htc-dlx
 * [new branch]      device-htc-vision                               -> yangxuan8282/device-htc-vision
 * [new branch]      device-huawei-kiwi                              -> yangxuan8282/device-huawei-kiwi
 * [new branch]      device-ouya-ouya                                -> yangxuan8282/device-ouya-ouya
 * [new branch]      device-planet-geminipda                         -> yangxuan8282/device-planet-geminipda
 * [new branch]      device-rpifoundation-rpi                        -> yangxuan8282/device-rpifoundation-rpi
 * [new branch]      device-samsung-g930f                            -> yangxuan8282/device-samsung-g930f
 * [new branch]      device-semc-anzu                                -> yangxuan8282/device-semc-anzu
 * [new branch]      device-xiaomi-rolex                             -> yangxuan8282/device-xiaomi-rolex
 * [new branch]      device/ipod1                                    -> yangxuan8282/device/ipod1
 * [new branch]      device/lg-d285-wifi                             -> yangxuan8282/device/lg-d285-wifi
 * [new branch]      deviceinfo_parse                                -> yangxuan8282/deviceinfo_parse
 * [new branch]      feature/1368-devicepkg-support-different-values -> yangxuan8282/feature/1368-devicepkg-support-different-values
 * [new branch]      feature/LVM                                     -> yangxuan8282/feature/LVM
 * [new branch]      feature/anbox                                   -> yangxuan8282/feature/anbox
 * [new branch]      feature/android-rild                            -> yangxuan8282/feature/android-rild
 * [new branch]      feature/bash-parser                             -> yangxuan8282/feature/bash-parser
 * [new branch]      feature/bullhead-osk-sdl                        -> yangxuan8282/feature/bullhead-osk-sdl
 * [new branch]      feature/depends-on                              -> yangxuan8282/feature/depends-on
 * [new branch]      feature/hybris                                  -> yangxuan8282/feature/hybris
 * [new branch]      feature/implement_gitlab_ci                     -> yangxuan8282/feature/implement_gitlab_ci
 * [new branch]      feature/linux-postmarketos-hammerhead           -> yangxuan8282/feature/linux-postmarketos-hammerhead
 * [new branch]      feature/linux-postmarketos-hammerhead-the-2nd   -> yangxuan8282/feature/linux-postmarketos-hammerhead-the-2nd
 * [new branch]      feature/native-cross-compile-qt                 -> yangxuan8282/feature/native-cross-compile-qt
 * [new branch]      feature/nemo                                    -> yangxuan8282/feature/nemo
 * [new branch]      feature/nheko                                   -> yangxuan8282/feature/nheko
 * [new branch]      feature/oprofile                                -> yangxuan8282/feature/oprofile
 * [new branch]      feature/phosh                                   -> yangxuan8282/feature/phosh
 * [new branch]      feature/pmbootstrap-timeout                     -> yangxuan8282/feature/pmbootstrap-timeout
 * [new branch]      feature/rotate-hildon-ui                        -> yangxuan8282/feature/rotate-hildon-ui
 * [new branch]      feature/timekeep                                -> yangxuan8282/feature/timekeep
 * [new branch]      feature/yamui                                   -> yangxuan8282/feature/yamui
 * [new branch]      fix/1298-make-copied-aport-world-readable       -> yangxuan8282/fix/1298-make-copied-aport-world-readable
 * [new branch]      fix/compiler-update                             -> yangxuan8282/fix/compiler-update
 * [new branch]      fix/hammerhead-osk                              -> yangxuan8282/fix/hammerhead-osk
 * [new branch]      fix/recovery-ld-path                            -> yangxuan8282/fix/recovery-ld-path
 * [new branch]      fix/recovery-mount                              -> yangxuan8282/fix/recovery-mount
 * [new branch]      fix/test-build-package-testcase                 -> yangxuan8282/fix/test-build-package-testcase
 * [new branch]      kernel-updates                                  -> yangxuan8282/kernel-updates
 * [new branch]      linux-rpi                                       -> yangxuan8282/linux-rpi
 * [new branch]      master                                          -> yangxuan8282/master
 * [new branch]      peruse-comic-book-reader-app                    -> yangxuan8282/peruse-comic-book-reader-app
 * [new branch]      pi-bluetooth                                    -> yangxuan8282/pi-bluetooth
 * [new branch]      pmbootstrap-feature/756-move-firmware-folder    -> yangxuan8282/pmbootstrap-feature/756-move-firmware-folder
 * [new branch]      postmarketos-ui-luna                            -> yangxuan8282/postmarketos-ui-luna
 * [new branch]      qemu-virglrenderer-support                      -> yangxuan8282/qemu-virglrenderer-support
 * [new branch]      titan-osk-sdl                                   -> yangxuan8282/titan-osk-sdl
 * [new branch]      update/osk-sdl                                  -> yangxuan8282/update/osk-sdl
 * [new branch]      wlan-prima-wcnss                                -> yangxuan8282/wlan-prima-wcnss
sebboh⬢truth:~/src/pmbootstrap$ git merge yangxuan8282/linux-rpi -m "pull in some changes"
Merge made by the 'recursive' strategy.
 aports/temp/linux-rpi/APKBUILD          |  202 ++++
 aports/temp/linux-rpi/config-rpi.armhf  | 5678 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 aports/temp/linux-rpi/config-rpi2.armhf | 5797 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 aports/temp/linux-rpi/issue-4973.patch  |   67 ++
 aports/temp/linux-rpi/markdt            |   59 ++
 5 files changed, 11803 insertions(+)
 create mode 100644 aports/temp/linux-rpi/APKBUILD
 create mode 100644 aports/temp/linux-rpi/config-rpi.armhf
 create mode 100644 aports/temp/linux-rpi/config-rpi2.armhf
 create mode 100644 aports/temp/linux-rpi/issue-4973.patch
 create mode 100755 aports/temp/linux-rpi/markdt
sebboh⬢truth:~/src/pmbootstrap$

So far, so good.

sebboh⬢truth:~/src/pmbootstrap$ ./pmbootstrap.py init
[16:01:31] Location of the 'work' path. Multiple chroots (native, device arch, device rootfs) will be created in there.
[16:01:31] Work path [/home/sebboh/.local/var/pmbootstrap]: 
[16:01:34] Target device (either an existing one, or a new one for porting).
[16:01:34] Available (86): amazon-thor, asus-flo, asus-grouper, asus-t00f, asus-tf101, asus-z00t, fairphone-fp2, google-glass, gp-peak, htc-a5ul, htc-ace, htc-bravo, htc-flounder, htc-m8, htc-vivo, huawei-angler, huawei-y530, infocus-flatfish, jolla-sbj, leeco-s2, lenovo-karate, lg-bullhead, lg-d285, lg-d855, lg-dory, lg-h815, lg-hammerhead, lg-lenok, lg-mako, motorola-athene, motorola-falcon, motorola-harpia, motorola-maserati, motorola-osprey, motorola-peregrine, motorola-potter, motorola-shamu, motorola-titan, nextbit-robin, nokia-n9, nokia-n900, oneplus-bacon, oneplus-oneplus2, oneplus-onyx, qemu-aarch64, qemu-amd64, qemu-vexpress, raspberry-pi, samsung-espresso10, samsung-gts210vewifi, samsung-i747m, samsung-i8190, samsung-i9003, samsung-i9070, samsung-i9100, samsung-i9195, samsung-i9305, samsung-i9505, samsung-klte, samsung-kminilte, samsung-kylessopen, samsung-kylevess, samsung-lt023g, samsung-maguro, samsung-manta, samsung-n5110, samsung-n7100, samsung-p4wifi, samsung-s6500d, semc-anzu, sony-amami, sony-aries, sony-castor-windy, sony-honami, sony-scorpion, sony-seagull, sony-sirius, sony-yuga, t2m-flame, teclast-x80pro, wiko-lenny3, xiaomi-armani, xiaomi-ido, xiaomi-mido, xiaomi-santoni, zte-kis3
[16:01:34] Device [samsung-i9100]: raspberry-pi

There could be trouble here. All of those changes I merged in happened in aports/temp/linux-rpi... But look, the name of the device I just selected doesn't exist in there!

sebboh⬢truth:~/src/pmbootstrap$ grep -Ri raspberry-pi
aports/device/device-raspberry-pi/APKBUILD:pkgname="device-raspberry-pi"
Binary file .git/index matches
sebboh⬢truth:~/src/pmbootstrap$

I don't know what else to do, so, let us continue with the pmbootstrap init.

[16:02:07] Which kernel do you want to use with your device?
[16:02:07] Available kernels (2):
[16:02:07] * rpi: Kernel for the Raspberry Pi Zero & 1
[16:02:07] * rpi2: Kernel for the Raspberry Pi 2 & 3
[16:02:07] Kernel [rpi]: rpi2
[16:02:12] This device has proprietary components, which trade some of your freedom with making more peripherals work.
[16:02:12] We would like to offer full functionality without hurting your freedom, but this is currently not possible for your device.
[16:02:12] device-raspberry-pi-nonfree-firmware: Bluetooth firmware for raspberry pi zero w, 3b/3b+
[16:02:12] Enable this package? (y/n) [y]: 
[16:02:13] Username [user]: sebboh
[16:02:16] Available user interfaces (7): 
[16:02:16] * none: No graphical environment
[16:02:16] * hildon: (X11) Lightweight GTK+2 UI (optimized for single-touch touchscreens)
[16:02:16] * i3wm: (X11) Tiling WM (keyboard required)
[16:02:16] * matchbox: (X11) Very basic user interface for handhelds
[16:02:16] * mate: (X11) MATE Desktop Environment, fork of GNOME2 (stylus recommended)
[16:02:16] * plasma-mobile: (Wayland) Mobile variant of KDE Plasma, optimized for touchscreen (aarch64, x86_64 or hardware acceleration required!)
[16:02:16] * weston: (Wayland) Reference compositor (demo, not a phone interface)
[16:02:16] * xfce4: (X11) Lightweight GTK+2 desktop (stylus recommended)
[16:02:16] User interface [weston]: xfce4
[16:02:31] Build options: Parallel jobs: 5, ccache per arch: 5G
[16:02:31] Change them? (y/n) [n]: y
[16:02:35] How many jobs should run parallel on this machine, when compiling?
[16:02:35] Jobs [5]: 4
[16:02:37] We use ccache to speed up building the same code multiple times. How much space should the ccache folder take up per architecture? After init is through, you can check the current usage with 'pmbootstrap stats'. Answer with 0 for infinite.
[16:02:37] Ccache size [5G]: 0
[16:02:39] Additional packages that will be installed to rootfs. Specify them in a comma separated list (e.g.: vim,file) or "none"
[16:02:39] Extra packages [none]: 
[16:02:41] Your host timezone: America/Chicago
[16:02:41] Use this timezone instead of GMT? (y/n) [y]: 
[16:02:42] Device hostname (short form, e.g. 'foo') [raspberry-pi]: love
[16:03:09] Would you like to copy your SSH public keys to the device? (y/n) [n]: y
[16:03:11] WARNING: The applications in the chroots do not get updated automatically.
[16:03:11] Run 'pmbootstrap zap' to delete all chroots once a day before working with pmbootstrap!
[16:03:11] It only takes a few seconds, and all packages are cached.
[16:03:11] Done!
sebboh⬢truth:~/src/pmbootstrap$

OK, time for the install.

sebboh⬢truth:~/src/pmbootstrap$ ./pmbootstrap.py install --sdcard=/dev/sdh
[20:30:38] *** (1/5) PREPARE NATIVE CHROOT ***
[20:30:39] *** (2/5) CREATE DEVICE ROOTFS ("raspberry-pi") ***
[20:30:39] Update package index for armhf (4 file(s))
[sudo] password for sebboh:
[20:30:57] WARNING: Package 'libdrm' in your aports folder has version 2.4.91-r1, but the binary package repositories already have version 2.4.92-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] WARNING: Package 'libdrm' in your aports folder has version 2.4.91-r1, but the binary package repositories already have version 2.4.92-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] WARNING: Package 'mesa' in your aports folder has version 18.0.2-r1, but the binary package repositories already have version 18.0.5-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] WARNING: Package 'mesa' in your aports folder has version 18.0.2-r1, but the binary package repositories already have version 18.0.5-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] WARNING: Package 'mesa' in your aports folder has version 18.0.2-r1, but the binary package repositories already have version 18.0.5-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] WARNING: Package 'mesa' in your aports folder has version 18.0.2-r1, but the binary package repositories already have version 18.0.5-r0! See also: <https://postmarketos.org/warning-repo2>
[20:30:57] (rootfs_raspberry-pi) install
[20:31:03] (rootfs_raspberry-pi) install
[20:31:09] (rootfs_raspberry-pi) write /etc/os-release
[20:31:10] (rootfs_raspberry-pi) install
[20:31:16] (rootfs_raspberry-pi) mkinitfs rpi2
[20:31:22]  *** SET LOGIN PASSWORD FOR: 'sebboh' ***
New password:
Retype new password:
passwd: password updated successfully
[20:31:32] NOTE: No valid keymap specified for device
[20:31:37] *** (3/5) PREPARE INSTALL BLOCKDEVICE ***
[20:31:38] (native) mount /dev/install (host: /dev/sdh)
[20:31:38] EVERYTHING ON /dev/sdh WILL BE ERASED! CONTINUE? (y/n) [n]: y
[20:31:40] (native) partition /dev/install (boot: 31M, root: the rest)
[20:33:45] WARNING: Full disk encryption is enabled!
[20:33:45] Make sure that osk-sdl has been properly configured for your device
[20:33:45] or else you will be unable to unlock the rootfs on boot!
[20:33:45] If you started a device port, it is recommended you disable
[20:33:45] FDE by re-running the install command with '--no-fde' until
[20:33:45] you have properly configured osk-sdl. More information:
[20:33:45] <https://postmarketos.org/osk-port>
[20:33:45] (native) format /dev/installp2 (root, luks), mount to /dev/mapper/pm_crypt
[20:33:45]  *** TYPE IN THE FULL DISK ENCRYPTION PASSWORD (TWICE!) ***
Enter passphrase for /dev/installp2:
Enter passphrase for /dev/installp2:
[20:40:06] (native) format /dev/mapper/pm_crypt
[20:40:26] (native) mount /dev/mapper/pm_crypt to /mnt/install
[20:40:26] (native) format /dev/installp1 (boot, fat16), mount to /mnt/install/boot
[20:40:27] *** (4/5) FILL INSTALL BLOCKDEVICE ***
[20:40:27] (native) copy rootfs_raspberry-pi to /mnt/install/
[20:41:28] Update package index for x86_64 (4 file(s))
[20:41:31] *** (5/5) FLASHING TO DEVICE ***
[20:41:31] Run the following to flash your installation to the target device:
[20:41:31] * pmbootstrap flasher flash_kernel
[20:41:31]   Flashes the kernel + initramfs to your device:
[20:41:31]   /home/sebboh/.local/var/pmbootstrap/chroot_rootfs_raspberry-pi/boot
[20:41:31] * If the above steps do not work, you can also create symlinks to the generated files with 'pmbootstrap export' and flash outside of pmbootstrap.
sebboh⬢truth:~/src/pmbootstrap$

Wow! I did a sync (or two!) and popped that microSD card into my Raspberry Pi. Here is the result:

photo of a computer monitor, raspberry pi 3B+, TI-82 calculator, and an NEC Terrain. The monitor displays Alpine Linux with xfce4 for the window manager.

I don't think I'll do much more with this install, though I have several spare microSD cards, so I'll leave it around. My next postmarketOS task will be to port it to the NEC Terrain (which happens to be visible in that photo).

'Till next time!

Tags: RPi, postmarketOS

Found a new tilde

June 08, 2018 —

Today I heard ben talking about his tilde so, I asked him for an account and he gave me one! :D

Tags: first-post, tildes