From 70806018a896847b9e3271ba889b683edecc7594 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Mon, 19 Aug 2019 23:46:10 +0200
Subject: [PATCH] feat(bootloader): Drop into MSC if no filesystem is available

---
 bootloader/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bootloader/main.c b/bootloader/main.c
index 4dd573775..5b99e5362 100644
--- a/bootloader/main.c
+++ b/bootloader/main.c
@@ -288,6 +288,13 @@ int main(void)
 		}
 	}
 
+	/* Get the intital SP of the firmware. If it is 0xFFFFFFFF, no image has been
+	 * flashed yet. Drop into MSC for initial flashing. */
+	if (*((uint32_t *)PARTITION_START) == 0xFFFFFFFF) {
+		printf("No valid image in flash\n");
+		msc();
+	}
+
 	printf("Trying to boot\n");
 
 	boot((uintptr_t *)PARTITION_START);
-- 
GitLab