From 2da30317a8adadfe0cd2a1066765ebc188631ff4 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:40:04 -0500 Subject: [PATCH 1/8] fix(msc): rename SD SPI fops symbol to match BF 4.5-m parity usbd_storage_sd_spi.c defined USBD_MSC_MICRO_SDIO_fops instead of USBD_MSC_MICRO_SD_SPI_fops. usb_msc_h7xx.c (and f7xx.c) reference the SPI name on the #elif USE_SDCARD_SPI branch, so any target with only USE_SDCARD_SPI (no USE_SDCARD_SDIO) failed with 'undeclared identifier'. Also caused a latent duplicate-symbol when both SDIO and SPI were enabled. Fix: rename to USBD_MSC_MICRO_SD_SPI_fops in both usbd_storage_sd_spi.c and usbd_storage.h. usbd_storage_sdio.c retains USBD_MSC_MICRO_SDIO_fops unchanged. Closes #1241. --- src/main/msc/usbd_storage.h | 4 ++-- src/main/msc/usbd_storage_sd_spi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index 3fb51e3e22..c88cddc3bc 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -30,7 +30,7 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; #ifdef USE_SDCARD -extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; +extern USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; @@ -38,7 +38,7 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; #ifdef USE_SDCARD -extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; +extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS extern USBD_STORAGE_cb_TypeDef USBD_MSC_EMFAT_fops; diff --git a/src/main/msc/usbd_storage_sd_spi.c b/src/main/msc/usbd_storage_sd_spi.c index 3efb975fce..69175b2a2f 100644 --- a/src/main/msc/usbd_storage_sd_spi.c +++ b/src/main/msc/usbd_storage_sd_spi.c @@ -110,7 +110,7 @@ static uint8_t STORAGE_Inquirydata[] = {//36 }; #ifdef USE_HAL_DRIVER -USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops = { +USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops = { STORAGE_Init, STORAGE_GetCapacity, STORAGE_IsReady, @@ -121,7 +121,7 @@ USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops = { (int8_t*)STORAGE_Inquirydata, }; #else -USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops = { +USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops = { STORAGE_Init, STORAGE_GetCapacity, STORAGE_IsReady, From 01cc4dec384a9ec4d615e2b037561e9023120e56 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:56:06 -0500 Subject: [PATCH 2/8] fix(msc): restore SDIO extern, split SDCARD guards to BF parity Previous commit replaced USBD_MSC_MICRO_SDIO_fops in usbd_storage.h, removing the extern needed by usb_msc_f7xx.c, usb_msc_h7xx.c (SDIO branch), and usb_msc_f4xx.c. Restore it under a USE_SDCARD_SDIO guard and add the SPI fops under USE_SDCARD_SPI, matching BF 4.5-m usbd_storage.h which uses separate guards for each symbol. --- src/main/msc/usbd_storage.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index c88cddc3bc..16b09555ca 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -29,7 +29,10 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD +#ifdef USE_SDCARD_SDIO +extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; +#endif +#ifdef USE_SDCARD_SPI extern USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS @@ -37,7 +40,10 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #endif #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD +#ifdef USE_SDCARD_SDIO +extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; +#endif +#ifdef USE_SDCARD_SPI extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS From 39d5501e469044e695398e462d53c3c8b57f9cbd Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:16:53 -0500 Subject: [PATCH 3/8] fix(msc): restore USE_SDCARD guard for SDIO extern in usbd_storage.h Targets that define only USE_SDCARD (no sub-type, e.g. ANYFCF7) broke when the SDIO fops extern was narrowed to USE_SDCARD_SDIO. Restore the broad USE_SDCARD guard for USBD_MSC_MICRO_SDIO_fops to preserve F4/F7 backward compat; keep the new USE_SDCARD_SPI guard for the SPI fops that fixes H7 targets. --- src/main/msc/usbd_storage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index 16b09555ca..ca3561bab6 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -29,7 +29,7 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD_SDIO +#ifdef USE_SDCARD extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_SDCARD_SPI @@ -40,7 +40,7 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #endif #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD_SDIO +#ifdef USE_SDCARD extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_SDCARD_SPI From d6c033d3df084b7195c2349e32b4c2763242ee74 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:29:38 -0500 Subject: [PATCH 4/8] Revert "fix(msc): restore USE_SDCARD guard for SDIO extern in usbd_storage.h" This reverts commit 39d5501e469044e695398e462d53c3c8b57f9cbd. --- src/main/msc/usbd_storage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index ca3561bab6..16b09555ca 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -29,7 +29,7 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD +#ifdef USE_SDCARD_SDIO extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_SDCARD_SPI @@ -40,7 +40,7 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #endif #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD +#ifdef USE_SDCARD_SDIO extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_SDCARD_SPI From 39ff67607998ae370c05508bc0e28ac87ae5ff19 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:29:38 -0500 Subject: [PATCH 5/8] Revert "fix(msc): restore SDIO extern, split SDCARD guards to BF parity" This reverts commit 01cc4dec384a9ec4d615e2b037561e9023120e56. --- src/main/msc/usbd_storage.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index 16b09555ca..c88cddc3bc 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -29,10 +29,7 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD_SDIO -extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; -#endif -#ifdef USE_SDCARD_SPI +#ifdef USE_SDCARD extern USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS @@ -40,10 +37,7 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #endif #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; -#ifdef USE_SDCARD_SDIO -extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; -#endif -#ifdef USE_SDCARD_SPI +#ifdef USE_SDCARD extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops; #endif #ifdef USE_FLASHFS From f7d07f51f9f697c9f9bb701cdf610696619d941b Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:29:38 -0500 Subject: [PATCH 6/8] Revert "fix(msc): rename SD SPI fops symbol to match BF 4.5-m parity" This reverts commit 2da30317a8adadfe0cd2a1066765ebc188631ff4. --- src/main/msc/usbd_storage.h | 4 ++-- src/main/msc/usbd_storage_sd_spi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/msc/usbd_storage.h b/src/main/msc/usbd_storage.h index c88cddc3bc..3fb51e3e22 100644 --- a/src/main/msc/usbd_storage.h +++ b/src/main/msc/usbd_storage.h @@ -30,7 +30,7 @@ #ifdef USE_HAL_DRIVER extern USBD_StorageTypeDef *USBD_STORAGE_fops; #ifdef USE_SDCARD -extern USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops; +extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_FLASHFS extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; @@ -38,7 +38,7 @@ extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops; #else extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; #ifdef USE_SDCARD -extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops; +extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops; #endif #ifdef USE_FLASHFS extern USBD_STORAGE_cb_TypeDef USBD_MSC_EMFAT_fops; diff --git a/src/main/msc/usbd_storage_sd_spi.c b/src/main/msc/usbd_storage_sd_spi.c index 69175b2a2f..3efb975fce 100644 --- a/src/main/msc/usbd_storage_sd_spi.c +++ b/src/main/msc/usbd_storage_sd_spi.c @@ -110,7 +110,7 @@ static uint8_t STORAGE_Inquirydata[] = {//36 }; #ifdef USE_HAL_DRIVER -USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops = { +USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops = { STORAGE_Init, STORAGE_GetCapacity, STORAGE_IsReady, @@ -121,7 +121,7 @@ USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops = { (int8_t*)STORAGE_Inquirydata, }; #else -USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops = { +USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops = { STORAGE_Init, STORAGE_GetCapacity, STORAGE_IsReady, From 4498bcb389c5d231e216b31fdcc6e82aa652a7cd Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:30:32 -0500 Subject: [PATCH 7/8] fix(msc): align H7 SPI SD fops with EF symbol name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usb_msc_h7xx.c used USBD_MSC_MICRO_SD_SPI_fops on the USE_SDCARD_SPI branch — a symbol that does not exist in EmuFlight. EF uses USBD_MSC_MICRO_SDIO_fops as the unified SPI SD storage fops name (defined in usbd_storage_sd_spi.c). Use the existing EF symbol. Closes #1241. --- src/main/drivers/usb_msc_h7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/drivers/usb_msc_h7xx.c b/src/main/drivers/usb_msc_h7xx.c index a9ae89cfa8..9070549395 100644 --- a/src/main/drivers/usb_msc_h7xx.c +++ b/src/main/drivers/usb_msc_h7xx.c @@ -90,7 +90,7 @@ uint8_t mscStart(void) #ifdef USE_SDCARD_SDIO USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops); #elif defined(USE_SDCARD_SPI) - USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SD_SPI_fops); + USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops); #else return 1; #endif From 78754017fdf7e5bdd9f46bb129409b757d7d932c Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 3 Jun 2026 18:08:40 -0500 Subject: [PATCH 8/8] style(msc): collapse identical SDIO/SPI branches in usb_msc_h7xx.c Both USE_SDCARD_SDIO and USE_SDCARD_SPI branches called the same USBD_MSC_RegisterStorage line. Collapse to a single || guard, consistent with the simpler pattern in usb_msc_f4xx.c and usb_msc_f7xx.c. --- src/main/drivers/usb_msc_h7xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/drivers/usb_msc_h7xx.c b/src/main/drivers/usb_msc_h7xx.c index 9070549395..c687d67c3c 100644 --- a/src/main/drivers/usb_msc_h7xx.c +++ b/src/main/drivers/usb_msc_h7xx.c @@ -87,9 +87,7 @@ uint8_t mscStart(void) switch (blackboxConfig()->device) { #ifdef USE_SDCARD case BLACKBOX_DEVICE_SDCARD: -#ifdef USE_SDCARD_SDIO - USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops); -#elif defined(USE_SDCARD_SPI) +#if defined(USE_SDCARD_SDIO) || defined(USE_SDCARD_SPI) USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops); #else return 1;