diff options
| author | Damien George <damien@micropython.org> | 2021-12-14 00:07:34 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-12-14 10:48:01 +1100 |
| commit | 6995cf03dda98f490ab95ff90bf395a5667067d6 (patch) | |
| tree | 37424c0e0b386f62c758c6c2bf6ff448833dd011 /ports/stm32/sdcard.c | |
| parent | b26704aac5dbeffe54c575c29a786879e439e72a (diff) | |
stm32/sdcard: Add config option to force MM card capacity.
The current ST HAL does not support reading the extended CSD so cannot
correctly detect the capacity of high-capacity cards. As a workaround, the
capacity can be forced via the MICROPY_HW_MMCARD_LOG_BLOCK_NBR config
option.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/sdcard.c')
| -rw-r--r-- | ports/stm32/sdcard.c | 8 |
1 files changed, 6 insertions, 2 deletions
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 |
