summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/boards/PYBD_SF2/mpconfigboard.h3
-rw-r--r--ports/stm32/sdcard.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/ports/stm32/boards/PYBD_SF2/mpconfigboard.h b/ports/stm32/boards/PYBD_SF2/mpconfigboard.h
index ea0abc6ea..9ac789a83 100644
--- a/ports/stm32/boards/PYBD_SF2/mpconfigboard.h
+++ b/ports/stm32/boards/PYBD_SF2/mpconfigboard.h
@@ -181,6 +181,9 @@ extern struct _spi_bdev_t spi_bdev2;
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
#define MICROPY_HW_SDCARD_MOUNT_AT_BOOT (0)
+// MM card: the size is hard-coded to support the WBUS-EMMC add-on
+#define MICROPY_HW_MMCARD_LOG_BLOCK_NBR (7469056 + 2048)
+
// USB config
#define MICROPY_HW_USB_FS (1)
#define MICROPY_HW_USB_HS (1)
diff --git a/ports/stm32/sdcard.c b/ports/stm32/sdcard.c
index 4e461749a..cb773f29d 100644
--- a/ports/stm32/sdcard.c
+++ b/ports/stm32/sdcard.c
@@ -309,8 +309,12 @@ STATIC HAL_StatusTypeDef sdmmc_init_mmc(void) {
return status;
}
- // As this is an eMMC card, overwrite LogBlockNbr with actual value
- sdmmc_handle.mmc.MmcCard.LogBlockNbr = 7469056 + 2048;
+ #ifdef MICROPY_HW_MMCARD_LOG_BLOCK_NBR
+ // A board can override the number of logical blocks (card capacity) if needed.
+ // This is needed when a card is high capacity because the extended CSD command
+ // is not supported by the current version of the HAL.
+ sdmmc_handle.mmc.MmcCard.LogBlockNbr = MICROPY_HW_MMCARD_LOG_BLOCK_NBR;
+ #endif
#if MICROPY_HW_SDCARD_BUS_WIDTH >= 4
// Configure the SDIO bus width for 4/8-bit wide operation