diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 55a0508e00..f4ab4f4163 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -328,7 +328,7 @@ static void MMCumount(void) { f_sync(&FDLogFile); // sync ALL mmcDisconnect(&MMCD1); // Brings the driver in a state safe for card removal. mmcStop(&MMCD1); // Disables the MMC peripheral. - f_mount(NULL, 0, 0); // FATFS: Unregister work area prior to discard it + f_mount(NULL, 0, 0); // FATFS: Unregister work area prior to discard it memset(&FDLogFile, 0, sizeof(FIL)); // clear FDLogFile fs_ready = false; // status = false scheduleMsg(&logger, "MMC/SD card removed"); @@ -344,12 +344,12 @@ static void MMCmount(void) { scheduleMsg(&logger, "Error: Already mounted. \"umountsd\" first"); return; } - if ((MMCD1.state != BLK_STOP) && (MMCD1.state != BLK_ACTIVE)) { - firmwareError(CUSTOM_OBD_MMC_START1, "mmc_state1 %d", MMCD1.state); - return; + if ((MMCD1.state == BLK_STOP) || (MMCD1.state == BLK_ACTIVE)) { + // looks like we would only get here after manual unmount with mmcStop? Do we really need to ever mmcStop? + // not sure if this code is needed + // start to initialize MMC/SD + mmcStart(&MMCD1, &mmccfg); // Configures and activates the MMC peripheral. } - // start to initialize MMC/SD - mmcStart(&MMCD1, &mmccfg); // Configures and activates the MMC peripheral. // Performs the initialization procedure on the inserted card. lockSpi(SPI_NONE); @@ -383,7 +383,7 @@ static void MMCmount(void) { unlockSpi(); // if Ok - mount FS now memset(&MMC_FS, 0, sizeof(FATFS)); - if (f_mount(&MMC_FS, 0, 0) == FR_OK) { + if (f_mount(&MMC_FS, "/", 1) == FR_OK) { sdStatus = SD_STATE_MOUNTED; incLogFileName(); createLogFile(); @@ -434,11 +434,6 @@ void initMmcCard(void) { // start to initialize MMC/SD mmcObjectInit(&MMCD1); // Initializes an instance. - if ((MMCD1.state != BLK_STOP) && (MMCD1.state != BLK_ACTIVE)) { - firmwareError(CUSTOM_OBD_MMC_START2, "mmc_state2 %d", MMCD1.state); - return; - } - mmcStart(&MMCD1, &mmccfg); chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL);