[U-Boot] [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.
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de --- arch/arm/mach-mvebu/spl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index e65f6ca..af61ded 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -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 */

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.
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de --- tools/kwbimage.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 1ff17ca..91e0990 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -115,6 +115,7 @@ struct boot_mode boot_modes[] = { { 0x78, "sata" }, { 0x9C, "pex" }, { 0x69, "uart" }, + { 0xAE, "sdio" }, {}, };

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.
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de --- tools/Makefile | 4 ++-- tools/kwbimage.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/Makefile b/tools/Makefile index 8ff9c2e..5d14a34 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 91e0990..3fa90d3 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -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

Hello Stefan,
On Mon, 20 Jul 2015 11:20:38 +0200, Stefan Roese sr@denx.de wrote:
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,

Hi Albert,
On 21.07.2015 09:37, Albert ARIBAUD wrote:
On Mon, 20 Jul 2015 11:20:38 +0200, Stefan Roese sr@denx.de wrote:
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

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.
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de Cc: Tom Rini trini@konsulko.com --- common/spl/spl_mmc.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 552f80d..d308679 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -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

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
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de --- include/configs/db-88f6820-gp.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/include/configs/db-88f6820-gp.h b/include/configs/db-88f6820-gp.h index 73b3236..739c2bf 100644 --- a/include/configs/db-88f6820-gp.h +++ b/include/configs/db-88f6820-gp.h @@ -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

Hi Stefan,
On Mon, Jul 20, 2015 at 11:20:40AM +0200, Stefan Roese wrote:
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:
Can you please define "bootable" here? Does the partition really need to have bootable flag configured?
Thanks, Luka
dd if=u-boot-spl.kwb of=/dev/sdX1
Signed-off-by: Stefan Roese sr@denx.de Cc: Luka Perkov luka.perkov@sartura.hr Cc: Dirk Eibach eibach@gdsys.de
include/configs/db-88f6820-gp.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/include/configs/db-88f6820-gp.h b/include/configs/db-88f6820-gp.h index 73b3236..739c2bf 100644 --- a/include/configs/db-88f6820-gp.h +++ b/include/configs/db-88f6820-gp.h @@ -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
2.4.6

Hi Luka,
On 20.07.2015 23:34, Luka Perkov wrote:
On Mon, Jul 20, 2015 at 11:20:40AM +0200, Stefan Roese wrote:
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:
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

Hello Stefan,
On Mon, 20 Jul 2015 11:20:36 +0200, Stefan Roese sr@denx.de wrote:
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,

Hi Albert,
On 21.07.2015 09:24, Albert ARIBAUD wrote:
On Mon, 20 Jul 2015 11:20:36 +0200, Stefan Roese sr@denx.de wrote:
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
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
participants (3)
-
Albert ARIBAUD
-
Luka Perkov
-
Stefan Roese