SPL mmc refactor and alternate boot device feature
v4 cover SPL mmc refactor and alternate boot device feature
This series has two parts: patches 1-7 perform refactors aimed at reducing the ifdef complexity of SPL mmc code (and some nand as well). This refactor also addresses a few design issues I noticed while working on the refactor.
Image size comparison for arm modules can be seen here:
http://patchwork.ozlabs.org/patch/534387/
Since the changes in V2 are minimal, the V1 results should still be valid for the V2 as well.
The rest of the series introduces a new SPL feature that allows board code to define a list of boot devices that SPL will try before failing (instead of the only one device it attempts now). This feature is useful for implementing fallbacks, as well as reacting to bootROM sequences. For example:
On CM-FX6, if boot from the alternate boot device (MMC) fails, the bootROM proceeds to try boot from SPI flash. If the SPI flash boot is succesful, SPL will still try to load U-Boot from MMC, instead of from the actual boot device SPI flash), and probably fail and hang. The alternate boot feature makes it possible for SPL to follow the MMC boot attempt with boot from the SPI flash. The CM-FX6 based miniature PC Utilite depends on this capability for its SPI flash boot to work, since SPI flash boot is only attempted if MMC boot fails.
Finally, patch 13 makes SPL look at the specific BOOT_DEVICE_MMCx, and search for the correct mmc device, instead of always going for mmc0.
This series was compile tested for arm and powerpc (patches 1-12). Patch 13 compile tested for sunxi.
Tested on CM-FX6.
Changes in V4:
- Rebased over current mainline. Rerun compile test for arm and powerpc
- Fixed typo in a commit message
- Moved announce_boot_device() code to after #ifndef BOOT_DEVICE_NONE
- Replaced one puts with printf
Changes in V3:
- Added documentation for spl_board_load_image().
- Reworked announce_boot_device() to make the code less repititive by utilizing a table of boot_device --> name.
Changes in V2:
- Per request I went over the changes to see if they should cause documentation updates or board updates, but found none to be necessary.
- Slight modification in patch 2 (and consequentially patch 8): removal of hang() in default switch case, and enclosing of default case in #ifdef LIBCONFIG to avoid compiler complaints if LIBCONFIG support not compiled in.
- Patch 13 is a new patch which makes SPL look at the value of BOOT_DEVICE_MMCx instead of always working with mmc0. A hack in sunxi boards that attempted to circumvent this issue is thus removed.
- Rebased over current mainline.
Nikita Kiryanov (13):
spl: nand: remove code duplication
spl: mmc: add break statements in spl_mmc_load_image()
spl: mmc: refactor device location code to its own function
spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
check
spl: mmc: move fs boot into its own function
spl: mmc: get rid of emmc boot code duplication
spl: change return values of spl_*_load_image()
common: spl: move image load to its own function
spl: add support for alternative boot device
spl: announce boot devices
arm: mx6: cm-fx6: define fallback boot devices for spl
spl: mmc: add support for BOOT_DEVICE_MMC2
arch/arm/cpu/armv7/sunxi/board.c | 14 +- arch/arm/include/asm/spl.h | 10 +- board/compulab/cm_fx6/spl.c | 19 +-- common/spl/spl.c | 194 +++++++++++++++++++------- common/spl/spl_ext.c | 6 + common/spl/spl_fat.c | 6 + common/spl/spl_mmc.c | 290 ++++++++++++++++++++++++--------------- common/spl/spl_nand.c | 47 ++++--- common/spl/spl_net.c | 9 +- common/spl/spl_nor.c | 6 +- common/spl/spl_onenand.c | 4 +- common/spl/spl_sata.c | 11 +- common/spl/spl_usb.c | 17 ++- common/spl/spl_ymodem.c | 5 +- drivers/mtd/spi/spi_spl_load.c | 17 ++- include/configs/cm_fx6.h | 1 - include/spl.h | 18 +-- 17 files changed, 446 insertions(+), 228 deletions(-)
Signature · 1 line
1.9.1
PATCH v4 1/13 spl: nand: remove code duplication
Remove code duplication in spl_nand_load_image().
No functional changes.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_nand.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
common/spl/spl_nand.c +16 -15
@@ -22,6 +22,19 @@ void spl_nand_load_image(void) nand_deselect(); }#else +static int spl_nand_load_element (int offset,struct image_header *header) +{ +int err; + + err =nand_spl_load_image (offset,sizeof (*header), (void *)header); +if (err) +return err; + +spl_parse_image_header (header); +return nand_spl_load_image (offset, spl_image.size, + (void *)spl_image.load_addr); +} +void spl_nand_load_image (void ) {struct image_header *header;
@@ -73,25 +86,13 @@ void spl_nand_load_image(void) }#endif #ifdef CONFIG_NAND_ENV_DST -nand_spl_load_image (CONFIG_ENV_OFFSET , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_ENV_OFFSET , spl_image.size, - (void *)spl_image.load_addr); +spl_nand_load_element (CONFIG_ENV_OFFSET , header);#ifdef CONFIG_ENV_OFFSET_REDUND -nand_spl_load_image (CONFIG_ENV_OFFSET_REDUND , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_ENV_OFFSET_REDUND , spl_image.size, - (void *)spl_image.load_addr); +spl_nand_load_element (CONFIG_ENV_OFFSET_REDUND , header);#endif #endif /* Load u-boot */ -nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS , - spl_image.size, (void *)(unsigned long )spl_image.load_addr); +spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS , header);nand_deselect (); }#endif
Signature · 1 line
1.9.1
PATCH v4 1/13 spl: nand: remove code duplication
Hello Nikita,
Am 08.11.2015 um 16:11 schrieb Nikita Kiryanov:
Quoted 13 lines
Remove code duplication in
spl_nand_load_image().No functional changes.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Scott Wood <[email protected]>Cc Igor Grinberg <[email protected]>Acked-by Scott Wood <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in V4:
- No changes.
Quoted 8 lines
Changes in V3:
- No changes.Changes in V2:
- No changes.common/spl/spl_nand.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
bye,
Heiko
Quoted 55 lines
common/spl/spl_nand.c +16
-15@@ -22,6 +22,19 @@ void spl_nand_load_image(void) nand_deselect(); }#else +static int spl_nand_load_element (int offset,struct image_header *header) +{ +int err; + + err =nand_spl_load_image (offset,sizeof (*header), (void *)header); +if (err) +return err; + +spl_parse_image_header (header); +return nand_spl_load_image (offset, spl_image.size, + (void *)spl_image.load_addr); +} +void spl_nand_load_image (void ) {struct image_header *header;@@ -73,25 +86,13 @@ void spl_nand_load_image(void) }#endif #ifdef CONFIG_NAND_ENV_DST -nand_spl_load_image (CONFIG_ENV_OFFSET , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_ENV_OFFSET , spl_image.size, - (void *)spl_image.load_addr); +spl_nand_load_element (CONFIG_ENV_OFFSET , header);#ifdef CONFIG_ENV_OFFSET_REDUND -nand_spl_load_image (CONFIG_ENV_OFFSET_REDUND , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_ENV_OFFSET_REDUND , spl_image.size, - (void *)spl_image.load_addr); +spl_nand_load_element (CONFIG_ENV_OFFSET_REDUND , header);#endif #endif /* Load u-boot */ -nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS , -sizeof (*header), (void *)header); -spl_parse_image_header (header); -nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS , - spl_image.size, (void *)(unsigned long )spl_image.load_addr); +spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS , header);nand_deselect (); }#endif
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v4 1/13 spl: nand: remove code duplication
In reply to Nikita KiryanovQuoted 10 lines · Nikita Kiryanov
Remove code duplication in
spl_nand_load_image().No functional changes.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Scott Wood <[email protected]>Cc Igor Grinberg <[email protected]>Acked-by Scott Wood <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/c2577b0f/attachment.sig>
PATCH v4 2/13 spl: mmc: add break statements in spl_mmc_load_image()
In reply to Nikita KiryanovThe original intention of the mmc load_image() function was to try multiple boot modes before failing. This is evident by the lack of break statements in the switch, and the following line in the default case:puts("spl: mmc: no boot mode left to try\n");
This implementation is problematic because:
- The availability of alternative boot modes is very arbitrary since it depends on the specific order of the switch cases. If your boot mode happens to be the first case, then you'll have a bunch of other boot modes as alternatives. If it happens to be the last case, then you have none.
- Opting in/out is tied to config options, so the only way for you to prevent an alternative boot mode from being attempted is to give up on the feature completely.
- This implementation makes the code more complicated and difficult to understand.
Address these issues by inserting a break statements between the cases to make the function try only one boot mode.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- Removed hang() in default cases, moved default case into ifdef LIBCOMMON.
common/spl/spl_mmc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
common/spl/spl_mmc.c +7 -6
@@ -164,6 +164,7 @@ void spl_mmc_load_image(void)if (!err)return ;#endif +break ;case MMCSD_MODE_FS :debug ("spl: mmc boot mode: fs\n" );
@@ -203,6 +204,7 @@ void spl_mmc_load_image(void)#endif #endif #endif +break ;#ifdef CONFIG_SUPPORT_EMMC_BOOT case MMCSD_MODE_EMMCBOOT :/*
@@ -240,15 +242,14 @@ void spl_mmc_load_image(void)if (!err)return ;#endif +break ;#endif case MMCSD_MODE_UNDEFINED : -default :#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -if (err) -puts ("spl: mmc: no boot mode left to try\n" ); -else -puts ("spl: mmc: wrong boot mode\n" ); +default : +puts ("spl: mmc: wrong boot mode\n" );#endif -hang (); } + +hang (); }
Signature · 1 line
1.9.1
PATCH v4 2/13 spl: mmc: add break statements in spl_mmc_load_image()
Quoted 18 lines · Nikita Kiryanov
The original intention of the mmc
load_image()function was to try multiple boot modes before failing. This is evident by the lack of break statements in the switch, and the following line in the default case:puts("spl: mmc: no boot mode left to try\n");This implementation is problematic because:
- The availability of alternative boot modes is very arbitrary since it depends on the specific order of the switch cases. If your boot mode happens to be the first case, then you'll have a bunch of other boot modes as alternatives. If it happens to be the last case, then you have none.
- Opting in/out is tied to config options, so the only way for you to prevent an alternative boot mode from being attempted is to give up on the feature completely.
- This implementation makes the code more complicated and difficult to understand.Address these issues by inserting a break statements between the cases to make the function try only one boot mode.
Quoted 8 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/52185286/attachment.sig>
PATCH v4 3/13 spl: mmc: refactor device location code to its own function
In reply to Nikita KiryanovSimplify spl_mmc_load_image() code by moving the part that finds the mmc device into its own function spl_mmc_find_device(), available in two flavors: DM and non-DM.
This refactor fixes a bug in which an error in the device location sequence does not necessarily aborts the rest of the code. With this refactor, we fail the moment there is an error.
---
Changes in V4:
- s/puts/printf/
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_mmc.c | 77 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 22 deletions(-)
common/spl/spl_mmc.c +55 -22
@@ -11,6 +11,7 @@#include <spl.h> #include <linux/compiler.h> #include <asm/u-boot.h> +#include <errno.h> #include <mmc.h> #include <image.h>
@@ -59,6 +60,58 @@ end:return 0 ; } +#ifdef CONFIG_DM_MMC +static int spl_mmc_find_device (struct mmc **mmc) +{ +struct udevice *dev; +int err; + + err =mmc_initialize (NULL ); +if (err) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +printf ("spl: could not initialize mmc. error: %d\n" , err); +#endif +return err; + } + + err =uclass_get_device (UCLASS_MMC ,0 , &dev); +if (err) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +printf ("spl: could not find mmc device. error: %d\n" , err); +#endif +return err; + } + + *mmc =NULL ; + *mmc =mmc_get_mmc_dev (dev); +return *mmc !=NULL ?0 : -ENODEV ; +} +#else +static int spl_mmc_find_device (struct mmc **mmc) +{ +int err; + + err =mmc_initialize (gd->bd); +if (err) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +printf ("spl: could not initialize mmc. error: %d\n" , err); +#endif +return err; + } + +/* We register only one device. So, the dev id is always 0 */ + *mmc =find_mmc_device (0 ); +if (!*mmc) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +puts ("spl: mmc device not found\n" ); +#endif +return -ENODEV ; + } + +return 0 ; +} +#endif +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION static int mmc_load_image_raw_partition (struct mmc *mmc,int partition) {
@@ -110,30 +163,10 @@ void spl_mmc_load_image(void)int err =0 ;__maybe_unused int part; -#ifdef CONFIG_DM_MMC -struct udevice *dev; - -mmc_initialize (NULL ); - err =uclass_get_device (UCLASS_MMC ,0 , &dev); - mmc =NULL ; -if (!err) - mmc =mmc_get_mmc_dev (dev); -#else -mmc_initialize (gd->bd); - -/* We register only one device. So, the dev id is always 0 */ - mmc =find_mmc_device (0 ); -if (!mmc) { -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -puts ("spl: mmc device not found\n" ); -#endif +if (spl_mmc_find_device (&mmc))hang (); - } -#endif - -if (!err) - err =mmc_init (mmc); + err =mmc_init (mmc);if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: mmc init failed with error: %d\n" , err);
Signature · 1 line
1.9.1
PATCH v4 3/13 spl: mmc: refactor device location code to its own function
Quoted 8 lines · Nikita Kiryanov
Simplify
spl_mmc_load_image()code by moving the part that finds the mmc device into its own functionspl_mmc_find_device(), available in two flavors: DM and non-DM.This refactor fixes a bug in which an error in the device location sequence does not necessarily aborts the rest of the code. With this refactor, we fail the moment there is an error.
Quoted 7 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/98b19400/attachment.sig>
PATCH v4 3/13 spl: mmc: refactor device location code to its own function
In reply to Nikita KiryanovQuoted 8 lines · Nikita Kiryanov
Simplify
spl_mmc_load_image()code by moving the part that finds the mmc device into its own functionspl_mmc_find_device(), available in two flavors: DM and non-DM.This refactor fixes a bug in which an error in the device location sequence does not necessarily aborts the rest of the code. With this refactor, we fail the moment there is an error.
Quoted 8 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/f0a46b20/attachment.sig>
PATCH v4 4/13 spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
In reply to Nikita KiryanovImplement default versions of falcon mode functions to make the CONFIG_SPL_OS_BOOT check in spl_mmc_load_image() unnecessary, thus reducing its #ifdef complexity.
No functional changes.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_ext.c | 6 ++++++ common/spl/spl_fat.c | 6 ++++++ common/spl/spl_mmc.c | 17 +++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-)
common/spl/spl_ext.c +6 -0
@@ -6,6 +6,7 @@#include <spl.h> #include <asm/u-boot.h> #include <ext4fs.h> +#include <errno.h> #include <image.h> #ifdef CONFIG_SPL_EXT_SUPPORT
@@ -135,5 +136,10 @@ defaults:return spl_load_image_ext (block_dev, partition,CONFIG_SPL_FS_LOAD_KERNEL_NAME ); } +#else +int spl_load_image_ext_os (block_dev_desc_t *block_dev,int partition) +{ +return -ENOSYS ; +}#endif #endif
common/spl/spl_fat.c +6 -0
@@ -13,6 +13,7 @@#include <spl.h> #include <asm/u-boot.h> #include <fat.h> +#include <errno.h> #include <image.h> static int fat_registered;
@@ -119,5 +120,10 @@ defaults:return spl_load_image_fat (block_dev, partition,CONFIG_SPL_FS_LOAD_KERNEL_NAME ); } +#else +int spl_load_image_fat_os (block_dev_desc_t *block_dev,int partition) +{ +return -ENOSYS ; +}#endif #endif
common/spl/spl_mmc.c +9 -8
@@ -154,6 +154,15 @@ static int mmc_load_image_raw_os(struct mmc *mmc)return mmc_load_image_raw_sector (mmc, CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR); } +#else +int spl_start_uboot (void ) +{ +return 1 ; +} +static int mmc_load_image_raw_os (struct mmc *mmc) +{ +return -ENOSYS ; +}#endif void spl_mmc_load_image (void )
@@ -179,13 +188,11 @@ void spl_mmc_load_image(void)case MMCSD_MODE_RAW :debug ("spl: mmc boot mode: raw\n" ); -#ifdef CONFIG_SPL_OS_BOOT if (!spl_start_uboot ()) { err =mmc_load_image_raw_os (mmc);if (!err)return ; } -#endif #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ) err =mmc_load_image_raw_partition (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION );
@@ -203,14 +210,12 @@ void spl_mmc_load_image(void)#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION #ifdef CONFIG_SPL_FAT_SUPPORT -#ifdef CONFIG_SPL_OS_BOOT if (!spl_start_uboot ()) { err =spl_load_image_fat_os (&mmc->block_dev,CONFIG_SYS_MMCSD_FS_BOOT_PARTITION );if (!err)return ; } -#endif #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME err = spl_load_image_fat(&mmc->block_dev, CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -220,14 +225,12 @@ void spl_mmc_load_image(void)#endif #endif #ifdef CONFIG_SPL_EXT_SUPPORT -#ifdef CONFIG_SPL_OS_BOOT if (!spl_start_uboot ()) { err =spl_load_image_ext_os (&mmc->block_dev,CONFIG_SYS_MMCSD_FS_BOOT_PARTITION );if (!err)return ; } -#endif #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME err = spl_load_image_ext(&mmc->block_dev, CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -257,13 +260,11 @@ void spl_mmc_load_image(void)hang (); } -#ifdef CONFIG_SPL_OS_BOOT if (!spl_start_uboot ()) { err =mmc_load_image_raw_os (mmc);if (!err)return ; } -#endif #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ) err =mmc_load_image_raw_partition (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION );
Signature · 1 line
1.9.1
PATCH v4 4/13 spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
Quoted 6 lines · Nikita Kiryanov
Implement default versions of falcon mode functions to make the
CONFIG_SPL_OS_BOOTcheck inspl_mmc_load_image()unnecessary, thus reducing its #ifdef complexity.No functional changes.
Quoted 10 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Cc Guillaume GARDET <[email protected]>Cc Suriyan Ramasami <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/2338e4b2/attachment.sig>
PATCH v4 5/13 spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
In reply to Nikita KiryanovImplement defaults for the raw partition image loading so that the #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION in spl_mmc_load_image() will no longer be necessary.
This change makes it possible for mmc_load_image_raw_partition() and mmc_load_image_raw_sector() to coexist.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_mmc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
common/spl/spl_mmc.c +9 -4
@@ -133,6 +133,12 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)return mmc_load_image_raw_sector (mmc, info.start); #endif } +#else +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1 +static int mmc_load_image_raw_partition (struct mmc *mmc,int partition) +{ +return -ENOSYS ; +}#endif #ifdef CONFIG_SPL_OS_BOOT
@@ -193,12 +199,12 @@ void spl_mmc_load_image(void)if (!err)return ; } -#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ) + err =mmc_load_image_raw_partition (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION );if (!err)return ; -#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) err =mmc_load_image_raw_sector (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR );if (!err)
@@ -265,12 +271,11 @@ void spl_mmc_load_image(void)if (!err)return ; } -#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ) err =mmc_load_image_raw_partition (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION );if (!err)return ; -#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) err =mmc_load_image_raw_sector (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR );if (!err)
Signature · 1 line
1.9.1
PATCH v4 5/13 spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
Quoted 7 lines · Nikita Kiryanov
Implement defaults for the raw partition image loading so that the #ifdef
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITIONinspl_mmc_load_image()will no longer be necessary.This change makes it possible for
mmc_load_image_raw_partition()andmmc_load_image_raw_sector()to coexist.
Quoted 8 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/9f62fcb9/attachment.sig>
PATCH v4 6/13 spl: mmc: move fs boot into its own function
In reply to Nikita KiryanovMove the code that handles fs boot out of spl_mmc_load_image() and into its own function to reduce the #ifdef complexity of spl_mmc_load_image().
No functional changes.
---
Changes in V4:
- Fixed typo in commit message.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_mmc.c | 81 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 30 deletions(-)
common/spl/spl_mmc.c +51 -30
@@ -171,6 +171,55 @@ static int mmc_load_image_raw_os(struct mmc *mmc) }#endif +#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION +int spl_mmc_do_fs_boot (struct mmc *mmc) +{ +int err = -ENOSYS ; + +#ifdef CONFIG_SPL_FAT_SUPPORT +if (!spl_start_uboot ()) { + err =spl_load_image_fat_os (&mmc->block_dev, +CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ); +if (!err) +return err; + } +#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME + err =spl_load_image_fat (&mmc->block_dev, +CONFIG_SYS_MMCSD_FS_BOOT_PARTITION , +CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); +if (!err) +return err; +#endif +#endif +#ifdef CONFIG_SPL_EXT_SUPPORT +if (!spl_start_uboot ()) { + err =spl_load_image_ext_os (&mmc->block_dev, +CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ); +if (!err) +return err; + } +#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME + err =spl_load_image_ext (&mmc->block_dev, +CONFIG_SYS_MMCSD_FS_BOOT_PARTITION , +CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); +if (!err) +return err; +#endif +#endif + +#if defined(CONFIG_SPL_FAT_SUPPORT ) || defined(CONFIG_SPL_EXT_SUPPORT ) + err = -ENOENT ; +#endif + +return err; +} +#else +int spl_mmc_do_fs_boot (struct mmc *mmc) +{ +return -ENOSYS ; +} +#endif +void spl_mmc_load_image (void ) {struct mmc *mmc;
@@ -214,38 +263,10 @@ void spl_mmc_load_image(void)case MMCSD_MODE_FS :debug ("spl: mmc boot mode: fs\n" ); -#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION -#ifdef CONFIG_SPL_FAT_SUPPORT -if (!spl_start_uboot ()) { - err =spl_load_image_fat_os (&mmc->block_dev, -CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ); -if (!err) -return ; - } -#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME - err =spl_load_image_fat (&mmc->block_dev, -CONFIG_SYS_MMCSD_FS_BOOT_PARTITION , -CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); -if (!err) -return ; -#endif -#endif -#ifdef CONFIG_SPL_EXT_SUPPORT -if (!spl_start_uboot ()) { - err =spl_load_image_ext_os (&mmc->block_dev, -CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ); -if (!err) -return ; - } -#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME - err =spl_load_image_ext (&mmc->block_dev, -CONFIG_SYS_MMCSD_FS_BOOT_PARTITION , -CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); + err =spl_mmc_do_fs_boot (mmc);if (!err)return ; -#endif -#endif -#endif +break ;#ifdef CONFIG_SUPPORT_EMMC_BOOT case MMCSD_MODE_EMMCBOOT :
Signature · 1 line
1.9.1
PATCH v4 6/13 spl: mmc: move fs boot into its own function
Quoted 5 lines · Nikita Kiryanov
Move the code that handles fs boot out of
spl_mmc_load_image()and into its own function to reduce the #ifdef complexity ofspl_mmc_load_image().No functional changes.
Quoted 8 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/06a11c5d/attachment.sig>
PATCH v4 7/13 spl: mmc: get rid of emmc boot code duplication
In reply to Nikita KiryanovGet rid of emmc boot code duplication in spl_mmc_load_image() using a switch case fallthrough into MMCSD_MODE_RAW. Since the #ifdef CONFIG_SUPPORT_EMMC_BOOT check is not really necessary, remove it in the process.
No functional changes.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl_mmc.c | 54 ++++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-)
common/spl/spl_mmc.c +18 -36
@@ -240,6 +240,24 @@ void spl_mmc_load_image(void) boot_mode =spl_boot_mode ();switch (boot_mode) { +case MMCSD_MODE_EMMCBOOT : +/* +* We need to check what the partition is configured to. +* 1 and 2 match up to boot0 / boot1 and 7 is user data +* which is the first physical partition (0). +*/ + part = (mmc->part_config >>3 ) &PART_ACCESS_MASK ; + +if (part ==7 ) + part =0 ; + +if (mmc_switch_part (0 , part)) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +puts ("spl: mmc partition switch failed\n" ); +#endif +hang (); + } +/* Fall through */ case MMCSD_MODE_RAW :debug ("spl: mmc boot mode: raw\n" );
@@ -268,42 +286,6 @@ void spl_mmc_load_image(void)return ;break ; -#ifdef CONFIG_SUPPORT_EMMC_BOOT -case MMCSD_MODE_EMMCBOOT : -/* -* We need to check what the partition is configured to. -* 1 and 2 match up to boot0 / boot1 and 7 is user data -* which is the first physical partition (0). -*/ - part = (mmc->part_config >>3 ) &PART_ACCESS_MASK ; - -if (part ==7 ) - part =0 ; - -if (mmc_switch_part (0 , part)) { -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -puts ("spl: mmc partition switch failed\n" ); -#endif -hang (); - } - -if (!spl_start_uboot ()) { - err =mmc_load_image_raw_os (mmc); -if (!err) -return ; - } - err =mmc_load_image_raw_partition (mmc, -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ); -if (!err) -return ; -#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) - err =mmc_load_image_raw_sector (mmc, -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ); -if (!err) -return ; -#endif -break ; -#endif case MMCSD_MODE_UNDEFINED :#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT default :
Signature · 1 line
1.9.1
PATCH v4 7/13 spl: mmc: get rid of emmc boot code duplication
Quoted 6 lines · Nikita Kiryanov
Get rid of emmc boot code duplication in
spl_mmc_load_image()using a switch case fallthrough intoMMCSD_MODE_RAW. Since the #ifdefCONFIG_SUPPORT_EMMC_BOOTcheck is not really necessary, remove it in the process.No functional changes.
Quoted 8 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Paul Kocialkowski <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/84d1f036/attachment.sig>
PATCH v4 8/13 spl: change return values of spl_*_load_image()
In reply to Nikita KiryanovMake spl_*_load_image() functions return a value instead of hanging if a problem is encountered. This enables main spl code to make the decision whether to hang or not, thus preparing it to support alternative boot devices.
Some boot devices (namely nand and spi) do not hang on error. Instead, they return normally and SPL proceeds to boot the contents of the load address. This is considered a bug and is rectified by hanging on error for these devices as well.
---
Changes in V4:
- No changes.
Changes in V3:
- Added documentation for spl_board_load_image().
Changes in V2:
- Minor collateral adjustments from changes in patch 2 (only one return statement at the end of spl_mmc_load_image).
arch/arm/cpu/armv7/sunxi/board.c | 4 +++- arch/arm/include/asm/spl.h | 10 ++++++++-- common/spl/spl.c | 43 +++++++++++++++++++++++++++------------- common/spl/spl_mmc.c | 26 ++++++++++++++---------- common/spl/spl_nand.c | 18 +++++++++++------ common/spl/spl_net.c | 9 ++++++--- common/spl/spl_nor.c | 6 ++++-- common/spl/spl_onenand.c | 4 +++- common/spl/spl_sata.c | 11 +++++++--- common/spl/spl_usb.c | 17 ++++++++++------ common/spl/spl_ymodem.c | 5 +++-- drivers/mtd/spi/spi_spl_load.c | 17 +++++++++++----- include/spl.h | 18 ++++++++--------- 13 files changed, 123 insertions(+), 65 deletions(-)
arch/arm/cpu/armv7/sunxi/board.c +3 -1
@@ -95,10 +95,12 @@ static int gpio_init(void)return 0 ; } -void spl_board_load_image (void ) +int spl_board_load_image (void ) {debug ("Returning to FEL sp=%x, lr=%x\n" , fel_stash.sp, fel_stash.lr);return_to_fel (fel_stash.sp, fel_stash.lr); + +return 0 ; }void s_init (void )
arch/arm/include/asm/spl.h +8 -2
@@ -31,8 +31,14 @@ enum { };#endif -/* Board-specific load method */ -void spl_board_load_image (void ); +/** +* Board specific load method for boards that have a special way of loading +* U-Boot, which does not fit with the existing SPL code. +* +* @return 0 on success, negative errno value on failure. +*/ + +int spl_board_load_image (void );/* Linker symbols. */ extern char __bss_start[], __bss_end[];
common/spl/spl.c +29 -14
110 lines not on this page · raw message
common/spl/spl_mmc.c +15 -11
@@ -10,6 +10,7 @@#include <dm.h> #include <spl.h> #include <linux/compiler.h> +#include <errno.h> #include <asm/u-boot.h> #include <errno.h> #include <mmc.h>
@@ -220,25 +221,27 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) }#endif -void spl_mmc_load_image (void ) +int spl_mmc_load_image (void ) {struct mmc *mmc;u32 boot_mode;int err =0 ;__maybe_unused int part; -if (spl_mmc_find_device (&mmc)) -hang (); + err =spl_mmc_find_device (&mmc); +if (err) +return err; err =mmc_init (mmc);if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: mmc init failed with error: %d\n" , err);#endif -hang (); +return err; } boot_mode =spl_boot_mode (); + err = -EINVAL ;switch (boot_mode) {case MMCSD_MODE_EMMCBOOT :/*
@@ -251,11 +254,12 @@ void spl_mmc_load_image(void)if (part ==7 ) part =0 ; -if (mmc_switch_part (0 , part)) { + err =mmc_switch_part (0 , part); +if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts ("spl: mmc partition switch failed\n" );#endif -hang (); +return err; }/* Fall through */ case MMCSD_MODE_RAW :
@@ -264,18 +268,18 @@ void spl_mmc_load_image(void)if (!spl_start_uboot ()) { err =mmc_load_image_raw_os (mmc);if (!err) -return ; +return err; } err =mmc_load_image_raw_partition (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION );if (!err) -return ; +return err;#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ) err =mmc_load_image_raw_sector (mmc,CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR );if (!err) -return ; +return err;#endif break ;case MMCSD_MODE_FS :
@@ -283,7 +287,7 @@ void spl_mmc_load_image(void) err =spl_mmc_do_fs_boot (mmc);if (!err) -return ; +return err;break ;case MMCSD_MODE_UNDEFINED :
@@ -293,5 +297,5 @@ void spl_mmc_load_image(void)#endif } -hang (); +return err; }
common/spl/spl_nand.c +12 -6
@@ -11,7 +11,7 @@#include <nand.h> #if defined(CONFIG_SPL_NAND_RAW_ONLY ) -void spl_nand_load_image (void ) +int spl_nand_load_image (void ) {nand_init ();
@@ -20,6 +20,8 @@ void spl_nand_load_image(void) (void *)CONFIG_SYS_NAND_U_BOOT_DST);spl_set_header_raw_uboot ();nand_deselect (); + + return 0; }#else static int spl_nand_load_element (int offset,struct image_header *header)
@@ -35,8 +37,9 @@ static int spl_nand_load_element(int offset, struct image_header *header) (void *)spl_image.load_addr); } -void spl_nand_load_image (void ) +int spl_nand_load_image (void ) { +int err;struct image_header *header; int *src __attribute__((unused)); int *dst __attribute__((unused));
@@ -73,10 +76,12 @@ void spl_nand_load_image(void)spl_parse_image_header (header);if (header->ih_os ==IH_OS_LINUX ) {/* happy - was a linux */ -nand_spl_load_image (CONFIG_SYS_NAND_SPL_KERNEL_OFFS , - spl_image.size, (void *)spl_image.load_addr); + err =nand_spl_load_image ( +CONFIG_SYS_NAND_SPL_KERNEL_OFFS , + spl_image.size, + (void *)spl_image.load_addr);nand_deselect (); -return ; +return err; }else {puts ("The Expected Linux image was not " "found. Please check your NAND "
@@ -92,7 +97,8 @@ void spl_nand_load_image(void)#endif #endif /* Load u-boot */ -spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS , header); + err =spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS , header);nand_deselect (); + return err; }#endif
common/spl/spl_net.c +6 -3
@@ -8,12 +8,13 @@* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> +#include <errno.h> #include <spl.h> #include <net.h> DECLARE_GLOBAL_DATA_PTR ; -void spl_net_load_image (const char *device) +int spl_net_load_image (const char *device) {int rv;
@@ -24,14 +25,16 @@ void spl_net_load_image(const char *device) rv =eth_initialize ();if (rv ==0 ) {printf ("No Ethernet devices found\n" ); -hang (); +return -ENODEV ; }if (device)setenv ("ethact" , device); rv =net_loop (BOOTP );if (rv <0 ) {printf ("Problem booting with BOOTP\n" ); -hang (); +return rv; }spl_parse_image_header ((struct image_header *)load_addr); + +return 0 ; }
common/spl/spl_nor.c +4 -2
@@ -7,7 +7,7 @@#include <common.h> #include <spl.h> -void spl_nor_load_image (void ) +int spl_nor_load_image (void ) {/* * Loading of the payload to SDRAM is done with skipping of
@@ -43,7 +43,7 @@ void spl_nor_load_image(void) (void *)(CONFIG_SYS_FDT_BASE ), (16 << 10)); -return ; +return 0 ; }else {puts ("The Expected Linux image was not found.\n" "Please check your NOR configuration.\n"
@@ -62,4 +62,6 @@ void spl_nor_load_image(void)memcpy ((void *)spl_image.load_addr, (void *)(CONFIG_SYS_UBOOT_BASE +sizeof (struct image_header )), spl_image.size); + +return 0 ; }
common/spl/spl_onenand.c +3 -1
@@ -14,7 +14,7 @@#include <asm/io.h> #include <onenand_uboot.h> -void spl_onenand_load_image (void ) +int spl_onenand_load_image (void ) {struct image_header *header;
@@ -28,4 +28,6 @@ void spl_onenand_load_image(void)spl_parse_image_header (header);onenand_spl_load_image (CONFIG_SYS_ONENAND_U_BOOT_OFFS , spl_image.size, (void *)spl_image.load_addr); + +return 0 ; }
common/spl/spl_sata.c +8 -3
@@ -14,12 +14,13 @@#include <asm/u-boot.h> #include <sata.h> #include <scsi.h> +#include <errno.h> #include <fat.h> #include <image.h> DECLARE_GLOBAL_DATA_PTR ; -void spl_sata_load_image (void ) +int spl_sata_load_image (void ) {int err;block_dev_desc_t *stor_dev;
@@ -29,11 +30,13 @@ void spl_sata_load_image(void)#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: sata init failed: err - %d\n" , err);#endif -hang (); +return err; }else {/* try to recognize storage devices immediately */ scsi_scan (0 ); stor_dev =scsi_get_dev (0 ); +if (!stor_dev) +return -ENODEV ; }#ifdef CONFIG_SPL_OS_BOOT
@@ -45,6 +48,8 @@ void spl_sata_load_image(void) CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);if (err) {puts ("Error loading sata device\n" ); -hang (); +return err; } + +return 0 ; }
common/spl/spl_usb.c +11 -6
@@ -12,6 +12,7 @@#include <common.h> #include <spl.h> #include <asm/u-boot.h> +#include <errno.h> #include <usb.h> #include <fat.h>
@@ -21,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;static int usb_stor_curr_dev =-1 ;/* current device */ #endif -void spl_usb_load_image (void ) +int spl_usb_load_image (void ) {int err;block_dev_desc_t *stor_dev;
@@ -32,13 +33,15 @@ void spl_usb_load_image(void)#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("%s: usb init failed: err - %d\n" , __func__, err);#endif -hang (); +return err; }#ifdef CONFIG_USB_STORAGE /* try to recognize storage devices immediately */ usb_stor_curr_dev =usb_stor_scan (1 ); stor_dev =usb_stor_get_dev (usb_stor_curr_dev); +if (!stor_dev) +return -ENODEV ;#endif debug ("boot mode - FAT\n" );
@@ -51,8 +54,10 @@ void spl_usb_load_image(void)CONFIG_SYS_USB_FAT_BOOT_PARTITION , CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); -if (err) { -puts ("Error loading USB device\n" ); -hang (); - } +if (err) { +puts ("Error loading from USB device\n" ); +return err; + } + +return 0 ; }
common/spl/spl_ymodem.c +3 -2
@@ -23,7 +23,7 @@ static int getcymodem(void) {return -1 ; } -void spl_ymodem_load_image (void ) +int spl_ymodem_load_image (void ) {int size =0 ;int err;
@@ -49,11 +49,12 @@ void spl_ymodem_load_image(void) } }else {printf ("spl: ymodem err - %s\n" ,xyzModem_error (err)); -hang (); +return ret; }xyzModem_stream_close (&err);xyzModem_stream_terminate (false, &getcymodem);printf ("Loaded %d bytes\n" , size); +return 0 ; }
drivers/mtd/spi/spi_spl_load.c +12 -5
@@ -12,6 +12,7 @@#include <common.h> #include <spi.h> #include <spi_flash.h> +#include <errno.h> #include <spl.h> #ifdef CONFIG_SPL_OS_BOOT
@@ -48,8 +49,9 @@ static int spi_load_image_os(struct spi_flash *flash,* configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -void spl_spi_load_image (void ) +int spl_spi_load_image (void ) { +int err =0 ;struct spi_flash *flash;struct image_header *header;
@@ -63,7 +65,7 @@ void spl_spi_load_image(void) CONFIG_SF_DEFAULT_MODE);if (!flash) {puts ("SPI probe failed.\n" ); -hang (); +return -ENODEV ; }/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
@@ -74,10 +76,15 @@ void spl_spi_load_image(void)#endif {/* Load u-boot, mkimage header is 64 bytes. */ -spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS ,0x40 , - (void *)header); + err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS ,0x40 , + (void *)header); +if (err) +return err; +spl_parse_image_header (header); -spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , + err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , spl_image.size, (void *)spl_image.load_addr); } + +return err; }
include/spl.h +9 -9
@@ -45,31 +45,31 @@ int spl_start_uboot(void);void spl_display_print (void );/* NAND SPL functions */ -void spl_nand_load_image (void ); +int spl_nand_load_image (void );/* OneNAND SPL functions */ -void spl_onenand_load_image (void ); +int spl_onenand_load_image (void );/* NOR SPL functions */ -void spl_nor_load_image (void ); +int spl_nor_load_image (void );/* MMC SPL functions */ -void spl_mmc_load_image (void ); +int spl_mmc_load_image (void );/* YMODEM SPL functions */ -void spl_ymodem_load_image (void ); +int spl_ymodem_load_image (void );/* SPI SPL functions */ -void spl_spi_load_image (void ); +int spl_spi_load_image (void );/* Ethernet SPL functions */ -void spl_net_load_image (const char *device); +int spl_net_load_image (const char *device);/* USB SPL functions */ -void spl_usb_load_image (void ); +int spl_usb_load_image (void );/* SATA SPL functions */ -void spl_sata_load_image (void ); +int spl_sata_load_image (void );/* SPL FAT image functions */ int spl_load_image_fat (block_dev_desc_t *block_dev,int partition,const char *filename);
Signature · 1 line
1.9.1
PATCH v4 8/13 spl: change return values of spl_*_load_image()
Quoted 10 lines · Nikita Kiryanov
Make spl_*_load_image() functions return a value instead of hanging if a problem is encountered. This enables main spl code to make the decision whether to hang or not, thus preparing it to support alternative boot devices.
Some boot devices (namely nand and spi) do not hang on error. Instead, they return normally and SPL proceeds to boot the contents of the load address. This is considered a bug and is rectified by hanging on error for these devices as well.
Quoted 10 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Cc Ian Campbell <[email protected]>Cc Hans De Goede <[email protected]>Cc Albert Aribaud <[email protected]>Cc Jagan Teki <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/22108db7/attachment.sig>
PATCH v4 9/13 common: spl: move image load to its own function
In reply to Nikita KiryanovRefactor spl image load code out of board_init_r and into its own function. This is a preparation for supporting alternative boot devices.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl.c | 117 ++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 67 deletions(-)
common/spl/spl.c +50 -67
@@ -178,122 +178,105 @@ int spl_init(void)return 0 ; } -void board_init_r (gd_t *dummy1,ulong dummy2) +static int spl_load_image (u32 boot_device) { -u32 boot_device; - -debug (">>spl:board_init_r()\n" ); - -#if defined(CONFIG_SYS_SPL_MALLOC_START ) -mem_malloc_init (CONFIG_SYS_SPL_MALLOC_START , -CONFIG_SYS_SPL_MALLOC_SIZE ); - gd->flags |=GD_FLG_FULL_MALLOC_INIT ; -#endif -if (!(gd->flags &GD_FLG_SPL_INIT )) { -if (spl_init ()) -hang (); - } -#ifndef CONFIG_PPC -/* -* timer_init() does not exist on PPC systems. The timer is initialized -* and enabled (decrementer) in interrupt_init() here. -*/ -timer_init (); -#endif - -#ifdef CONFIG_SPL_BOARD_INIT -spl_board_init (); -#endif - - boot_device =spl_boot_device (); -debug ("boot device - %d\n" , boot_device);switch (boot_device) {#ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM : -if (spl_ram_load_image ()) -hang (); -break ; +return spl_ram_load_image ();#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :case BOOT_DEVICE_MMC2_2 : -if (spl_mmc_load_image ()) -hang (); -break ; +return spl_mmc_load_image ();#endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND : -if (spl_nand_load_image ()) -hang (); -break ; +return spl_nand_load_image ();#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND : -if (spl_onenand_load_image ()) -hang (); -break ; +return spl_onenand_load_image ();#endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR : -if (spl_nor_load_image ()) -hang (); -break ; +return spl_nor_load_image ();#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART : -if (spl_ymodem_load_image ()) -hang (); -break ; +return spl_ymodem_load_image ();#endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI : -if (spl_spi_load_image ()) -hang (); -break ; +return spl_spi_load_image ();#endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC :#ifdef CONFIG_SPL_ETH_DEVICE -if (spl_net_load_image (CONFIG_SPL_ETH_DEVICE )) -hang (); +return spl_net_load_image (CONFIG_SPL_ETH_DEVICE );#else -if (spl_net_load_image (NULL )) -hang (); +return spl_net_load_image (NULL );#endif -break ;#endif #ifdef CONFIG_SPL_USBETH_SUPPORT case BOOT_DEVICE_USBETH : -if (spl_net_load_image ("usb_ether" )) -hang (); -break ; +return spl_net_load_image ("usb_ether" );#endif #ifdef CONFIG_SPL_USB_SUPPORT case BOOT_DEVICE_USB : -if (spl_usb_load_image ()) -hang (); -break ; +return spl_usb_load_image ();#endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA : -if (spl_sata_load_image ()) -hang (); -break ; +return spl_sata_load_image ();#endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD : -if (spl_board_load_image ()) -hang (); -break ; +return spl_board_load_image ();#endif default :#if defined(CONFIG_SPL_SERIAL_SUPPORT ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT )puts ("SPL: Unsupported Boot Device!\n" );#endif -hang (); +return -ENODEV ; } +return -EINVAL ; +} + +void board_init_r (gd_t *dummy1,ulong dummy2) +{ +u32 boot_device; + +debug (">>spl:board_init_r()\n" ); + +#if defined(CONFIG_SYS_SPL_MALLOC_START ) +mem_malloc_init (CONFIG_SYS_SPL_MALLOC_START , +CONFIG_SYS_SPL_MALLOC_SIZE ); + gd->flags |=GD_FLG_FULL_MALLOC_INIT ; +#endif +if (!(gd->flags &GD_FLG_SPL_INIT )) { +if (spl_init ()) +hang (); + } +#ifndef CONFIG_PPC +/* +* timer_init() does not exist on PPC systems. The timer is initialized +* and enabled (decrementer) in interrupt_init() here. +*/ +timer_init (); +#endif + +#ifdef CONFIG_SPL_BOARD_INIT +spl_board_init (); +#endif + + boot_device =spl_boot_device (); +debug ("boot device - %d\n" , boot_device); +if (spl_load_image (boot_device)) +hang (); +switch (spl_image.os) {case IH_OS_U_BOOT :debug ("Jumping to U-Boot\n" );
Signature · 1 line
1.9.1
PATCH v4 9/13 common: spl: move image load to its own function
Quoted 10 lines · Nikita Kiryanov
Refactor spl image load code out of
board_init_rand into its own function. This is a preparation for supporting alternative boot devices.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/01f9dccd/attachment.sig>
PATCH v4 10/13 spl: add support for alternative boot device
In reply to Nikita KiryanovIntroduce spl_boot_list array, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of only spl_boot_device(), but board_boot_order() can be overridden by board code to populate the array with custom values.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
common/spl/spl.c +29 -4
@@ -178,6 +178,23 @@ int spl_init(void)return 0 ; } +#ifndef BOOT_DEVICE_NONE +#define BOOT_DEVICE_NONE 0xdeadbeef +#endif + +static u32 spl_boot_list[] = { +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +}; + +__weak void board_boot_order (u32 *spl_boot_list) +{ + spl_boot_list[0 ] =spl_boot_device (); +} +static int spl_load_image (u32 boot_device) {switch (boot_device) {
@@ -247,7 +264,7 @@ static int spl_load_image(u32 boot_device)void board_init_r (gd_t *dummy1,ulong dummy2) { -u32 boot_device; +int i;debug (">>spl:board_init_r()\n" );
@@ -272,10 +289,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2)spl_board_init ();#endif - boot_device =spl_boot_device (); -debug ("boot device - %d\n" , boot_device); -if (spl_load_image (boot_device)) +board_boot_order (spl_boot_list); +for (i =0 ; i <ARRAY_SIZE (spl_boot_list) && + spl_boot_list[i] !=BOOT_DEVICE_NONE ; i++) { +if (!spl_load_image (spl_boot_list[i])) +break ; + } + +if (i ==ARRAY_SIZE (spl_boot_list) || + spl_boot_list[i] ==BOOT_DEVICE_NONE ) { +puts ("SPL: failed to boot from all boot devices\n" );hang (); + }switch (spl_image.os) {case IH_OS_U_BOOT :
Signature · 1 line
1.9.1
PATCH v4 10/13 spl: add support for alternative boot device
Quoted 14 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
Changes in V4:
- No changes.
Quoted 8 lines
Changes in V3:
- No changes.Changes in V2:
- No changes.common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
PATCH v4 10/13 spl: add support for alternative boot device
In reply to Nikita KiryanovQuoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/890f30f5/attachment.sig>
PATCH v4 10/13 spl: add support for alternative boot device
Hi Tom,
Quoted 14 lines · Tom Rini
Quoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 5 lines
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Based on the content of your reply I'm guessing you're referring to the next patch, not this one.
I suppose that announcing can be made into an optional feature. However, I also think that since printing is an optional feature that can greatly increase binary size, it shouldn't be coupled with other, often non-optional libcommon features the way it currently is via CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to implement a way to exclude printing support from SPL even if libcommon is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).
This will also make it possible to remove all those #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.
Quoted 3 lines
Signature · 2 lines
-- Tom
PATCH v4 10/13 spl: add support for alternative boot device
Quoted 34 lines · Nikita Kiryanov
Hi Tom,
Quoted 14 lines · Tom Rini
Quoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 5 lines
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Based on the content of your reply I'm guessing you're referring to the next patch, not this one.
I suppose that announcing can be made into an optional feature. However, I also think that since printing is an optional feature that can greatly increase binary size, it shouldn't be coupled with other, often non-optional libcommon features the way it currently is via
CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to implement a way to exclude printing support from SPL even if libcommon is included (CONFIG_SPL_SILENTthat replaces printfs with empty stubs?).
Quoted 2 lines
This will also make it possible to remove all those #ifdef
CONFIG_SPL_LIBCOMMON_SUPPORTchecks that appear all over the SPL code.
I think that my recently posted tiny-printf patches:
https://patchwork.ozlabs.org/patch/545034/
https://patchwork.ozlabs.org/patch/545033/
https://patchwork.ozlabs.org/patch/545036/
https://patchwork.ozlabs.org/patch/545035/
can solve this size issue on x600 (and perhaps other) board.
Comments welcome...
Thanks,
Stefan
PATCH v4 10/13 spl: add support for alternative boot device
Quoted 38 lines · Stefan Roese
Quoted 34 lines · Nikita Kiryanov
Hi Tom,
Quoted 14 lines · Tom Rini
Quoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 5 lines
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Based on the content of your reply I'm guessing you're referring to the next patch, not this one.
I suppose that announcing can be made into an optional feature. However, I also think that since printing is an optional feature that can greatly increase binary size, it shouldn't be coupled with other, often non-optional libcommon features the way it currently is via
CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to implement a way to exclude printing support from SPL even if libcommon is included (CONFIG_SPL_SILENTthat replaces printfs with empty stubs?).Quoted 2 lines
This will also make it possible to remove all those #ifdef
CONFIG_SPL_LIBCOMMON_SUPPORTchecks that appear all over the SPL code.
Quoted 8 lines
I think that my recently posted tiny-printf patches:
https://patchwork.ozlabs.org/patch/545034/
https://patchwork.ozlabs.org/patch/545033/
https://patchwork.ozlabs.org/patch/545036/
https://patchwork.ozlabs.org/patch/545035/can solve this size issue on x600 (and perhaps other) board.
If you can see if x600 builds again in mainline that would be good :)
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151119/8ffdd81f/attachment.sig>
PATCH v4 10/13 spl: add support for alternative boot device
Hi Tom,
Quoted 41 lines · Tom Rini
Quoted 40 lines · Stefan Roese
Quoted 34 lines · Nikita Kiryanov
Hi Tom,
Quoted 14 lines · Tom Rini
Quoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 5 lines
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Based on the content of your reply I'm guessing you're referring to the next patch, not this one.
I suppose that announcing can be made into an optional feature. However, I also think that since printing is an optional feature that can greatly increase binary size, it shouldn't be coupled with other, often non-optional libcommon features the way it currently is via
CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to implement a way to exclude printing support from SPL even if libcommon is included (CONFIG_SPL_SILENTthat replaces printfs with empty stubs?).Quoted 2 lines
This will also make it possible to remove all those #ifdef
CONFIG_SPL_LIBCOMMON_SUPPORTchecks that appear all over the SPL code.I think that my recently posted tiny-printf patches:
Quoted 8 lines
Quoted 6 lines
https://patchwork.ozlabs.org/patch/545034/
https://patchwork.ozlabs.org/patch/545033/
https://patchwork.ozlabs.org/patch/545036/
https://patchwork.ozlabs.org/patch/545035/can solve this size issue on x600 (and perhaps other) board.
If you can see if x600 builds again in mainline that would be good :)
Yes, I can confirm, that build with the tiny-printf fixes the build issue on x600. So once you add this tiny-printf patchset, I'll send a patch to move x600 over to use this smaller version.
Thanks,
Stefan
PATCH v4 10/13 spl: add support for alternative boot device
In reply to Nikita KiryanovQuoted 17 lines · Nikita Kiryanov
Hi Tom,
Quoted 14 lines · Tom Rini
Quoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
Quoted 5 lines
So, a problem with this patch is that we push the x600 board, which is an 8KiB SPL target, over the line. I feel like maybe we need a follow-up patch that makes announcing depend not on libcommon (which x600 needs) but something else to know that there's a reason to announce.
Based on the content of your reply I'm guessing you're referring to the next patch, not this one.
Oh yes, oops.
Quoted 10 lines
I suppose that announcing can be made into an optional feature. However, I also think that since printing is an optional feature that can greatly increase binary size, it shouldn't be coupled with other, often non-optional libcommon features the way it currently is via
CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to implement a way to exclude printing support from SPL even if libcommon is included (CONFIG_SPL_SILENTthat replaces printfs with empty stubs?).This will also make it possible to remove all those #ifdef
CONFIG_SPL_LIBCOMMON_SUPPORTchecks that appear all over the SPL code.
So the reason I'm thinking that we want this announce thing separate is that (due to the way you re-worked it I think, based on Simons' request) this added a huge amount of space. We went from OK to overflowing by more than 1KiB. So I'm not immediately sure that we can regain that space with a more (space) efficient printing infrastructure.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151119/8c906c6b/attachment.sig>
PATCH v4 10/13 spl: add support for alternative boot device
In reply to Nikita KiryanovQuoted 11 lines · Nikita Kiryanov
Introduce
spl_boot_listarray, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of onlyspl_boot_device(), butboard_boot_order()can be overridden by board code to populate the array with custom values.Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/5334ebbc/attachment.sig>
PATCH v4 11/13 spl: announce boot devices
In reply to Nikita KiryanovNow that we support alternative boot devices, it can sometimes be unclear which boot devices was actually used. Provide a function to announce which boot devices are attempted during boot.
---
Changes in V2:
- Moved new code to be located after #ifndef BOOT_DEVICE_NONE
Changes in V3:
- Reworked announce_boot_device() to make the code less repititive by utilizing a table of boot_device --> name.
Changes in V2:
- No changes.
common/spl/spl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
common/spl/spl.c +79 -0
@@ -195,6 +195,84 @@ __weak void board_boot_order(u32 *spl_boot_list) spl_boot_list[0 ] =spl_boot_device (); } +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +__weak void spl_board_announce_boot_device (void ) { } +#endif + +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +struct boot_device_name { + u32 boot_dev; + const char *name; +}; + +struct boot_device_name boot_name_table[] = { +#ifdef CONFIG_SPL_RAM_DEVICE + { BOOT_DEVICE_RAM, "RAM" }, +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT + { BOOT_DEVICE_MMC1, "MMC" }, + { BOOT_DEVICE_MMC2, "MMC" }, + { BOOT_DEVICE_MMC2_2, "MMC" }, +#endif +#ifdef CONFIG_SPL_NAND_SUPPORT + { BOOT_DEVICE_NAND, "NAND" }, +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT + { BOOT_DEVICE_ONENAND, "OneNAND" }, +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT + { BOOT_DEVICE_NOR, "NOR" }, +#endif +#ifdef CONFIG_SPL_YMODEM_SUPPORT + { BOOT_DEVICE_UART, "UART" }, +#endif +#ifdef CONFIG_SPL_SPI_SUPPORT + { BOOT_DEVICE_SPI, "SPI" }, +#endif +#ifdef CONFIG_SPL_ETH_SUPPORT +#ifdef CONFIG_SPL_ETH_DEVICE + { BOOT_DEVICE_CPGMAC, "eth device" }, +#else + { BOOT_DEVICE_CPGMAC, "net" }, +#endif +#endif +#ifdef CONFIG_SPL_USBETH_SUPPORT + { BOOT_DEVICE_USBETH, "USB eth" }, +#endif +#ifdef CONFIG_SPL_USB_SUPPORT + { BOOT_DEVICE_USB, "USB" }, +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT + { BOOT_DEVICE_SATA, "SATA" }, +#endif + /* Keep this entry last */ + { BOOT_DEVICE_NONE, "unknown boot device" }, +}; + +static void announce_boot_device(u32 boot_device) +{ + int i; + + puts("Trying to boot from "); + +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE + if (boot_device == BOOT_DEVICE_BOARD) { + spl_board_announce_boot_device(); + puts("\n"); + return; + } +#endif + for (i = 0; i < ARRAY_SIZE(boot_name_table) - 1; i++) { + if (boot_name_table[i].boot_dev == boot_device) + break; + } + + printf("%s\n", boot_name_table[i].name); +} +#else +static inline void announce_boot_device(u32 boot_device) { } +#endif + static int spl_load_image(u32 boot_device) { switch (boot_device) {
@@ -292,6 +370,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)board_boot_order (spl_boot_list);for (i =0 ; i <ARRAY_SIZE (spl_boot_list) && spl_boot_list[i] !=BOOT_DEVICE_NONE ; i++) { +announce_boot_device (spl_boot_list[i]);if (!spl_load_image (spl_boot_list[i]))break ; }
Signature · 1 line
1.9.1
PATCH v4 11/13 spl: announce boot devices
Quoted 17 lines · Nikita Kiryanov
Now that we support alternative boot devices, it can sometimes be unclear which boot devices was actually used. Provide a function to announce which boot devices are attempted during boot.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
Changes in V2:
- Moved new code to be located after #ifndefBOOT_DEVICE_NONEChanges in V3:
- Reworkedannounce_boot_device()to make the code less repititive by utilizing a table ofboot_device--> name.
Quoted 5 lines
Changes in V2:
- No changes.common/spl/spl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
PATCH v4 11/13 spl: announce boot devices
In reply to Nikita KiryanovQuoted 10 lines · Nikita Kiryanov
Now that we support alternative boot devices, it can sometimes be unclear which boot devices was actually used. Provide a function to announce which boot devices are attempted during boot.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/1575ebfe/attachment.sig>
PATCH v4 12/13 arm: mx6: cm-fx6: define fallback boot devices for spl
In reply to Nikita KiryanovUse spl alternate boot device feature to define fallback to the main boot device as it is defined by hardware.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- No changes.
board/compulab/cm_fx6/spl.c | 19 ++++++++++--------- include/configs/cm_fx6.h | 1 - 2 files changed, 10 insertions(+), 10 deletions(-)
board/compulab/cm_fx6/spl.c +10 -9
@@ -337,16 +337,17 @@ void board_init_f(ulong dummy)board_init_r (NULL ,0 ); } -void spl_board_init (void ) +void board_boot_order (u32 *spl_boot_list) { -u32 boot_device =spl_boot_device (); - -if (boot_device ==BOOT_DEVICE_SPI ) -puts ("Booting from SPI flash\n" ); -else if (boot_device ==BOOT_DEVICE_MMC1 ) -puts ("Booting from MMC\n" ); -else -puts ("Unknown boot device\n" ); + spl_boot_list[0 ] =spl_boot_device (); +switch (spl_boot_list[0 ]) { +case BOOT_DEVICE_SPI : + spl_boot_list[1 ] =BOOT_DEVICE_MMC1 ; +break ; +case BOOT_DEVICE_MMC1 : + spl_boot_list[1 ] =BOOT_DEVICE_SPI ; +break ; + } }#ifdef CONFIG_SPL_MMC_SUPPORT
include/configs/cm_fx6.h +0 -1
@@ -230,7 +230,6 @@/* SPL */ #include "imx6_spl.h" -#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_MMC_SUPPORT #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x80/* offset 64 kb */ #define CONFIG_SYS_MONITOR_LEN (CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS / 2 * 1024)
Signature · 1 line
1.9.1
PATCH v4 12/13 arm: mx6: cm-fx6: define fallback boot devices for spl
Quoted 9 lines · Nikita Kiryanov
Use spl alternate boot device feature to define fallback to the main boot device as it is defined by hardware.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Igor Grinberg <[email protected]>Cc Stefano Babic <[email protected]>Cc Tom Rini <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/404aa6f6/attachment.sig>
PATCH v4 13/13 spl: mmc: add support for BOOT_DEVICE_MMC2
In reply to Nikita KiryanovCurrently the mmc device that SPL looks at is always mmc0, regardless of the BOOT_DEVICE_MMCx value. This forces some boards to implement hacks in order to boot from other mmc devices.
Make SPL take into account the correct mmc device.
---
Changes in V4:
- No changes.
Changes in V3:
- No changes.
Changes in V2:
- New patch.
arch/arm/cpu/armv7/sunxi/board.c | 10 +--------- common/spl/spl.c | 2 +- common/spl/spl_mmc.c | 41 ++++++++++++++++++++++++++++++++-------- include/spl.h | 2 +- 4 files changed, 36 insertions(+), 19 deletions(-)
arch/arm/cpu/armv7/sunxi/board.c +1 -9
@@ -173,16 +173,8 @@ u32 spl_boot_device(void)#ifdef CONFIG_MMC if (CONFIG_MMC_SUNXI_SLOT_EXTRA ==2 ) { mmc1 =find_mmc_device (1 ); -if (sunxi_mmc_has_egon_boot_signature (mmc1)) { -/* -* spl_mmc.c: spl_mmc_load_image() is hard-coded to -* use find_mmc_device(0), no matter what we -* return. Swap mmc0 and mmc2 to make this work. -*/ - mmc0->block_dev.dev =1 ; - mmc1->block_dev.dev =0 ; +if (sunxi_mmc_has_egon_boot_signature (mmc1))return BOOT_DEVICE_MMC2 ; - } }#endif
common/spl/spl.c +1 -1
@@ -284,7 +284,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :case BOOT_DEVICE_MMC2_2 : -return spl_mmc_load_image (); +return spl_mmc_load_image (boot_device);#endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :
common/spl/spl_mmc.c +33 -8
81 lines not on this page · raw message
include/spl.h +1 -1
@@ -54,7 +54,7 @@ int spl_onenand_load_image(void);int spl_nor_load_image (void );/* MMC SPL functions */ -int spl_mmc_load_image (void ); +int spl_mmc_load_image (u32 boot_device);/* YMODEM SPL functions */ int spl_ymodem_load_image (void );
Signature · 1 line
1.9.1
PATCH v4 13/13 spl: mmc: add support for BOOT_DEVICE_MMC2
Quoted 8 lines · Nikita Kiryanov
Currently the mmc device that SPL looks at is always mmc0, regardless of the
BOOT_DEVICE_MMCxvalue. This forces some boards to implement hacks in order to boot from other mmc devices.Make SPL take into account the correct mmc device.
Signed-off-by Nikita Kiryanov <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/39b70697/attachment.sig>