[U-Boot] [uBoot] TI: configs: Commonize the boot of different devices

Dan Murphy dmurphy at ti.com
Wed Nov 20 20:40:18 CET 2013


Commonize in the ti_armv7_common.h the boot scripts for
USB, MMC and NAND.

Each board file can then select which BOOT_TARGETS are applicable
for the target board.
And any parameters based on that.

Finally removed the findfdt from the common file and made this more board
specific as omap4_common should not reference panda.

This implemenation was adopted from the tegra-common-post.h file.

Signed-off-by: Dan Murphy <dmurphy at ti.com>
---
 include/configs/am335x_evm.h      |   77 ++++++++++++++++++++++---------------
 include/configs/dra7xx_evm.h      |   25 ++++++++++++
 include/configs/omap4_common.h    |   36 ++---------------
 include/configs/omap4_panda.h     |   29 ++++++++++++++
 include/configs/omap4_sdp4430.h   |   26 +++++++++++++
 include/configs/omap5_common.h    |   22 +++--------
 include/configs/omap5_uevm.h      |   25 ++++++++++++
 include/configs/ti_armv7_common.h |   72 ++++++++++++++++++++++++++++++++++
 8 files changed, 233 insertions(+), 79 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index c2ba7e3..40ecb66 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -31,27 +31,6 @@
 /* Always 128 KiB env size */
 #define CONFIG_ENV_SIZE			(128 << 10)
 
-#ifdef CONFIG_NAND
-#define NANDARGS \
-	"mtdids=" MTDIDS_DEFAULT "\0" \
-	"mtdparts=" MTDPARTS_DEFAULT "\0" \
-	"nandargs=setenv bootargs console=${console} " \
-		"${optargs} " \
-		"root=${nandroot} " \
-		"rootfstype=${nandrootfstype}\0" \
-	"dfu_alt_info_nand=" DFU_ALT_INFO_NAND "\0" \
-	"nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0" \
-	"nandrootfstype=ubifs rootwait=1\0" \
-	"nandsrcaddr=0x280000\0" \
-		"nandboot=echo Booting from nand ...; " \
-		"run nandargs; " \
-		"nand read ${loadaddr} ${nandsrcaddr} ${nandimgsize}; " \
-		"bootz ${loadaddr}\0" \
-	"nandimgsize=0x500000\0"
-#else
-#define NANDARGS ""
-#endif
-
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 
 #ifndef CONFIG_SPL_BUILD
@@ -163,17 +142,11 @@
 			"setenv fdtfile am335x-evmsk.dtb; fi; " \
 		"if test $fdtfile = undefined; then " \
 			"echo WARNING: Could not determine device tree to use; fi; \0" \
-	NANDARGS
+	BOOTCMD_COMMON \
+	BOOTCMD_MMC \
+	BOOTCMD_NAND
 #endif
 
-#define CONFIG_BOOTCOMMAND \
-	"run findfdt; " \
-	"run mmcboot;" \
-	"setenv mmcdev 1; " \
-	"setenv bootpart 1:2; " \
-	"run mmcboot;" \
-	"run nandboot;"
-
 /* NS16550 Configuration */
 #define CONFIG_SYS_NS16550_COM1		0x44e09000	/* Base EVM has UART0 */
 #define CONFIG_SYS_NS16550_COM2		0x48022000	/* UART1 */
@@ -317,6 +290,10 @@
 	"uEnv.txt fat 0 1"
 #ifdef CONFIG_NAND
 #define CONFIG_DFU_NAND
+
+#ifdef DFU_ALT_INFO_NAND
+#undef DFU_ALT_INFO_NAND
+#endif
 #define DFU_ALT_INFO_NAND \
 	"SPL part 0 1;" \
 	"SPL.backup1 part 0 2;" \
@@ -349,7 +326,15 @@
 #define CONFIG_ENV_SECT_SIZE		(4 << 10) /* 4 KB sectors */
 #define CONFIG_ENV_OFFSET		(768 << 10) /* 768 KiB in */
 #define CONFIG_ENV_OFFSET_REDUND	(896 << 10) /* 896 KiB in */
+
+#ifdef MTDIDS_DEFAULT
+#undef MTDIDS_DEFAULT
+#endif
 #define MTDIDS_DEFAULT			"nor0=m25p80-flash.0"
+
+#ifdef MTDPARTS_DEFAULT
+#undef MTDPARTS_DEFAULT
+#endif
 #define MTDPARTS_DEFAULT		"mtdparts=m25p80-flash.0:128k(SPL)," \
 					"512k(u-boot),128k(u-boot-env1)," \
 					"128k(u-boot-env2),3464k(kernel)," \
@@ -381,7 +366,14 @@
 #define CONFIG_CMD_NAND
 #define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #if !defined(CONFIG_SPI_BOOT) && !defined(CONFIG_NOR_BOOT)
+#ifdef MTDIDS_DEFAULT
+#undef MTDIDS_DEFAULT
+#endif
 #define MTDIDS_DEFAULT			"nand0=omap2-nand.0"
+
+#ifdef MTDPARTS_DEFAULT
+#undef MTDPARTS_DEFAULT
+#endif
 #define MTDPARTS_DEFAULT		"mtdparts=omap2-nand.0:128k(SPL)," \
 					"128k(SPL.backup1)," \
 					"128k(SPL.backup2)," \
@@ -424,7 +416,14 @@
 #define CONFIG_ENV_SECT_SIZE		(128 << 10)	/* 128 KiB */
 #define CONFIG_ENV_OFFSET		(512 << 10)	/* 512 KiB */
 #define CONFIG_ENV_OFFSET_REDUND	(768 << 10)	/* 768 KiB */
+#ifdef MTDIDS_DEFAULT
+#undef MTDIDS_DEFAULT
+#endif
 #define MTDIDS_DEFAULT			"nor0=physmap-flash.0"
+
+#ifdef MTDPARTS_DEFAULT
+#undef MTDPARTS_DEFAULT
+#endif
 #define MTDPARTS_DEFAULT		"mtdparts=physmap-flash.0:" \
 					"512k(u-boot)," \
 					"128k(u-boot-env1)," \
@@ -433,4 +432,22 @@
 #endif
 #endif  /* NOR support */
 
+#ifdef CONFIG_MMC
+#define BOOT_TARGETS_MMC "mmc0"
+#else
+#define BOOT_TARGETS_MMC ""
+#endif
+
+#ifdef CONFIG_USB_HOST
+#define BOOT_TARGETS_USB "usb"
+#else
+#define BOOT_TARGETS_USB ""
+#endif
+
+#ifdef CONFIG_NAND
+#define BOOT_TARGETS_NAND "nand"
+#else
+#define BOOT_TARGETS_NAND ""
+#endif
+
 #endif	/* ! __CONFIG_AM335X_EVM_H */
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 8a69c7d..31cf7b6 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -83,4 +83,29 @@
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_OMAP_USB2PHY2_HOST
 
+#define FIND_FDT_FILE \
+	"findfdt="\
+		"if test $board_name = dra7xx; then " \
+			"setenv fdtfile dra7-evm.dtb; fi;" \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree to use; fi; \0" \
+
+#ifdef CONFIG_MMC
+#define BOOT_TARGETS_MMC "mmc0"
+#else
+#define BOOT_TARGETS_MMC ""
+#endif
+
+#ifdef CONFIG_USB_HOST
+#define BOOT_TARGETS_USB "usb"
+#else
+#define BOOT_TARGETS_USB ""
+#endif
+
+#ifdef CONFIG_NAND
+#define BOOT_TARGETS_NAND "nand"
+#else
+#define BOOT_TARGETS_NAND ""
+#endif
+
 #endif /* __CONFIG_DRA7XX_EVM_H */
diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h
index ea56eeb..e0524a3 100644
--- a/include/configs/omap4_common.h
+++ b/include/configs/omap4_common.h
@@ -114,39 +114,11 @@
 	"mmcboot=echo Booting from mmc${mmcdev} ...; " \
 		"run mmcargs; " \
 		"bootz ${loadaddr} - ${fdtaddr}\0" \
-	"findfdt="\
-		"if test $board_name = sdp4430; then " \
-			"setenv fdtfile omap4-sdp.dtb; fi; " \
-		"if test $board_name = panda; then " \
-			"setenv fdtfile omap4-panda.dtb; fi;" \
-		"if test $board_name = panda-a4; then " \
-			"setenv fdtfile omap4-panda-a4.dtb; fi;" \
-		"if test $board_name = panda-es; then " \
-			"setenv fdtfile omap4-panda-es.dtb; fi;" \
-		"if test $fdtfile = undefined; then " \
-			"echo WARNING: Could not determine device tree to use; fi; \0" \
 	"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
-
-#define CONFIG_BOOTCOMMAND \
-	"run findfdt; " \
-	"mmc dev ${mmcdev}; if mmc rescan; then " \
-		"echo SD/MMC found on device ${mmcdev};" \
-		"if run loadbootscript; then " \
-			"run bootscript; " \
-		"else " \
-			"if run loadbootenv; then " \
-				"run importbootenv; " \
-			"fi;" \
-			"if test -n ${uenvcmd}; then " \
-				"echo Running uenvcmd ...;" \
-				"run uenvcmd;" \
-			"fi;" \
-		"fi;" \
-		"if run loadimage; then " \
-			"run loadfdt;" \
-			"run mmcboot; " \
-		"fi; " \
-	"fi"
+	FIND_FDT_FILE \
+	BOOTCMD_COMMON \
+	BOOTCMD_MMC \
+	BOOTCMD_USB
 
 /* Defines for SPL */
 #define CONFIG_SPL_TEXT_BASE		0x40304350
diff --git a/include/configs/omap4_panda.h b/include/configs/omap4_panda.h
index 6820e42..8c480c0 100644
--- a/include/configs/omap4_panda.h
+++ b/include/configs/omap4_panda.h
@@ -42,6 +42,24 @@
 #include <configs/omap4_common.h>
 #define CONFIG_CMD_NET
 
+#ifdef CONFIG_MMC
+#define BOOT_TARGETS_MMC "mmc0"
+#else
+#define BOOT_TARGETS_MMC ""
+#endif
+
+#ifdef CONFIG_USB_HOST
+#define BOOT_TARGETS_USB "usb"
+#else
+#define BOOT_TARGETS_USB ""
+#endif
+
+#ifdef CONFIG_NAND
+#define BOOT_TARGETS_NAND "nand"
+#else
+#define BOOT_TARGETS_NAND ""
+#endif
+
 /* GPIO */
 #define CONFIG_CMD_GPIO
 
@@ -50,4 +68,15 @@
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 
+#define FIND_FDT_FILE \
+	"findfdt="\
+		"if test $board_name = panda; then " \
+			"setenv fdtfile omap4-panda.dtb; fi;" \
+		"if test $board_name = panda-a4; then " \
+			"setenv fdtfile omap4-panda-a4.dtb; fi;" \
+		"if test $board_name = panda-es; then " \
+			"setenv fdtfile omap4-panda-es.dtb; fi;" \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree to use; fi; \0" \
+
 #endif /* __CONFIG_PANDA_H */
diff --git a/include/configs/omap4_sdp4430.h b/include/configs/omap4_sdp4430.h
index b352511..f4f086f 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -32,4 +32,30 @@
 #define CONFIG_ENV_OFFSET		0xE0000
 #define CONFIG_CMD_SAVEENV
 
+#ifdef CONFIG_MMC
+#define BOOT_TARGETS_MMC "mmc0"
+#else
+#define BOOT_TARGETS_MMC ""
+#endif
+
+#ifdef CONFIG_USB_HOST
+#define BOOT_TARGETS_USB "usb"
+#else
+#define BOOT_TARGETS_USB ""
+#endif
+
+#ifdef CONFIG_NAND
+#define BOOT_TARGETS_NAND "nand"
+#else
+#define BOOT_TARGETS_NAND ""
+#endif
+
+#define FIND_FDT_FILE \
+	"findfdt="\
+		"if test $board_name = sdp4430; then " \
+			"setenv fdtfile omap4-sdp.dtb; fi; " \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree to use; fi; \0" \
+
+
 #endif /* __CONFIG_SDP4430_H */
diff --git a/include/configs/omap5_common.h b/include/configs/omap5_common.h
index c7fa37e..4d5e5f4 100644
--- a/include/configs/omap5_common.h
+++ b/include/configs/omap5_common.h
@@ -116,23 +116,11 @@
 				"bootz ${loadaddr} - ${fdtaddr}; " \
 			"fi;" \
 		"fi;\0" \
-	"findfdt="\
-		"if test $board_name = omap5_uevm; then " \
-			"setenv fdtfile omap5-uevm.dtb; fi; " \
-		"if test $board_name = dra7xx; then " \
-			"setenv fdtfile dra7-evm.dtb; fi;" \
-		"if test $fdtfile = undefined; then " \
-			"echo WARNING: Could not determine device tree to use; fi; \0" \
-	"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \
-
-#define CONFIG_BOOTCOMMAND \
-	"run findfdt; " \
-	"run mmcboot;" \
-	"setenv mmcdev 1; " \
-	"setenv bootpart 1:2; " \
-	"setenv mmcroot /dev/mmcblk0p2 rw; " \
-	"run mmcboot;" \
-
+	"loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \
+	FIND_FDT_FILE \
+	BOOTCMD_COMMON \
+	BOOTCMD_MMC \
+	BOOTCMD_USB
 
 /*
  * SPL related defines.  The Public RAM memory map the ROM defines the
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index 4d3a800..a432a23 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -66,6 +66,31 @@
 
 #define CONSOLEDEV		"ttyO2"
 
+#ifdef CONFIG_MMC
+#define BOOT_TARGETS_MMC "mmc0"
+#else
+#define BOOT_TARGETS_MMC ""
+#endif
+
+#ifdef CONFIG_USB_HOST
+#define BOOT_TARGETS_USB "usb"
+#else
+#define BOOT_TARGETS_USB ""
+#endif
+
+#ifdef CONFIG_NAND
+#define BOOT_TARGETS_NAND "nand"
+#else
+#define BOOT_TARGETS_NAND ""
+#endif
+
+#define FIND_FDT_FILE \
+	"findfdt="\
+		"if test $board_name = omap5_uevm; then " \
+			"setenv fdtfile omap5-uevm.dtb; fi; " \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree to use; fi; \0" \
+
 /* Max time to hold reset on this board, see doc/README.omap-reset-time */
 #define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC	16296
 
diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
index 84269ad..e11d357 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -248,4 +248,76 @@
 #endif
 #endif /* !CONFIG_NOR_BOOT */
 
+/* Boot defines */
+#define BOOTCMD_COMMON \
+	"rootpart=1\0" \
+	"script_boot=" \
+		"if load ${devtype} ${devnum}:${rootpart} ${loadaddr} ${bootdir}/${bootfile}; then " \
+			"run findfdt; " \
+			"load ${devtype} ${devnum}:${rootpart} ${fdtaddr} ${bootdir}/${fdtfile};" \
+			"bootz ${loadaddr} - ${fdtaddr}; " \
+		"fi;\0" \
+	\
+	"scan_boot=" \
+		"echo Scanning ${devtype} ${devnum}...; " \
+		"for prefix in ${bootdir}; do " \
+			"for script in ${bootfile}; do " \
+				"run script_boot; " \
+			"done; " \
+		"done;\0" \
+	"boot_targets=" \
+		BOOT_TARGETS_USB " " \
+		BOOT_TARGETS_MMC " " \
+		BOOT_TARGETS_NAND " " \
+		"\0"
+
+/* USB MSD Boot */
+#define BOOTCMD_INIT_USB "run usb_init; "
+#define BOOTCMD_USB \
+	"usb_init=" \
+		"usb start 0;\0 " \
+	"usb_boot=" \
+		"setenv devtype usb; " \
+		BOOTCMD_INIT_USB \
+		"if usb dev 0; then " \
+			"run scan_boot; " \
+		"fi\0" \
+	"bootcmd_usb=setenv devnum 0; run usb_boot;\0"
+
+/* MMC Boot */
+#define BOOTCMD_MMC \
+	"mmc_boot=" \
+		"setenv devtype mmc; " \
+		"if mmc dev ${devnum}; then " \
+			"run mmcargs;" \
+			"run scan_boot; " \
+		"fi\0" \
+	"bootcmd_mmc0=setenv devnum 0; setenv rootpart 2; run mmc_boot;\0" \
+
+/* NAND Boot */
+#define DFU_ALT_INFO_NAND ""
+#define MTDIDS_DEFAULT ""
+#define MTDPARTS_DEFAULT ""
+
+#define BOOTCMD_NAND \
+	"mtdids=" MTDIDS_DEFAULT "\0" \
+	"mtdparts=" MTDPARTS_DEFAULT "\0" \
+	"nandargs=setenv bootargs console=${console} " \
+		"${optargs} " \
+		"root=${nandroot} " \
+		"rootfstype=${nandrootfstype}\0" \
+	"dfu_alt_info_nand=" DFU_ALT_INFO_NAND "\0" \
+	"nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0" \
+	"nandrootfstype=ubifs rootwait=1\0" \
+	"nandsrcaddr=0x280000\0" \
+	"nandboot=echo Booting from nand ...; " \
+		"run nandargs; " \
+		"nand read ${loadaddr} ${nandsrcaddr} ${nandimgsize}; " \
+		"bootz ${loadaddr}\0" \
+	"nandimgsize=0x500000\0" \
+	"bootcmd_nand=run nandboot;\0"
+
+#define CONFIG_BOOTCOMMAND \
+	"for target in ${boot_targets}; do run bootcmd_${target}; done"
+
 #endif	/* __CONFIG_TI_ARMV7_COMMON_H__ */
-- 
1.7.9.5



More information about the U-Boot mailing list