patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH 0/2] img/combined: avoid chainloading in GRUB
@ 2022-04-20 10:12 Alyssa Ross
  2022-04-20 10:12 ` [PATCH 1/2] img/live: switch to systemd-boot Alyssa Ross
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alyssa Ross @ 2022-04-20 10:12 UTC (permalink / raw)
  To: devel; +Cc: Ville Ilvonen, Puck Meerburg

Ville, could you give these patches a try on your P43s and see if
"Try Spectrum" can boot now?

Alyssa Ross (2):
  img/live: switch to systemd-boot
  img/combined: avoid chainloading in GRUB

 img/combined/default.nix | 10 ++++++++++
 img/combined/grub.cfg.in |  5 +++--
 img/live/Makefile        | 23 +++++++++++------------
 img/live/default.nix     |  2 +-
 img/live/etc/os-release  |  5 -----
 5 files changed, 25 insertions(+), 20 deletions(-)
 delete mode 100644 img/live/etc/os-release


base-commit: 82212bb2207b9cb43f4510f373fb9ba8acfde21e
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] img/live: switch to systemd-boot
  2022-04-20 10:12 [PATCH 0/2] img/combined: avoid chainloading in GRUB Alyssa Ross
@ 2022-04-20 10:12 ` Alyssa Ross
  2022-04-21 11:48   ` Alyssa Ross
  2022-04-20 10:12 ` [PATCH 2/2] img/combined: avoid chainloading in GRUB Alyssa Ross
  2022-04-21  9:57 ` [PATCH 0/2] " ville.ilvonen
  2 siblings, 1 reply; 6+ messages in thread
From: Alyssa Ross @ 2022-04-20 10:12 UTC (permalink / raw)
  To: devel; +Cc: Ville Ilvonen, Puck Meerburg

This will make it easier to dual-boot Spectrum with other operating
systems, and hopefully make it possible to avoid chainloading (which
has firmware compatibility issues) in the combined image.

We're not exactly following Boot Loader Specification[1] best
practices here — we don't namespace installation by version or
machine-id.  But it's better than what we had before, and I think
it'll be easier to figure out what to do about namespacing once we've
figured out how updates will work.

[1]: https://systemd.io/BOOT_LOADER_SPECIFICATION/

Cc: Puck Meerburg <puck@puckipedia.com>
---
 img/live/Makefile       | 23 +++++++++++------------
 img/live/default.nix    |  2 +-
 img/live/etc/os-release |  5 -----
 3 files changed, 12 insertions(+), 18 deletions(-)
 delete mode 100644 img/live/etc/os-release

diff --git a/img/live/Makefile b/img/live/Makefile
index 8f47028..1277431 100644
--- a/img/live/Makefile
+++ b/img/live/Makefile
@@ -22,22 +22,21 @@ build/live.img: $(SCRIPTS)/format-uuid.sh $(SCRIPTS)/make-gpt.sh build/boot.fat
 	    $(EXT_FS):9293e1ff-cee4-4658-88be-898ec863944f
 	mv $@.tmp $@
 
-build/cmdline: build/rootfs.verity.roothash
-	printf "ro console=ttyS0 roothash=" > $@
+build/spectrum.conf: build/rootfs.verity.roothash
+	printf "title Spectrum\n" > $@
+	printf "linux /spectrum/linux\n" >> $@
+	printf "initrd /spectrum/initrd\n" >> $@
+	printf "options ro console=ttyS0 roothash=" >> $@
 	cat build/rootfs.verity.roothash >> $@
 
-build/bootx64.efi: etc/os-release build/cmdline $(INITRAMFS)
-	$(OBJCOPY) --add-section .osrel=etc/os-release --change-section-vma .osrel=0x20000 \
-	    --add-section .cmdline=build/cmdline --change-section-vma .cmdline=0x30000 \
-	    --add-section .linux=$(KERNEL) --change-section-vma .linux=0x40000 \
-	    --add-section .initrd=$(INITRAMFS) --change-section-vma .initrd=0x3000000 \
-	    $(EFI_STUB) $@
-
-build/boot.fat: build/bootx64.efi
+build/boot.fat: $(KERNEL) $(INITRAMFS) $(SYSTEMD_BOOT_EFI) build/spectrum.conf
 	$(TRUNCATE) -s 220200960 $@
 	$(MKFS_FAT) $@
-	$(MMD) -i $@ ::/EFI ::/EFI/BOOT
-	$(MCOPY) -i $@ build/bootx64.efi ::/EFI/BOOT
+	$(MMD) -i $@ ::/EFI ::/EFI/BOOT ::/loader ::/loader/entries ::/spectrum
+	$(MCOPY) -i $@ build/spectrum.conf ::/loader/entries
+	$(MCOPY) -i $@ $(KERNEL) ::/spectrum/linux
+	$(MCOPY) -i $@ $(INITRAMFS) ::/spectrum/initrd
+	$(MCOPY) -i $@ $(SYSTEMD_BOOT_EFI) ::/EFI/BOOT/BOOTX64.EFI
 
 # veritysetup format produces two files, but Make only (portably)
 # supports one output per rule, so we combine the two outputs then
diff --git a/img/live/default.nix b/img/live/default.nix
index c9cd354..bebc1c1 100644
--- a/img/live/default.nix
+++ b/img/live/default.nix
@@ -26,11 +26,11 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cryptsetup dosfstools jq mtools util-linux ];
 
-  EFI_STUB = "${systemd}/lib/systemd/boot/efi/linuxx64.efi.stub";
   EXT_FS = extfs;
   INITRAMFS = initramfs;
   KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}";
   ROOT_FS = rootfs;
+  SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-bootx64.efi";
 
   buildFlags = [ "build/live.img" ];
   makeFlags = [ "SCRIPTS=${scripts}" ];
diff --git a/img/live/etc/os-release b/img/live/etc/os-release
deleted file mode 100644
index 7980810..0000000
--- a/img/live/etc/os-release
+++ /dev/null
@@ -1,5 +0,0 @@
-# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
-# SPDX-License-Identifier: CC0-1.0
-
-PRETTY_NAME="Spectrum"
-VERSION_ID=0.1
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] img/combined: avoid chainloading in GRUB
  2022-04-20 10:12 [PATCH 0/2] img/combined: avoid chainloading in GRUB Alyssa Ross
  2022-04-20 10:12 ` [PATCH 1/2] img/live: switch to systemd-boot Alyssa Ross
@ 2022-04-20 10:12 ` Alyssa Ross
  2022-04-21 11:48   ` Alyssa Ross
  2022-04-21  9:57 ` [PATCH 0/2] " ville.ilvonen
  2 siblings, 1 reply; 6+ messages in thread
From: Alyssa Ross @ 2022-04-20 10:12 UTC (permalink / raw)
  To: devel; +Cc: Ville Ilvonen, Puck Meerburg

Some UEFI implementations (like the one on Ville's Thinkpad P43s)
failed to chainload Spectrum from GRUB.  Now that Spectrum has a
proper bootloader, we can avoid that chainloading entirely, which will
hopefully make the broken firmware happier.

Reported-by: Ville Ilvonen <ville.ilvonen@unikie.com>
Cc: Puck Meerburg <puck@puckipedia.com>
---
 img/combined/default.nix | 10 ++++++++++
 img/combined/grub.cfg.in |  5 +++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/img/combined/default.nix b/img/combined/default.nix
index 86e07e2..16cd506 100644
--- a/img/combined/default.nix
+++ b/img/combined/default.nix
@@ -35,6 +35,16 @@ let
 
   grubCfg = substituteAll {
     src = ./grub.cfg.in;
+
+    nativeBuildInputs = [ mtools ];
+
+    preInstall = ''
+      export spectrumKernelParams="$(
+          mcopy -i ${eosimages.image}@@1M ::/loader/entries/spectrum.conf - |
+          grep '^options ' |
+          sed 's/^options //')"
+    '';
+
     linux = removePrefix storeDir installer.kernel;
     initrd = removePrefix storeDir installer.initramfs;
     inherit (installer) kernelParams;
diff --git a/img/combined/grub.cfg.in b/img/combined/grub.cfg.in
index 1a91a75..31b09d6 100644
--- a/img/combined/grub.cfg.in
+++ b/img/combined/grub.cfg.in
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: EUPL-1.2
-# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
 insmod efi_gop
 insmod efi_uga
@@ -13,7 +13,8 @@ terminal_output gfxterm
 
 menuentry "Try Spectrum" {
   loopback live (hd0,gpt3)/Spectrum-0.0-x86_64-generic.0.Live.img
-  chainloader (live,gpt1)/efi/boot/bootx64.efi
+  linux (live,gpt1)/spectrum/linux @spectrumKernelParams@
+  initrd (live,gpt1)/spectrum/initrd
 }
 
 menuentry "Install Spectrum" {
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] img/combined: avoid chainloading in GRUB
  2022-04-20 10:12 [PATCH 0/2] img/combined: avoid chainloading in GRUB Alyssa Ross
  2022-04-20 10:12 ` [PATCH 1/2] img/live: switch to systemd-boot Alyssa Ross
  2022-04-20 10:12 ` [PATCH 2/2] img/combined: avoid chainloading in GRUB Alyssa Ross
@ 2022-04-21  9:57 ` ville.ilvonen
  2 siblings, 0 replies; 6+ messages in thread
From: ville.ilvonen @ 2022-04-21  9:57 UTC (permalink / raw)
  To: devel

Alyssa Ross wrote:
> Ville, could you give these patches a try on your P43s and see if
> "Try Spectrum" can boot now?

Yes, Lenovo P43s "Try Spectrum" boots to desktop now. Thanks.

-Ville

> Alyssa Ross (2):
>   img/live: switch to systemd-boot
>   img/combined: avoid chainloading in GRUB
> img/combined/default.nix | 10 ++++++++++
>  img/combined/grub.cfg.in |  5 +++--
>  img/live/Makefile        | 23 +++++++++++------------
>  img/live/default.nix     |  2 +-
>  img/live/etc/os-release  |  5 -----
>  5 files changed, 25 insertions(+), 20 deletions(-)
>  delete mode 100644 img/live/etc/os-release
> base-commit: 82212bb2207b9cb43f4510f373fb9ba8acfde21e


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] img/live: switch to systemd-boot
  2022-04-20 10:12 ` [PATCH 1/2] img/live: switch to systemd-boot Alyssa Ross
@ 2022-04-21 11:48   ` Alyssa Ross
  0 siblings, 0 replies; 6+ messages in thread
From: Alyssa Ross @ 2022-04-21 11:48 UTC (permalink / raw)
  To: Alyssa Ross, devel; +Cc: Ville Ilvonen, Puck Meerburg

This patch has been committed as b72a136e9ae265f61f5c6dbbd37367c8e659ae49,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=b72a136e9ae265f61f5c6dbbd37367c8e659ae49.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] img/combined: avoid chainloading in GRUB
  2022-04-20 10:12 ` [PATCH 2/2] img/combined: avoid chainloading in GRUB Alyssa Ross
@ 2022-04-21 11:48   ` Alyssa Ross
  0 siblings, 0 replies; 6+ messages in thread
From: Alyssa Ross @ 2022-04-21 11:48 UTC (permalink / raw)
  To: Alyssa Ross, devel; +Cc: Ville Ilvonen, Puck Meerburg

This patch has been committed as b1ff26eb27ea905357f8bf217d0f0cfbea33c37b,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=b1ff26eb27ea905357f8bf217d0f0cfbea33c37b.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-21 11:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 10:12 [PATCH 0/2] img/combined: avoid chainloading in GRUB Alyssa Ross
2022-04-20 10:12 ` [PATCH 1/2] img/live: switch to systemd-boot Alyssa Ross
2022-04-21 11:48   ` Alyssa Ross
2022-04-20 10:12 ` [PATCH 2/2] img/combined: avoid chainloading in GRUB Alyssa Ross
2022-04-21 11:48   ` Alyssa Ross
2022-04-21  9:57 ` [PATCH 0/2] " ville.ilvonen

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).