mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-13 00:17:23 +00:00
configs: apple: Add custom bootcmd to boot from preferred ESP
AsahiLinux uses a distinct EFI system partition per OS installation 1). To boot the intended system u-boot has to prefer the intended partition for booting. The previous stage bootloader specifies in UUID of the partition in the device tree as "/chosen/asahi,efi-system-partition". 'apple_bootcmd' reads the UUID from the device tree and uses modified distro boot scripts to only boot from a partition with a matching UUID. If it fails it tries to boot from the first USB device. 1: https://github.com/AsahiLinux/docs/wiki/Open-OS-Ecosystem-on-Apple-Silicon-Macs Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
parent
32505f74cd
commit
300817d324
1 changed files with 44 additions and 1 deletions
|
@ -27,8 +27,51 @@
|
|||
|
||||
#include <config_distro_bootcmd.h>
|
||||
|
||||
#if CONFIG_IS_ENABLED(CMD_NVME) && CONFIG_IS_ENABLED(CMD_USB)
|
||||
#define BOOTENV_APPLE \
|
||||
"scan_dev_for_boot_partuuid=" \
|
||||
"part list ${devtype} ${devnum} -bootable devplist; " \
|
||||
"env exists devplist || setenv devplist 1; " \
|
||||
"for distro_bootpart in ${devplist}; do " \
|
||||
"part uuid ${devtype} ${devnum}:${distro_bootpart} " \
|
||||
"partuuid; " \
|
||||
"if test U${partuuid} = U${esp_partuuid} ; then " \
|
||||
"if fstype ${devtype} " \
|
||||
"${devnum}:${distro_bootpart} "\
|
||||
"bootfstype; then " \
|
||||
"run scan_dev_for_boot; " \
|
||||
"fi; " \
|
||||
"fi; " \
|
||||
"done; " \
|
||||
"setenv partuuid; " \
|
||||
"setenv devplist\0" \
|
||||
"nvme_boot_partuuid=" \
|
||||
"run nvme_init; " \
|
||||
"if nvme dev ${devnum}; then " \
|
||||
"devtype=nvme; run scan_dev_for_boot_partuuid;" \
|
||||
" fi\0" \
|
||||
"bootcmd_apple_nvme0=devnum=0; run nvme_boot_partuuid\0" \
|
||||
"apple_bootcfg=" \
|
||||
"if fdt addr ${fdtcontroladdr}; then " \
|
||||
"fdt get value esp_partuuid /chosen asahi,efi-system-partition; "\
|
||||
"fi\0" \
|
||||
"apple_bootcmd=" \
|
||||
"setenv nvme_need_init; run apple_bootcfg; " \
|
||||
"if test -n ${esp_partuuid}; then " \
|
||||
"run bootcmd_apple_nvme0; " \
|
||||
"echo Failed to boot from ESP with UUID ${esp_partuuid}; " \
|
||||
"echo Trying to boot from USB ...; " \
|
||||
"fi; " \
|
||||
"run bootcmd_usb0; " \
|
||||
"echo Failed to find boot partition `run distro_bootcmd` to boot from any partition\0" \
|
||||
"bootcmd=run apple_bootcmd\0"
|
||||
#else
|
||||
#define BOOTENV_APPLE
|
||||
#endif
|
||||
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
ENV_DEVICE_SETTINGS \
|
||||
BOOTENV
|
||||
BOOTENV \
|
||||
BOOTENV_APPLE
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue