[1/2] board: engicam: Handle mmc recovery partition, root

Message ID 20190321085002.21084-1-jagan@amarulasolutions.com
State New
Headers show
Series
  • [1/2] board: engicam: Handle mmc recovery partition, root
Related show

Commit Message

Jagan Teki March 21, 2019, 8:50 a.m. UTC
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.

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

Patch

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);