Skip to contentSkip to conversation

arm: mvebu: Add SPL SDIO/MMC boot support

PATCH New Stefan Roese 3 participants 11 messages Jul 20, 2015 – Jul 21, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 arm: mvebu: Add SPL SDIO/MMC boot support

This patch adds basic SDIO/MMC booting support to MVEBU SoC's. Since I don't know of a way to test the boot-device upon runtime, this patch hardcodes the spl_boot_device instead.

Tested on Marvell DB-88F6820-GP board.

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
---
 arch/arm/mach-mvebu/spl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/spl.c +12 -1
index e65f6ca..af61ded 100644
@@ -14,10 +14,21 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 spl_boot_device(void)
 {
-	/* Right now only booting via SPI NOR flash is supported */
+#if defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
 	return BOOT_DEVICE_SPI;
+#endif
+#if defined(CONFIG_SPL_MMC_SUPPORT)
+	return BOOT_DEVICE_MMC1;
+#endif
 }
 
+#ifdef CONFIG_SPL_MMC_SUPPORT
+u32 spl_boot_mode(void)
+{
+	return MMCSD_MODE_RAW;
+}
+#endif
+
 void board_init_f(ulong dummy)
 {
 	/* Set global data pointer */
Signature · 1 line
2.4.6
#1 lore raw

PATCH 2/5 kwbimage: Add support for SDIO/MMC boot device selection

This patch adds support to select the "sdio" as boot device in the kwbimage.cfg file. This line selects this SDIO device:

BOOT_FROM sdio

Tested on Marvell DB-88F6820-GP board.

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
---
 tools/kwbimage.c | 1 +
 1 file changed, 1 insertion(+)
tools/kwbimage.c +1 -0
index 1ff17ca..91e0990 100644
@@ -115,6 +115,7 @@ struct boot_mode boot_modes[] = {
 	{ 0x78, "sata" },
 	{ 0x9C, "pex"  },
 	{ 0x69, "uart" },
+	{ 0xAE, "sdio" },
 	{},
 };
 
Signature · 1 line
2.4.6
#2 lore raw

PATCH 3/5 kwbimage: Rename CONFIG_SYS_SPI_U_BOOT_OFFS to CONFIG_SYS_U_BOOT_OFFS

In reply to Stefan Roese

To use this offset for other boot device (like SDIO/MMC), lets rename it to a more generic name. This will be used be the SDIO/MMC SPL boot support for the A38x.

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
---
 tools/Makefile   |  4 ++--
 tools/kwbimage.c | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)
tools/Makefile +2 -2
index 8ff9c2e..5d14a34 100644
@@ -116,8 +116,8 @@ ifdef CONFIG_FIT_SIGNATURE
 HOST_EXTRACFLAGS	+= -DCONFIG_FIT_SIGNATURE
 endif
 
-ifdef CONFIG_SYS_SPI_U_BOOT_OFFS
-HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_SPI_U_BOOT_OFFS=$(CONFIG_SYS_SPI_U_BOOT_OFFS)
+ifdef CONFIG_SYS_U_BOOT_OFFS
+HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS)
 endif
 
 # MXSImage needs LibSSL
tools/kwbimage.c +6 -6
index 91e0990..3fa90d3 100644
@@ -421,15 +421,15 @@ static size_t image_headersz_v1(struct image_tool_params *params,
 			*hasext = 1;
 	}
 
-#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
-	if (headersz > CONFIG_SYS_SPI_U_BOOT_OFFS) {
+#if defined(CONFIG_SYS_U_BOOT_OFFS)
+	if (headersz > CONFIG_SYS_U_BOOT_OFFS) {
 		fprintf(stderr, "Error: Image header (incl. SPL image) too big!\n");
-		fprintf(stderr, "header=0x%x CONFIG_SYS_SPI_U_BOOT_OFFS=0x%x!\n",
-			(int)headersz, CONFIG_SYS_SPI_U_BOOT_OFFS);
-		fprintf(stderr, "Increase CONFIG_SYS_SPI_U_BOOT_OFFS!\n");
+		fprintf(stderr, "header=0x%x CONFIG_SYS_U_BOOT_OFFS=0x%x!\n",
+			(int)headersz, CONFIG_SYS_U_BOOT_OFFS);
+		fprintf(stderr, "Increase CONFIG_SYS_U_BOOT_OFFS!\n");
 		return 0;
 	} else {
-		headersz = CONFIG_SYS_SPI_U_BOOT_OFFS;
+		headersz = CONFIG_SYS_U_BOOT_OFFS;
 	}
 #endif
 
Signature · 1 line
2.4.6
#3 lore raw

PATCH 3/5 kwbimage: Rename CONFIG_SYS_SPI_U_BOOT_OFFS to CONFIG_SYS_U_BOOT_OFFS

Hello Stefan,

Quoted 3 lines · Stefan Roese

To use this offset for other boot device (like SDIO/MMC), lets rename it to a more generic name. This will be used be the SDIO/MMC SPL boot support for the A38x.

Hmm, what if SPL gets support for booting from several sources with different U-Boot offsets for different sources?

Amicalement,

Signature · 1 line
Albert.
#4 lore raw

PATCH 3/5 kwbimage: Rename CONFIG_SYS_SPI_U_BOOT_OFFS to CONFIG_SYS_U_BOOT_OFFS

Hi Albert,

Quoted 7 lines · Albert ARIBAUD
Quoted 3 lines · Stefan Roese

To use this offset for other boot device (like SDIO/MMC), lets rename it to a more generic name. This will be used be the SDIO/MMC SPL boot support for the A38x.

Hmm, what if SPL gets support for booting from several sources with different U-Boot offsets for different sources?

If this happens then lets deal with it. For now I prefer to not add a new define / macro, if the current one can handle both supported cases.

Thanks,
Stefan

#5 lore raw

PATCH 4/5 spl: spl_mmc: Add option to boot from a MMC partition with offset

In reply to Stefan Roese

This patch introduces the option to boot from a MMC card parition with an offset. This can be done by using both defines together:

define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ((160 << 10) / 512)

The example above loads the main U-Boot at offset 160KiB from the MMC partition 1.

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
Cc Tom Rini <[email protected]>
---
 common/spl/spl_mmc.c | 5 +++++
 1 file changed, 5 insertions(+)
common/spl/spl_mmc.c +5 -0
index 552f80d..d308679 100644
@@ -67,7 +67,12 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
 		return -1;
 	}
 
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
+	return mmc_load_image_raw_sector(mmc, info.start +
+					 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
+#else
 	return mmc_load_image_raw_sector(mmc, info.start);
+#endif
 }
 #endif
 
Signature · 1 line
2.4.6
#6 lore raw

PATCH 5/5 arm: mvebu: db-88f6820-gp: Add SDIO/MMC SPL boot support

In reply to Stefan Roese

This patch adds the configuration options to boot via SDIO/MMC on the Marvell DB-88F6820-GP Armada A38x board. The default boot device is still SPI NOR flash.

To enable MMC booting on this board 2 things need to be changes:
a) Change kwbimage.cfg
BOOT_FROM sdio
b) In the config header select
#define CONFIG_SPL_BOOT_DEVICE SPL_BOOT_SDIO_MMC_CARD

The generated image needs to be copied to the first bootable MMC partition:

dd if=u-boot-spl.kwb of=/dev/sdX1

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
---
 include/configs/db-88f6820-gp.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/configs/db-88f6820-gp.h +28 -0
index 73b3236..739c2bf 100644
@@ -110,6 +110,17 @@
 	"initrd_high=0x10000000\0"
 
 /* SPL */
+/*
+ * Select the boot device here
+ *
+ * Currently supported are:
+ * SPL_BOOT_SPI_NOR_FLASH	- Booting via SPI NOR flash
+ * SPL_BOOT_SDIO_MMC_CARD	- Booting via SDIO/MMC card (partition 1)
+ */
+#define SPL_BOOT_SPI_NOR_FLASH		1
+#define SPL_BOOT_SDIO_MMC_CARD		2
+#define CONFIG_SPL_BOOT_DEVICE		SPL_BOOT_SPI_NOR_FLASH
+
 /* Defines for SPL */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_SIZE			(140 << 10)
@@ -131,6 +142,7 @@
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
 
+#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH
 /* SPL related SPI defines */
 #define CONFIG_SPL_SPI_SUPPORT
 #define CONFIG_SPL_SPI_FLASH_SUPPORT
@@ -138,6 +150,22 @@
 #define CONFIG_SPL_SPI_BUS		0
 #define CONFIG_SPL_SPI_CS		0
 #define CONFIG_SYS_SPI_U_BOOT_OFFS	0x20000
+#define CONFIG_SYS_U_BOOT_OFFS		CONFIG_SYS_SPI_U_BOOT_OFFS
+#endif
+
+#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD
+/* SPL related MMC defines */
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
+#define CONFIG_SYS_MMC_U_BOOT_OFFS		(160 << 10)
+#define CONFIG_SYS_U_BOOT_OFFS			CONFIG_SYS_MMC_U_BOOT_OFFS
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	(CONFIG_SYS_U_BOOT_OFFS / 512)
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	((512 << 10) / 512) /* 512KiB */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER	0x00180000	/* in SDRAM */
+#endif
+#endif
 
 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
 #define CONFIG_SYS_MVEBU_DDR_A38X
Signature · 1 line
2.4.6
#7 lore raw

PATCH 5/5 arm: mvebu: db-88f6820-gp: Add SDIO/MMC SPL boot support

Hi Stefan,

Quoted 4 lines · Stefan Roese

This patch adds the configuration options to boot via SDIO/MMC on the Marvell DB-88F6820-GP Armada A38x board. The default boot device is still SPI NOR flash.

Quoted 8 lines

To enable MMC booting on this board 2 things need to be changes:
a) Change kwbimage.cfg
BOOT_FROM sdio
b) In the config header select
#define CONFIG_SPL_BOOT_DEVICE SPL_BOOT_SDIO_MMC_CARD

The generated image needs to be copied to the first bootable MMC partition:

Can you please define "bootable" here? Does the partition really need to have bootable flag configured?

Thanks,
Luka

Quoted 65 lines

dd if=u-boot-spl.kwb of=/dev/sdX1

Cc Luka Perkov <[email protected]>
Cc Dirk Eibach <[email protected]>
---
 include/configs/db-88f6820-gp.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/configs/db-88f6820-gp.h +28 -0
index 73b3236..739c2bf 100644
@@ -110,6 +110,17 @@
 	"initrd_high=0x10000000\0"
 
 /* SPL */
+/*
+ * Select the boot device here
+ *
+ * Currently supported are:
+ * SPL_BOOT_SPI_NOR_FLASH	- Booting via SPI NOR flash
+ * SPL_BOOT_SDIO_MMC_CARD	- Booting via SDIO/MMC card (partition 1)
+ */
+#define SPL_BOOT_SPI_NOR_FLASH		1
+#define SPL_BOOT_SDIO_MMC_CARD		2
+#define CONFIG_SPL_BOOT_DEVICE		SPL_BOOT_SPI_NOR_FLASH
+
 /* Defines for SPL */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_SIZE			(140 << 10)
@@ -131,6 +142,7 @@
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
 
+#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH
 /* SPL related SPI defines */
 #define CONFIG_SPL_SPI_SUPPORT
 #define CONFIG_SPL_SPI_FLASH_SUPPORT
@@ -138,6 +150,22 @@
 #define CONFIG_SPL_SPI_BUS		0
 #define CONFIG_SPL_SPI_CS		0
 #define CONFIG_SYS_SPI_U_BOOT_OFFS	0x20000
+#define CONFIG_SYS_U_BOOT_OFFS		CONFIG_SYS_SPI_U_BOOT_OFFS
+#endif
+
+#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD
+/* SPL related MMC defines */
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
+#define CONFIG_SYS_MMC_U_BOOT_OFFS		(160 << 10)
+#define CONFIG_SYS_U_BOOT_OFFS			CONFIG_SYS_MMC_U_BOOT_OFFS
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	(CONFIG_SYS_U_BOOT_OFFS / 512)
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	((512 << 10) / 512) /* 512KiB */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER	0x00180000	/* in SDRAM */
+#endif
+#endif
 
 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
 #define CONFIG_SYS_MVEBU_DDR_A38X
Signature · 1 line
2.4.6
#8 lore raw

PATCH 5/5 arm: mvebu: db-88f6820-gp: Add SDIO/MMC SPL boot support

Hi Luka,

Quoted 11 lines · Luka Perkov
Quoted 10 lines · Stefan Roese

This patch adds the configuration options to boot via SDIO/MMC on the Marvell DB-88F6820-GP Armada A38x board. The default boot device is still SPI NOR flash.

To enable MMC booting on this board 2 things need to be changes:
a) Change kwbimage.cfg
BOOT_FROM sdio
b) In the config header select

    #define CONFIG_SPL_BOOT_DEVICE	SPL_BOOT_SDIO_MMC_CARD
Quoted 5 lines
Quoted 2 lines

The generated image needs to be copied to the first bootable MMC partition:

Can you please define "bootable" here? Does the partition really need to have bootable flag configured?

Correct. Thats how I understand it from the documentation. Trying to boot from a partition that did not have this "bootable" flag set did not work IIRC.

Thanks,
Stefan

#9 lore raw

PATCH 1/5 arm: mvebu: Add SPL SDIO/MMC boot support

In reply to Stefan Roese

Hello Stefan,

Quoted 3 lines · Stefan Roese

This patch adds basic SDIO/MMC booting support to MVEBU SoC's. Since I don't know of a way to test the boot-device upon runtime, this patch hardcodes the spl_boot_device instead.

Not sure about 6820, but for 6710 this info can be traced back from the functional spec [1] to the device data sheet [2] as the sample-at-reset (SAR) data, which (for the 6710 at least) is an embedded XLS sheet [3]. Maybe you can find the same info for 6820?

For 6710:

[1] "88F6710, 88F6707, and 88F6W11 ARMADA ? 370 SoC Functional Specifications ? Unrestricted"
Doc. No. MV-S107979-U0, Rev. B

[2] "88F6710, 88F6707, and 88F6W11 ARMADA ? 370 SoC Hardware

    Specifications"
    Doc. No. MV-S107978-00, Rev. G

[3] "Sample at Reset Table" and "Boot Source List" tabs in

    88F6707_Pin_information.xls

Amicalement,

Signature · 1 line
Albert.
#10 lore raw

PATCH 1/5 arm: mvebu: Add SPL SDIO/MMC boot support

Hi Albert,

Quoted 16 lines · Albert ARIBAUD
Quoted 3 lines · Stefan Roese

This patch adds basic SDIO/MMC booting support to MVEBU SoC's. Since I don't know of a way to test the boot-device upon runtime, this patch hardcodes the spl_boot_device instead.

Not sure about 6820, but for 6710 this info can be traced back from the functional spec [1] to the device data sheet [2] as the sample-at-reset (SAR) data, which (for the 6710 at least) is an embedded XLS sheet [3]. Maybe you can find the same info for 6820?

For 6710:

[1] "88F6710, 88F6707, and 88F6W11 ARMADA ? 370 SoC Functional Specifications ? Unrestricted"
Doc. No. MV-S107979-U0, Rev. B

Quoted 6 lines

[2] "88F6710, 88F6707, and 88F6W11 ARMADA ? 370 SoC Hardware

     Specifications"
     Doc. No. MV-S107978-00, Rev. G

[3] "Sample at Reset Table" and "Boot Source List" tabs in

     88F6707_Pin_information.xls

Thanks Albert. Yes, this seems possible for AXP and A38x. I currently don't have access to the SD-card booting A38x platform though. So I would like to get this patch accepted now. And will send a patch for runtime boot-device detection later. Or perhaps somebody else will jump in... :)

Thanks,
Stefan