From 2ac362f2a32d06e87bfa098d2d5f4d6575daed01 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 24 Jun 2026 10:46:43 +0200 Subject: [PATCH] arch/arm: fix DMA transfers with sizes smaller than 4 bytes. When the buffer to send has a size not multiple of 4 bytes, 4-byte words are sent correctly, but when the code reaches the section to send the remaining bytes (1, 2 or 3) it was taking the remaining byte count as origin of the copy, instead of the buffer (as it should). This commit fixes it to correctly copy from the buffer pointer. Signed-off-by: Carlos Sanchez --- arch/arm/src/common/stm32/stm32_sdio_m3m4_v1.c | 2 +- arch/arm/src/stm32f7/stm32_sdmmc.c | 2 +- arch/arm/src/stm32h7/stm32_sdmmc.c | 2 +- arch/arm/src/stm32l4/stm32l4_sdmmc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/common/stm32/stm32_sdio_m3m4_v1.c b/arch/arm/src/common/stm32/stm32_sdio_m3m4_v1.c index 3387e111c4e0e..460ce937c489e 100644 --- a/arch/arm/src/common/stm32/stm32_sdio_m3m4_v1.c +++ b/arch/arm/src/common/stm32/stm32_sdio_m3m4_v1.c @@ -1087,7 +1087,7 @@ static void stm32_sendfifo(struct stm32_dev_s *priv) * padding with zero as necessary to extend to a full word. */ - uint8_t *ptr = (uint8_t *)priv->remaining; + uint8_t *ptr = (uint8_t *)priv->buffer; int i; data.w = 0; diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.c b/arch/arm/src/stm32f7/stm32_sdmmc.c index d82877095a158..772e62572bf4f 100644 --- a/arch/arm/src/stm32f7/stm32_sdmmc.c +++ b/arch/arm/src/stm32f7/stm32_sdmmc.c @@ -1313,7 +1313,7 @@ static void stm32_sendfifo(struct stm32_dev_s *priv) * padding with zero as necessary to extend to a full word. */ - uint8_t *ptr = (uint8_t *)priv->remaining; + uint8_t *ptr = (uint8_t *)priv->buffer; int i; data.w = 0; diff --git a/arch/arm/src/stm32h7/stm32_sdmmc.c b/arch/arm/src/stm32h7/stm32_sdmmc.c index 2aca3035cd277..0e713eadb0795 100644 --- a/arch/arm/src/stm32h7/stm32_sdmmc.c +++ b/arch/arm/src/stm32h7/stm32_sdmmc.c @@ -1232,7 +1232,7 @@ static void stm32_sendfifo(struct stm32_dev_s *priv) * padding with zero as necessary to extend to a full word. */ - uint8_t *ptr = (uint8_t *)priv->remaining; + uint8_t *ptr = (uint8_t *)priv->buffer; int i; data.w = 0; diff --git a/arch/arm/src/stm32l4/stm32l4_sdmmc.c b/arch/arm/src/stm32l4/stm32l4_sdmmc.c index bea2a35c088d8..3f1aaef30c862 100644 --- a/arch/arm/src/stm32l4/stm32l4_sdmmc.c +++ b/arch/arm/src/stm32l4/stm32l4_sdmmc.c @@ -1177,7 +1177,7 @@ static void stm32_sendfifo(struct stm32_dev_s *priv) * padding with zero as necessary to extend to a full word. */ - uint8_t *ptr = (uint8_t *)priv->remaining; + uint8_t *ptr = (uint8_t *)priv->buffer; int i; data.w = 0;