This would be very helpful for kernel development (mainlining devices is one of our goals after all), and also this would make it easier to bisect kernels in case something doesn't work anymore after a new kernel release.
CC: @ata2001, @bhush9, @drebrez, @filippz, @flacks, @fourkbomb, @opendata26, @pavelmachek, @z3ntu
I came up with the following concept for supporting the mainlining process with pmbootstrap. These are just ideas, I have not written code yet. Please verify from an users point of view, if that workflow makes sense to you and whether it would really simplify mainlining.
pmbootstrap init. The checked out source tree is a few GB in size, so my assumption is that people will only want it once on their machine, and the location won't change often.$ pmbootstrap init
...
Build options: Parallel jobs: 3, ..., Linux tree: none
Change them? (y/n) [n]: y
...
Path to the checked out mainline Linux source tree (useful for mainlining your device):
Linux tree [none]: ~/code/linux
...
$ pmbootstrap initfs hook_add debug-shell
(apply changes to local kernel sources)
$ pmbootstrap build linux-postmarketos-mainline --localsrc --force
$ pmbootstrap flasher boot --flavor postmarketos-mainline
The important change is the --localsrc flag:
$ pmbootstrap build linux-postmarketos-mainline --localsrc --force
Here's how pmbootstrap would treat that flag:
/mnt/local-kernel-src/ in the native chrootpmbootstrap sets a new environment variable PMB_LOCAL_SRC=/mnt/local-kernel-src/ during the buildlinux-postmarketos-mainline APKBUILD to check for this variable, and if it is set:kbuilddir variable to point to PMB_LOCAL_SRCmake mrproper in prepare()pkgdesc to the current git commitpmbootstrap menuconfig works as usuallyI don't want a full clean after each test 馃槈 Just running make -j9 is enough for me. Seems quite good for me otherwise.
For reference, these are the commands I use:
setup:
set -gx ARCH arm; set -gx CROSS_COMPILE arm-none-eabi- # fish shell equivalent of export ARCH=arm etc
build:
make -j9
cat arch/arm/boot/zImage arch/arm/boot/dts/qcom-msm8974-fairphone-fp2.dtb > ../zImage-dtb
cd ..
./make_bootimg.sh
cd out
sign_img mainline-boot.img
fastboot boot mainline-boot.img.signed
The make_bootimg.sh script contains
#!/bin/bash
rm out/*
mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x01000000 --second_offset 0x00f00000 --tags_offset 0x00000100 --cmdline 'rdinit=/init cma=64m msm.vram=16m PMOS_NO_OUTPUT_REDIRECT' --kernel zImage-dtb --ramdisk ramdisk.cpio.gz -o out/mainline-boot.img
And about the sign_img script, see https://z3ntu.github.io/2017/06/16/Signing-boot-images.html
Quick TLDR about sign_img: the FP2 bootloader is 'technically' 'locked' so it doesn't accept images via fastboot boot that aren't signed, but the bootloader also doesn't care what the signature contains (as far as I can tell) so signing the image with your own key works fine. Then the 'signed' image can be normally launched with fastboot boot.
@ollieparanoid Seems quite good also to me.
Possible problem with the last step, after you rebuild the linux-postmarketos-mainline, it doesn't get installed/updated in the chroot where the flasher will run, because in https://github.com/postmarketOS/pmbootstrap/blob/master/pmb/flasher/frontend.py#L36 will call https://github.com/postmarketOS/pmbootstrap/blob/master/pmb/chroot/initfs.py#L34 which it reinstall only the updated postmarketos-mkinitfs.
We should also reinstall the linux-postmarketos-mainline at some point, manually or always like for the initramfs, or with an additional flag in the flasher....