Skip to content

Commit 15165b7

Browse files
committed
drivers: sdmmc_stm32: Fix bus width initialization sequence
Fix SDMMC initialization by starting with 1-bit bus mode and properly configuring wide bus operation after HAL initialization. The SDMMC protocol requires initialization to start in 1-bit mode before switching to wider bus widths. Previously, the driver attempted to initialize directly with the target bus width, which could cause later read/write failures. Changes: - Initialize with SDMMC_BUS_WIDE_1B instead of target bus width - Add HAL_SD_ConfigWideBusOperation() call after successful init - Add error logging for wide bus configuration failures Fixes potential SDMMC read/write failures issues on STM32 platforms. Signed-off-by: Shan Pen <[email protected]>
1 parent 5945a3f commit 15165b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/disk/sdmmc_stm32.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ static int stm32_sdmmc_access_init(struct disk_info *disk)
365365
LOG_ERR("failed to init stm32_sdmmc (ErrorCode 0x%X)", priv->hsd.ErrorCode);
366366
return -EIO;
367367
}
368-
368+
if (HAL_SD_ConfigWideBusOperation(&priv->hsd, priv->hsd.Init.BusWide) != HAL_OK) {
369+
LOG_ERR("failed to configure wide bus operation");
370+
}
369371
#ifdef CONFIG_SDMMC_STM32_HWFC
370372
stm32_sdmmc_fc_enable(priv);
371373
#endif

0 commit comments

Comments
 (0)