SPL mmc refactor and alternate boot device feature
v2 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 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 | 2 +- board/compulab/cm_fx6/spl.c | 19 +-- common/spl/spl.c | 191 ++++++++++++++++++++------ 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, 441 insertions(+), 222 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/13 spl: nand: remove code duplication
Remove code duplication in spl_nand_load_image().
No functional 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 v2 1/13 spl: nand: remove code duplication
Quoted 8 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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl_nand.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
PATCH v2 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 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 v2 2/13 spl: mmc: add break statements in spl_mmc_load_image()
Quoted 24 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.
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]>
Quoted 7 lines
---
Changes in V2:
- Removedhang()in default cases, moved default case into ifdef LIBCOMMON.common/spl/spl_mmc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
PATCH v2 2/13 spl: mmc: add break statements in spl_mmc_load_image()
In reply to Nikita KiryanovQuoted 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 6 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]>
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/20151103/5f160402/attachment.sig>
PATCH v2 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 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 +puts ("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 v2 3/13 spl: mmc: refactor device location code to its own function
Hi Nikita,
Quoted 14 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.
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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl_mmc.c | 77 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 22 deletions(-)
But can we only have one spl_mmc_find_device() function, with the #ifdef CONFIG_DM_MMC inside it?
Quoted 106 lines
common/spl/spl_mmc.c +55
-23@@ -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 +puts ("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); --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 3/13 spl: mmc: refactor device location code to its own function
Hi Simon,
Quoted 21 lines · Simon Glass
Hi Nikita,
Quoted 18 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.
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]>---
Changes in V2:
- No changes.
Quoted 7 lines
Quoted 2 lines
common/spl/spl_mmc.c | 77 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 22 deletions(-)Reviewed-by Simon Glass <[email protected]>But can we only have one
spl_mmc_find_device()function, with the #ifdefCONFIG_DM_MMCinside it?
I prefer to have as few #ifdefs inside a function as possible. Besides, once driver model becomes ubiquitous we're going to have only one spl_mmc_find_device() anyway.
Quoted 7 lines
Quoted 3 lines
--
1.9.1Regards,
Simon
PATCH v2 3/13 spl: mmc: refactor device location code to its own function
In reply to Nikita KiryanovQuoted 7 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.
[snip]
common/spl/spl_mmc.c end: · line 81
Quoted 3 lines
common/spl/spl_mmc.c +3
-0+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +puts ("spl: could not find mmc device. error: %d\n" , err); +#endif
Should be printf. And this reminds me that after we dug into things before, there's really not a reason to use 'puts' sometimes and 'printf' another, we can always just do printf and it doesn't actually change the size.
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/20151103/9145257f/attachment.sig>
PATCH v2 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 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 v2 4/13 spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
Quoted 14 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.
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]>
Quoted 8 lines
---
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(-)
PATCH v2 4/13 spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
In reply to Nikita KiryanovQuoted 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 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]>Cc Guillaume GARDET <[email protected]>Cc Suriyan Ramasami <[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/20151103/4e552c1f/attachment.sig>
PATCH v2 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 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 v2 5/13 spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
Quoted 13 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.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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl_mmc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
PATCH v2 5/13 spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
In reply to Nikita KiryanovQuoted 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 6 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]>
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/20151103/06fd726c/attachment.sig>
PATCH v2 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 complexit of spl_mmc_load_image().
No functional 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 v2 6/13 spl: mmc: move fs boot into its own function
Quoted 2 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 complexit ofspl_mmc_load_image().
complexity
Quoted 9 lines
No functional changes.
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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl_mmc.c | 81 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 30 deletions(-)
PATCH v2 6/13 spl: mmc: move fs boot into its own function
In reply to Nikita KiryanovQuoted 11 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 complexit ofspl_mmc_load_image().No functional changes.
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]>
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/20151103/bb38f628/attachment.sig>
PATCH v2 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 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 v2 7/13 spl: mmc: get rid of emmc boot code duplication
Quoted 12 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.
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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl_mmc.c | 54 ++++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-)
PATCH v2 7/13 spl: mmc: get rid of emmc boot code duplication
In reply to Nikita KiryanovQuoted 4 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.
Quoted 8 lines
No functional changes.
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]>
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/20151103/2afafc29/attachment.sig>
PATCH v2 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 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 | 2 +- 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, 116 insertions(+), 64 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 +1 -1
@@ -32,7 +32,7 @@ enum {#endif /* Board-specific load method */ -void spl_board_load_image (void ); +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 v2 8/13 spl: change return values of spl_*_load_image()
Hi Nikita,
Quoted 61 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.
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]>---
Changes in V2:
- Minor collateral adjustments from changes in patch 2 (only one return statement at the end ofspl_mmc_load_image).arch/arm/cpu/armv7/sunxi/board.c | 4 +++- arch/arm/include/asm/spl.h | 2 +- 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, 116 insertions(+), 64 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 +0
-0
arch/arm/include/asm/spl.h enum { · line 35
Quoted 5 lines
arch/arm/include/asm/spl.h +1
-1@@ -32,7 +32,7 @@ enum {#endif /* Board-specific load method */ -void spl_board_load_image (void ); +int spl_board_load_image (void );
Please add a comment about what this does, and the return value.
Quoted 31 lines
arch/arm/include/asm/spl.h +0
-0/* Linker symbols. */ extern char __bss_start[], __bss_end[];common/spl/spl.c +4
-2@@ -132,7 +132,7 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) }#ifdef CONFIG_SPL_RAM_DEVICE -static void spl_ram_load_image (void ) +static int spl_ram_load_image (void ) {const struct image_header *header;@@ -145,6 +145,8 @@ static void spl_ram_load_image(void) (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header ));spl_parse_image_header (header); + + return 0; }#endif @@ -208,68 +210,81 @@ void board_init_r(gd_t *dummy1, ulong dummy2)switch (boot_device) {#ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM : -spl_ram_load_image (); +if (spl_ram_load_image ())
common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 222
Quoted 10 lines
common/spl/spl.c +3
-1+hang ();break ;#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :case BOOT_DEVICE_MMC2_2 : -spl_mmc_load_image (); +if (spl_mmc_load_image ()) +hang ();
Can you use something like:
ret = spl_mmc_load_image()
and put the hang() after the switch()?
Quoted 40 lines
common/spl/spl.c +10
-5break ;#endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND : -spl_nand_load_image (); +if (spl_nand_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND : -spl_onenand_load_image (); +if (spl_onenand_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR : -spl_nor_load_image (); +if (spl_nor_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART : -spl_ymodem_load_image (); +if (spl_ymodem_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI : -spl_spi_load_image (); +if (spl_spi_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC :#ifdef CONFIG_SPL_ETH_DEVICE
common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 265
Quoted 10 lines
common/spl/spl.c +4
-2-spl_net_load_image (CONFIG_SPL_ETH_DEVICE ); +if (spl_net_load_image (CONFIG_SPL_ETH_DEVICE )) +hang ();#else -spl_net_load_image (NULL ); +if (spl_net_load_image (NULL )) +hang ();#endif break ;#endif
[snip]
Regards,
Simon
PATCH v2 8/13 spl: change return values of spl_*_load_image()
Hi Simon,
Quoted 66 lines · Simon Glass
Hi Nikita,
Quoted 63 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.
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]>---
Changes in V2:
- Minor collateral adjustments from changes in patch 2 (only one return statement at the end ofspl_mmc_load_image).arch/arm/cpu/armv7/sunxi/board.c | 4 +++- arch/arm/include/asm/spl.h | 2 +- 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, 116 insertions(+), 64 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 +0
-0@@ -32,7 +32,7 @@ enum {#endif
Quoted 5 lines
arch/arm/include/asm/spl.h enum { · line 35
Quoted 3 lines
arch/arm/include/asm/spl.h +1
-1/* Board-specific load method */ -void spl_board_load_image (void ); +int spl_board_load_image (void );Please add a comment about what this does, and the return value.
OK
Quoted 45 lines
Quoted 32 lines
arch/arm/include/asm/spl.h +0
-0/* Linker symbols. */ extern char __bss_start[], __bss_end[];common/spl/spl.c +4
-2@@ -132,7 +132,7 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) }#ifdef CONFIG_SPL_RAM_DEVICE -static void spl_ram_load_image (void ) +static int spl_ram_load_image (void ) {const struct image_header *header;@@ -145,6 +145,8 @@ static void spl_ram_load_image(void) (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header ));spl_parse_image_header (header); + + return 0; }#endif @@ -208,68 +210,81 @@ void board_init_r(gd_t *dummy1, ulong dummy2)switch (boot_device) {#ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM : -spl_ram_load_image (); +if (spl_ram_load_image ())common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 222
Quoted 10 lines
common/spl/spl.c +3
-1+hang ();break ;#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :case BOOT_DEVICE_MMC2_2 : -spl_mmc_load_image (); +if (spl_mmc_load_image ()) +hang ();Can you use something like:
Quoted 3 lines
ret =
spl_mmc_load_image()and put the
hang()after theswitch()?
The next patch takes care of that.
Quoted 57 lines
Quoted 41 lines
common/spl/spl.c +10
-5break ;#endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND : -spl_nand_load_image (); +if (spl_nand_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND : -spl_onenand_load_image (); +if (spl_onenand_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR : -spl_nor_load_image (); +if (spl_nor_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART : -spl_ymodem_load_image (); +if (spl_ymodem_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI : -spl_spi_load_image (); +if (spl_spi_load_image ()) +hang ();break ;#endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC :#ifdef CONFIG_SPL_ETH_DEVICE common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 265
Quoted 10 lines
common/spl/spl.c +4
-2-spl_net_load_image (CONFIG_SPL_ETH_DEVICE ); +if (spl_net_load_image (CONFIG_SPL_ETH_DEVICE )) +hang ();#else -spl_net_load_image (NULL ); +if (spl_net_load_image (NULL )) +hang ();#endif break ;#endif [snip]
Regards,
Simon
PATCH v3 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 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 v3 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 8 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]>
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/20151103/88d2a92f/attachment.sig>
PATCH v3 8/13 spl: change return values of spl_*_load_image()
In reply to Nikita KiryanovQuoted 26 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.
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]>---
Changes in V3:
- Added documentation forspl_board_load_image().Changes in V2:
- Minor collateral adjustments from changes in patch 2 (only one return statement at the end ofspl_mmc_load_image).
Quoted 15 lines
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(-)
PATCH v2 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 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 v2 9/13 common: spl: move image load to its own function
Quoted 8 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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl.c | 117 ++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 67 deletions(-)
PATCH v2 9/13 common: spl: move image load to its own function
In reply to Nikita KiryanovQuoted 8 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]>
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/20151103/dbd03348/attachment.sig>
PATCH v2 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 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 v2 10/13 spl: add support for alternative boot device
Hi Nikita,
Quoted 9 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]>
Quoted 6 lines
---
Changes in V2:
- No changes.common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
How will we convert this to driver model? I'm worried that this might create a separate method which will live forever.
Quoted 61 lines
common/spl/spl.c +29
-5@@ -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 : --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 10/13 spl: add support for alternative boot device
Quoted 16 lines · Simon Glass
Hi Nikita,
Quoted 13 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]>---
Changes in V2:
- No changes.
Quoted 5 lines
Quoted 2 lines
common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)How will we convert this to driver model? I'm worried that this might create a separate method which will live forever.
I don't see how this is related to driver model. This code just fills in an array and iterates over it. Can you elaborate?
Quoted 68 lines
Quoted 62 lines
common/spl/spl.c +29
-5@@ -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 : --Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 10/13 spl: add support for alternative boot device
Quoted 17 lines · Nikita Kiryanov
Quoted 16 lines · Simon Glass
Hi Nikita,
Quoted 13 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]>---
Changes in V2:
- No changes.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)How will we convert this to driver model? I'm worried that this might create a separate method which will live forever.
I don't see how this is related to driver model. This code just fills in an array and iterates over it. Can you elaborate?
Indeed. With DM we'd just want to make sure that we probe for the device before trying to use it, yes?
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/20151103/651275d8/attachment.sig>
PATCH v2 10/13 spl: add support for alternative boot device
Hi,
Quoted 21 lines · Tom Rini
Quoted 20 lines · Nikita Kiryanov
Quoted 19 lines · Simon Glass
Hi Nikita,
Quoted 15 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]>---
Changes in V2:
- No changes.common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
How will we convert this to driver model? I'm worried that this might create a separate method which will live forever.
I don't see how this is related to driver model. This code just fills in an array and iterates over it. Can you elaborate?
Indeed. With DM we'd just want to make sure that we probe for the device before trying to use it, yes?
I'm not sure, hence my question.
I imagine that we might have a 'boot device' as a child of each of these, but I'm really not sure. Let's worry about it later.
Regards,
Simon
PATCH v2 10/13 spl: add support for alternative boot device
In reply to Nikita KiryanovQuoted 9 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]>
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/20151103/f9f7cc90/attachment.sig>
PATCH v2 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:
- No changes.
common/spl/spl.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
common/spl/spl.c +86 -0
@@ -178,6 +178,91 @@ int spl_init(void)return 0 ; } +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +__weak void spl_board_announce_boot_device (void ) { } +#endif + +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +static void announce_boot_device (u32 boot_device) +{ +puts ("Trying to boot from " ); +switch (boot_device) { +#ifdef CONFIG_SPL_RAM_DEVICE +case BOOT_DEVICE_RAM : +puts ("RAM" ); +break ; +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT +case BOOT_DEVICE_MMC1 : +case BOOT_DEVICE_MMC2 : +case BOOT_DEVICE_MMC2_2 : +puts ("MMC" ); +break ; +#endif +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +puts ("NAND" ); +break ; +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +puts ("OneNAND" ); +break ; +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +puts ("NOR" ); +break ; +#endif +#ifdef CONFIG_SPL_YMODEM_SUPPORT +case BOOT_DEVICE_UART : +puts ("UART" ); +break ; +#endif +#ifdef CONFIG_SPL_SPI_SUPPORT +case BOOT_DEVICE_SPI : +puts ("SPI" ); +break ; +#endif +#ifdef CONFIG_SPL_ETH_SUPPORT +case BOOT_DEVICE_CPGMAC : +#ifdef CONFIG_SPL_ETH_DEVICE +puts ("eth device" ); +#else +puts ("net" ); +#endif +break ; +#endif +#ifdef CONFIG_SPL_USBETH_SUPPORT +case BOOT_DEVICE_USBETH : +puts ("USB eth" ); +break ; +#endif +#ifdef CONFIG_SPL_USB_SUPPORT +case BOOT_DEVICE_USB : +puts ("USB" ); +break ; +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT +case BOOT_DEVICE_SATA : +puts ("SATA" ); +break ; +#endif +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +case BOOT_DEVICE_BOARD : +spl_board_announce_boot_device (); +break ; +#endif +default : +printf ("%d (unknown boot device)" , boot_device); + } + +puts ("\n" ); +} +#else +static inline void announce_boot_device (u32 boot_device) { } +#endif +#ifndef BOOT_DEVICE_NONE #define BOOT_DEVICE_NONE 0xdeadbeef#endif
@@ -292,6 +377,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 v2 11/13 spl: announce boot devices
Hi Nikita,
Quoted 34 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]>---
Changes in V2:
- No changes.common/spl/spl.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)common/spl/spl.c +11
-0@@ -178,6 +178,91 @@ int spl_init(void)return 0 ; } +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +__weak void spl_board_announce_boot_device (void ) { } +#endif + +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +static void announce_boot_device (u32 boot_device) +{ +puts ("Trying to boot from " ); +switch (boot_device) { +#ifdef CONFIG_SPL_RAM_DEVICE +case BOOT_DEVICE_RAM :
common/spl/spl.c int spl_init(void) · line 201
Quoted 10 lines
common/spl/spl.c +10
-0+puts ("RAM" ); +break ; +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT +case BOOT_DEVICE_MMC1 : +case BOOT_DEVICE_MMC2 : +case BOOT_DEVICE_MMC2_2 : +puts ("MMC" ); +break ; +#endif
Perhaps we need a table of function pointers with the name for each? This code seems very repetitive.
Quoted 76 lines
common/spl/spl.c +65
-1+#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +puts ("NAND" ); +break ; +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +puts ("OneNAND" ); +break ; +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +puts ("NOR" ); +break ; +#endif +#ifdef CONFIG_SPL_YMODEM_SUPPORT +case BOOT_DEVICE_UART : +puts ("UART" ); +break ; +#endif +#ifdef CONFIG_SPL_SPI_SUPPORT +case BOOT_DEVICE_SPI : +puts ("SPI" ); +break ; +#endif +#ifdef CONFIG_SPL_ETH_SUPPORT +case BOOT_DEVICE_CPGMAC : +#ifdef CONFIG_SPL_ETH_DEVICE +puts ("eth device" ); +#else +puts ("net" ); +#endif +break ; +#endif +#ifdef CONFIG_SPL_USBETH_SUPPORT +case BOOT_DEVICE_USBETH : +puts ("USB eth" ); +break ; +#endif +#ifdef CONFIG_SPL_USB_SUPPORT +case BOOT_DEVICE_USB : +puts ("USB" ); +break ; +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT +case BOOT_DEVICE_SATA : +puts ("SATA" ); +break ; +#endif +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +case BOOT_DEVICE_BOARD : +spl_board_announce_boot_device (); +break ; +#endif +default : + printf("%d (unknown boot device)", boot_device); + } + +puts ("\n" ); +} +#else +static inline void announce_boot_device (u32 boot_device) { } +#endif +#ifndef BOOT_DEVICE_NONE #define BOOT_DEVICE_NONE 0xdeadbeef#endif @@ -292,6 +377,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 ; } --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 11/13 spl: announce boot devices
Quoted 42 lines · Simon Glass
Hi Nikita,
Quoted 39 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]>---
Changes in V2:
- No changes.common/spl/spl.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)common/spl/spl.c +16
-0@@ -178,6 +178,91 @@ int spl_init(void)return 0 ; } +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +__weak void spl_board_announce_boot_device (void ) { } +#endif + +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +static void announce_boot_device (u32 boot_device) +{ +puts ("Trying to boot from " ); +switch (boot_device) { +#ifdef CONFIG_SPL_RAM_DEVICE +case BOOT_DEVICE_RAM : +puts ("RAM" ); +break ; +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT +case BOOT_DEVICE_MMC1 :
Quoted 8 lines
common/spl/spl.c int spl_init(void) · line 201
Quoted 5 lines
common/spl/spl.c +5
-0+case BOOT_DEVICE_MMC2 : +case BOOT_DEVICE_MMC2_2 : +puts ("MMC" ); +break ; +#endif Perhaps we need a table of function pointers with the name for each? This code seems very repetitive.
Or BOOT_DEVICE_* -> name. It'll still have a lot of repetitive lines but I guess the function itself will look nicer. I'll prepare something in a V3..
Quoted 83 lines
Quoted 77 lines
common/spl/spl.c +65
-1+#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +puts ("NAND" ); +break ; +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +puts ("OneNAND" ); +break ; +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +puts ("NOR" ); +break ; +#endif +#ifdef CONFIG_SPL_YMODEM_SUPPORT +case BOOT_DEVICE_UART : +puts ("UART" ); +break ; +#endif +#ifdef CONFIG_SPL_SPI_SUPPORT +case BOOT_DEVICE_SPI : +puts ("SPI" ); +break ; +#endif +#ifdef CONFIG_SPL_ETH_SUPPORT +case BOOT_DEVICE_CPGMAC : +#ifdef CONFIG_SPL_ETH_DEVICE +puts ("eth device" ); +#else +puts ("net" ); +#endif +break ; +#endif +#ifdef CONFIG_SPL_USBETH_SUPPORT +case BOOT_DEVICE_USBETH : +puts ("USB eth" ); +break ; +#endif +#ifdef CONFIG_SPL_USB_SUPPORT +case BOOT_DEVICE_USB : +puts ("USB" ); +break ; +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT +case BOOT_DEVICE_SATA : +puts ("SATA" ); +break ; +#endif +#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE +case BOOT_DEVICE_BOARD : +spl_board_announce_boot_device (); +break ; +#endif +default : + printf("%d (unknown boot device)", boot_device); + } + +puts ("\n" ); +} +#else +static inline void announce_boot_device (u32 boot_device) { } +#endif +#ifndef BOOT_DEVICE_NONE #define BOOT_DEVICE_NONE 0xdeadbeef#endif @@ -292,6 +377,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 ; } --Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v3 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 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
@@ -178,6 +178,84 @@ int spl_init(void)return 0 ; } +#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 + #ifndef BOOT_DEVICE_NONE #define BOOT_DEVICE_NONE 0xdeadbeef #endif
@@ -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 v3 11/13 spl: announce boot devices
Quoted 8 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]>
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/20151103/0fe19481/attachment.sig>
PATCH v2 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 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 v2 12/13 arm: mx6: cm-fx6: define fallback boot devices for spl
Quoted 7 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]>
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/20151103/c2e62620/attachment.sig>
PATCH v2 12/13 arm: mx6: cm-fx6: define fallback boot devices for spl
In reply to Nikita KiryanovQuoted 52 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]>---
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
-0
include/configs/cm_fx6.h line 235
Quoted 7 lines
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)
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 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 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
@@ -291,7 +291,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 v2 13/13 spl: mmc: add support for BOOT_DEVICE_MMC2
Quoted 10 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]>Cc Hans De Goede <[email protected]>Cc Tom Rini <[email protected]>Cc Ian Campbell <[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/20151103/4d577053/attachment.sig>