[U-Boot] [PATCH 2/2] efi_loader: Fall back to fdtfile naming convention

Andreas Färber afaerber at suse.de
Thu Apr 14 15:43:32 CEST 2016


Am 13.04.2016 um 23:22 schrieb Alexander Graf:
> When there is no $fdtfile variable set, we still have a good chance
> that on 32bit arm the fdtfile really is just called $soc-$board.dtb.
> 
> Enable the exports for $soc and $board in our distr defaults and make
> use of them in the efi boot script.
> 
> Reported-by: Andreas Faerber <afaerber at suse.de>
> Reported-by: Stephen Warren <swarren at wwwdotorg.org>
> Signed-off-by: Alexander Graf <agraf at suse.de>
> ---
>  include/config_distro_bootcmd.h  | 24 +++++++++++++++++++++---
>  include/config_distro_defaults.h |  1 +
>  2 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index 67eb8f2..eaaf2cc 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -99,6 +99,21 @@
>  #endif
>  
>  #ifdef BOOTEFI_NAME
> +#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
> +/*
> + * On 32bit ARM systems there is a reasonable number of systems that follow
> + * the $soc-$board$boardver.dtb name scheme for their device trees. Use that
> + * scheme if we don't have an explicit fdtfile variable.
> + */

Why limit this to 32-bit? If fdtfile is not set and we drop the
limitation above, then for CONFIG_ARM64 (and theoretically MIPS) we
could add the vendor subdir to our prefixes. Even without the latter it
does no harm, your config_distro_defaults.h change below does not seem
to be limited to ARM anyway.

> +#define BOOTENV_EFI_SET_FDTFILE_FALLBACK                                  \
> +	"if test -z \"${fdtfile}\" -a -n \"${soc}\"; then "               \
> +	  "setenv efifdtfile ${soc}-${board}${boardver}.dtb; "            \

Please consistently use efi_ for readability.

The logic looks slightly weird on first sight, being separated from the
below context. Can't we just set fdtfile here if unset and drop the four
extra lines below? Once boot has executed, there may be leftover
variables such as filesize anyway.

Regards,
Andreas

> +	"fi; "
> +#else
> +#define BOOTENV_EFI_SET_FDTFILE_FALLBACK
> +#endif
> +
> +
>  #define BOOTENV_SHARED_EFI                                                \
>  	"boot_efi_binary="                                                \
>  		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> @@ -111,14 +126,16 @@
>  	\
>  	"load_efi_dtb="                                                   \
>  		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> -			"${fdt_addr_r} ${prefix}${fdtfile}\0"             \
> +			"${fdt_addr_r} ${prefix}${efifdtfile}\0"          \
>  	\
>  	"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0"                        \
>  	"scan_dev_for_efi="                                               \
> +	        "setenv efifdtfile ${fdtfile}; "                          \
> +	        BOOTENV_EFI_SET_FDTFILE_FALLBACK                          \
>  		"for prefix in ${efi_dtb_prefixes}; do "                  \
>  			"if test -e ${devtype} "                          \
>  					"${devnum}:${distro_bootpart} "   \
> -					"${prefix}${fdtfile}; then "      \
> +					"${prefix}${efifdtfile}; then "   \
>  				"run load_efi_dtb; "                      \
>  			"fi;"                                             \
>  		"done;"                                                   \
> @@ -128,7 +145,8 @@
>  					"efi/boot/"BOOTEFI_NAME"; "       \
>  				"run boot_efi_binary; "                   \
>  				"echo EFI LOAD FAILED: continuing...; "   \
> -		"fi; \0"
> +		"fi; "                                                    \
> +		"setenv efifdtfile\0"
>  #define SCAN_DEV_FOR_EFI "run scan_dev_for_efi;"
>  #else
>  #define BOOTENV_SHARED_EFI
> diff --git a/include/config_distro_defaults.h b/include/config_distro_defaults.h
> index 076be4d..ae68e3a 100644
> --- a/include/config_distro_defaults.h
> +++ b/include/config_distro_defaults.h
> @@ -65,5 +65,6 @@
>  #define CONFIG_ISO_PARTITION
>  #define CONFIG_SUPPORT_RAW_INITRD
>  #define CONFIG_SYS_HUSH_PARSER
> +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
>  
>  #endif	/* _CONFIG_CMD_DISTRO_DEFAULTS_H */
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


More information about the U-Boot mailing list