Repartitioning your chromebook's hard drive

I don't really remember how I did this. There are a couple of guides out there the should get you started. Probably what I did was to create a crouton chroot, repartitioned the hard drive there and then used debootstrap on the newly created partition. If you happen to do this yourself right now (or have a lively recollection of how you did it), please drop me a mail.

Repartitioning your chromebook's hard drive (alternative)

After needing a factory reset when sending the chromebook to warranty service, I needed to do this another time, and was a bit bothered by the complexity of the above. What turned out to be a lot simpler was downloading Kali Linux' image and dd it to an USB stick:

cd /tmp
wget -O- https://images.offensive-security.com/arm-images/kali-2017.2-acer.img.xz | xz -d > kali.img
dd if=kali.img of=/dev/sdDOUBLE_CHECK_WHICH_LETTER

Then on your chromebook, you only need to turn on developer mode and after that usb booting:

sudo crossystem dev_boot_usb=1

Now reboot, and press Ctrl+U on the screen informing you about dev mode. This should boot Kali from your USB stick. In my case, I could simply dd my backup, in your case, you'll want to shrink partition 1 as small as possible, and replace partitions 6 and 7 by ones with size 16MB for the kernel and the rest of the disk for ROOT-C respectively. This way, you can dual boot linux and Chome OS by manipulating the priority fields using cgpt. Also be sure to set the correct partition types (kernel, rootfs respectively) using cgpt, and to activate your new kernel partition using

cgpt add -i6 -T1 -P10 /dev/mmcblk0

It makes sense to keep this image in case your kernel compilation experiments below fail.

Installing Debian

After repartitioning, use debootstrap and the rest should be simple.

Compiling a vanilla kernel

sudo apt-get install build-essential firmware-misc-nonfree libncurses5-dev vboot-kernel-utils u-boot-tools

You should start out from a known working kernel configuration and then adapt what you need. Given we need to produce a kernel image suitable for coreboot (actually depthcharge loaded by coreboot), you might want to use my build script which in turn calls my install script. Place both of them in ~/bin if you want to use them unmodified.

Installing vanilla coreboot

This was done on an amd64 machine as I didn't manage to get coreboot to compile on the machine itself. First, we need some dependencies:

sudo apt-get install build-essential pkg-config git libssl-dev uuid-dev libc6-dev liblzma-dev libyaml-dev libftdi-dev m4 bison flex flashrom zlib1g-dev gnat-7

For coreboot itself:

cd /var/tmp
git clone https://review.coreboot.org/coreboot.git
cd coreboot
git submodule update --init --checkout
# this is my config, edit with make menuconfig if you feel like it
wget -O .config https://opensource.holgerbrunn.net/debian-on-acer-cb5/coreboot.config
make crossgcc-arm CPUS=4
ln payloads/libpayload/configs/config.nyan payloads/libpayload/configs/config.nyan_big
make

Now you will need to get the file

build/coreboot.rom
to your chromebook, or use mine. A slight complication here is that the vanilla kernel doesn't recognize the spi (as of 4.5.7), so for the actual flashing, you need to boot the 3.10 kernel built above. Then use flashrom to flash the image:

flashrom -p linux_spi:dev=/dev/spidev32765.0 -w /tmp/coreboot.rom

Now if not something horrible happened, your system should reboot with only some weird messages, but without the scary screen. And it will be a bit scary because there's no indication the machine is turned on. In case you want to flash back a stock image, refer to the unbricking section below.

Unbricking your chromebook

The first thing I did when playing with coreboot, was rendering my chromebook unusable by flashing a non-working coreboot image. The following steps will help you if you did the same mistake. First, you'll need some hardware:

(the links point to where I bought my stuff, buy yours wherever you see fit)

Install raspbian on your PI, get it connected to the net and run

sudo su
apt-get update
apt-get upgrade
# get a coffee
apt-get install libapr1 libaprutil1 libftdi-dev libftdi1 libneon27-gnutls libpci-dev libserf1 libsvn1 libusb-dev subversion
exit
cd /var/tmp
svn co svn://flashrom.org/flashrom/trunk flashrom
cd flashrom
make
to have the flashing program in place. Also run
sudo raspi-config
select advanced options and enable SPI. Reboot your PI.

Now open your chromebook and connect the chip to be flashed with your PI. Align your Chromebook so that you can read U37 in the lower right corner of the mainboard (left of the SD card reader). Put your PI next to it so that the USB ports point to the left and the pin rows are on your near end. Then the wiring should be the following:

On the clip
/ 1 2 3
4 5 6 7
On the PI
/ / / / / / / 7 2 5 3 6 / / / / / / / 1
count the first seven pins from the left the following five are connected ignore the next 7 pins
/ / / / / / / / 4 / / / / / / / / / / /
count the first eight pins from the left ignore the rest

Run flashrom and read your broken bios in the first place

sudo /var/tmp/flashrom/flashrom --programmer linux_spi:dev=/dev/spidev0.0 --read /var/tmp/faulty_bios
which should output something like
flashrom v0.9.8-r1896 on Linux 4.1.6-v7+ (armv7l)
flashrom is free software, get the source code at http://www.flashrom.org

Calibrating delay loop... OK.
Found Winbond flash chip "W25Q32.W" (4096 kB, SPI) on linux_spi.
Reading flash...
Then get a working stock image or use mine and flash that
sudo /var/tmp/flashrom/flashrom --programmer linux_spi:dev=/dev/spidev0.0 --write /tmp/big_fw_5771.63.0
which should look like
flashrom v0.9.8-r1896 on Linux 4.1.6-v7+ (armv7l)
flashrom is free software, get the source code at http://www.flashrom.org
      
Calibrating delay loop... OK.
Found Winbond flash chip "W25Q32.W" (4096 kB, SPI) on linux_spi.
Reading old flash chip contents... done.
Erasing and writing flash chip... Erase/write done.
Verifying flash... VERIFIED.
Now disconnect the clip, reassemble your chromebook and prepare for your happy dance, because it's booting again!