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
This commit is contained in:
Vencislav Atanasov 2024-06-18 18:17:40 +03:00 committed by Solomon Peachy
parent e80cf93b67
commit b3e6b12266

View file

@ -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
}
}