User:Ollieparanoid/p-boot
In order to debug why HDMI is not working with the postmarketOS stock install, but is working with megi's multi-distro demo image, I looked into packaging p-boot for postmarketOS (details).
While I was preparing this, megi was able to reproduce the bug and found that it is definitively p-boot related (kernel bug not being triggered if graphical p-boot is used), so I didn't actually try to use these scripts. I'll dump them here for reference.
So this is all untested... and while thinking about it, it will fail to find initramfs-extra, we'd need a good solution for that.
p-boot APKBUILD:
# NOTE: no source tarballs available, build with 'pmbootstrap build --src=path/to/p-boot p-boot --arch=aarch64'
# build master, as 0.9 lacks support for dtb, dtb2
pkgname=p-boot
pkgver=0.9
pkgrel=0
pkgdesc="PinePhone Bootloader"
url="https://xnux.eu/p-boot/"
arch="all"
license="GPL-3.0-or-later"
makedepends="ninja musl-dev"
options="!check"
prepare() {
# Don't directly call cross compiler, it would complain about missing
# headers
sed -i "s/^aarch64_prefix = aarch64-linux-musl-/aarch64_prefix = /g" \
build/build.ninja
# Don't build p-boot-conf twice
touch build/p-boot-conf-native
}
build() {
ninja -C build
}
package() {
for bin in mksunxiboot p-boot-conf p-boot-select; do
install -Dm755 "build/$bin" "$pkgdir/bin/$bin"
done
for pboot in p-boot-dtest.bin p-boot-serial.bin p-boot-tiny.bin \
p-boot.bin; do
install -Dm644 "build/$pboot" "$pkgdir/usr/share/p-boot/$pboot"
done
}
We'd need to run this after successful mkinitfs:
#!/bin/sh -ex
if mount | grep -q ' on /boot'; then
blockdev="$(mount | sed -n -E 's:.*(/dev/mmcblk\d)p\d on /boot .*:\1:p')"
echo "$blockdev" > /boot/blockdev
cp -r /boot /boot_
umount /boot
rmdir /boot
mv /boot_ /boot
fi
blockdev="$(cat /boot/blockdev)"
cat << EOF > /boot/boot.conf
no = 1
name = postmarketOS
atf = /boot/fw.bin # FIXME
dtb = /boot/sun50i-a64-pinephone-1.1.dtb
dtb2 = /boot/sun50i-a64-pinephone-1.2.dtb
linux = /boot/vmlinuz-postmarketos-allwinner
bootargs = # FIXME, needs $blockdev as pmos_root
EOF
# Generate p-boot FS image
p-boot-conf /boot "${blockdev}p1"
# Install p-boot
dd if=/usr/share/p-boot/p-boot.bin "of=$blockdev" bs=1024 seek=8