[U-Boot] [Patch v2 4/7] TQMa6: add SPI NOR boot support

Markus Niebel list-09_u-boot at tqsc.de
Mon Jun 16 18:51:23 CEST 2014


From: Markus Niebel <Markus.Niebel at tqs.de>

This patch adds support for booting from SPI NOR flash and
having the environment also in SPI NOR. Also all environment
settings to allow update of bootloader and kernel are added.

Signed-off-by: Markus Niebel <Markus.Niebel at tq-group.com>
---
 board/tqc/tqma6/README  |    4 ++
 boards.cfg              |    2 +
 include/configs/tqma6.h |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+)

diff --git a/board/tqc/tqma6/README b/board/tqc/tqma6/README
index 096cd17..2c012e7 100644
--- a/board/tqc/tqma6/README
+++ b/board/tqc/tqma6/README
@@ -9,6 +9,7 @@ U-Boot to the TQ Systems TQMa6 modules.
 The following boot source is supported:
 
 - SD/eMMC
+- SPI NOR
 
 2. Building
 ------------
@@ -24,8 +25,11 @@ s - means i.MX6S: TQMa6S  (i.MX6S)
 
 baseboard is a placeholder for the boot device
 mmc - means eMMC
+spi - mean SPI NOR
 
 This gives the following configurations:
 
 tqma6q_mba6_mmc_config
+tqma6q_mba6_spi_config
 tqma6s_mba6_mmc_config
+tqma6s_mba6_spi_config
diff --git a/boards.cfg b/boards.cfg
index 4868ed9..d41288a 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -331,7 +331,9 @@ Active  arm         armv7          mx6         freescale       mx6slevk
 Active  arm         armv7          mx6         gateworks       gw_ventana          gwventana                            gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6QDL,SPL                                                  Tim Harvey <tharvey at gateworks.com>
 Active  arm         armv7          mx6         solidrun        hummingboard        hummingboard_solo                     hummingboard:IMX_CONFIG=board/solidrun/hummingboard/solo.cfg,MX6S,DDR_MB=512                                                      Jon Nettleton <jon.nettleton at gmail.com>
 Active  arm         armv7          mx6         tqc             tqma6               tqma6q_mba6_mmc                       tqma6:IMX_CONFIG=board/tqc/tqma6/tqma6q.cfg,MX6Q,MBA6,TQMA6X_MMC_BOOT                                                            Markus Niebel <Markus.Niebel at tq-group.com>
+Active  arm         armv7          mx6         tqc             tqma6               tqma6q_mba6_spi                       tqma6:IMX_CONFIG=board/tqc/tqma6/tqma6q.cfg,MX6Q,MBA6,TQMA6X_SPI_BOOT                                                            Markus Niebel <Markus.Niebel at tq-group.com>
 Active  arm         armv7          mx6         tqc             tqma6               tqma6s_mba6_mmc                       tqma6:IMX_CONFIG=board/tqc/tqma6/tqma6s.cfg,MX6S,MBA6,TQMA6X_MMC_BOOT                                                            Markus Niebel <Markus.Niebel at tq-group.com>
+Active  arm         armv7          mx6         tqc             tqma6               tqma6s_mba6_spi                       tqma6:IMX_CONFIG=board/tqc/tqma6/tqma6s.cfg,MX6S,MBA6,TQMA6X_SPI_BOOT                                                            Markus Niebel <Markus.Niebel at tq-group.com>
 Active  arm         armv7          omap3       -               overo               omap3_overo                           -                                                                                                                                 Steve Sakoman <sakoman at gmail.com>
 Active  arm         armv7          omap3       -               pandora             omap3_pandora                         -                                                                                                                                 Grazvydas Ignotas <notasas at gmail.com>
 Active  arm         armv7          omap3       8dtech          eco5pk              eco5pk                                -                                                                                                                                 Raphael Assenat <raph at 8d.com>
diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h
index 2c5016d..d2b12c3 100644
--- a/include/configs/tqma6.h
+++ b/include/configs/tqma6.h
@@ -211,6 +211,109 @@
 #define CONFIG_BOOTCOMMAND \
 	"run mmcboot; run netboot; run panicboot"
 
+#elif defined(CONFIG_TQMA6X_SPI_BOOT)
+
+#define CONFIG_FLASH_SECTOR_SIZE	0x10000
+
+#define CONFIG_UBOOT_OFFSET		0x400
+#define CONFIG_UBOOT_SECTOR_START	0x0
+/* max u-boot size: 512k */
+#define CONFIG_UBOOT_SECTOR_SIZE	CONFIG_FLASH_SECTOR_SIZE
+#define CONFIG_UBOOT_SECTOR_COUNT	0x8
+#define CONFIG_UBOOT_SIZE		(CONFIG_UBOOT_SECTOR_SIZE * \
+					 CONFIG_UBOOT_SECTOR_COUNT)
+
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#define CONFIG_ENV_OFFSET		(CONFIG_UBOOT_SIZE)
+#define CONFIG_ENV_SECT_SIZE		CONFIG_FLASH_SECTOR_SIZE
+#define CONFIG_ENV_OFFSET_REDUND	(CONFIG_ENV_OFFSET + \
+					 CONFIG_ENV_SECT_SIZE)
+
+#define CONFIG_ENV_SPI_BUS		(CONFIG_SF_DEFAULT_BUS)
+#define CONFIG_ENV_SPI_CS		(CONFIG_SF_DEFAULT_CS)
+#define CONFIG_ENV_SPI_MAX_HZ		(CONFIG_SF_DEFAULT_SPEED)
+#define CONFIG_ENV_SPI_MODE		(CONFIG_SF_DEFAULT_MODE)
+
+#define CONFIG_FDT_OFFSET		(CONFIG_ENV_OFFSET_REDUND + \
+					 CONFIG_ENV_SECT_SIZE)
+#define CONFIG_FDT_SECT_SIZE		(CONFIG_FLASH_SECTOR_SIZE)
+
+#define CONFIG_FDT_SECTOR_START		0x0a /* 8 Sector u-boot, 2 Sector env */
+#define CONFIG_FDT_SECTOR_COUNT		0x01
+
+#define CONFIG_KERNEL_SECTOR_START	0x10
+#define CONFIG_KERNEL_SECTOR_COUNT	0x60
+
+#define CONFIG_EXTRA_BOOTDEV_ENV_SETTINGS                                      \
+	"mmcblkdev=0\0"                                                        \
+	"uboot_offset="__stringify(CONFIG_UBOOT_OFFSET)"\0"                    \
+	"uboot_sectors="__stringify(CONFIG_UBOOT_SECTOR_COUNT)"\0"             \
+	"fdt_start="__stringify(CONFIG_FDT_SECTOR_START)"\0"                   \
+	"fdt_sectors="__stringify(CONFIG_FDT_SECTOR_COUNT)"\0"                 \
+	"kernel_start="__stringify(CONFIG_KERNEL_SECTOR_START)"\0"             \
+	"kernel_sectors="__stringify(CONFIG_KERNEL_SECTOR_COUNT)"\0"           \
+	"update_uboot=if tftp ${uboot}; then "                                 \
+		"if itest ${filesize} > 0; then "                              \
+			"setexpr blkc ${filesize} + "                          \
+				__stringify(CONFIG_UBOOT_OFFSET) "; "          \
+			"setexpr size ${uboot_sectors} * "                     \
+				__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "      \
+			"if itest ${blkc} <= ${size}; then "                   \
+				"sf probe; "                                   \
+				"sf erase 0 ${size}; "                         \
+				"sf write ${loadaddr} ${uboot_offset} "        \
+					"${filesize}; "                        \
+			"fi; "                                                 \
+		"fi; fi; "                                                     \
+		"setenv filesize 0; setenv blkc; setenv size \0"               \
+	"update_kernel=run kernel_name; if tftp ${kernel}; then "              \
+		"if itest ${filesize} > 0; then "                              \
+			"setexpr size ${kernel_sectors} * "                    \
+				__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "      \
+			"setexpr offset ${kernel_start} * "                    \
+				__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "      \
+			"if itest ${filesize} <= ${size}; then "               \
+				"sf probe; "                                   \
+				"sf erase ${offset} ${size}; "                 \
+				"sf write ${loadaddr} ${offset} "              \
+					"${filesize}; "                        \
+			"fi; "                                                 \
+		"fi; fi; "                                                     \
+		"setenv filesize 0; setenv size ; setenv offset\0"             \
+	"update_fdt=if tftp ${fdt_file}; then "                                \
+		"if itest ${filesize} > 0; then "                              \
+			"setexpr size ${fdt_sectors} * "                       \
+				__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "      \
+			"setexpr offset ${fdt_start} * "                       \
+				__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "      \
+			"if itest ${filesize} <= ${size}; then "               \
+				"sf probe; "                                   \
+				"sf erase ${offset} ${size}; "                 \
+				"sf write ${loadaddr} ${offset} "              \
+					"${filesize}; "                        \
+			"fi; "                                                 \
+		"fi; fi; "                                                     \
+		"setenv filesize 0; setenv size ; setenv offset\0"             \
+	"loadimage=sf probe; "                                                 \
+		"setexpr size ${kernel_sectors} * "                            \
+			__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "              \
+		"setexpr offset ${kernel_start} * "                            \
+			__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "              \
+		"sf read ${loadaddr} ${offset} ${size}; "                      \
+		"setenv size ; setenv offset\0"                                \
+	"loadfdt=sf probe; "                                                   \
+		"setexpr size ${fdt_sectors} * "                               \
+			__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "              \
+		"setexpr offset ${fdt_start} * "                               \
+			__stringify(CONFIG_FLASH_SECTOR_SIZE)"; "              \
+		"sf read ${${fdt_addr}} ${offset} ${size}; "                   \
+		"setenv size ; setenv offset\0"                                \
+
+
+#define CONFIG_BOOTCOMMAND                                                     \
+	"sf probe; run mmcboot; run netboot; run panicboot"                    \
+
 #else
 
 #error "need to define boot source"
-- 
1.7.9.5



More information about the U-Boot mailing list