STM32CubeF4 icon indicating copy to clipboard operation
STM32CubeF4 copied to clipboard

sd_diskio_dma_rtos_template - SD_write with Scratch buffer not working as expected

Open DeeFuse opened this issue 3 years ago • 2 comments

SD_write is not using the scratch buffer when trying to write a non aligned buffer using the DMA template. SD_read has the correct brace placement to branch to the scratch buffer implementaion when using unaligned buffers.

The true codepath of the alignment check in L413 should end in L465 but ends at L563 Thus skipping any unaligned writes when having the scratchbuffer enabled. Note: with the scratchbuffer disabled, the write will be performed (with garbage at the beginning if unaligned)

Describe the set-up Clean Project using CubeMX and STM32Cube_FW_F4_V1.26.2

Describe the bug When enabling ENABLE_SCRATCH_BUFFER in FATFS/Target/sd_diskio.c the function SD_write will return immideately when a unaligned pointer to a buffer is supplied. It should instead call the memcpy scratchbuffer path.

How To Reproduce Create a CubeMX Project with SDIO + FATFS using DMA and FreeRTOS

Example Project demonstrating the wrong generation: SDIO_DMA_Test.zip

DeeFuse avatar Apr 29 '22 10:04 DeeFuse

Hi @DeeFuse,

Thank you for this report. I see you are using version 1.26.2 of the firmware. Newer version 1.27.0 is already available. Have given it a try?

Thanks,

ALABSTM avatar Apr 29 '22 11:04 ALABSTM

1.27.0 produces the same file (the template hasn't been changed since 2020) sd_diskio_dma_rtos_template_bspv1.c This problem is related to #2

DeeFuse avatar Apr 29 '22 11:04 DeeFuse