Pinebook Pro Custom Kernel

Table of Contents

Preface

Here's how to compile tsys' mainline linux kernel for the Pinebook Pro. I'm using the "debian way" of installing the kernel. When compiling the kernel, we can tell "make" to package the binaries as multiple debian archive files (.deb). Afterward, we can simple run "dpkg -i .deb" to install it.

Setting up our enviroment

Here we'll download the dependencies and the linux sources.

sudo apt-get install linux-headers-$(uname -r) libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf bc fakeroot

# Linux sources
git clone --depth=1 https://gitlab.manjaro.org/tsys/linux-pinebook-pro
cd linux-pinebook-pro

Compiling the kernel

The "ARCH" variable specifies the target machines architecture.

The "CROSS_COMPILE" variable specifies which compiler the system should use.

Running "make menuconfig" opens an ncurses menu which you can use to modify the kernel. You don't need to change anything. Run the command and exit the ncurses menu to save the kernel configuration to "$PWD/.config"

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu

# Exit the ncurses menu to save the default config
make -j 6 menuconfig
make -j 6 deb-pkg

The compiling process should take about two hours. My pinebook was left on a desk and stayed consistently at 68.4-69.8 degrees Celsius. The output deb files are in "../"

Installing the packages files

I forgot the exact names of the output deb files.

sudo dpkg -i linux-headers-*.deb
sudo dpkg -i linux-image-*.deb
sudo dpkg -i linux-libc-*.deb

DON'T REBOOT YET! It turns out that uboot, at least from the debian installer, isn't compiled with a gzip decompressor. If you haven't noticed, your linux kernel and initrd are actually both gzip archives! This confused the heck out of me at first. You'll need to decompress the files and put them back in /boot

# We need to rename them with the suffix ".gz" or else gzip returns errors
cd ~
mv /boot/vmlinuz-5.10.0-rc5-1-pinebookpro-arm64+ ~/vmlinuz-5.10.0-rc5-1-pinebookpro-arm64+.gz
gzip -d ~/vmlinuz-5.10.0-rc5-1-pinebookpro-arm64+.gz
mv ~/vmlinuz-5.10.0-rc5-1-pinebookpro-arm64+ /boot/

mv /boot/initrd.img-5.10.0-rc5-1-pinebookpro-arm64+ ~/initrd.img-5.10.0-rc5-1-pinebookpro-arm64+.gz
gzip -d ~/initrd.img-5.10.0-rc5-1-pinebookpro-arm64+.gz
mv ~/initrd.img-5.10.0-rc5-1-pinebookpro-arm64+

DONE! You can boot into your new mainline kernel now.

Uboot (IMPORTANT)

Remove "maxcpus=4" from /boot/extlinux/extlinux.conf

This option was automatically added and is supposed to make boot times faster. Just remove it from the uboot config. The boot times are fine without it and are infact LONGER if you keep it.

FYI: Normally the default kernel re-enables the two large cores once it's booted. For some reason this one does not.

## /boot/extlinux/extlinux.conf
default 10
menu title U-Boot menu
prompt 0
timeout 10


label l0
        menu label Debian GNU/Linux bullseye/sid 5.10.0-rc5-1-pinebookpro-arm64+
        linux /vmlinuz-5.10.0-rc5-1-pinebookpro-arm64+
        initrd /initrd.img-5.10.0-rc5-1-pinebookpro-arm64+
        fdt /rk3399-pinebook-pro.dtb
        append root=PARTLABEL=mmcblk1-RootFS console=ttyS2,1500000n8 console=tty0 ro quiet splash plymouth.ignore-serial-consoles maxcpus=6 coherent_pool=1M

Encryption

I couldn't boot from my encrypted debian install. According to this post, you can update your initrd to include modules to decrypt the file system, but the display won't work. I couldn't even get a prompt to appear using the serial console when attempting this. I'm opting for an encrypted home partition instead.