Skip to content

Commit cd094ed

Browse files
ExaltZephyrerwango
authored andcommitted
stm32cube: stm32h7rs: 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 a03834c commit cd094ed

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

stm32cube/stm32h7rsxx/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,12 @@ Patch List:
5353
the card identification sequence is skipped.
5454
Impacted files:
5555
stm32cube/stm32h7rsxx/drivers/src/stm32h7rsxx_hal_sdio.c
56+
57+
*Fix SDIO polling mode data transfer issues
58+
Fixes two related issues in the STM32H7RS 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/stm32h7rsxx/drivers/src/stm32h7rsxx_hal_sdio.c
5663

5764
See release_note.html from STM32Cube

stm32cube/stm32h7rsxx/drivers/src/stm32h7rsxx_hal_sdio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ HAL_StatusTypeDef HAL_SDIO_ReadExtended(SDIO_HandleTypeDef *hsdio, const HAL_SDI
10111011
cmd |= Argument->Block_Mode << 27U;
10121012
cmd |= Argument->OpCode << 26U;
10131013
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1014-
cmd |= (Size_byte & 0x1FFU);
1014+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
10151015
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
10161016
if (errorstate != HAL_SDIO_ERROR_NONE)
10171017
{
@@ -1156,7 +1156,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, const HAL_SD
11561156
uint8_t byteCount;
11571157
uint32_t data;
11581158
uint32_t dataremaining;
1159-
uint8_t *u32tempbuff = pData;
1159+
uint32_t *u32tempbuff = (uint32_t *) pData;
11601160
uint32_t nbr_of_block;
11611161

11621162
/* Check the parameters */
@@ -1216,7 +1216,7 @@ HAL_StatusTypeDef HAL_SDIO_WriteExtended(SDIO_HandleTypeDef *hsdio, const HAL_SD
12161216
cmd |= Argument->Block_Mode << 27U;
12171217
cmd |= Argument->OpCode << 26U;
12181218
cmd |= (Argument->Reg_Addr & 0x1FFFFU) << 9U;
1219-
cmd |= (Size_byte & 0x1FFU);
1219+
cmd |= ((nbr_of_block == 0U)? Size_byte : nbr_of_block)& 0x1FFU;
12201220
errorstate = SDMMC_SDIO_CmdReadWriteExtended(hsdio->Instance, cmd);
12211221
if (errorstate != HAL_SDIO_ERROR_NONE)
12221222
{

0 commit comments

Comments
 (0)