[U-Boot] [PATCH v3] ARM64: zynqmp: Add support for standard distro boot commands

Alexander Graf agraf at suse.de
Thu Jun 2 11:44:31 CEST 2016



On 02.06.16 11:29, Michal Simek wrote:
> Nand and QSPI are not defined now but this will be extended.
> Based on selected bootmode boot_targets are rewritten.
> Patch also contains detection if variables are saved. If yes don't
> rewrite boot_targets variable.
> 
> Also move variable setup to the end of file because SCSI needs to be
> defined before others macros are using it.
> 
> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
> ---
> 
> Changes in v3:
> - Fix buffer overflow reported by Alexander
> - Remove also unused variables from board files
> 
> Changes in v2:
> - Append default boot_targets to the list
> 
> Patch depends on
> "env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used"
> 
> ---
>  board/xilinx/zynqmp/zynqmp.c                     | 31 ++++++++++---
>  include/configs/xilinx_zynqmp.h                  | 59 ++++++++++++++++++------
>  include/configs/xilinx_zynqmp_ep.h               |  7 ---
>  include/configs/xilinx_zynqmp_zc1751_xm015_dc1.h |  7 ---
>  include/configs/xilinx_zynqmp_zc1751_xm016_dc2.h |  7 ---
>  include/configs/xilinx_zynqmp_zc1751_xm018_dc4.h |  7 ---
>  include/configs/xilinx_zynqmp_zc1751_xm019_dc5.h |  7 ---
>  include/configs/xilinx_zynqmp_zcu102.h           |  7 ---
>  8 files changed, 68 insertions(+), 64 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 4623cd49e9c7..db240d92f17c 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -9,6 +9,7 @@
>  #include <sata.h>
>  #include <ahci.h>
>  #include <scsi.h>
> +#include <malloc.h>
>  #include <asm/arch/clk.h>
>  #include <asm/arch/hardware.h>
>  #include <asm/arch/sys_proto.h>
> @@ -214,6 +215,13 @@ int board_late_init(void)
>  {
>  	u32 reg = 0;
>  	u8 bootmode;
> +	const char *mode;
> +	char *new_targets;
> +
> +	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> +		debug("Saved variables - Skipping\n");
> +		return 0;
> +	}
>  
>  	reg = readl(&crlapb_base->boot_mode);
>  	bootmode = reg & BOOT_MODES_MASK;
> @@ -222,37 +230,46 @@ int board_late_init(void)
>  	switch (bootmode) {
>  	case JTAG_MODE:
>  		puts("JTAG_MODE\n");
> -		setenv("modeboot", "jtagboot");
> +		mode = "pxe dhcp";
>  		break;
>  	case QSPI_MODE_24BIT:
>  	case QSPI_MODE_32BIT:
> -		setenv("modeboot", "qspiboot");
> +		mode = "qspi0";
>  		puts("QSPI_MODE\n");
>  		break;
>  	case EMMC_MODE:
>  		puts("EMMC_MODE\n");
> -		setenv("modeboot", "sdboot");
> +		mode = "mmc0";
>  		break;
>  	case SD_MODE:
>  		puts("SD_MODE\n");
> -		setenv("modeboot", "sdboot");
> +		mode = "mmc0";
>  		break;
>  	case SD_MODE1:
>  		puts("SD_MODE1\n");
>  #if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1)
> -		setenv("sdbootdev", "1");
> +		mode = "mmc1";
> +#else
> +		mode = "mmc0";
>  #endif
> -		setenv("modeboot", "sdboot");
>  		break;
>  	case NAND_MODE:
>  		puts("NAND_MODE\n");
> -		setenv("modeboot", "nandboot");
> +		mode = "nand0";
>  		break;
>  	default:
> +		mode = "";
>  		printf("Invalid Boot Mode:0x%x\n", bootmode);
>  		break;
>  	}
>  
> +	/* One terminating char */
> +	new_targets = calloc(1, strlen(mode) +
> +				strlen(getenv("boot_targets")) + 1);

This is still missing the space in the reservation :).


Alex


More information about the U-Boot mailing list