Installing Linux 5.4 ChromiumOS Kernel on Pixelbook with modified SEABIOS from mrchromebox.tech

2020-05-04

Note: None of this is really required anymore, there are several other people who have done a better job of this and created ansible scripts to lessen the burden. Such as https://github.com/jmontleon/pixelbook-fedora

First set your machine to developer mode and all that, there are about 100 guides for it so find one of those first.

I first used chrx to partition my disks, it’s a two step program, first you partition disks then you install ubuntu. I dont like Ubuntu so just do the first part and dont rerun the script, if you change your mind about your partition sizes you’ll need to edit the script because it assumes that partitioning is correct and continues with second part of the script if the linux partition (Unused Kernel C and Unused Rootfs) are greater than 0 or something like that. Or you can just factory reset your pixelbook. https://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format

Then install whatever distro you want really, I used void, arch also works well. Ctrl + L at the scary screen and install from your usb key, if you need to factory reset then you’ll need an usb c usb stick as dongles wont get detected that early. But installing linux with a usb stick and a dongle works fine sort of, give it some time to initialize before you hit Ctrl + L, atleast that was my experience.

If you cant get grub to show up you probably need to

fdisk /dev/nvme0n1 fdisk open /dev/nvme0n1

t changing type

6 choosing partition #6 (Unused Kernel C)

4 setting it to BIOS BOOT (4) get full list by pressing L

Now you should boot into whatever distro you installed

Time to install the latest chromiumos kernel.

We need the latest firmware, you can download it from the chromiumos git repo but it doesnt have what we need. So we need to get the recovery file and extract what we need from that then we can overwrite with updated firmware from the public chromiumos-linux-firmware repo if you’d like. Make sure EVERYTHING gets copied now from the location we mounted the firmware image /mnt/tmp/lib/firmware/ to the /lib/firmware on our machine.

wget https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_11021.81.0_eve_recovery_stable-channel_mp.bin.zip
unzip chromeos_11021.81.0_eve_recovery_stable-channel_mp.bin.zip
sudo kpartx -av chromeos_11021.81.0_eve_recovery_stable-channel_mp.bin
mkdir /mnt/tmp
mount -t ext2 /dev/mapper/loop0p3 -o ro /mnt/tmp
cp /mnt/tmp/lib/firmware/* /lib/firmware/*

You might also want to download the latest linux-firmware because some files are overlapping and then we will get the newest we can, until we get a new firmware image for the 5.4 kernel and can get the stuff that currently is not available on the repo.

https://chromium.googlesource.com/chromiumos/third_party/linux-firmware/

git clone https://chromium.googlesource.com/chromiumos/third_party/linux-firmware

and copy those files into /lib/firmware

or something like that, you might want to clone the factory-eve branch, do that like this

git clone https://chromium.googlesource.com/chromiumos/third_party/linux-firmware -b factory-eve-9667.B

We also need to compile our new kernel, follow the arch linux traditional compilation guide or gentoo handbook or random github repos. https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation https://github.com/megabytefisher/eve-linux-hacks/ https://wiki.gentoo.org/wiki/Kernel/Configuration

Make sure we have a modified .config as the default wont work, its named config in this directory and you need to save it and name it .config and save it wherever you download the kernel I will attach one but you might want to look through it yourself. I added necessary flags for TPM to the default .config and necessary modules for unique chrome hardware drivers. Also added the default cpu governor to powersave instead of performance as another pixelbook config did, this lead to alot of coil whine on my machine, I believe it was coil whine it was unpleasant atleast. If it doesnt scare you feel free to change it or else just change it in userspace with the cpupower program or cpupower-gui.

Find what else might necessary here https://github.com/flantel/pixelbook-linux https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/heads/chromeos-5.4/chromeos/config/ pineview is the config we would be using on chromiumos, i believe. https://github.com/dnschneid/crouton/wiki/Build-chrome-os-kernel-and-kernel-modules https://chromium.googlesource.com/chromiumos/docs/+/master/kernel_faq.md

Also, important. Backlight wont work out of the box unless youre using the full rom firmware (I think), if youre dual booting with SEABIOS like me you will need a hack to force DPCD mode, otherwise i915 will try using PWM for backlight control due to pins not being connected blah blah, look it up. https://unrelenting.technology/articles/FreeBSD-and-custom-firmware-on-the-Google-Pixelbook Really, look it up it’s a good writeup about the pixelbook and linux/bsd.

So we will need to add the patch from said link to our the kernel we will download in the next step. After downloading open the file /drivers/gpu/drm/i915/display/inteldpaux_backlight.c and go to line 271 (might change in the future and this patch might not work depending on how much they change the i915 driver but for now its line 271) and merge this

So download the chromium-5.4 kernel like this

git clone https://chromium.googlesource.com/chromiumos/third_party/kernel -b chromeos-5.4

open the file and edit, here is the patch, apply it.

IMPORTANT: IF YOU ARE RUNNING THE UEFI FIRMWARE YOU PROBABLY DO NOT NEED TO APPLY THIS PATCH!!! TRY WITHOUT IT AND IF IT DOESNT WORK ADD THE PATCH AND JUST CONTINUTE FROM THE make -j15 modules COMMAND AGAIN.

+++ w/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
@@ -252,8 +252,12 @@ intel_dp_aux_display_control_capable(struct intel_connector *connector)
         * the panel can support backlight control over the aux channel
         */
        if (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP &&
-           (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP) &&
-           !(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)) {
+           (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)
+/* for Pixelbook (eve), simpler version of https://patchwork.kernel.org/patch/9618065/ */
+#if 0
+            && !(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)
+#endif
+                       ) {
                DRM_DEBUG_KMS("AUX Backlight Control Supported!\n");
                return true;
        }

It should look like this after you have applied the patch

intel_dp_aux_display_control_capable(struct intel_connector *connector)
{
    struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base);
    /* Check the eDP Display control capabilities registers to determine if
     * the panel can support backlight control over the aux channel
     */
    if (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP &&
                   (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)
        /* for Pixelbook (eve), simpler version of https://patchwork.kernel.org/patch/9618065/ */
        #if 0
                    && !(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)
        #endif
                               ) {
        DRM_DEBUG_KMS("AUX Backlight Control Supported!\n");
        return true;
    }
    return false;
} 

Now time to build the kernel, dont forget to add the .config file before you run these commands!

make -j15
make -j15 modules
sudo make modules_install

compilation took 45 minutes on my machine, I7 pixelbook.

Install modules with mkinitcpio or dracut, include some firmware files. i.e add FILES=(/lib/firmware/i915/kbl_dmc_ver1.bin /lib/firmware/i915/kbl_guc_ver9_14.bin) to /etc/mkinitcpio.conf I also added MODULES=(intel_agp i915) for good measure, but ymmv.

Make sure you also download xf86-video-intel and use some grub boot flags, I used these, you might want to use some other.

loglevel=4 slub_debug=P page_poison=1 pci=noaer i915.enable_dpcd_backlight=1 pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1 intel_idle.max_cstate=1 elevator=noop i915.semaphores=1 intel_iommu=on nmi_watchdog=0 i915.enable_guc=2 mitigations=off acpi_osi=linux acpi_backlight=vendor

You might not want to use the mitigations=off flag, also i915.enable.dbc=1 is enabled on chromeos which makes the colors washed out so, if you want that, enable it. I think I also missed some flags you can find them somewhere in the chromiumos repo. You can read more about the dbc flag in the following thread, you might get 20-40 minutes more battery life but you will also get washed out colors and screen flicker. https://www.reddit.com/r/PixelBook/comments/fqe2rj/how_to_fix_washed_out_colors_backlight_flickering/

And then add /etc/X11/xorg.conf.d files, I’ll add them to this repo. Also, if you want the touchpad to behave as on chromeos check out my other repo’s there are forks of the CMT driver with necessary patches. You might need to google to find all necessary dependencies but its not difficult to compile the driver yourself.

https://github.com/soppelmann/xf86-input-cmt

And necessary dependencies

https://github.com/soppelmann/libevdevc

https://github.com/soppelmann/libgestures/

Get natural scrolling working like this, you might want to add it to the xorg.conf.d file, 12 id the id of my touchpad, find yours by running xinput –list

xinput set-prop '12' 'Australian Scrolling' 1

Or add the following line to the /etc/X11/xorg.conf.d/50-touchpad-cmt-eve.conf file Option "Australian Scrolling" "1"

with mkinitcpio it will be: sudo mkinitcpio -k 5.4.35-chromium -g /boot/initramfs-5.4.35-chromium.img or something like that. Check /lib/modules for what the actual directory name is called, you choose this in the config file

afterwards copy into /boot/ and run grub-mkconfig update-grub or use grub-customizer.

To install the kernel is literally to copy it into the /boot directory, grub reads that directory and creates boot entries for you. All that is needed is the vmlinuz file but we also want a initramfs (copied there by the mkinitcpio command) and a systemmap.

We copy it all like this

sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-somenumberandname

sudo cp System.map /boot/System.map-somenumberandname

Only problem now is that the backlight is messed up when entering sleep mode zzz, I changed the acpid event handler so it doesnt enter sleep mode. Problem was that after waking from sleep the max brightness is halved even though the sys file shows it to be at the highest.

Edit the file /etc/acpi/handler.sh and uncomment the line zzz after button/lid close

Also, brightness is set at 0 at startup, I fixed this by setting the brightness to 100 in /etc/rc.local Maybe you could try the i915.invert_brightness parameter but this also works, somewhat.

xbacklight -set 100

(this command will only work if youre using acpilight, otherwise you can echo something to /sys/class/backlight/intel_backlight/brightness but this is easier for me.

I’ll use this until I figure out how the get the backlight working properly, its good enough for now atleast. 50% backlight as maximum is ok and you can see it as a power saving measure. :-) Another option is to invoke rtcwake when closing/opening the lid, I’ll expirement with that later.

I also blacklisted some kernel modules I dont need, I attached the blacklist.conf I used, it goes in /etc/modprobe.d/

And now you can enjoy your pixelbook with the latest kernel with some minor caveats but it shouldnt be too hard to fix. Battery life is comparable to Chromeos too which is nice, but it all depends on your DE,WM and set of programs.

Tested at idle with chromium open and brightness at 40%

Powerstat on chromeos 4.4.211-17203-gbe96242e05a2

  Time    User  Nice   Sys  Idle    IO  Run Ctxt/s  IRQ/s Fork Exec Exit  Watts
----- ---- ---- ---- ------ 
 Average  16.9   0.0   8.8  74.0   0.3  2.8 4667.0 2536.9 37.3 14.1 37.3   5.80 
 GeoMean  16.5   0.0   8.7  73.8   0.2  2.1 4551.6 2030.1 34.5 13.4 35.4   5.77 
  StdDev   4.2   0.0   1.6   5.6   0.1  2.2 1149.8 2089.7 17.3  4.6 13.0   0.69 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------ 
 Minimum  13.9   0.0   7.3  60.3   0.1  1.0 3934.0 1437.8 20.0  8.0 22.0   5.41 
 Maximum  27.0   0.0  12.6  78.2   0.5  8.0 7418.8 7746.6 83.0 21.0 65.0   7.74 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------ 
Summary:
System:   5.80 Watts on average with standard deviation 0.69

Powerstat on Void with KDE5 as DE and i3-gaps as WM 5.4.35chromium+

  Time    User  Nice   Sys  Idle    IO  Run Ctxt/s  IRQ/s Fork Exec Exit  Watts
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------
 Average   4.4   0.0   1.7  93.7   0.2  1.4 1829.9 3209.3 22.4 12.1 11.2   5.57
 GeoMean   1.0   0.0   0.6  92.6   0.0  1.2 1207.8 1070.9  7.0 11.2  6.5   5.56
  StdDev   9.4   0.0   2.6  12.3   0.4  0.9 2143.5 4018.2 61.4  6.8 16.7   0.45
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------
 Minimum   0.3   0.0   0.2  51.6   0.0  1.0  620.1  294.4  4.0 10.0  4.0   5.31
 Maximum  36.5   0.0   9.9  99.5   2.0  5.0 9585.4 11041.3 286.0 41.0 66.0   7.12
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------
Summary:
System:   5.57 Watts on average with standard deviation 0.45

Also when touching the touchpad there are alot of interrupts that you can find in /proc/interrupts, I couldnt figure out a way to solve that but it also happens on chromeos so, wontfix.

I also couldnt get the iwl7000 driver working, I believe its used together with the iwlfifi driver on chromeos but I think I need to point to some firmware files, it shouldnt be too hard as they are available in /lib/firmware/ if someone figures this out please write.

Also, bluetooth is working, I needed to add bluetoothd to my init system, you might need to do the same.
ln -s /etc/sv/bluetoothd /var/service on void. Also make sure you uncomment the blacklist of the bluetooth modules like so in /etc/modprobe.d/blacklist.conf if you added that file.

# blacklist bluetooth

# blacklist btintel

# blacklist btrtl

# blacklist btusb

There are some more things to add that I havent written, (tablet mode switch, audio, SuzyQ, TPM, EC, External displays) and I should rewrite/reformat all of this into a more readable format and fix grammar but this is good enough for now. Good luck