23 Commits

Author SHA1 Message Date
Valentin David
0267590c2a bootloader/assets/data/grub-recovery.cfg: set root when chainloading
Upstream grub does not pass to LoadImage the correct path to the
loaded binary. This results in second grub not knowing where it was
loaded from and loading the wrong grub.cfg. If we set "root", then the
path becomes correct.

Currently in mantic, the Ubuntu patch that used to be applied to 2.06
is not applied to 2.12. So we are we are back to upstream behavior.

The common use case for chainloading in EFI with grub (see
30_os-prober) always sets root. So we should do it and not get broken
again.
2023-10-11 10:16:09 +01:00
Michael Vogt
946fb0db42 Merge pull request #12285 from alfonsosanchezbeato/fix-grub-no-system
bootloader/assets: fix grub.cfg when there are no labels
2022-11-01 14:24:24 +01:00
Valentin David
2670743b56 bootloader: do not specify Core version in grub entry
Ubuntu Core 22 now shows "Run Ubuntu Core 20" as boot entry.
2022-10-24 17:15:15 +02:00
Alfonso Sánchez-Beato
d4036a5b7a bootloader/assets: fix grub.cfg when there are no labels
grub's regexp does not change the store variable if there is no match,
so checking for empty variable after the regexp call was not really
working. Instead, check for successful regexp call.
2022-10-20 16:23:56 +01:00
Michael Vogt
5595253031 bootloader/assets: add ttyS0,115200n8 to grub.cfg
This commit will help the boot speed on most PC devices and
requested by the Taipei team.

The changes to the auto-generated parts are done via:
```
$ cd boot/assets
$ go build  -o ./genasset/genasset  ./genasset/
$ ./genasset/genasset -in ./data/grub.cfg -out grub_cfg_asset.go -name grub.cfg
```
and the `Snapd-Boot-Config-Edition` for `grub.cfg` was bumped.

Note that no changes for the recovery grub configuration are done
in this commit. I'm happy to do a follwup for this.
2022-07-20 11:54:17 +02:00
Alfonso Sánchez-Beato
8cf83e1524 b/a/d/grub.cfg: remove kernel_fallback varible
Not needed anymore as we reboot instead of chainloading after a
failure.
2022-04-21 12:53:35 +02:00
Alfonso Sánchez-Beato
b7eca4e8d0 Merge branch 'master' into add-grub-fallback 2022-04-21 12:44:19 +02:00
Maciej Borzecki
c60b4d40d6 Merge remote-tracking branch 'upstream/master' into bboozzoo/factory-reset-spread-no-encrypt 2022-04-06 14:34:46 +02:00
alfonsosanchezbeato
d5b3bcc309 b/a: do not set console in kernel command line for arm64
* b/assets: use different kernel command line for arm64

Do not set console in the kernel command line for arm64. The defaults
are better than setting ttyS0 as in x86, also this is our choice in
server images. The kernel will choose the preferred console depending
on whether dtb or ACPI is available:

1. When having a device tree, it will take the content of the
   /chosen/stdout-path node [1]. This node is properly filled in most
   of the cases.

2. If using ACPI tables, it will look for the console in the ACPI SPCR
   table [2,3]. This is different to what is done in x86 [4], as in that
   case the SPCR table is used only if earlycon is set.

[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/chosen.txt
[2] https://docs.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[3] https://elixir.bootlin.com/linux/v5.17/source/arch/arm64/kernel/acpi.c#L229
[4] https://elixir.bootlin.com/linux/v5.17/source/arch/x86/kernel/acpi/boot.c#L1615

* b/assets: register different grub snippets per arch

This is needed now as the kernel command line parameters will differ
across architectures.

* b/a/grub.go: fix tests for ubuntu-18.04-32

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2022-04-05 11:27:25 +02:00
Maciej Borzecki
df919bcca2 bootloader/assets: add menu entry for factory reset mode
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-03-30 13:53:00 +02:00
Alfonso Sánchez-Beato
8650c00045 Merge branch 'master' into add-grub-fallback 2022-03-23 14:20:41 +01:00
Alfonso Sánchez-Beato
41cb1b79f7 b/assets: revert grub-recovery.cfg edition to 1 again
There is no need for the bump as no new features are added by using
gnu_arch in the grub script.
2022-02-11 15:44:19 +01:00
Alfonso Sánchez-Beato
261ac5e688 bootloader/assets: update grub.cfg edition number 2022-02-11 13:26:49 +01:00
Alfonso Sánchez-Beato
660db7bf77 bootloader: use different grub binaries in different arch
Use different grub binaries in different architectures, by checking
the grub_cfg variable in the grub recovery script. Also, increase the
config edition for grub-recovery.cfg.

Provide the different names for the assets in snapd by using constants
in files tagged for different architectures.
2022-02-11 12:31:02 +01:00
Alfonso Sánchez-Beato
e26c07a456 bootloader/assets: on failure, reboot instead of chainloading
If we chainload in the case of a failed kernel update, we will not be
able to unseal keys from the TMP, as the measurements in the PCR
registers store all the history since we booted so we will get there
unexpected values in the fail case. Instead, reboot so we clean the
PCR registers and we can start the old kernel.
2021-12-13 15:49:44 +01:00
Alfonso Sánchez-Beato
07a05f6f6b bootloader/assets: add fallback entry to grub.cfg
Add fallback entry to grub configuration, so in updates we boot the
previous kernel if the new one fails to be loaded by grub or the
systemd stub. This is needed when failures happen before exitting UEFI
boot services: otherwise we get stuck in a grub menu and a manual
reboot would be needed. The case when the kernel itself fails should
be handled by a hw watchdog.

Also, remove the test for the kernel file so the fallback mechanism
also works when the try-kernel.efi link has not been
created (previously we would get stuck in grub prompt if that
happened).
2021-11-22 17:57:14 +01:00
Maciej Borzecki
9efaa6ff96 bootloader/assets: update recovery grub to allow system labels generated by snapd
Update the recovery grub boot config to allow all system labels that are
considered valid by snapd, which are typically just numbers based on date, eg.
20210706 but follow the same rules as model names so hyphen separated
numbers/letters are allowed.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-07-07 07:01:29 +02:00
Maciej Borzecki
1d910cddd4 bootloader/assets: move command line arguments assignment
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-04-16 14:15:22 +02:00
Maciej Borzecki
7677942be4 bootloader/assets: tweak comment about what gets loaded from the bootenv
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-04-16 08:04:56 +02:00
Maciej Borzecki
d0897fb526 bootloader/assets: add support for snapd_full_cmdline_args to grub assets
Add support for snapd_full_cmdline_args variable that carries a set of command
line arguments that shall be used in place of the static and extra ones. Thus
the contents of the new variable effectively become the list of arguments that
directly follows `snapd_recovery_mode=.. snapd_recovery_system=...` in the
kernel command line passed by grub.

The boot config edition is not bumped yet, thus it will not trigger an automatic
boot config update when a new snapd gets installed.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-04-15 19:17:48 +02:00
Dimitri John Ledkov
c77ae0c563 bootloader/assets/grub: adjust fwsetup menuentry label
Make fwsetup menuentry label match upstream, classic, .iso installers.
2020-10-20 18:34:28 +01:00
Maciej Borzecki
2dee694980 Merge remote-tracking branch 'upstream/master' into bboozzoo/uc20-bootloader-command-line-glue-wip
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-07-27 10:06:51 +02:00
Maciej Borzecki
1d2ad6821c bootloader/assets/grub: generate grub assets from script files
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-07-24 13:31:50 +02:00