From 2cf6d5b44b07fa0fbf03d5639555967b689fb796 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Mon, 13 Nov 2023 14:06:54 +0100
Subject: [PATCH] reform-flash-uboot: inform about the DIP switch on imx8mq

---
 sbin/reform-display-config |  2 --
 sbin/reform-flash-uboot    | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/sbin/reform-display-config b/sbin/reform-display-config
index 798cb73..f42be59 100755
--- a/sbin/reform-display-config
+++ b/sbin/reform-display-config
@@ -65,10 +65,8 @@ fi
 
 if [ "--emmc" = "$1" ]; then
 	echo "Your /boot partition is on emmc (/dev/$BOOTPART)." >&2
-	echo "Make sure that your DIP switch has been set to OFF." >&2
 else
 	echo "Your /boot partition is on your SD-Card (/dev/$BOOTPART)." >&2
-	echo "Make sure that your DIP switch has been set to ON." >&2
 fi
 
 echo "Restart MNT Reform (type: reboot) after saving your work to activate the changes."
diff --git a/sbin/reform-flash-uboot b/sbin/reform-flash-uboot
index b77c735..0520d44 100755
--- a/sbin/reform-flash-uboot
+++ b/sbin/reform-flash-uboot
@@ -170,3 +170,27 @@ for dev in "$@"; do
 
 	dd if=/boot/flash.bin of="$dev" bs=512 seek="$ubootoffset" skip="$flashbinoffset"
 done
+
+# inform about the DIP switch position only on imx8mq
+case "$(cat /proc/device-tree/model)" in "MNT Reform 2"|"MNT Reform 2 HDMI")
+	DOMMC=0
+	DOSD=0
+	for dev in "$@"; do
+		case $dev in
+			emmc) dev=/dev/${MMCDEV}boot0;;
+			sd)   dev=/dev/${SDDEV};;
+		esac
+		case $dev in
+			"/dev/${MMCDEV}"*) DOMMC=1;;
+			"/dev/${SDDEV}"*)  DOSD=1;;
+		esac
+	done
+	if [ "$DOMMC" != "0" ]; then
+		echo "For the i.MX8MQ to load u-boot from MMC, make sure" >&2
+		echo "that your DIP switch is set to OFF." >&2
+	fi
+	if [ "$DOSD" != "0" ]; then
+		echo "For the i.MX8MQ to load u-boot from SD-Card, make sure" >&2
+		echo "that your DIP switch is set to ON." >&2
+	fi
+esac
-- 
GitLab