mach-k3: am62*: Fix backup from eMMC boot mode
Subsystems (2)
PATCH 1/1 mach-k3: am62*: Fix backup from eMMC boot mode
Currently logic in spl_mmc_boot_mode only lookes at main devstat to determine the bootmode to return. Thus, when using: 'eMMC boot' as primary boot mode and 'MMCSD boot from eMMC UDA' as backup boot mode, 'eMMC boot' is always selected. Add check for bootindex to determine if ROM boot via backup boot mode and return MMCSD_MODE_FS which is the only supported backup bootmode with eMMC device.
--- arch/arm/mach-k3/am62ax/am62a7_init.c | 22 +++++++++++++--------- arch/arm/mach-k3/am62px/am62p5_init.c | 24 ++++++++++++++---------- arch/arm/mach-k3/am62x/am625_init.c | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-)
arch/arm/mach-k3/am62ax/am62a7_init.c +13 -9
@@ -218,17 +218,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ; +default :return MMCSD_MODE_FS ; -return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ; } }
arch/arm/mach-k3/am62px/am62p5_init.c +14 -10
@@ -264,18 +264,22 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ; + fallthrough; +default :return MMCSD_MODE_FS ; -return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; - fallthrough; -default : + } + }else {return MMCSD_MODE_FS ; } }
arch/arm/mach-k3/am62x/am625_init.c +13 -9
@@ -314,17 +314,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ; +default :return MMCSD_MODE_FS ; -return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ; } }
Signature · 1 line
2.49.0
Hi Judith,
Quoted 1 line · Judith Mendez
Currently logic in
spl_mmc_boot_modeonly lookes at main devstat
Nit: s/lookes/looks
Quoted 38 lines
to determine the bootmode to return. Thus, when using: 'eMMC boot' as primary boot mode and 'MMCSD boot from eMMC UDA' as backup boot mode, 'eMMC boot' is always selected. Add check for bootindex to determine if ROM boot via backup boot mode and return
MMCSD_MODE_FSwhich is the only supported backup bootmode with eMMC device.Signed-off-by Judith Mendez <[email protected]>--- arch/arm/mach-k3/am62ax/am62a7_init.c | 22 +++++++++++++--------- arch/arm/mach-k3/am62px/am62p5_init.c | 24 ++++++++++++++---------- arch/arm/mach-k3/am62x/am625_init.c | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-)arch/arm/mach-k3/am62ax/am62a7_init.c +11
-4@@ -218,17 +218,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ; +default :return MMCSD_MODE_FS ;
arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 238
Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +2
-5-return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ; } }
[snip]
Just having a check for bootindex before the switch block would be more readable imo, like:
if (bootindex != K3_PRIMARY_BOOTMODE)
return MMCSD_MODE_FS;
switch (bootmode) {
<Existing code>
}
Regards,
Anshul
Hi Anshul,
Quoted 61 lines · Anshul Dalal
Hi Judith,
Quoted 1 line · Judith Mendez
Currently logic in
spl_mmc_boot_modeonly lookes at main devstatNit: s/lookes/looks
Quoted 38 lines
to determine the bootmode to return. Thus, when using: 'eMMC boot' as primary boot mode and 'MMCSD boot from eMMC UDA' as backup boot mode, 'eMMC boot' is always selected. Add check for bootindex to determine if ROM boot via backup boot mode and return
MMCSD_MODE_FSwhich is the only supported backup bootmode with eMMC device.Signed-off-by Judith Mendez <[email protected]>--- arch/arm/mach-k3/am62ax/am62a7_init.c | 22 +++++++++++++--------- arch/arm/mach-k3/am62px/am62p5_init.c | 24 ++++++++++++++---------- arch/arm/mach-k3/am62x/am625_init.c | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-)arch/arm/mach-k3/am62ax/am62a7_init.c +11
-4@@ -218,17 +218,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ; +default :return MMCSD_MODE_FS ;arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 238
Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +2
-5-return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ; } }[snip]
Just having a check for bootindex before the switch block would be more readable imo, like:
Quoted 7 lines
if (bootindex !=
K3_PRIMARY_BOOTMODE)return MMCSD_MODE_FS;switch (bootmode) {
<Existing code>
}
Actually, I like that, thanks, will fix for v2.
~ Judith
On August 18, 2025 thus sayeth Judith Mendez:
Quoted 37 lines
Currently logic in
spl_mmc_boot_modeonly lookes at main devstat to determine the bootmode to return. Thus, when using: 'eMMC boot' as primary boot mode and 'MMCSD boot from eMMC UDA' as backup boot mode, 'eMMC boot' is always selected. Add check for bootindex to determine if ROM boot via backup boot mode and returnMMCSD_MODE_FSwhich is the only supported backup bootmode with eMMC device.Signed-off-by Judith Mendez <[email protected]>--- arch/arm/mach-k3/am62ax/am62a7_init.c | 22 +++++++++++++--------- arch/arm/mach-k3/am62px/am62p5_init.c | 24 ++++++++++++++---------- arch/arm/mach-k3/am62x/am625_init.c | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-)arch/arm/mach-k3/am62ax/am62a7_init.c +10
-4@@ -218,17 +218,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ;
arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 236
Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +3
-5+default :return MMCSD_MODE_FS ; -return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ;
Is any warning given to us when we fall back to the UDA partition? How do people know their boot partition is dead? Could we bail out early with a message:
if (bootindex != K3_PRIMARY_BOOTMODE) {
pr_alert("using MMC backup in UDA\n")
return MMCSD_MODE_FS;
}
switch (bootmode) {
case BOOT_DEVICE_EMMC:
... bla bla bla ...~Bryan
Hi Bryan,
Quoted 53 lines · Bryan Brattlof
On August 18, 2025 thus sayeth Judith Mendez:
Quoted 37 lines
Currently logic in
spl_mmc_boot_modeonly lookes at main devstat to determine the bootmode to return. Thus, when using: 'eMMC boot' as primary boot mode and 'MMCSD boot from eMMC UDA' as backup boot mode, 'eMMC boot' is always selected. Add check for bootindex to determine if ROM boot via backup boot mode and returnMMCSD_MODE_FSwhich is the only supported backup bootmode with eMMC device.Signed-off-by Judith Mendez <[email protected]>--- arch/arm/mach-k3/am62ax/am62a7_init.c | 22 +++++++++++++--------- arch/arm/mach-k3/am62px/am62p5_init.c | 24 ++++++++++++++---------- arch/arm/mach-k3/am62x/am625_init.c | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-)arch/arm/mach-k3/am62ax/am62a7_init.c +10
-4@@ -218,17 +218,21 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 bootmode_cfg = (devstat &MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK ) >>MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT ; -switch (bootmode) { -case BOOT_DEVICE_EMMC : -if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +if (bootindex ==K3_PRIMARY_BOOTMODE ) { +switch (bootmode) { +case BOOT_DEVICE_EMMC : +if (IS_ENABLED (CONFIG_SUPPORT_EMMC_BOOT )) +return MMCSD_MODE_EMMCBOOT ; +if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +return MMCSD_MODE_FS ;return MMCSD_MODE_EMMCBOOT ; -if (IS_ENABLED (CONFIG_SPL_FS_FAT ) ||IS_ENABLED (CONFIG_SPL_FS_EXT4 )) +case BOOT_DEVICE_MMC : +if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) +return MMCSD_MODE_RAW ;arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 236
Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +3
-5+default :return MMCSD_MODE_FS ; -return MMCSD_MODE_EMMCBOOT ; -case BOOT_DEVICE_MMC : -if (bootmode_cfg &MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK ) -return MMCSD_MODE_RAW ; -default : + } + }else {return MMCSD_MODE_FS ;Is any warning given to us when we fall back to the UDA partition? How do people know their boot partition is dead? Could we bail out early with a message:
Quoted 9 lines
if (bootindex != K3_PRIMARY_BOOTMODE) {
pr_alert("using MMC backup in UDA\n")
return MMCSD_MODE_FS;
}
switch (bootmode) {
case BOOT_DEVICE_EMMC:
... bla bla bla ...Ok, sure will add print, thanks!
~ Judith