summaryrefslogtreecommitdiffstatshomepage
path: root/stm/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm/main.c')
-rw-r--r--stm/main.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/stm/main.c b/stm/main.c
index 3425435942..3484fd28d0 100644
--- a/stm/main.c
+++ b/stm/main.c
@@ -10,6 +10,7 @@
#include <stm32f4xx_rtc.h>
#include <stm32f4xx_usart.h>
#include <stm32f4xx_rng.h>
+#include <usbd_storage_msd.h>
#include <stm_misc.h>
#include "std.h"
@@ -815,14 +816,6 @@ soft_reset:
flash_error(4);
}
-#ifdef USE_HOST_MODE
- // USB host
- pyb_usb_host_init();
-#elif defined(USE_DEVICE_MODE)
- // USB device
- pyb_usb_dev_init();
-#endif
-
if (first_soft_reset) {
#if MICROPY_HW_HAS_MMA7660
// MMA: init and reset address to zero
@@ -839,10 +832,23 @@ soft_reset:
FRESULT res = f_mount(&fatfs1, "1:", 1);
if (res != FR_OK) {
printf("[SD] could not mount SD card\n");
+ } else {
+ if (first_soft_reset) {
+ // use SD card as medium for the USB MSD
+ usbd_storage_select_medium(USBD_STORAGE_MEDIUM_SDCARD);
+ }
}
}
#endif
+#ifdef USE_HOST_MODE
+ // USB host
+ pyb_usb_host_init();
+#elif defined(USE_DEVICE_MODE)
+ // USB device
+ pyb_usb_dev_init();
+#endif
+
// run main script
{
vstr_t *vstr = vstr_new();