Skip to content

Commit 1c3f467

Browse files
ExaltZephyrerwango
authored andcommitted
stm32cube: stm32u5 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 16a38bf commit 1c3f467

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

stm32cube/stm32u5xx/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,11 @@ Patch List:
5454
Impacted files:
5555
stm32cube/stm32u5xx/drivers/src/stm32u5xx_hal_sdio.c
5656

57+
*Fix SDIO polling mode data transfer issues
58+
Fixes two related issues in the STM32U5 SDIO driver: incorrect block count calculation
59+
that caused the card to hang, and improper buffer size handling that led to misaligned FIFO writes.
60+
Together, these changes ensure correct and stable data transfer in polling mode.
61+
Impacted file:
62+
stm32cube/stm32u5xx/drivers/src/stm32u5xx_hal_sdio.c
63+
5764
See release_note.html from STM32Cube

stm32cube/stm32u5xx/drivers/src/stm32u5xx_hal_sdio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ HAL_StatusTypeDef HAL_SDIO_ReadExtended(SDIO_HandleTypeDef *hsdio, HAL_SDIO_Exte
10021002
cmd |= Argument->Block_Mode << 27U;
10031003
cmd |= Argument->OpCode << 26U;
10041004
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1005-
cmd |= (Size_byte & 0x1FFU);
1005+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
10061006
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
10071007
if (errorstate != HAL_SDIO_ERROR_NONE)
10081008
{
@@ -1147,7 +1147,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, HAL_SDIO_Ext
11471147
uint8_t byteCount;
11481148
uint32_t data;
11491149
uint32_t dataremaining;
1150-
uint8_t *u32tempbuff = pData;
1150+
uint32_t *u32tempbuff = (uint32_t *) pData;
11511151
uint32_t nbr_of_block;
11521152

11531153
/* Check the parameters */
@@ -1207,7 +1207,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, HAL_SDIO_Ext
12071207
cmd |= Argument->Block_Mode << 27U;
12081208
cmd |= Argument->OpCode << 26U;
12091209
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1210-
cmd |= (Size_byte & 0x1FFU);
1210+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
12111211
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
12121212
if (errorstate != HAL_SDIO_ERROR_NONE)
12131213
{

0 commit comments

Comments
 (0)