[U-Boot] [PATCH v2 1/3] spl: mmc: support uboot image offset on main partition

On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that.
This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il --- v2: Rebase on top of current master --- common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 5d6da5db89bc..e43eefe046bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -293,6 +293,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes).
+config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET + hex "U-Boot main hardware partition image offset" + depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR + default 0x0 + help + On some platforms SPL location depends on hardware partition. The ROM + code skips the MBR sector when loading SPL from main hardware data + partition. This adds offset to the main U-Boot image. Set this symbol + to the number of skipped sectors. + + If unsure, leave the default. + config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b3619889f794..72439c029f4a 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,16 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); }
+static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) +{ +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR) + if (part == 0) + return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET; +#endif + + return 0; +} + static __maybe_unused int mmc_load_image_raw_sector(struct spl_image_info *spl_image, struct mmc *mmc, unsigned long sector) @@ -312,7 +322,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, static struct mmc *mmc; u32 boot_mode; int err = 0; - __maybe_unused int part; + __maybe_unused int part = 0;
/* Perform peripheral init only once */ if (!mmc) { @@ -371,7 +381,8 @@ int spl_mmc_load(struct spl_image_info *spl_image, return err; #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR - err = mmc_load_image_raw_sector(spl_image, mmc, raw_sect); + err = mmc_load_image_raw_sector(spl_image, mmc, + raw_sect + spl_mmc_raw_uboot_offset(part)); if (!err) return err; #endif

Armada 38x ROM skips the first SD card offset when loading SPL. This affects the location of the main U-Boot image. SPL MMC code now supports U-Boot image offset based on run-time detection of the boot partition. Use this feature to make the same generated image support both SD card and eMMC boot partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il --- configs/clearfog_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index b7b886be4f7a..3609445c1e95 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -22,7 +22,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_TEXT_BASE=0x40000030 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141 +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1 CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y

On 29.07.19 09:12, Baruch Siach wrote:
Armada 38x ROM skips the first SD card offset when loading SPL. This affects the location of the main U-Boot image. SPL MMC code now supports U-Boot image offset based on run-time detection of the boot partition. Use this feature to make the same generated image support both SD card and eMMC boot partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
configs/clearfog_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index b7b886be4f7a..3609445c1e95 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -22,7 +22,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_TEXT_BASE=0x40000030 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141 +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1
While looking at this patch, shouldn't this new Kconfig symbol include "SECTOR" for better transparency? And why "DATA"? Perhaps use CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR_OFFSET?
Thanks, Stefan

Hi Baruch,
On 06.08.19 08:20, Stefan Roese wrote:
On 29.07.19 09:12, Baruch Siach wrote:
Armada 38x ROM skips the first SD card offset when loading SPL. This affects the location of the main U-Boot image. SPL MMC code now supports U-Boot image offset based on run-time detection of the boot partition. Use this feature to make the same generated image support both SD card and eMMC boot partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
configs/clearfog_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index b7b886be4f7a..3609445c1e95 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -22,7 +22,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_TEXT_BASE=0x40000030 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141 +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1
While looking at this patch, shouldn't this new Kconfig symbol include "SECTOR" for better transparency? And why "DATA"? Perhaps use CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR_OFFSET?
Any updates on this?
Thanks, Stefan

Hi Stefan,
On Mon, Aug 12, 2019 at 03:14:16PM +0200, Stefan Roese wrote:
On 06.08.19 08:20, Stefan Roese wrote:
On 29.07.19 09:12, Baruch Siach wrote:
Armada 38x ROM skips the first SD card offset when loading SPL. This affects the location of the main U-Boot image. SPL MMC code now supports U-Boot image offset based on run-time detection of the boot partition. Use this feature to make the same generated image support both SD card and eMMC boot partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
configs/clearfog_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index b7b886be4f7a..3609445c1e95 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -22,7 +22,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_TEXT_BASE=0x40000030 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141 +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1
While looking at this patch, shouldn't this new Kconfig symbol include "SECTOR" for better transparency? And why "DATA"? Perhaps use CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR_OFFSET?
"DATA" is for the main eMMC data hardware partition, as opposed to boot partitions. This offset only applied to data partition. The symbol name should reflect that, I think.
We could use CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_SECTOR_OFFSET. Isn't that too long?
baruch

SPL now automatically selects the correct U-Boot image offset for both eMMC and SD card. No need to tweak CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR anymore.
Signed-off-by: Baruch Siach baruch@tkos.co.il --- board/solidrun/clearfog/README | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/board/solidrun/clearfog/README b/board/solidrun/clearfog/README index 6171ce66f4f8..9375be84957a 100644 --- a/board/solidrun/clearfog/README +++ b/board/solidrun/clearfog/README @@ -20,12 +20,6 @@ of "/dev/sdX" here! Install U-Boot on eMMC: -----------------------
-The ROM loads the bootloader from eMMC first boot partition at offset 0. This -is unlike load from SD card that is at offset 512. As a result, the offset of -the main U-Boot image on the eMMC boot partition changes. Set -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x140 for SPL to load U-Boot from -the correct location. - To make SPL load the main U-Boot image from the eMMC boot partition enable eMMC boot acknowledgement and boot partition with the following U-Boot command:

On 29.07.19 09:12, Baruch Siach wrote:
SPL now automatically selects the correct U-Boot image offset for both eMMC and SD card. No need to tweak CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR anymore.
Signed-off-by: Baruch Siach baruch@tkos.co.il
board/solidrun/clearfog/README | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/board/solidrun/clearfog/README b/board/solidrun/clearfog/README index 6171ce66f4f8..9375be84957a 100644 --- a/board/solidrun/clearfog/README +++ b/board/solidrun/clearfog/README @@ -20,12 +20,6 @@ of "/dev/sdX" here! Install U-Boot on eMMC:
-The ROM loads the bootloader from eMMC first boot partition at offset 0. This -is unlike load from SD card that is at offset 512. As a result, the offset of -the main U-Boot image on the eMMC boot partition changes. Set -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x140 for SPL to load U-Boot from -the correct location.
- To make SPL load the main U-Boot image from the eMMC boot partition enable eMMC boot acknowledgement and boot partition with the following U-Boot command:
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan

On 29.07.19 09:12, Baruch Siach wrote:
On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that.
This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
v2: Rebase on top of current master
common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 5d6da5db89bc..e43eefe046bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -293,6 +293,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes).
+config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET
- hex "U-Boot main hardware partition image offset"
- depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- default 0x0
- help
On some platforms SPL location depends on hardware partition. The ROM
code skips the MBR sector when loading SPL from main hardware data
partition. This adds offset to the main U-Boot image. Set this symbol
to the number of skipped sectors.
If unsure, leave the default.
- config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b3619889f794..72439c029f4a 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,16 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); }
+static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) +{ +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR)
Use if (IS_ENABLED()) instead ?
- if (part == 0)
Why is this restricted to part == 0 ?
return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET;
+#endif
- return 0;
+}
- static __maybe_unused int mmc_load_image_raw_sector(struct spl_image_info *spl_image, struct mmc *mmc, unsigned long sector)
@@ -312,7 +322,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, static struct mmc *mmc; u32 boot_mode; int err = 0;
- __maybe_unused int part;
__maybe_unused int part = 0;
/* Perform peripheral init only once */ if (!mmc) {
@@ -371,7 +381,8 @@ int spl_mmc_load(struct spl_image_info *spl_image, return err; #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
err = mmc_load_image_raw_sector(spl_image, mmc, raw_sect);
err = mmc_load_image_raw_sector(spl_image, mmc,
if (!err) return err; #endifraw_sect + spl_mmc_raw_uboot_offset(part));
Thanks, Stefan

Hi Baruch,
On 06.08.19 08:15, Stefan Roese wrote:
On 29.07.19 09:12, Baruch Siach wrote:
On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that.
This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
v2: Rebase on top of current master
common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 5d6da5db89bc..e43eefe046bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -293,6 +293,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes).
+config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET
- hex "U-Boot main hardware partition image offset"
- depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- default 0x0
- help
On some platforms SPL location depends on hardware partition. The ROM
code skips the MBR sector when loading SPL from main hardware data
partition. This adds offset to the main U-Boot image. Set this symbol
to the number of skipped sectors.
If unsure, leave the default.
- config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b3619889f794..72439c029f4a 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,16 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); }
+static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) +{ +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR)
Use if (IS_ENABLED()) instead ?
- if (part == 0)
Why is this restricted to part == 0 ?
Any updates on this?
Thanks, Stefan

Hi Stefan,
On Mon, Aug 12, 2019 at 03:13:58PM +0200, Stefan Roese wrote:
On 06.08.19 08:15, Stefan Roese wrote:
On 29.07.19 09:12, Baruch Siach wrote:
On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that.
This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
v2: Rebase on top of current master
common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 5d6da5db89bc..e43eefe046bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -293,6 +293,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes). +config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET
- hex "U-Boot main hardware partition image offset"
- depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- default 0x0
- help
On some platforms SPL location depends on hardware partition. The ROM
code skips the MBR sector when loading SPL from main hardware data
partition. This adds offset to the main U-Boot image. Set this symbol
to the number of skipped sectors.
If unsure, leave the default.
- config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b3619889f794..72439c029f4a 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,16 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); } +static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) +{ +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR)
Use if (IS_ENABLED()) instead ?
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET is not defined when CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is disabled. Using 'if (IS_ENABLED())' would break the build.
- if (part == 0)
Why is this restricted to part == 0 ?
As explained in the commit log, the ROM skips the first sector of the main data partition (where part == 0). Otherwise (where part != 0), the ROM load SPL from sector 0. That is the whole point of this patch set. Detect the SPL offset at run-time, instead of hard coding it at build time.
Any updates on this?
Thanks for the reminder. I somehow missed your previous email.
baruch

Hi Baruch,
On 12.08.19 16:25, Baruch Siach wrote:
Hi Stefan,
On Mon, Aug 12, 2019 at 03:13:58PM +0200, Stefan Roese wrote:
On 06.08.19 08:15, Stefan Roese wrote:
On 29.07.19 09:12, Baruch Siach wrote:
On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that.
This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition.
Signed-off-by: Baruch Siach baruch@tkos.co.il
v2: Rebase on top of current master
common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 5d6da5db89bc..e43eefe046bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -293,6 +293,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes). +config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET
- hex "U-Boot main hardware partition image offset"
- depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- default 0x0
- help
On some platforms SPL location depends on hardware partition. The ROM
code skips the MBR sector when loading SPL from main hardware data
partition. This adds offset to the main U-Boot image. Set this symbol
to the number of skipped sectors.
If unsure, leave the default.
- config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b3619889f794..72439c029f4a 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,16 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); } +static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) +{ +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR)
Use if (IS_ENABLED()) instead ?
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET is not defined when CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is disabled. Using 'if (IS_ENABLED())' would break the build.
- if (part == 0)
Why is this restricted to part == 0 ?
As explained in the commit log, the ROM skips the first sector of the main data partition (where part == 0). Otherwise (where part != 0), the ROM load SPL from sector 0. That is the whole point of this patch set. Detect the SPL offset at run-time, instead of hard coding it at build time.
I see, thanks. Frankly, I don't really like this SoC specific extension in the common code. Even though its "configurable" and won't "hurt" the other users of this code. But I also don't see a better way to implement this feature. So if nobody else objects, lets move forward with this patchset.
Thanks, Stefan
participants (2)
-
Baruch Siach
-
Stefan Roese