/\___/\
   /       \
  l  u   u  l
--l----*----l--      _   _ _                      _           _             
   \   w   /        | |_(_) |_ ____ __  __ _ _ _ ( )___  _ __| |__ _ __ ___ 
     ======         | / / |  _|_ / '  \/ _` | ' \|/(_-< | '_ \ / _` / _/ -_)
   /       \ __     |_\_\_|\__/__|_|_|_\__,_|_||_| /__/ | .__/_\__,_\__\___|
   l        l\ \                                        |_|                 
   l        l/ /
   l  l l   l /
   \ ml lm /_/
	
kitzman's place

PostmarketOS mingling

embedded linux

I have this old HTC lying around and I’m currently playing around with it.

Setting it up

Obviously the first step is installing a bootloader after unlocking. The second step is building and installing pmOS itself, and the ‘pmbootstrap’ tool does a great job at automating the process.

The partition table is slightly different than Android systems. pmOS creates a single partition, which in itself contains a partition table. This will have the same format as any Linux partition table.

The mounts are also done in the same way as any POSIX compliant system: /boot , /etc , etc, so no /vendor or /system directories.

If firmware, properietary libraries, or configuration files are missing, you can just try to download the stock ROM, or a LineageOS (official or not) build, and take them from there. I only used the wifi card firmware, and “calibration” + “calibration_EMEA” files.

Hacking (kernel)

Obviously you might want to hack yourself at the features.

The bootstrap tools stores contents at $HOME/.local/var/pmbootstrap . In the git cache directory, you can find the pmOS repo, and thus the device definitions, including the kernels.

In my case, the kernel was an old LineageOS-based one, but found a newer, unofficial one. So just changing the APKBUILD and the configuration did the job.

N.B: if you change any of those two, make sure to run pmbootstrap shutdown , then pmbootstrap zap , then pmbootstrap checksum linux-$device , then try to rebuild; sometimes removing the already built kernel helps.

For example, some things I’ve changed: enabled LED GPIO, and changed the location of the firmware, and after the installation, I’ve added the files from the original stock ROM.

Hacking (building packages)

Obviously, you’d probably like to install packages which are not necessarily found in the pmaports. I’ve avoided using the qemu-chroot method, but for sure that’s the easiest one.

However if you run a system such as Arch, you can probably set up your AUR helper and a repo, and build packages with crosstool-ng.

On Gentoo, you can use crossdev. Not only it will build your toolchain, but you will also have portage set up for cross compiling. In case of doubt, just use -fPIC -static flags.

Playing around with it

I highly recommend Vlang. Just use compatible include files, set VFLAGS, and hack away.

I wrote a basic example - check out pls_reboot.v in resources .

Sometimes it helps to check out the Android code, or you can try guessing which functions to use from the symbols found in vendor’s libraries.