The Music in Noise

How to Install Debian Trixie with the Mainline Kernel on the Asus C201

Published:

Requirements

Device Preparation

Preparing the SD Card

I will be assuming the SD card’s device name is /dev/sdb for this section. Remember to adapt these commands to the device name on your computer before running any of them.

Insert the SD card into your auxiliary computer and format it with the following command (make sure you have sgdisk installed):

$ sgdisk -o -a 8192 \
         -n 1:0:+32M -t 1:7F00 -c 1:"KERN-A" -A 1:=:0x011F000000000000 \
         -n 2:0:0    -t 2:8300 -c 2:"ROOTFS" /dev/sdb

Format the root partition of the SD card, which will be located on /dev/sdb2:

$ mkfs.ext4 /dev/sdb2

Preparing the Additional USB Drive

If your auxiliary computer is of the armhf architecture, you can skip this step.

On the auxiliary computer, follow the ArchLinuxARM installation instructions. I found more success when using the mainline kernel option explained at the end.

Installing the Base System

First Stage deboostrap

I will be assuming the SD card’s device name is /dev/sdb for this section. Remember to adapt these commands to the device name on your computer before running any of them.

Mount the root partition of your SD card:

$ mkdir root/
$ mount /dev/sdb2 root/

Run deboostrap on the root partition:

$ debootstrap --arch=armhf --foreign trixie ./root http://http.debian.net/debian

Second Stage debootstrap

I will be assuming the SD card’s device name is /dev/mmcblk1 for the rest of this post. Remember to adapt these commands to the device name on your computer before running any of them.

If your auxiliary computer is not armhf, boot into ArchLinuxARM on the USB drive on the Chromebook and run the rest of the commands from there mounting the SD card onto the system.

Mount the root partitions of your SD card:

$ mkdir root/
$ mount /dev/mmcblk1p2 root/

Run the second stage of debootstrap:

$ chroot ./root/ /debootstrap/debootstrap --second-stage

System Configuration

Add the following line to the /etc/fstab of your installation:

/dev/mmcblk1p2  /  ext4  errors=remount-ro  0 1

Modify the /etc/apt/sources.list file to add more branches:

deb http://http.debian.net/debian trixie main contrib non-free non-free-firmware
deb-src http://http.debian.net/debian trixie main contrib non-free non-free-firmware

Select a timezone (from within the root/ directory):

$ ln -sf usr/share/zoneinfo/Europe/Madrid etc/localtime

Set root password:

$ chroot ./root passwd root

Set hostname:

$ echo "my-hostname" > root/etc/hostname

Kernel Installation

Update repositories:

$ chroot ./root apt-get update

Install necessary packages:

$ chroot ./root apt-get install -y cgpt vboot-utils vboot-kernel-utils u-boot-tools

Install the kernel package:

$ chroot ./root apt-get install -y linux-image-armmp-lpae

Write the FIT image configuration to kernel.its in the root directory of the partition (assuming the Linux version being used is 6.12.43+deb13, adapt where necessary):

/dts-v1/;

/ {
    description = "Linux kernel image with one or more FDT blobs";
    #address-cells = <1>;
    images {
        kernel@1{
            description = "vmlinuz";
            data = /incbin/("/boot/vmlinuz-6.12.43+deb13-armmp-lpae");
            type = "kernel_noload";
            arch = "arm";
            os = "linux";
            compression = "none";
            hash@1{
                algo = "sha1";
            };
        };
        fdt@1{
            description = "dtb";
            data = /incbin/("/usr/lib/linux-image-6.12.43+deb13-armmp-lpae/rk3288-veyron-speedy.dtb");
            type = "flat_dt";
            arch = "arm";
            compression = "none";
            hash@1{
                algo = "sha1";
            };
        };
        ramdisk@1{
            description = "initrd.img";
            data = /incbin/("/boot/initrd.img-6.12.43+deb13-armmp-lpae");
            type = "ramdisk";
            arch = "arm";
            os = "linux";
            compression = "none";
            hash@1{
                algo = "sha1";
            };
        };
    };
    configurations {
        default = "conf@1";
        conf@1{
            kernel = "kernel@1";
            fdt = "fdt@1";
            ramdisk = "ramdisk@1";
        };
    };
};

Prepare the kernel signature:

$ chroot ./root mkimage -f kernel.its kernel.itb

Create an empty bootloader:

$ dd if=/dev/zero of=./root/bootloader.bin bs=512 count=1

Create a kernel command-line file cmdline in the root directory of the root partition:

console=ttyS2,115200n8 earlyprintk=ttyS2,115200n8 console=tty1 nosplash root=/dev/mmcblk1p2 rw rootwait rootfstype=ext4 lsm.module_locking=0

Sign the kernel:

$ chroot ./root vbutil_kernel \
    --pack kernel.signed \
    --version 1 \
    --vmlinuz kernel.itb \
    --arch arm \
    --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
    --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
    --config cmdline \
    --bootloader bootloader.bin

Write the kernel image to the kernel partition:

$ dd if=./root/kernel.signed of=/dev/mmcblk1p1

You should now be able to reboot the system into your new Debian Trixie. The console you see at first is the Systemd output console. To actually get a login prompt, use Ctrl+Alt+F2 (the right-arrow media key) and you’ll see a login prompt.

Maintenance

As you’ve probably noticed, we had to sign the kernel and manually install it with dd. This means for every kernel update you’ll likely have to do the same. All that should be necessary is to modify the kernel.its file with the new kernel version number in all three locations, and then run the same commands as before starting from the mkimage command.

Happy hacking and God bless!

Caveats

Although I’ve gotten the installation to work just fine, there are some caveats that I haven’t figured out as of yet. The primary one that seems to be specific to this installation with Debian—it did not happen with ArchLinuxARM—is that the media/function keys from F8 through F10, represented by the volume-control keys on the keyboard, do not seem to work.

Acknowledgments

I’d like to mention that most of this process is based on what atopuzov’s guide says. I’ve obviously modified and verified this guide for use with Debian Trixie rather than Stretch, but the procedure is mostly the same.