Skip to content

Depthcharge bootloader support

Alper Nebi Yasak requested to merge alpernebbi/flash-kernel:master into master

Hello!

I was working on running Debian on my chromebook the right way. After some changes to the Debian kernel (now merged), the linux-image-4.19.0-5-arm64 kernel boots on my machine, but still needs some depthcharge-specific work after every kernel/initramfs change. This process could be made into a standalone package, but I guess adapting it to flash-kernel is the proper way to support chromebooks. I'm testing this MR on my machine and it seems to work well.

For reference, I'm running a debootstrapped Debian from a USB device (/dev/sda) with four partitions, first three of size 32MiB for depthcharge images. I've manually added an /etc/fstab entry, set MODULES=dep in /etc/initramfs-tools/initramfs.conf. I've also added some modules into /etc/initramfs-tools/modules.conf (the most essential of those are already merged into initramfs-tools). Installing this and updating initramfs works as it should. I've also tested generating an image that's too big and having an /etc/fstab file that points to a drive with no valid depthcharge partitions. Those error conditions are properly reported.

I've implemented a way to find physical disks for LVM and LUKS in find_depthcharge_part and tested that it can resolve a chain of /dev/mapper/luks-* -> LUKS /dev/dm-1 -> LVM /dev/dm-0 -> /dev/sda5 -> /dev/sda, though I haven't added test code for that since I couldn't figure out the best way to do it. After finding /dev/sda, the rest of the function chooses a nice partition. Right now, disks containing both /boot (if exists) and / partitions are searched, since I guess both of them are guaranteed be available at boot-time.

In addition, I tested this on today's daily netboot arm64 debian-installer image, I just had to add firmware and pack it the way depthcharge wants. I set up encrypted rootfs on LVM and a /boot partition on different disks. After going through a full installation, I've dropped to a shell, copied a local build of this deb and apt-installed it on the target. I couldn't install the local udeb with anna-install, so I installed the current version and replaced the all.db and functions with these ones. After that, I could run the flash-kernel step without error. (Well, I had to adjust the initramfs-tools configuration to actually make it bootable.)

Other than these, I did some trivial modifications to write_mtd and check_mtd_size, but I don't have any device I can test the mtd-flashing code paths on.

My device seems to have a 32MiB limit on the size of this image, but I found a commit in the depthcharge repository claiming they bumped it up to 512MiB. I don't know if changes make it back to previous devices, I've been waiting for the ChromeOS 75 release to run a recovery (to upgrade the firmware) so that I can test that. I haven't put checks for this size limit as it could be machine-dependent or version-dependent.

I don't expect this to make it to Buster, and AFAIK I'll need to work on d-i more for the depthcharge partitioning to be possible. So don't feel rushed, but I'd be happy to have feedback on how I can improve this.

Edited by Alper Nebi Yasak

Merge request reports

Loading