diff --git a/include/configs/apple.h b/include/configs/apple.h index b06660add4..8d39e7d076 100644 --- a/include/configs/apple.h +++ b/include/configs/apple.h @@ -27,8 +27,51 @@ #include +#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