Description
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