distro: load FDT from any partition on boot device
PATCH 1/1 distro: load FDT from any partition on boot device
In the EFI_LOADER boot path, we were only checking the FAT partition containing the EFI payload for dtb files. But this is somewhat of a fiction. In reality there will be one small (V)FAT partition containing grub (or whatever the payload may be), and a second boot partition containing kernel/initrd/fdt (typically ext4). It is this second partition where we should be looking for a FDT to load.
So instead scan all the partitions of the disk containing the EFI payload. This matches where grub looks for kernel/initrd (barring custom grub.cfg, in which case the user can use grub's 'devicetree' command to load the correct FDT).
The other option is somehow passing the ${fdtfile} to grub so that it can load the FDT based on selected kernel version location (which grub knows) and SoC/board specific ${fdtfile} (which grub does not know).
--- include/config_distro_bootcmd.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)
include/config_distro_bootcmd.h +23 -11
@@ -126,25 +126,37 @@"fi\0" \ \"load_efi_dtb=" \ -"load ${devtype} ${devnum}:${distro_bootpart} " \ -"${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \ +"load ${devtype} ${devnum}:${dtb_devp} " \ +"${fdt_addr_r} ${prefix}${efi_fdtfile} && " \ +"run boot_efi_binary\0" \ \"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \ -"scan_dev_for_efi=" \ +"scan_dev_for_dtb=" \"setenv efi_fdtfile ${fdtfile}; " \BOOTENV_EFI_SET_FDTFILE_FALLBACK \ -"for prefix in ${efi_dtb_prefixes}; do " \ -"if test -e ${devtype} " \ -"${devnum}:${distro_bootpart} " \ -"${prefix}${efi_fdtfile}; then " \ -"run load_efi_dtb; " \ -"fi;" \ -"done;" \ +"part list ${devtype} ${devnum} dtb_devplist; " \ +"env exists dtb_devplist || setenv dtb_devplist " \ +"${distro_bootpart}; " \ +"for dtb_devp in ${dtb_devplist}; do " \ +"for prefix in ${efi_dtb_prefixes}; do " \ +"if test -e ${devtype} " \ +"${devnum}:${dtb_devp} " \ +"${prefix}${efi_fdtfile};" \ +" then " \ +"echo Found DTB ${devtype} " \ +"${devnum}:${dtb_devp} " \ +"${prefix}${efi_fdtfile};" \ +"run load_efi_dtb; " \ +"fi;" \ +"done; " \ +"done; " \ +"run boot_efi_binary\0" \ +"scan_dev_for_efi=" \"if test -e ${devtype} ${devnum}:${distro_bootpart} " \"efi/boot/" BOOTEFI_NAME "; then " \"echo Found EFI removable media binary " \"efi/boot/" BOOTEFI_NAME "; " \ -"run boot_efi_binary; " \ +"run scan_dev_for_dtb; " \"echo EFI LOAD FAILED: continuing...; " \"fi; " \"setenv efi_fdtfile\0"
Signature · 1 line
2.13.5
PATCH 1/1 distro: load FDT from any partition on boot device
Quoted 38 lines · Rob Clark
In the
EFI_LOADERboot path, we were only checking the FAT partition containing the EFI payload for dtb files. But this is somewhat of a fiction. In reality there will be one small (V)FAT partition containing grub (or whatever the payload may be), and a second boot partition containingkernel/initrd/fdt(typically ext4). It is this second partition where we should be looking for a FDT to load.So instead scan all the partitions of the disk containing the EFI payload. This matches where grub looks for kernel/initrd (barring custom grub.cfg, in which case the user can use grub's 'devicetree' command to load the correct FDT).
The other option is somehow passing the ${fdtfile} to grub so that it can load the FDT based on selected kernel version location (which grub knows) and SoC/board specific ${fdtfile} (which grub does not know).
Signed-off-by Rob Clark <[email protected]>--- include/config_distro_bootcmd.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)include/config_distro_bootcmd.h +4
-3@@ -126,25 +126,37 @@"fi\0" \ \"load_efi_dtb=" \ -"load ${devtype} ${devnum}:${distro_bootpart} " \ -"${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \ +"load ${devtype} ${devnum}:${dtb_devp} " \ +"${fdt_addr_r} ${prefix}${efi_fdtfile} && " \ +"run boot_efi_binary\0" \ \"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \ -"scan_dev_for_efi=" \ +"scan_dev_for_dtb=" \
include/config_distro_bootcmd.h line 137
Quoted 10 lines
include/config_distro_bootcmd.h +1
-7"setenv efi_fdtfile ${fdtfile}; " \BOOTENV_EFI_SET_FDTFILE_FALLBACK \ -"for prefix in ${efi_dtb_prefixes}; do " \ -"if test -e ${devtype} " \ -"${devnum}:${distro_bootpart} " \ -"${prefix}${efi_fdtfile}; then " \ -"run load_efi_dtb; " \ -"fi;" \ -"done;" \ +"part list ${devtype} ${devnum} dtb_devplist; " \
part list spawns 128 error messages for me on a USB stick with an iso dd'ed onto it. I'm not sure we want to do that twice during boot.
Quoted 6 lines
include/config_distro_bootcmd.h +6
-0+"env exists dtb_devplist || setenv dtb_devplist " \ +"${distro_bootpart}; " \ +"for dtb_devp in ${dtb_devplist}; do " \ +"for prefix in ${efi_dtb_prefixes}; do " \ +"if test -e ${devtype} " \ +"${devnum}:${dtb_devp} " \
include/config_distro_bootcmd.h line 153
Quoted 10 lines
include/config_distro_bootcmd.h +10
-0+"${prefix}${efi_fdtfile};" \ +" then " \ +"echo Found DTB ${devtype} " \ +"${devnum}:${dtb_devp} " \ +"${prefix}${efi_fdtfile};" \ +"run load_efi_dtb; " \ +"fi;" \ +"done; " \ +"done; " \ +"run boot_efi_binary\0" \
This will run the EFI binary twice if we find a DT on disk. Or really nr_dtb_parts_found + 1 times :).
We also don't want to loop through 50 other partitions if the 1st one already contained a dtb. Instead the loop really should end after the first successful boot attempt on that device.
(other distro targets should still get boot attempts, you may want to exit grub from dhcp to enter grub on scsi).
Furthermore I remember that Andreas worked in that area too before, let's make sure to CC him.
Alex
PATCH 1/1 distro: load FDT from any partition on boot device
Quoted 69 lines · Alexander Graf
Quoted 66 lines · Rob Clark
In the
EFI_LOADERboot path, we were only checking the FAT partition containing the EFI payload for dtb files. But this is somewhat of a fiction. In reality there will be one small (V)FAT partition containing grub (or whatever the payload may be), and a second boot partition containingkernel/initrd/fdt(typically ext4). It is this second partition where we should be looking for a FDT to load.So instead scan all the partitions of the disk containing the EFI payload. This matches where grub looks for kernel/initrd (barring custom grub.cfg, in which case the user can use grub's 'devicetree' command to load the correct FDT).
The other option is somehow passing the ${fdtfile} to grub so that it can load the FDT based on selected kernel version location (which grub knows) and SoC/board specific ${fdtfile} (which grub does not know).
Signed-off-by Rob Clark <[email protected]>--- include/config_distro_bootcmd.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)include/config_distro_bootcmd.h +4
-5@@ -126,25 +126,37 @@"fi\0" \ \"load_efi_dtb=" \ -"load ${devtype} ${devnum}:${distro_bootpart} " \ -"${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \ +"load ${devtype} ${devnum}:${dtb_devp} " \ +"${fdt_addr_r} ${prefix}${efi_fdtfile} && " \ +"run boot_efi_binary\0" \ \"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \ -"scan_dev_for_efi=" \ +"scan_dev_for_dtb=" \"setenv efi_fdtfile ${fdtfile}; " \BOOTENV_EFI_SET_FDTFILE_FALLBACK \ -"for prefix in ${efi_dtb_prefixes}; do " \ -"if test -e ${devtype} " \
- "${devnum}:${distro_bootpart} "
\
- "${prefix}${efi_fdtfile}; then "
\
- "runload_efi_dtb; "
\
- "fi;"
\
Quoted 8 lines
Quoted 4 lines
- "done;"
\
+ "part list ${devtype} ${devnum}dtb_devplist; "
\part list spawns 128 error messages for me on a USB stick with an iso dd'ed onto it. I'm not sure we want to do that twice during boot.
I'm not sure how to avoid doing two 'part list's since one we want to find *all* the partitions, not just the -bootable ones..
I'd suggest you might be better off fixing the root problem here ;-)
Quoted 28 lines
Quoted 28 lines
+ "env exists
dtb_devplist|| setenvdtb_devplist"
\
+ "${distro_bootpart}; "
\
+ "fordtb_devpin ${dtb_devplist}; do "
\
+ "for prefix in ${efi_dtb_prefixes}; do "
\
+ "if test -e ${devtype} "
\
+ "${devnum}:${dtb_devp} "
\
+
"${prefix}${efi_fdtfile};"\
+ " then "
\
+ "echo Found DTB ${devtype} "
\
+ "${devnum}:${dtb_devp} "
\
+
"${prefix}${efi_fdtfile};"\
+ "runload_efi_dtb; "
\
+ "fi;"
\
+ "done; "
\
Quoted 8 lines
Quoted 4 lines
+ "done; "
\
+ "run boot_efi_binary\0"
\This will run the EFI binary twice if we find a DT on disk. Or really
nr_dtb_parts_found+ 1 times :).
only if the EFI binary returns, which isn't usually going to be the case for distro boot
That said, if grub scripting supported "break", this would make this much easier
Quoted 9 lines
We also don't want to loop through 50 other partitions if the 1st one already contained a dtb. Instead the loop really should end after the first successful boot attempt on that device.
(other distro targets should still get boot attempts, you may want to exit grub from dhcp to enter grub on scsi).
Furthermore I remember that Andreas worked in that area too before, let's make sure to CC him.
If someone has a better patch, then I'm fine to go with that. I just needed something to get fedora booting
BR,
-R
PATCH 1/1 distro: load FDT from any partition on boot device
Quoted 79 lines · Rob Clark
Quoted 69 lines · Alexander Graf
Quoted 66 lines · Rob Clark
In the
EFI_LOADERboot path, we were only checking the FAT partition containing the EFI payload for dtb files. But this is somewhat of a fiction. In reality there will be one small (V)FAT partition containing grub (or whatever the payload may be), and a second boot partition containingkernel/initrd/fdt(typically ext4). It is this second partition where we should be looking for a FDT to load.So instead scan all the partitions of the disk containing the EFI payload. This matches where grub looks for kernel/initrd (barring custom grub.cfg, in which case the user can use grub's 'devicetree' command to load the correct FDT).
The other option is somehow passing the ${fdtfile} to grub so that it can load the FDT based on selected kernel version location (which grub knows) and SoC/board specific ${fdtfile} (which grub does not know).
Signed-off-by Rob Clark <[email protected]>--- include/config_distro_bootcmd.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)include/config_distro_bootcmd.h +4
-5@@ -126,25 +126,37 @@"fi\0" \ \"load_efi_dtb=" \ -"load ${devtype} ${devnum}:${distro_bootpart} " \ -"${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \ +"load ${devtype} ${devnum}:${dtb_devp} " \ +"${fdt_addr_r} ${prefix}${efi_fdtfile} && " \ +"run boot_efi_binary\0" \ \"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \ -"scan_dev_for_efi=" \ +"scan_dev_for_dtb=" \"setenv efi_fdtfile ${fdtfile}; " \BOOTENV_EFI_SET_FDTFILE_FALLBACK \ -"for prefix in ${efi_dtb_prefixes}; do " \ -"if test -e ${devtype} " \
- "${devnum}:${distro_bootpart} "
\
- "${prefix}${efi_fdtfile}; then "
\
- "runload_efi_dtb; "
\
- "fi;"
\Quoted 8 lines
Quoted 4 lines
- "done;"
\
+ "part list ${devtype} ${devnum}dtb_devplist; "
\part list spawns 128 error messages for me on a USB stick with an iso dd'ed onto it. I'm not sure we want to do that twice during boot.
Quoted 4 lines
I'm not sure how to avoid doing two 'part list's since one we want to find *all* the partitions, not just the -bootable ones..
I'd suggest you might be better off fixing the root problem here ;-)
Most probably, yes.
Quoted 38 lines
Quoted 29 lines
Quoted 29 lines
+ "env exists
dtb_devplist|| setenvdtb_devplist"
\
+ "${distro_bootpart}; "
\
+ "fordtb_devpin ${dtb_devplist}; do "
\
+ "for prefix in ${efi_dtb_prefixes}; do "
\
+ "if test -e ${devtype} "
\
+ "${devnum}:${dtb_devp} "
\
+
"${prefix}${efi_fdtfile};"\
+ " then "
\
+ "echo Found DTB ${devtype} "
\
+ "${devnum}:${dtb_devp} "
\
+
"${prefix}${efi_fdtfile};"\
+ "runload_efi_dtb; "
\
+ "fi;"
\
+ "done; "
\Quoted 8 lines
Quoted 4 lines
+ "done; "
\
+ "run boot_efi_binary\0"
\This will run the EFI binary twice if we find a DT on disk. Or really
nr_dtb_parts_found+ 1 times :).
Quoted 2 lines
only if the EFI binary returns, which isn't usually going to be the case for distro boot
In a naive view, yes :). All our grub configs on iso have a "Boot local disk" entry which is simply "exit" in UEFI. For those it definitely can occur. And I make quite heavy use of it too ;).
Quoted 1 line
That said, if grub scripting supported "break", this would make this much easier
Or alternatively set a variable that skips efi execution after you executed once. Then reset the variable at the end of the loop.
Quoted 5 lines
Quoted 5 lines
We also don't want to loop through 50 other partitions if the 1st one already contained a dtb. Instead the loop really should end after the first successful boot attempt on that device.
Quoted 8 lines
Quoted 5 lines
(other distro targets should still get boot attempts, you may want to exit grub from dhcp to enter grub on scsi).
Furthermore I remember that Andreas worked in that area too before, let's make sure to CC him.
If someone has a better patch, then I'm fine to go with that. I just needed something to get fedora booting
I'm not saying better patch, I want to get his input because he worked on the same thing before, so he cares and knows which makes him an ideal reviewer :).
Alex