diff --git a/src/main/drivers/sdio_h7xx.c b/src/main/drivers/sdio_h7xx.c index 9d8dd1890..d069ad8b2 100644 --- a/src/main/drivers/sdio_h7xx.c +++ b/src/main/drivers/sdio_h7xx.c @@ -168,8 +168,14 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd) } if (sdioHardware->instance == SDMMC1) { + __HAL_RCC_SDMMC1_CLK_DISABLE(); + __HAL_RCC_SDMMC1_FORCE_RESET(); + __HAL_RCC_SDMMC1_RELEASE_RESET(); __HAL_RCC_SDMMC1_CLK_ENABLE(); } else if (sdioHardware->instance == SDMMC2) { + __HAL_RCC_SDMMC2_CLK_DISABLE(); + __HAL_RCC_SDMMC2_FORCE_RESET(); + __HAL_RCC_SDMMC2_RELEASE_RESET(); __HAL_RCC_SDMMC2_CLK_ENABLE(); } diff --git a/src/main/drivers/system.h b/src/main/drivers/system.h index 0122eb504..a79428079 100644 --- a/src/main/drivers/system.h +++ b/src/main/drivers/system.h @@ -42,6 +42,7 @@ typedef enum { FAILURE_SDCARD_READ_FAILED, FAILURE_SDCARD_WRITE_FAILED, FAILURE_SDCARD_INITIALISATION_FAILED, + FAILURE_SDCARD_REQUIRED, } failureMode_e; #define WARNING_FLASH_DURATION_MS 50 diff --git a/src/main/fc/init.c b/src/main/fc/init.c index eee71bd7a..900c96cde 100644 --- a/src/main/fc/init.c +++ b/src/main/fc/init.c @@ -374,6 +374,10 @@ void init(void) sdCardAndFSInit(); initFlags |= SD_INIT_ATTEMPTED; + if (!sdcard_isInserted()) { + failureMode(FAILURE_SDCARD_REQUIRED); + } + while (afatfs_getFilesystemState() != AFATFS_FILESYSTEM_STATE_READY) { afatfs_poll();