[U-Boot] [PATCH RFC 1/4] config: remove distro_default from common.h

From: Stephen Warren swarren@nvidia.com
Including it from here doesn't ensure that the config options show up in all the right places. Instead, each per-board header file (or a file that boards include) should include it themselves directly.
Signed-off-by: Stephen Warren swarren@nvidia.com --- This series is based on: a) Dennis Gilmore's series to add config_distro_default.h. Since that series is RFC, so is this. b) My recent series to implement the "exists" shell command. --- include/common.h | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/include/common.h b/include/common.h index 00969a51240d..d49c51464dad 100644 --- a/include/common.h +++ b/include/common.h @@ -99,11 +99,6 @@ typedef volatile unsigned char vu_char; #include <flash.h> #include <image.h>
-/* use generic distro config */ -#ifdef DISTRO_DEFAULTS -#include <config_distro_default.h> -#endif - #ifdef DEBUG #define _DEBUG 1 #else

From: Stephen Warren swarren@nvidia.com
Modify all Tegra boards to include the "distro defaults" header, so that all the config options distros expect are enabled. Remove any #defines that enable the same options from the Tegra files.
Signed-off-by: Stephen Warren swarren@nvidia.com --- include/configs/tegra-common.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h index 522cd4133d77..406a0c0fd2fa 100644 --- a/include/configs/tegra-common.h +++ b/include/configs/tegra-common.h @@ -29,7 +29,6 @@ #define CONFIG_DISPLAY_BOARDINFO
#define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */ -#define CONFIG_OF_LIBFDT /* enable passing of devicetree */
/* Environment */ #define CONFIG_ENV_VARS_UBOOT_CONFIG @@ -69,33 +68,20 @@ #undef CONFIG_CMD_NET /* network support */
/* turn on command-line edit/hist/auto */ -#define CONFIG_CMDLINE_EDITING #define CONFIG_COMMAND_HISTORY -#define CONFIG_AUTO_COMPLETE
/* turn on commonly used storage-related commands */ - -#define CONFIG_DOS_PARTITION -#define CONFIG_EFI_PARTITION #define CONFIG_PARTITION_UUIDS -#define CONFIG_FS_EXT4 -#define CONFIG_FS_FAT -#define CONFIG_CMD_EXT2 -#define CONFIG_CMD_FAT -#define CONFIG_CMD_FS_GENERIC #define CONFIG_CMD_PART
#define CONFIG_SYS_NO_FLASH
#define CONFIG_CONSOLE_MUX #define CONFIG_SYS_CONSOLE_IS_IN_ENV -#define CONFIG_BOOTDELAY 2 /* -1 to disable auto boot */
/* * Miscellaneous configurable options */ -#define CONFIG_SYS_LONGHELP /* undef to save memory */ -#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */ #define CONFIG_SYS_PROMPT V_PROMPT /* * Increasing the size of the IO buffer as default nfsargs size is more @@ -133,8 +119,6 @@ #define CONFIG_TEGRA_GPIO #define CONFIG_CMD_GPIO #define CONFIG_CMD_ENTERRCM -#define CONFIG_CMD_BOOTZ -#define CONFIG_SUPPORT_RAW_INITRD
/* Defines for SPL */ #define CONFIG_SPL @@ -157,4 +141,8 @@ #define CONFIG_BOUNCE_BUFFER #define CONFIG_CRC32_VERIFY
+#ifndef CONFIG_SPL_BUILD +#include <config_distro_default.h> +#endif + #endif /* _TEGRA_COMMON_H_ */

From: Stephen Warren swarren@nvidia.com
Update the common Tegra boot scripts in the default environment to
a) Make use of the new "exists" shell command to avoid some error messges.
b) Allow booting using the sysboot command and extlinux.conf. This allows easy creation of boot menus, and provides a simple interface for distros to parameterize/configure the boot process.
Signed-off-by: Stephen Warren swarren@nvidia.com --- include/configs/tegra-common-post.h | 39 ++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/include/configs/tegra-common-post.h b/include/configs/tegra-common-post.h index a3242fe61299..493f6dfe4a19 100644 --- a/include/configs/tegra-common-post.h +++ b/include/configs/tegra-common-post.h @@ -69,20 +69,41 @@ #define BOOTCMDS_COMMON \ "rootpart=1\0" \ \ + "do_script_boot=" \ + "load ${devtype} ${devnum}:${rootpart} " \ + "${scriptaddr} ${prefix}${script}; " \ + "source ${scriptaddr}\0" \ + \ "script_boot=" \ - "if load ${devtype} ${devnum}:${rootpart} " \ - "${scriptaddr} ${prefix}${script}; then " \ - "echo ${script} found! Executing ...;" \ - "source ${scriptaddr};" \ - "fi;\0" \ + "for script in ${boot_scripts}; do " \ + "if exists ${devtype} ${devnum}:${rootpart} " \ + "${prefix}${script}; then " \ + "echo Found U-Boot script " \ + "${prefix}${script}; " \ + "run do_script_boot;" \ + "echo SCRIPT FAILED; continuing...; " \ + "fi; " \ + "done\0" \ + \ + "do_sysboot_boot=" \ + "sysboot ${devtype} ${devnum}:${rootpart} any " \ + "${scriptaddr} ${prefix}extlinux.conf\0" \ + \ + "sysboot_boot=" \ + "if exists ${devtype} ${devnum}:${rootpart} " \ + "${prefix}extlinux.conf; then " \ + "echo Found extlinux config " \ + "${prefix}extlinux.conf; " \ + "run do_sysboot_boot;" \ + "echo SCRIPT FAILED; continuing...; " \ + "fi\0" \ \ "scan_boot=" \ "echo Scanning ${devtype} ${devnum}...; " \ "for prefix in ${boot_prefixes}; do " \ - "for script in ${boot_scripts}; do " \ - "run script_boot; " \ - "done; " \ - "done;\0" \ + "run script_boot; " \ + "run sysboot_boot; " \ + "done\0" \ \ "boot_targets=" \ BOOT_TARGETS_MMC " " \

From: Stephen Warren swarren@nvidia.com
People who write (or scripts that auto-generate) extlinux.conf don't want to know about HW-specific information such as FDT filenames. Create a new extlinux.conf tag "fdtdir" that specifies only the directory where FDT files are located, and defer all knowledge of the filename to U-Boot. The algorithm implemented is:
========== if $fdt_addr_r is set: if "fdt" tag was specified in extlinux.conf: load the FDT from the filename in the tag else if "fdtdir" tag was specified in extlinux.conf: if "fdtfile" is set in the environment: load the FDT from filename in "$fdtfile" else: load the FDT from some automatically generated filename
if no FDT file was loaded, and $fdtaddr is set: # This indicates an FDT packaged with firmware use the FDT at $fdtaddr ==========
A small part of an example /boot/extlinux.conf might be:
========== LABEL primary LINUX zImage FDTDIR ./
LABEL failsafe LINUX bkp/zImage FDTDIR bkp/ ==========
... with /boot/tegra20-seaboard.dtb or /boot/bkp/tegra20-seaboard.dtb being loaded by the sysboot/pxe code.
Signed-off-by: Stephen Warren swarren@nvidia.com --- common/cmd_pxe.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 6 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 20569bb04201..5d356295e48e 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -459,6 +459,7 @@ struct pxe_label { char *append; char *initrd; char *fdt; + char *fdtdir; int ipappend; int attempted; int localboot; @@ -531,6 +532,9 @@ static void label_destroy(struct pxe_label *label) if (label->fdt) free(label->fdt);
+ if (label->fdtdir) + free(label->fdtdir); + free(label); }
@@ -689,13 +693,67 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) bootm_argv[3] = getenv("fdt_addr_r");
/* if fdt label is defined then get fdt from server */ - if (bootm_argv[3] && label->fdt) { - if (get_relfile_envaddr(cmdtp, label->fdt, "fdt_addr_r") < 0) { - printf("Skipping %s for failure retrieving fdt\n", - label->name); - return 1; + if (bootm_argv[3]) { + char *fdtfile = NULL; + char *fdtfilefree = NULL; + + if (label->fdt) { + fdtfile = label->fdt; + } else if (label->fdtdir) { + fdtfile = getenv("fdtfile"); + /* + * For complex cases, it might be worth calling a + * board- or SoC-provided function here to provide a + * better default: + * + * if (!fdtfile) + * fdtfile = gen_fdtfile(); + * + * If this is added, be sure to keep the default below, + * or move it to the default weak implementation of + * gen_fdtfile(). + */ + if (!fdtfile) { + char *soc = getenv("soc"); + char *board = getenv("board"); + char *slash; + + len = strlen(label->fdtdir); + if (!len) + slash = "./"; + else if (label->fdtdir[len - 1] != '/') + slash = "/"; + else + slash = ""; + + len = strlen(label->fdtdir) + strlen(slash) + + strlen(soc) + 1 + strlen(board) + 5; + fdtfilefree = malloc(len); + if (!fdtfilefree) { + printf("malloc fail (FDT filename)\n"); + return 1; + } + + snprintf(fdtfilefree, len, "%s%s%s-%s.dtb", + label->fdtdir, slash, soc, board); + fdtfile = fdtfilefree; + } } - } else + + if (fdtfile) { + int err = get_relfile_envaddr(cmdtp, fdtfile, "fdt_addr_r"); + free(fdtfilefree); + if (err < 0) { + printf("Skipping %s for failure retrieving fdt\n", + label->name); + return 1; + } + } else { + bootm_argv[3] = NULL; + } + } + + if (!bootm_argv[3]) bootm_argv[3] = getenv("fdt_addr");
if (bootm_argv[3]) @@ -730,6 +788,7 @@ enum token_type { T_PROMPT, T_INCLUDE, T_FDT, + T_FDTDIR, T_ONTIMEOUT, T_IPAPPEND, T_INVALID @@ -760,6 +819,7 @@ static const struct token keywords[] = { {"initrd", T_INITRD}, {"include", T_INCLUDE}, {"fdt", T_FDT}, + {"fdtdir", T_FDTDIR}, {"ontimeout", T_ONTIMEOUT,}, {"ipappend", T_IPAPPEND,}, {NULL, T_INVALID} @@ -1148,6 +1208,11 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_sliteral(c, &label->fdt); break;
+ case T_FDTDIR: + if (!label->fdtdir) + err = parse_sliteral(c, &label->fdtdir); + break; + case T_LOCALBOOT: label->localboot = 1; err = parse_integer(c, &label->localboot_val);
participants (1)
-
Stephen Warren