summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-05 16:13:05 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-05 16:13:05 +1100
commitcc92c0572e2b6dba3c5897d5778704aaccbb567e (patch)
treed3a2a14f5cd6e612c5adca4ca19e18dc342da59a
parent4607be3768b0f6fd187fb7f17545ec3a7d28b94c (diff)
stm32/main: Remove need for first_soft_reset variable.
-rw-r--r--ports/stm32/main.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 1f39b9b9c..9d568675e 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -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 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,11 +551,18 @@ 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
+
// set sys.path based on mounted filesystems (/sd is first so it can override /flash)
if (mounted_sdcard) {
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_sd));
@@ -688,6 +688,5 @@ soft_reset_exit:
pyb_thread_deinit();
#endif
- first_soft_reset = false;
goto soft_reset;
}