The PINE64 Rockpro64 is quite well supported on postmarketOS, but if you want the most minimal installation without any phone patches and opinionated base packages it's possible to create an Alpine Linux installation for it and only picking the uboot and linux packages from postmarketOS.
This is basically an Alpine chroot installation but running on real hardware. In my case I'm using the USB-eMMC adapter from the pine64 store as /dev/sdb
but it should work exactly the same when doing an installation on the SD card.
Another important thing to note is the RK3399 boot order. The SoC will try to boot from the SPI chip, eMMC and SD in that order. It will boot the first device it finds a valid rockchip boot signature on (on sector 64) and will not try the next device if that device is not bootable. Make sure you fully wipe any boot device before the one you want booting.
binfmt_misc
The first thing you need to have setup is binfmt_misc
, this allows you to run aarch64 binaries on your x86_64 system directly making the chrooting while installing work. For a lot of distributions this comes enabled by default but when it's not, this is the instructions to enable it:
$ modprobe binfmt_misc
$ mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
If this fails it most likely means the kernel you're running doesn't have CONFIG_BINFMT_MISC
enabled.
Partitioning
The partitioning is pretty basic, One /boot partition and one for the rootfs. The first partition starts with an ~32MB offset though because that area of the storage device is used by uboot.
$ sfdisk /dev/sdb << EOF
65000,400000,L
400000,,L
EOF
$ mkfs.ext4 /dev/sdb1 -L boot
$ mkfs.ext4 /dev/sdb2 -L root
$ mkdir -p /mnt/disk
$ mount /dev/sdb2 /mnt/disk
$ mkdir -p /mnt/disk/boot
$ mount /dev/sdb1 /mnt/disk/boot
Both these partitions can be formatted ext4. The u-boot bootloader should support vfat and all the ext versions.
Installing Alpine
The installation is done through the apk
command. If you're not doing the installation from an Alpine Linux install you need to use apk.static
instead. Instructions for getting the apk tools on your own linux install are on the Alpine Wiki page for chroots.
These instructions will use the Alpine edge repository for the main install and the postmarketOS repository for the bootloader and kernel package.
$ apk.static \
-X http://dl-cdn.alpinelinux.org/alpine/edge/main \
-X http://mirror.postmarketos.org/postmarketos/master \
-U --allow-untrusted -p /mnt/disk --arch aarch64 --initdb \
add alpine-base mkinitfs postmarketos-keys u-boot-rockpro64 linux-postmarketos-rockchip
# Create an extlinux.conf in /boot for uboot
$ mkdir -p /mnt/disk/boot/extlinux
$ cat > /mnt/disk/boot/extlinux/extlinux.conf << EOF
timeout 10
default Alpine
menu title boot prev kernel
label Alpine
kernel /vmlinuz-postmarketos-rockchip
fdt /dtbs-postmarketos-rockchip/rockchip/rk3399-rockpro64.dtb
initrd /initramfs-postmarketos-rockchip
append console=tty0 console=ttyS2,1500000n8 panic=10 coherent_pool=1M video=HDMI-A-1:1920x1080@60 root=LABEL=root
EOF
# Install uboot between the partition table and the first partition
dd if=/mnt/disk/usr/share/u-boot/pine64-rockpro64/u-boot-rockchip.bin of=/dev/sdb seek=64
Doing the set-up inside the Alpine install
After running the apk command you'll need to chroot into the Alpine installation and do the rest of the basic setup tasks. Since you got this far into the instructions and are planning to run Alpine, I'm going to assume you know what you want installed on it and how to do an Alpine Linux installation from scratch.
The quick notes are: add repositories, setup hostname, timezone, resolver, and a root password.
$ mount -o bind /dev /mnt/disk/dev
$ mount -t proc none /mnt/disk/proc
$ mount -o bind /sys /mnt/disk/sys
$ chroot /mnt/disk /bin/ash -l
# this is the point where you do the alpine stuffs
# Adding the repositories and keys
$ cat > /etc/apk/repositories << EOF
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://mirror.postmarketos.org/postmarketos/master
EOF
# Adding a valid fstab
cat > /etc/fstab << EOF
# <device> <dir> <type> <options> <dump> <fsck>
LABEL=root / ext4 defaults 0 1
LABEL=boot /boot ext4 defaults 0 1
EOF
# Setting up the runlevels
$ rc-update add devfs sysinit
$ rc-update add dmesg sysinit
$ rc-update add mdev sysinit
$ rc-update add hwclock boot
$ rc-update add modules boot
$ rc-update add sysctl boot
$ rc-update add hostname boot
$ rc-update add bootmisc boot
$ rc-update add syslog boot
$ rc-update add mount-ro shutdown
$ rc-update add killprocs shutdown
$ rc-update add savecache shutdown
# Basic config of the installation
$ cat > /etc/resolv.conf << EOF
nameserver 1.1.1.1
nameserver 8.8.8.8
EOF
$ passwd
# Closing the chroot again and unmounting everything
$ exit
$ sudo umount /mnt/disk/sys
$ sudo umount /mnt/disk/proc
$ sudo umount /mnt/disk/dev
$ sudo umount /mnt/disk/boot
$ sudo umount /mnt/disk
After this you can stick the eMMC or SD in the rockpro and it should boot :)