rockchip: spl: Support reading FIT from eMMC boot partition
Subsystems (3)
RFC 1/1 rockchip: spl: Support reading FIT from eMMC boot partition
Enable support for loading FIT from eMMC boot partition when SUPPORT_EMMC_BOOT Kconfig option is enabled.
FIT is only loaded from boot partition when the boot partition is set to boot0 (1) or boo1 (2) in the extcsd partition config. FIT is read from sector 1024 (512 KiB) of the configured boot partition.
Following can be used to write U-Boot to boot partition 1 of eMMC:
# Load TPL+SPL from SD-card
=> load mmc 1:1 20000000 idbloader.img
=> mmc dev 0
# Access eMMC user partition
=> mmc partconf 0 0 0 0
# Write TPL+SPL to eMMC user partition (512 KiB @ 32 KiB) => mmc write 20000000 40 400
# Load FIT from SD-card
=> load mmc 1:1 20000000 u-boot.itb
=> mmc dev 0
# Access eMMC boot partition 1
=> mmc partconf 0 0 0 1
# Write FIT to eMMC boot partition 1 (2 MiB @ 512 KiB) => mmc write 20000000 400 1000
# Configure to use boot partition 1
=> mmc partconf 0 0 1 0
# Show partition config
=> mmc partconf 0
---
- Is loading FIT from emmc boot partition a feature of intereset to anyone else?
- I used a @ 512 KiB offset for FIT, should leave enough space for e.g. TPL/SPL, vendor storage or environment before FIT.
- Is @ 512 KiB offset a good default option? Or would e.g. @ 0 or @ 32KiB a more apropriate offset?
- This does not add kind of fallback to use the normal @ 8 MiB offset in user partition. Is that something that would be needed?
--- arch/arm/mach-rockchip/spl.c | 23 +++++++++++++++++++++++ configs/generic-rk3568_defconfig | 1 + configs/generic-rk3588_defconfig | 1 + 3 files changed, 25 insertions(+)
arch/arm/mach-rockchip/spl.c +23 -0
@@ -68,9 +68,32 @@ u32 spl_boot_device(void)u32 spl_mmc_boot_mode (struct mmc *mmc,const u32 boot_device) { +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT ) && !IS_SD (mmc)) { +switch (EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config)) { +case 1 : +case 2 : +/* Read FIT from a boot partition */ +return MMCSD_MODE_EMMCBOOT ; + } + } +return MMCSD_MODE_RAW ; } +unsigned long arch_spl_mmc_get_uboot_raw_sector (struct mmc *mmc,unsigned long raw_sect) +{ +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT ) && !IS_SD (mmc)) { +switch (EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config)) { +case 1 : +case 2 : +/* Read FIT from sector 1024 (512 KiB) of boot partition */ +return 0x400 ; + } + } + +return raw_sect; +} +#define TIMER_LOAD_COUNT_L 0x00#define TIMER_LOAD_COUNT_H 0x04#define TIMER_CONTROL_REG 0x10
configs/generic-rk3568_defconfig +1 -0
@@ -51,6 +51,7 @@ CONFIG_ROCKCHIP_GPIO=y CONFIG_MISC=y # CONFIG_ROCKCHIP_IODOMAIN is not set CONFIG_SUPPORT_EMMC_RPMB=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_SPL_MMC_HS200_SUPPORT=y CONFIG_MMC_DW=y
configs/generic-rk3588_defconfig +1 -0
@@ -52,6 +52,7 @@ CONFIG_SPL_CLK=y CONFIG_ROCKCHIP_GPIO=y CONFIG_MISC=y CONFIG_SUPPORT_EMMC_RPMB=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_SPL_MMC_HS200_SUPPORT=y CONFIG_MMC_DW=y
Signature · 1 line
2.43.0
Hello Jonas,
Quoted 32 lines · Jonas Karlman
Enable support for loading FIT from eMMC boot partition when
SUPPORT_EMMC_BOOTKconfigoption is enabled.FIT is only loaded from boot partition when the boot partition is set to boot0 (1) or boo1 (2) in the extcsd partition config. FIT is read from sector 1024 (512 KiB) of the configured boot partition.
Following can be used to write U-Boot to boot partition 1 of eMMC:
# Load TPL+SPL from SD-card
=> load mmc 1:1 20000000 idbloader.img=> mmc dev 0
# Access eMMC user partition
=> mmc partconf 0 0 0 0
# Write TPL+SPL to eMMC user partition (512 KiB @ 32 KiB) => mmc write 20000000 40 400# Load FIT from SD-card
=> load mmc 1:1 20000000 u-boot.itb=> mmc dev 0
# Access eMMC boot partition 1
=> mmc partconf 0 0 0 1
# Write FIT to eMMC boot partition 1 (2 MiB @ 512 KiB) => mmc write 20000000 400 1000# Configure to use boot partition 1
=> mmc partconf 0 0 1 0
# Show partition config
=> mmc partconf 0
Quoted 4 lines
Signed-off-by Jonas Karlman <[email protected]>---
- Is loading FIT from emmc boot partition a feature of intereset to anyone else?
I find this quite usable. Thus, I'd support this feature to be polished further and eventually merged.
Quoted 7 lines
- I used a @ 512 KiB offset for FIT, should leave enough space for e.g. TPL/SPL, vendor storage or environment before FIT.
- Is @ 512 KiB offset a good default option? Or would e.g. @ 0 or @ 32KiB a more apropriate offset?
- This does not add kind of fallback to use the normal @ 8 MiB offset in
user partition. Is that something that would be needed?
I'd say that the fallback is needed, because we still want to be able to continue booting the standard way.
Quoted 68 lines
--- arch/arm/mach-rockchip/spl.c | 23 +++++++++++++++++++++++ configs/generic-rk3568_defconfig | 1 + configs/generic-rk3588_defconfig | 1 + 3 files changed, 25 insertions(+)arch/arm/mach-rockchip/spl.c +23
-0@@ -68,9 +68,32 @@ u32 spl_boot_device(void)u32 spl_mmc_boot_mode (struct mmc *mmc,const u32 boot_device) { +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT ) && !IS_SD (mmc)) { +switch (EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config)) { +case 1 : +case 2 : +/* Read FIT from a boot partition */ +return MMCSD_MODE_EMMCBOOT ; + } + } +return MMCSD_MODE_RAW ; } +unsigned long arch_spl_mmc_get_uboot_raw_sector (struct mmc *mmc,unsigned long raw_sect) +{ +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT ) && !IS_SD (mmc)) { +switch (EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config)) { +case 1 : +case 2 : +/* Read FIT from sector 1024 (512 KiB) of boot partition */ +return 0x400 ; + } + } + +return raw_sect; +} +#define TIMER_LOAD_COUNT_L 0x00#define TIMER_LOAD_COUNT_H 0x04#define
TIMER_CONTROL_REG0x10configs/generic-rk3568_defconfig +1
-0@@ -51,6 +51,7 @@ CONFIG_ROCKCHIP_GPIO=y CONFIG_MISC=y # CONFIG_ROCKCHIP_IODOMAIN is not set CONFIG_SUPPORT_EMMC_RPMB=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_SPL_MMC_HS200_SUPPORT=y CONFIG_MMC_DW=yconfigs/generic-rk3588_defconfig +1
-0@@ -52,6 +52,7 @@ CONFIG_SPL_CLK=y CONFIG_ROCKCHIP_GPIO=y CONFIG_MISC=y CONFIG_SUPPORT_EMMC_RPMB=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_SPL_MMC_HS200_SUPPORT=y CONFIG_MMC_DW=y