Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA
Subsystems (3)
PATCH v2 1/5 spl: Kconfig: Add missing SPL_LOAD_BLOCK for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We need to explicitly select SPL_LOAD_BLOCK when USE_PARTITION_TYPE is enabled, just like the other choices do.
--- common/spl/Kconfig | 1 + 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
@@ -573,6 +573,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE bool "MMC raw mode: by partition type" + select SPL_LOAD_BLOCK depends on DOS_PARTITION help Use partition type for specifying U-Boot partition on MMC/SD in
Signature · 1 line
2.51.0
v2 cover Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA
Changes in v2:
- split off "select SPL_LOAD_BLOCK" change
- address build breakage with CONFIG_SPL_SYS_MMCSD_RAW_MODE off
- fix build condition and add comment to mach-socfpga/board.c patch
Several fixes needed after the mmc raw-mode was consolidated a while ago. Not all the fallouts can be blamed to that refactoring. It also looks to me like booting from mmc just worked by chance before.
This series now permits U-Boot proper loading from SPL via partition type, at least on the DE0-Nano-SoC (other boards not available for testing).
Note that even if the socfpga specific changes should not be accepted due to switching to fat mode booting, the first two patches are generic fixes, affecting all RAW_MODE_U_BOOT_USE_PARTITION_TYPE user - of which we have none in-tree, though.
Jan
Jan Kiszka (5):
spl: Kconfig: Add missing SPL_LOAD_BLOCK for
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
being a choice
spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of
U-Boot from SPL
configs: socfpga: Fix de0_nano_soc boot
arch/arm/mach-socfpga/board.c | 11 +++++++++++ common/spl/Kconfig | 1 + common/spl/spl_mmc.c | 21 +++++++++------------ configs/socfpga_de0_nano_soc_defconfig | 1 + include/part.h | 3 ++- 5 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.51.0
PATCH v2 3/5 spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
From: Jan Kiszka <[email protected]>
This function and the sector parameter evolved over the time. By now, sector is influenced by spl_mmc_get_uboot_raw_sector which allows to adjust the read sector with an offset that U-Boot proper may have inside the partition. That used to work by chance if both CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION were enabled. Since 2a00d73d081a they are a choice, and we need to drop the condition to maintain this feature.
--- common/spl/spl_mmc.c | 4 ---- 1 file changed, 4 deletions(-)
common/spl/spl_mmc.c +0 -4
@@ -137,11 +137,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, return ret; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR return mmc_load_image_raw_sector (spl_image, bootdev, mmc, info.start + sector); -#else -return mmc_load_image_raw_sector (spl_image, bootdev, mmc, info.start); -#endif }#endif
Signature · 1 line
2.51.0
PATCH v2 4/5 arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of U-Boot from SPL
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
If U-Boot is located on MMC, SPL and U-Boot proper are glued together. More precisely, SPL is stored 4 times. Take this and its padding into account and adjust sector number via board_spl_mmc_get_uboot_raw_sector. This allows loading from a partition, without the need to hard-code the offset via SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
--- arch/arm/mach-socfpga/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm/mach-socfpga/board.c +11 -0
@@ -14,6 +14,7 @@#include <hang.h> #include <handoff.h> #include <image.h> +#include <spl.h> #include <usb.h> #include <usb/dwc2_udc.h> #include <asm/global_data.h>
@@ -209,3 +210,13 @@ void lmb_arch_add_memory(void) } }#endif + +#if (defined(TARGET_SOCFPGA_ARRIA10 ) || defined(TARGET_SOCFPGA_GEN5 )) && \ + defined(CONFIG_XPL_BUILD ) +unsigned long board_spl_mmc_get_uboot_raw_sector (struct mmc *mmc, +unsigned long raw_sect) +{ +/* offset of u-boot proper inside u-boot-with-spl.sfp image */ +return (CONFIG_SPL_PAD_TO *4 ) /512 + raw_sect; +} +#endif
Signature · 1 line
2.51.0
PATCH v2 5/5 configs: socfpga: Fix de0_nano_soc boot
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
By default, the de0_nano_soc used raw sectors, but the address became invalid due the raw-mode refactorings. With loading via partition type fixed, we can switch to that mode which is in line with what the ROM loader does.
--- configs/socfpga_de0_nano_soc_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/socfpga_de0_nano_soc_defconfig +1 -0
@@ -28,6 +28,7 @@ CONFIG_SPL_NO_BSS_LIMIT=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_HAVE_INIT_STACK=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_SYS_MAXARGS=32
Signature · 1 line
2.51.0
PATCH v2 2/5 spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Add SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE as condition where so far SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION was enough - though often by chance as both options were enabled.
--- common/spl/spl_mmc.c | 17 +++++++++-------- include/part.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)
common/spl/spl_mmc.c +9 -8
@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)return 0 ; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct mmc *mmc, int partition,
@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image, raw_sect =spl_mmc_get_uboot_raw_sector (mmc, raw_sect); -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION - ret =mmc_load_image_raw_partition (spl_image, bootdev, - mmc, raw_part, - raw_sect); -if (!ret) -return 0 ; -#endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR ret =mmc_load_image_raw_sector (spl_image, bootdev, mmc, raw_sect +spl_mmc_raw_uboot_offset (part));if (!ret)return 0 ; +#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) + ret =mmc_load_image_raw_partition (spl_image, bootdev, + mmc, raw_part, + raw_sect); +if (!ret) +return 0 ;#endif /* If RAW mode fails, try FS mode. */ fallthrough;
include/part.h +2 -1
@@ -461,7 +461,8 @@ ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);#ifdef CONFIG_XPL_BUILD # define part_print_ptr (x) NULL# if defined(CONFIG_SPL_FS_EXT4 ) || defined(CONFIG_SPL_FS_FAT ) || \ - defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION ) + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE )# define part_get_info_ptr (x) x# else # define part_get_info_ptr (x) NULL
Signature · 1 line
2.51.0
Re: [PATCH v2 1/5] spl: Kconfig: Add missing SPL_LOAD_BLOCK for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
In reply to Jan KiszkaQuoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
We need to explicitly select
SPL_LOAD_BLOCKwhenUSE_PARTITION_TYPEis enabled, just like the other choices do.Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")Signed-off-by Jan Kiszka <[email protected]>
Signature · 1 line
Tom
Re: [PATCH v2 2/5] spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice
In reply to Jan KiszkaQuoted 42 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPEas condition where so farSYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITIONwas enough - though often by chance as both options were enabled.Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")Signed-off-by Jan Kiszka <[email protected]>--- common/spl/spl_mmc.c | 17 +++++++++-------- include/part.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)common/spl/spl_mmc.c +2
-8@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)return 0 ; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct mmc *mmc, int partition,@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image, raw_sect =spl_mmc_get_uboot_raw_sector (mmc, raw_sect); -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION - ret =mmc_load_image_raw_partition (spl_image, bootdev, - mmc, raw_part, - raw_sect); -if (!ret) -return 0 ; -#endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR ret =mmc_load_image_raw_sector (spl_image, bootdev, mmc, raw_sect +spl_mmc_raw_uboot_offset (part));
common/spl/spl_mmc.c int spl_mmc_load(struct spl_image_info *spl_image, · line 436
Quoted 10 lines
common/spl/spl_mmc.c +7
-0if (!ret)return 0 ; +#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) + ret =mmc_load_image_raw_partition (spl_image, bootdev, + mmc, raw_part, + raw_sect); +if (!ret) +return 0 ;#endif
Why do we change the order here?
Signature · 1 line
Tom
Re: [PATCH v2 3/5] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
In reply to Jan KiszkaQuoted 11 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This function and the sector parameter evolved over the time. By now, sector is influenced by
spl_mmc_get_uboot_raw_sectorwhich allows to adjust the read sector with an offset that U-Boot proper may have inside the partition. That used to work by chance if bothCONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTORandCONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITIONwere enabled. Since2a00d73d081athey are a choice, and we need to drop the condition to maintain this feature.
Quoted 1 line
Signed-off-by Jan Kiszka <[email protected]>
Signature · 1 line
Tom
Re: [PATCH v2 2/5] spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice
In reply to Tom RiniQuoted 48 lines · Tom Rini
Quoted 46 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPEas condition where so farSYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITIONwas enough - though often by chance as both options were enabled.Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")Signed-off-by Jan Kiszka <[email protected]>--- common/spl/spl_mmc.c | 17 +++++++++-------- include/part.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)common/spl/spl_mmc.c +4
-8@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)return 0 ; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct mmc *mmc, int partition,@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image, raw_sect =spl_mmc_get_uboot_raw_sector (mmc, raw_sect); -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION - ret =mmc_load_image_raw_partition (spl_image, bootdev, - mmc, raw_part, - raw_sect); -if (!ret) -return 0 ; -#endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR ret =mmc_load_image_raw_sector (spl_image, bootdev, mmc, raw_sect +spl_mmc_raw_uboot_offset (part));if (!ret)return 0 ; +#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE )
Quoted 9 lines
common/spl/spl_mmc.c int spl_mmc_load(struct spl_image_info *spl_image, · line 436
Quoted 6 lines
common/spl/spl_mmc.c +5
-0+ ret =mmc_load_image_raw_partition (spl_image, bootdev, + mmc, raw_part, + raw_sect); +if (!ret) +return 0 ;#endif Why do we change the order here?
Because v1 tried #if ...USE_SECTOR #else - and failed. Leftover. If preferred, I can keep the original order. OTOH, it's the order of mode enumerations now.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Tom Rini
Reviewed-byRe: [PATCH v2 2/5] spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice
Quoted 59 lines · Jan Kiszka
Quoted 48 lines · Tom Rini
Quoted 46 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPEas condition where so farSYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITIONwas enough - though often by chance as both options were enabled.Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")Signed-off-by Jan Kiszka <[email protected]>--- common/spl/spl_mmc.c | 17 +++++++++-------- include/part.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)common/spl/spl_mmc.c +4
-8@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)return 0 ; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE ) static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct mmc *mmc, int partition,@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image, raw_sect =spl_mmc_get_uboot_raw_sector (mmc, raw_sect); -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION - ret =mmc_load_image_raw_partition (spl_image, bootdev, - mmc, raw_part, - raw_sect); -if (!ret) -return 0 ; -#endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR ret =mmc_load_image_raw_sector (spl_image, bootdev, mmc, raw_sect +spl_mmc_raw_uboot_offset (part));if (!ret)return 0 ; +#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION ) || \ + defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE )Quoted 9 lines
common/spl/spl_mmc.c int spl_mmc_load(struct spl_image_info *spl_image, · line 436
Quoted 6 lines
common/spl/spl_mmc.c +5
-0+ ret =mmc_load_image_raw_partition (spl_image, bootdev, + mmc, raw_part, + raw_sect); +if (!ret) +return 0 ;#endif Why do we change the order here?
Quoted 3 lines
Because v1 tried #if ...USE_SECTOR #else - and failed. Leftover. If preferred, I can keep the original order. OTOH, it's the order of mode enumerations now.
OK, order of enumerations makes sense. Please re-word to explain this change as intentional and why and with that:
Signature · 1 line
Tom
Re: [PATCH v2 3/5] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
In reply to Jan KiszkaHi Jan,
common/spl/spl_mmc.c static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, · line 142
Quoted 13 lines · Jan Kiszka
common/spl/spl_mmc.c +0
-4@@ -137,11 +137,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, return ret; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR return mmc_load_image_raw_sector (spl_image, bootdev, mmc, info.start + sector); -#else -return mmc_load_image_raw_sector (spl_image, bootdev, mmc, info.start); -#endif }#endif
This patch seems correct, however in testing, it does not boot for me on cyclone V.
The reason is because the sector offset is zero, rather than the expected value (0x200 for socfpga gen 5).
This happens because of Kconfig dependency:
https://gitlab.com/u-boot/u-boot/-/blob/master/common/spl/Kconfig?ref_type=heads#L586
I removed this "depends on" and thereafter I am able to load the main u-boot successfully, although I don't think that is necessarily the right way to fix the issue.
Regards
Ralph
Re: [PATCH v2 3/5] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
Quoted 2 lines · Ralph Siemsen
The reason is because the sector offset is zero, rather than the expected value (
0x200for socfpga gen 5).
Actually I see now that your subsequent patch in arch/arm/mach-socfpga/board.c should handle this, but there's a problem with the #if defined tests. I'll reply to that email.
Ralph
Re: [PATCH v2 4/5] arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of U-Boot from SPL
In reply to Jan KiszkaHi Jan,
arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 215
Quoted 11 lines · Jan Kiszka
arch/arm/mach-socfpga/board.c +3
-0@@ -209,3 +210,13 @@ void lmb_arch_add_memory(void) } }#endif + +#if (defined(TARGET_SOCFPGA_ARRIA10 ) || defined(TARGET_SOCFPGA_GEN5 )) && \ + defined(CONFIG_XPL_BUILD )
This seems to be missing two CONFIG_ prefixes:
#if (defined(CONFIG_TARGET_SOCFPGA_ARRIA10) ||defined(CONFIG_TARGET_SOCFPGA_GEN5)) &&
Regards,
Ralph
Re: [PATCH v2 4/5] arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of U-Boot from SPL
Quoted 18 lines · Ralph Siemsen
Hi Jan,
arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 215
Quoted 11 lines · Jan Kiszka
arch/arm/mach-socfpga/board.c +3
-0@@ -209,3 +210,13 @@ void lmb_arch_add_memory(void) } }#endif + +#if (defined(TARGET_SOCFPGA_ARRIA10 ) || defined(TARGET_SOCFPGA_GEN5 )) && \ + defined(CONFIG_XPL_BUILD )This seems to be missing two
CONFIG_prefixes:
Quoted 3 lines
#if (
defined(CONFIG_TARGET_SOCFPGA_ARRIA10)||defined(CONFIG_TARGET_SOCFPGA_GEN5)) &&
Indeed. I was lacking a target to catch this. v3 is on the way.
Thanks,
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center