Skip to contentSkip to conversation

ARM64: zynqmp: Add support for standard distro boot commands

PATCH New Michal Simek 2 participants 2 messages Jun 2, 2016 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ARM64: zynqmp: Add support for standard distro boot commands

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.

---

Changes in v4:
- Give one more byte for space in malloc buffer

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                     | 34 +++++++++++---
 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, 71 insertions(+), 64 deletions(-)
board/xilinx/zynqmp/zynqmp.c +27 -7
index 4623cd49e9c7..f15dc5d71522 100644
@@ -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,49 @@ 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 + one byte for space between mode
+	 * and default boot_targets
+	 */
+	new_targets = calloc(1, strlen(mode) +
+				strlen(getenv("boot_targets")) + 2);
+
+	sprintf(new_targets, "%s %s", mode, getenv("boot_targets"));
+	setenv("boot_targets", new_targets);
+
 	return 0;
 }
 
include/configs/xilinx_zynqmp.h +44 -15

71 lines not on this page · raw message

include/configs/xilinx_zynqmp_ep.h +0 -7
index 95063557137b..c5bd5da43c5e 100644
@@ -22,13 +22,6 @@
 
 #define COUNTER_FREQUENCY	4000000
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x400000\0" \
-	"fdt_offset=0x2400000\0" \
-	"kernel_size=0x2000000\0" \
-	"fdt_size=0x80000\0" \
-	"board=ep108\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_EP_H */
include/configs/xilinx_zynqmp_zc1751_xm015_dc1.h +0 -7
index 3c0ba883dbba..c9f443207d90 100644
@@ -17,13 +17,6 @@
 
 #define CONFIG_IDENT_STRING	" Xilinx ZynqMP ZC1751 xm015 dc1"
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x400000\0" \
-	"fdt_offset=0x2400000\0" \
-	"kernel_size=0x2000000\0" \
-	"fdt_size=0x80000\0" \
-	"board=zc1751-dc1\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_ZC1751_XM015_DC1_H */
include/configs/xilinx_zynqmp_zc1751_xm016_dc2.h +0 -7
index 83ea624c51c4..526d0bbe5852 100644
@@ -14,13 +14,6 @@
 
 #define CONFIG_IDENT_STRING	" Xilinx ZynqMP ZC1751 xm016 dc2"
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x400000\0" \
-	"fdt_offset=0x2400000\0" \
-	"kernel_size=0x2000000\0" \
-	"fdt_size=0x80000\0" \
-	"board=zc1751-dc2\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_ZC1751_XM016_DC2_H */
include/configs/xilinx_zynqmp_zc1751_xm018_dc4.h +0 -7
index fd2ec6a77516..65277a64c3c4 100644
@@ -12,13 +12,6 @@
 
 #define CONFIG_IDENT_STRING	" Xilinx ZynqMP ZC1751 xm018 dc4"
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x400000\0" \
-	"fdt_offset=0x2400000\0" \
-	"kernel_size=0x2000000\0" \
-	"fdt_size=0x80000\0" \
-	"board=zc1751-dc4\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_ZC1751_XM018_DC4_H */
include/configs/xilinx_zynqmp_zc1751_xm019_dc5.h +0 -7
index 4f8f5c10536d..76350d957950 100644
@@ -15,13 +15,6 @@
 
 #define CONFIG_IDENT_STRING	" Xilinx ZynqMP ZC1751 xm019 dc5"
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x400000\0" \
-	"fdt_offset=0x2400000\0" \
-	"kernel_size=0x2000000\0" \
-	"fdt_size=0x80000\0" \
-	"board=zc1751-dc5\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_ZC1751_XM019_DC5_H */
include/configs/xilinx_zynqmp_zcu102.h +0 -7
index 09c4a51a2ec0..7ceab3230b88 100644
@@ -53,13 +53,6 @@
 #define CONFIG_ZYNQ_GEM_EEPROM_ADDR	0x54
 #define CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET	0x20
 
-#define CONFIG_KERNEL_FDT_OFST_SIZE \
-	"kernel_offset=0x180000\0" \
-	"fdt_offset=0x100000\0" \
-	"kernel_size=0x1e00000\0" \
-	"fdt_size=0x80000\0" \
-	"board=zcu102\0"
-
 #include <configs/xilinx_zynqmp.h>
 
 #endif /* __CONFIG_ZYNQMP_ZCU102_H */
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/1 ARM64: zynqmp: Add support for standard distro boot commands

Quoted 9 lines · Michal Simek

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.

Alex