stm32/main: Remove need for first_soft_reset variable.
@@ -263,7 +263,7 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
}
#if MICROPY_HW_HAS_SDCARD
-STATIC bool init_sdcard_fs(bool first_soft_reset) {
+STATIC bool init_sdcard_fs(void) {
bool first_part = true;
for (int part_num = 1; part_num <= 4; ++part_num) {
// create vfs object
@@ -308,12 +308,12 @@ STATIC bool init_sdcard_fs(bool first_soft_reset) {
}
}
- if (first_soft_reset) {
- // use SD card as medium for the USB MSD
#if defined(USE_DEVICE_MODE)
+ if (pyb_usb_storage_medium == PYB_USB_STORAGE_MEDIUM_NONE) {
+ // if no USB MSC medium is selected then use the SD card
pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_SDCARD;
- #endif
}
+ #endif
#if defined(USE_DEVICE_MODE)
// only use SD card as current directory if that's what the USB medium is
@@ -470,13 +470,6 @@ int main(void) {
#endif
storage_init();
-#if defined(USE_DEVICE_MODE)
- // default to internal flash being the usb medium
- pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_FLASH;
-#endif
-
- int first_soft_reset = true;
-
soft_reset:
// check if user switch held to select the reset mode
@@ -558,8 +551,15 @@ soft_reset:
if (sdcard_is_present()) {
// if there is a file in the flash called "SKIPSD", then we don't mount the SD card
if (!mounted_flash || f_stat(&fs_user_mount_flash.fatfs, "/SKIPSD", NULL) != FR_OK) {
- mounted_sdcard = init_sdcard_fs(first_soft_reset);
+ mounted_sdcard = init_sdcard_fs();
+ }
}
+#endif
+
+ #if defined(USE_DEVICE_MODE)
+ // if the SD card isn't used as the USB MSC medium then use the internal flash
+ if (pyb_usb_storage_medium == PYB_USB_STORAGE_MEDIUM_NONE) {
+ pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_FLASH;
}
#endif
@@ -688,6 +688,5 @@ soft_reset_exit:
pyb_thread_deinit();
#endif
- first_soft_reset = false;
goto soft_reset;
}
