STMicroelectronics / STM32CubeF4

STM32Cube MCU Full Package for the STM32F4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
824 stars 408 forks source link

sd_diskio_dma_rtos_template - SD_write with Scratch buffer not working as expected #129

Open DeeFuse opened 2 years ago

DeeFuse commented 2 years ago

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

ALABSTM commented 2 years ago

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,

DeeFuse commented 2 years ago

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