Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DeeFuse opened this issue Apr 29, 2022 · 2 comments
Assignees
Labels
fs File system-related issue or pull-request mw Middleware-related issue or pull-request.

Comments

@DeeFuse
Copy link

DeeFuse commented Apr 29, 2022

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
Copy link
Contributor

ALABSTM commented Apr 29, 2022

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
Copy link
Author

DeeFuse commented Apr 29, 2022

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

@ALABSTM ALABSTM self-assigned this May 4, 2022
@ASELSTM ASELSTM added the mw Middleware-related issue or pull-request. label Apr 18, 2023
@ALABSTM ALABSTM added the fs File system-related issue or pull-request label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs File system-related issue or pull-request mw Middleware-related issue or pull-request.
Projects
None yet
Development

No branches or pull requests

3 participants