Arch Linux + Mainline kernel on kevin (Chromebook Plus)

Note: Adapted/inspired by this page


This guide will walk you through installed Arch Linux with a mainline kernel on a USB key suitable for booting on the Chromebook Plus (kevin).

Preparing the USB key

Plug the USB key into your chromebook and run the following commands in the shell to create a new partition table and 2 partitions - one for the kernel and another for rootfs.

umount /dev/sda*

fdisk /dev/sda
Command (m for help): g
Command (m for help): w
Command (m for help): q

; cgpt create /dev/sda
; cgpt add -i 1 -t kernel -b 8192 -s 65536 -l Kernel -S 1 -T 5 -P 10 /dev/sda

; cgpt show /dev/sda
       start        size    part  contents
           0           1          PMBR
           1           1          Pri GPT header
        8192       65536       1  Label: "Kernel"
                                  Type: ChromeOS kernel
                                  UUID: A1E0BF2A-3687-A949-86F8-40507B1D0756
                                  Attr: priority=10 tries=5 successful=1
       73728   122470755       2  Label: "Root"
                                  Type: Linux data
                                  UUID: A3590EA0-A89B-434F-B6C3-902C0A87CDFB
   122544483          32          Sec GPT table
   122544515           1          Sec GPT header

The numbers above will differ depending on the size of your USB key. Grab the value under the "start" column for the "Sec GPT table" row and insert it in the command below (<start_value>)

; cgpt add -i 2 -t data -b 73728 -s `expr <start_value> - 73728` -l Root /dev/sda

; sudo partx -a /dev/sda

; sudo mkfs.ext4 /dev/sda2

Your USB key is now formatted in such a way that the chromebook can book from it. Next step is to put something bootable on it.

Download Arch rootfs

The following will download the latest Arch Linux image for gru-kevin and flash the rootfs partition.

; cd /tmp
; wget
; mkdir root
; sudo mount /dev/sda2 root
; sudo tar -xf ArchLinuxARM-gru-latest.tar.gz -C root

In order to test the image and your partition table, flash the kernel partition from the Arch tarball to your USB key
; sudo dd if=root/boot/vmlinux.kpart of=/dev/sda1
; sync

Finally, unmount the root partition:
; umount root

Unplug the USB key from your workstation and test boot it on your kevin by pressing Ctrl+U at the developer screen. The device should boot to a login prompt (user: root, passwd: root).
; reboot

Preparing the kernel

Back on your workstation, sync a linux-next kernel for maximum freshness.

Apply the following patches to enable display:

Building the kernel

You'll need to grab the kernel.keyblock and kernel_data_key.vbprivk files in order to package the kernel. They're stored in Arch Linux's PKGBUILDs repo on github here. I put them in <kernel_root>/resources/gru-kevin/.

Also stored in <kernel_root>/resources/gru-kevin is the rk3399-gru-kevin.its file. Create and copy/paste the following into it:

/ {
description = "Chrome OS kernel image with one or more FDT blobs";
#address-cells = <1>;

images {
kernel@1 {
data = /incbin/("../../.build_arm64/arch/arm64/boot/Image");
type = "kernel_noload";
arch = "arm64";
os = "linux";
compression = "none";
load = <0>;
entry = <0>;
fdt@1 {
description = "rk3399-gru-kevin";
data = /incbin/("../../.build_arm64/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash@1 {
algo = "sha1";
configurations {
default = "conf@1";
conf@1 {
kernel = "kernel@1";
fdt = "fdt@1";

Grab my build script from github, and add a build.ini file in the kernel root with the following (changing the bold parts to suit your environment):
; From /dev/by-partuuid
; From /dev/by-uuid

; Choose one of these, not both. defconfig builds from an existing defconfig,
; whereas config_file points to a config file that will used verbatim
;config_file=<path to config file>

; For the kernel build command; required

; vbutil_kernel arguments, optional
cmdline=console=tty1 console=ttyS2,115200n8 earlyprintk=ttyS2,115200n8 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd

; mkimage arguments, optional

; post-build options

Simply run the script from the kernel root directory to build and flash your kernel. If all goes well, you should now have a USB key that will boot a mainline kernel with Arch Linux rootfs.