Message ID | 20200718205148.1743807-4-computersforpeace@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | Add support for Chromium OS and Google WiFi | expand |
Hi, > -----Original Message----- > From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] > On Behalf Of Brian Norris > Sent: Samstag, 18. Juli 2020 22:52 > To: openwrt-devel@lists.openwrt.org > Cc: Brian Norris <computersforpeace@gmail.com> > Subject: [RFC PATCH 3/5] image-commands: support Chromium OS image- > type creation > > See the previous patches, which implemented the cros-vbutil verified-boot > payload-packing tool, and extended ptgen for the CrOS kernel partition type. > With these, it's now possible to package kernel + rootfs to make disk images > that can boot a Chrome OS-based system (e.g., Chromebooks, or even a few > AP models). > > gen_image_vboot.sh borrows a bit of structure from gen_image_generic.sh, > but I didn't feel it fit well to try and add new flags to the latter, given the > difference in its FAT kernel packaging and our raw kernel partition packing. > > Signed-off-by: Brian Norris <computersforpeace@gmail.com> > --- > include/image-commands.mk | 17 +++++++++++++++++ > scripts/gen_image_vboot.sh | 29 +++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > create mode 100755 scripts/gen_image_vboot.sh > > diff --git a/include/image-commands.mk b/include/image-commands.mk > index e7db7128b4ca..ca8e826ffb1e 100644 > --- a/include/image-commands.mk > +++ b/include/image-commands.mk Why is this added globally and not just for ipq40xx (same for the script)? Do you plan to use it for other targets? Best Adrian > @@ -164,6 +164,23 @@ define Build/fit > @mv $@.new $@ > endef > > +define Build/cros-image > + $(SCRIPT_DIR)/gen_image_vboot.sh \ > + $@ \ > + $(CONFIG_TARGET_KERNEL_PARTSIZE) $(IMAGE_KERNEL) \ > + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) > endef > + > +# NB: Chrome OS bootloaders replace the '%U' in command lines with the > +UUID of # the kernel partition it chooses to boot from. This gives a > +flexible way to # consistently build and sign kernels that always use > +the subsequent # (PARTNROFF=1) partition as their rootfs. > +define Build/cros-vboot > + $(STAGING_DIR_HOST)/bin/cros-vbutil \ > + -k $@ -c "root=PARTUUID=%U/PARTNROFF=1" -o $@.new > + @mv $@.new $@ > +endef > + > define Build/lzma > $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1)) endef diff --git > a/scripts/gen_image_vboot.sh b/scripts/gen_image_vboot.sh new file > mode 100755 index 000000000000..acded33de654 > --- /dev/null > +++ b/scripts/gen_image_vboot.sh > @@ -0,0 +1,29 @@ > +#!/usr/bin/env bash > +# Copyright (C) 2020 OpenWrt.org > +set -e -x > +[ $# == 5 ] || { > + echo "SYNTAX: $0 <file> <kernel size> <kernel image> <rootfs size> > <rootfs image>" > + exit 1 > +} > + > +OUTPUT="$1" > +KERNELSIZE="$2" > +KERNELIMAGE="$3" > +ROOTFSSIZE="$4" > +ROOTFSIMAGE="$5" > + > +rm -f "${OUTPUT}" > + > +head=16 > +sect=63 > + > +# create partition table > +set $(ptgen -o "$OUTPUT" -h $head -s $sect -g -T cros_kernel -p > +${KERNELSIZE}m -p ${ROOTFSSIZE}m) > + > +KERNELOFFSET="$(($1 / 512))" > +KERNELSIZE="$2" > +ROOTFSOFFSET="$(($3 / 512))" > +ROOTFSSIZE="$(($4 / 512))" > + > +dd if="${KERNELIMAGE}" of="${OUTPUT}" bs=512 > seek="${KERNELOFFSET}" > +conv=notrunc dd if="${ROOTFSIMAGE}" of="${OUTPUT}" bs=512 > +seek="${ROOTFSOFFSET}" conv=notrunc > -- > 2.27.0 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Hi Adrian, On Sat, Jul 18, 2020 at 2:14 PM <mail@adrianschmutzler.de> wrote: > > -----Original Message----- > > From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] > > On Behalf Of Brian Norris > > Sent: Samstag, 18. Juli 2020 22:52 > > To: openwrt-devel@lists.openwrt.org > > Cc: Brian Norris <computersforpeace@gmail.com> > > Subject: [RFC PATCH 3/5] image-commands: support Chromium OS image- > > type creation > > > > See the previous patches, which implemented the cros-vbutil verified-boot > > payload-packing tool, and extended ptgen for the CrOS kernel partition type. > > With these, it's now possible to package kernel + rootfs to make disk images > > that can boot a Chrome OS-based system (e.g., Chromebooks, or even a few > > AP models). > > > > gen_image_vboot.sh borrows a bit of structure from gen_image_generic.sh, > > but I didn't feel it fit well to try and add new flags to the latter, given the > > difference in its FAT kernel packaging and our raw kernel partition packing. > > > > Signed-off-by: Brian Norris <computersforpeace@gmail.com> > > --- > > include/image-commands.mk | 17 +++++++++++++++++ > > scripts/gen_image_vboot.sh | 29 +++++++++++++++++++++++++++++ > > 2 files changed, 46 insertions(+) > > create mode 100755 scripts/gen_image_vboot.sh > > > > diff --git a/include/image-commands.mk b/include/image-commands.mk > > index e7db7128b4ca..ca8e826ffb1e 100644 > > --- a/include/image-commands.mk > > +++ b/include/image-commands.mk > > Why is this added globally and not just for ipq40xx (same for the script)? > > Do you plan to use it for other targets? Great question! Perhaps I should have noted that in the cover letter a little more explicitly -- I noted that these image-generation commands are applicable to all Chrome OS based devices (Chromebooks, etc.), but there's one device in particular that may be quite relevant: Google OnHub. It's got an IPQ8064 SoC running a Chrome OS stack, and I hear there are some others who may be interested in porting to it too. I don't have immediate plans to do that myself though, and if it's preferred to start ipq40xx-local and move later if needed, I can do that too. Brian
diff --git a/include/image-commands.mk b/include/image-commands.mk index e7db7128b4ca..ca8e826ffb1e 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -164,6 +164,23 @@ define Build/fit @mv $@.new $@ endef +define Build/cros-image + $(SCRIPT_DIR)/gen_image_vboot.sh \ + $@ \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $(IMAGE_KERNEL) \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) +endef + +# NB: Chrome OS bootloaders replace the '%U' in command lines with the UUID of +# the kernel partition it chooses to boot from. This gives a flexible way to +# consistently build and sign kernels that always use the subsequent +# (PARTNROFF=1) partition as their rootfs. +define Build/cros-vboot + $(STAGING_DIR_HOST)/bin/cros-vbutil \ + -k $@ -c "root=PARTUUID=%U/PARTNROFF=1" -o $@.new + @mv $@.new $@ +endef + define Build/lzma $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1)) endef diff --git a/scripts/gen_image_vboot.sh b/scripts/gen_image_vboot.sh new file mode 100755 index 000000000000..acded33de654 --- /dev/null +++ b/scripts/gen_image_vboot.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Copyright (C) 2020 OpenWrt.org +set -e -x +[ $# == 5 ] || { + echo "SYNTAX: $0 <file> <kernel size> <kernel image> <rootfs size> <rootfs image>" + exit 1 +} + +OUTPUT="$1" +KERNELSIZE="$2" +KERNELIMAGE="$3" +ROOTFSSIZE="$4" +ROOTFSIMAGE="$5" + +rm -f "${OUTPUT}" + +head=16 +sect=63 + +# create partition table +set $(ptgen -o "$OUTPUT" -h $head -s $sect -g -T cros_kernel -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m) + +KERNELOFFSET="$(($1 / 512))" +KERNELSIZE="$2" +ROOTFSOFFSET="$(($3 / 512))" +ROOTFSSIZE="$(($4 / 512))" + +dd if="${KERNELIMAGE}" of="${OUTPUT}" bs=512 seek="${KERNELOFFSET}" conv=notrunc +dd if="${ROOTFSIMAGE}" of="${OUTPUT}" bs=512 seek="${ROOTFSOFFSET}" conv=notrunc
See the previous patches, which implemented the cros-vbutil verified-boot payload-packing tool, and extended ptgen for the CrOS kernel partition type. With these, it's now possible to package kernel + rootfs to make disk images that can boot a Chrome OS-based system (e.g., Chromebooks, or even a few AP models). gen_image_vboot.sh borrows a bit of structure from gen_image_generic.sh, but I didn't feel it fit well to try and add new flags to the latter, given the difference in its FAT kernel packaging and our raw kernel partition packing. Signed-off-by: Brian Norris <computersforpeace@gmail.com> --- include/image-commands.mk | 17 +++++++++++++++++ scripts/gen_image_vboot.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 scripts/gen_image_vboot.sh