[U-Boot] [PATCH 1/2] board: engicam: Handle mmc recovery partition, root

Shyam Saini shyam.saini at amarulasolutions.com
Fri Apr 26 09:01:45 UTC 2019


From: Jagan Teki <jagan at amarulasolutions.com>

Since i.CoreM6 support recovery boot via bootcount, update
the mmcpart and mmcroot dynamically based on used mmc partition
layout instead statically defined in include/configs.

Tested-by: Shyam Saini <shyam.saini at amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 board/engicam/common/board.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 7486f0ac2d..571d36fc63 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -19,12 +19,20 @@ static void mmc_late_init(void)
 {
 	char cmd[32];
 	char mmcblk[32];
+	unsigned long bootcount = bootcount_load() + 1;
+	unsigned long bootlimit = env_get_ulong("bootlimit", 10, 0);
 	u32 dev_no = mmc_get_env_dev();
+	u32 mmcpart = 1;
 
 	env_set_ulong("mmcdev", dev_no);
 
+	if (bootlimit && bootcount > bootlimit)
+		mmcpart = 3;
+
+	env_set_ulong("mmcpart", mmcpart);
+
 	/* Set mmcblk env */
-	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
+	sprintf(mmcblk, "/dev/mmcblk%dp%d rootwait rw", dev_no, mmcpart + 1);
 	env_set("mmcroot", mmcblk);
 
 	sprintf(cmd, "mmc dev %d", dev_no);
-- 
2.11.0



More information about the U-Boot mailing list