Pinebook Pro kernel compilation

I am a new, proud owner of a Pinebook Pro. The default OS (Debian stretch) comes with a kernel 4.4.190 (updates to 4.4.196). As there is no IO accounting support in the original kernel, also no btrfs support, I set out to compile a custom kernel on the pinebook pro plus booting it safely.

You will need:

  • a Pinebook Pro
  • an SD Card (at least 8GB)
  • patience

DISCLAIMER

These instructions are potentially able to brick your device. There are (somewhat painful) ways to get back from a bricked Pinebook Pro (using the RockChip Flash Tool or the UART console). So, if you never compiled a kernel and actually gotten to start it, you might want to refrain from following this guide.

Setting up the SD card

First, I acquired the original Debian image here: https://github.com/mrfixit2001/debian_desktop/releases/download/190905/pinebookpro-debian-desktop-mrfixit-190905.img.xz.

This needs to be decompressed and „flashed“ to your SD card (careful!). Be sure to use the right device, otherwise you might end up bricking your Pinebook Pro…

xz -d pinebookpro-debian-desktop-mrfixit-190905.img.xz

sudo dd if=pinebookpro-debian-desktop-mrfixit-190905.img of=/dev/mmcblk0
sync

Eject and insert the SD card.

sudo mount /dev/mmcblk0p1 /mnt/
nano /mnt/extlinux/extlinux.conf

Make sure it says
root=/dev/mmcblk1p2
in line #8 – this will load the kernel from SD, but set the root to your EMMC (interal) drive.

Reboot and make sure your device boots up normally. If you already did the update before, you will see that your kernel version now („uname -a“) should be 4.4.190 instead of the updated 4.4.196 on your internal drive.

Setting up the build environment

For this, we will use Debian „Buster“ on your pinebook pro. How? By using snap & lxd!

sudo apt install snapd
sudo snap install lxd
sudo /snap/bin/lxd init

Accept all defaults BUT for the storage pool – set up a new pool with storage backend „dir“.

Once that’s done, set up a new Debian Buster container:

sudo /snap/bin/lxc launch images:debian/buster myvm

Depending on your internet connection, this takes a while. Once that’s done, we’re ready to use the container:

sudo /snap/bin/lxc exec myvm /bin/bash

Now you’re in a shell in your container. First, you want to install some packages:

apt-get install crossbuild-essential-arm64 libncurses-dev git bc ccache nano

The kernel is an aarch64-kernel, the system is armhf however – that’s why we’re installing a cross compiler (credits). Edit your ~/.bashrc and add

export PATH="/usr/lib/ccache:$PATH"

At the bottom, then do

. ~/.bashrc

That should speed up compilation dramatically.

Use the source!

Make a new directory for your linux kernel, i.e. mkdir ~/src. Change to that directory cd ~/src and download the kernel sources of your choice, i.e.
git clone https://github.com/mrfixit2001/rockchip-kernel.git linux

Copy the existing kernel configuration to your source tree:

zcat /proc/config.gz ~/src/linux/.config
cd ~/src/linux/
make oldconfig

Almost set to go!

make menuconfig

Do your changes, save… now, compile the kernel:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 6 bindeb-pkg

And the device tree afterwards:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 6 rockchip/rk3399-pinebookpro.dtb

Log off from your container by using CTRL-D (or the method of your liking). The kernel is now in (with my names):

/var/snap/lxd/common/lxd/containers/myvm/rootfs/root/src

We’re going to install this and move it carefully. Make sure /boot/ isn’t mounted:

sudo umount /boot
sudo mount /dev/mmcblk0p1 /mnt/
sudo dpkg -i --force-architecture /var/snap/lxd/common/lxd/containers/myvm/rootfs/root/src/linux-image-4.4.196-gb9a54c00f_4.4.196-gb9a54c00f_arm64.deb
(or whatever .deb you just created).

cp /mnt/rk3399-pinebookpro.dtb /mnt/rk3399-pinebookpro.dtb.bak

cp /var/snap/lxd/common/lxd/containers/myvm/rootfs/root/src/linux/arch/arm64/boot/dts/rockchip/rk3399-pinebookpro.dtb /mnt/

Copy the kernel to SD card:

cp /boot/vmlinuz-4.4.196-gb9a54c00f /mnt/Image

Done! Reboot…

Yes, I know that there are LXD Api functions to work with container files, and working as root is not advised. But for the time being, it „works for me™“.

Hinterlasse einen Kommentar.

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.