summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVencislav Atanasov <user890104@freemyipod.org>2024-06-18 18:17:40 +0300
committerSolomon Peachy <pizza@shaftnet.org>2024-06-18 20:45:40 -0400
commitb3e6b122662a696494a2c325c69d33b3856167ad (patch)
tree2832910d1ecd565e614d80de84d95f6ff6836fdb
parente80cf93b67eba00df7dcd35f6ec972e66a5a5e84 (diff)
downloadrockbox-b3e6b122662a696494a2c325c69d33b3856167ad.tar.gz
rockbox-b3e6b122662a696494a2c325c69d33b3856167ad.zip
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
-rw-r--r--apps/main.c14
1 files 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)
608#ifndef USB_NONE 608#ifndef USB_NONE
609 lcd_puts(0, 2, "Insert USB cable"); 609 lcd_puts(0, 2, "Insert USB cable");
610 lcd_puts(0, 3, "and fix it."); 610 lcd_puts(0, 3, "and fix it.");
611#elif !defined(DEBUG) 611#elif !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK)
612 lcd_puts(0, 2, "Rebooting in 5s"); 612 lcd_puts(0, 2, "Rebooting in 5s");
613#endif 613#endif
614 lcd_update(); 614 lcd_update();
@@ -617,11 +617,19 @@ static void init(void)
617 usb_start_monitoring(); 617 usb_start_monitoring();
618 while(button_get(true) != SYS_USB_CONNECTED) {}; 618 while(button_get(true) != SYS_USB_CONNECTED) {};
619 gui_usb_screen_run(true); 619 gui_usb_screen_run(true);
620#else 620#elif !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK)
621 sleep(HZ*5); 621 sleep(HZ*5);
622#endif 622#endif
623#if !defined(DEBUG) 623
624#if !defined(DEBUG) && !(CONFIG_STORAGE & STORAGE_RAMDISK)
624 system_reboot(); 625 system_reboot();
626#else
627 rc = disk_mount_all();
628 if (rc <= 0) {
629 lcd_putsf(0, 4, "Error mounting: %08x", rc);
630 lcd_update();
631 sleep(HZ*5);
632 }
625#endif 633#endif
626 } 634 }
627 } 635 }