summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2019-06-21 15:53:50 +0800
committerJi Luo <ji.luo@nxp.com>2020-05-18 09:45:08 +0800
commited915f7d455a34ede75d9962919181b8b8ba57ec (patch)
tree4c0a39ebbc104a1231f1e285f863fcab3400f260 /common
parent648a4c5376bed206061bd12f5991a55ac8aeabb3 (diff)
MA-14916-4 support dual bootloader for imx8m/imx8q
This commit enables dual bootloader feature for imx8m/imx8q, but as commit 'a2018ab' already brings in some dual bootloader codes when enabling fastboot support, so this commit won't be a complete and standalone patch to introduce the dual bootloader feature. This commit will do the following: 1. clean up dual bootloader flow and add missing implementation. 2. Merge the dual bootloader entry for fit and container to one function 'mmc_load_image_raw_sector_dual_uboot'. Change-Id: Ic9410a48092cc05de599dd897fc912177e2a1fe1 Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_fit.c14
-rw-r--r--common/spl/spl_mmc.c32
2 files changed, 32 insertions, 14 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 5955e9fc85..dd887ded56 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -63,6 +63,10 @@ static int find_node_from_desc(const void *fit, int node, const char *str)
return -ENOENT;
}
+#ifdef CONFIG_DUAL_BOOTLOADER
+extern int spl_fit_get_rbindex(const void *fit, int images);
+#endif
+
/**
* spl_fit_get_image_name(): By using the matching configuration subnode,
* retrieve the name of an image, specified by a property name and an index
@@ -572,6 +576,16 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
return -1;
}
+#if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_IMX_TRUSTY_OS)
+ int rbindex;
+ rbindex = spl_fit_get_rbindex(fit, images);
+ if (rbindex < 0) {
+ printf("Error! Can't get rollback index!\n");
+ return -1;
+ } else
+ spl_image->rbindex = rbindex;
+#endif
+
#ifdef CONFIG_SPL_FPGA_SUPPORT
node = spl_fit_get_image_node(fit, images, "fpga", 0);
if (node >= 0) {
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index af9f6f96ff..748f6e0970 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -41,7 +41,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
return 0;
}
-static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
+ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
ulong count, void *buf)
{
struct mmc *mmc = load->dev;
@@ -62,6 +62,8 @@ static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part)
#if defined(CONFIG_IMX_TRUSTY_OS)
/* Pre-declaration of check_rpmb_blob. */
int check_rpmb_blob(struct mmc *mmc);
+int mmc_load_image_raw_sector_dual_uboot(struct spl_image_info *spl_image,
+ struct mmc *mmc);
#endif
static __maybe_unused
@@ -116,21 +118,10 @@ end:
return -1;
}
- /* Images loaded, now check the rpmb keyblob for Trusty OS.
- * Skip this step when the dual bootloader feature is enabled
- * since the blob should be checked earlier.
- */
-#if defined(CONFIG_IMX_TRUSTY_OS)
- if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
-#if !defined(CONFIG_DUAL_BOOTLOADER)
- ret = check_rpmb_blob(mmc);
-#endif
- } else {
-#if !defined(CONFIG_AVB_ATX)
+ /* Images loaded, now check the rpmb keyblob for Trusty OS. */
+#if defined(CONFIG_IMX_TRUSTY_OS) && !defined(CONFIG_AVB_ATX)
ret = check_rpmb_blob(mmc);
#endif
- }
-#endif
return ret;
}
@@ -383,11 +374,18 @@ int spl_mmc_load(struct spl_image_info *spl_image,
* 1 and 2 match up to boot0 / boot1 and 7 is user data
* which is the first physical partition (0).
*/
+#ifdef CONFIG_DUAL_BOOTLOADER
+ /* Bootloader is stored in eMMC user partition for
+ * dual bootloader.
+ */
+ part = 0;
+#else
part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
if (part == 7)
part = 0;
#endif
+#endif
if (CONFIG_IS_ENABLED(MMC_TINY))
err = mmc_switch_part(mmc, part);
@@ -410,7 +408,9 @@ int spl_mmc_load(struct spl_image_info *spl_image,
return err;
}
+#ifndef CONFIG_DUAL_BOOTLOADER
raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
+#endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
err = mmc_load_image_raw_partition(spl_image, mmc, raw_part,
@@ -419,8 +419,12 @@ int spl_mmc_load(struct spl_image_info *spl_image,
return err;
#endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
+#ifdef CONFIG_DUAL_BOOTLOADER
+ err = mmc_load_image_raw_sector_dual_uboot(spl_image, mmc);
+#else
err = mmc_load_image_raw_sector(spl_image, mmc,
raw_sect + spl_mmc_raw_uboot_offset(part));
+#endif
if (!err)
return err;
#endif