From b3e6b122662a696494a2c325c69d33b3856167ad Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Tue, 18 Jun 2024 18:17:40 +0300 Subject: Prevent rebooting in early USB mode in case of a RAM disk If disk_mount_all() fails at startup, the device should enter USB mode, so the storage can be repartitioned/reformatted. After unmounting/ejecting, the device is rebooted. Unfortunately if the storage is a RAM disk, the data won't persist after a reboot, so this patch tries to mount the storage again, instead of just rebooting. Change-Id: I421a9fd8ae536bee07d292f27d1da0615456df62 --- apps/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/main.c b/apps/main.c index edeeed7d8a..20b9a0bc55 100644 --- a/apps/main.c +++ b/apps/main.c @@ -608,7 +608,7 @@ static void init(void) #ifndef USB_NONE lcd_puts(0, 2, "Insert USB cable"); lcd_puts(0, 3, "and fix it."); -#elif !defined(DEBUG) +#elif !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK) lcd_puts(0, 2, "Rebooting in 5s"); #endif lcd_update(); @@ -617,11 +617,19 @@ static void init(void) usb_start_monitoring(); while(button_get(true) != SYS_USB_CONNECTED) {}; gui_usb_screen_run(true); -#else +#elif !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK) sleep(HZ*5); #endif -#if !defined(DEBUG) + +#if !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK) system_reboot(); +#else + rc = disk_mount_all(); + if (rc <= 0) { + lcd_putsf(0, 4, "Error mounting: %08x", rc); + lcd_update(); + sleep(HZ*5); + } #endif } } -- cgit v1.2.3