Skip to content

Commit a03834c

Browse files
ExaltZephyrerwango
authored andcommitted
stm32cube: stm32h5: sdio: fix SDIO polling mode
transfer issues this commit fixes two issues in SDIO driver: incorrect block count calculation and improper buffer size handling. Signed-off-by: Sarah Younis <[email protected]>
1 parent 2aa7906 commit a03834c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

stm32cube/stm32h5xx/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,11 @@ Patch List:
6767
Impacted files:
6868
stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_sdio.c
6969

70+
*Fix SDIO polling mode data transfer issues
71+
Fixes two related issues in the STM32H5 SDIO driver: incorrect block count calculation
72+
that caused the card to hang, and improper buffer size handling that led to misaligned FIFO writes.
73+
Together, these changes ensure correct and stable data transfer in polling mode.
74+
Impacted file:
75+
stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_sdio.c
76+
7077
See release_note.html from STM32Cube

stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_sdio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ HAL_StatusTypeDef HAL_SDIO_ReadExtended(SDIO_HandleTypeDef *hsdio, const HAL_SDI
10221022
cmd |= Argument->Block_Mode << 27U;
10231023
cmd |= Argument->OpCode << 26U;
10241024
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1025-
cmd |= (Size_byte & 0x1FFU);
1025+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
10261026
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
10271027
if (errorstate != HAL_SDIO_ERROR_NONE)
10281028
{
@@ -1167,7 +1167,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, const HAL_SD
11671167
uint8_t byteCount;
11681168
uint32_t data;
11691169
uint32_t dataremaining;
1170-
uint8_t *u32tempbuff = pData;
1170+
uint32_t *u32tempbuff = (uint32_t *) pData;
11711171
uint32_t nbr_of_block;
11721172

11731173
/* Check the parameters */
@@ -1227,7 +1227,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, const HAL_SD
12271227
cmd |= Argument->Block_Mode << 27U;
12281228
cmd |= Argument->OpCode << 26U;
12291229
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1230-
cmd |= (Size_byte & 0x1FFU);
1230+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
12311231
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
12321232
if (errorstate != HAL_SDIO_ERROR_NONE)
12331233
{

0 commit comments

Comments
 (0)