I'm trying to write to SD Card on STM32F769I-DISCO1 board.
Had to adjust the the configurations because the SD Card connector on this board is wired to SDMMC 2-.
This requires hacking "halconf.h" to force FATFS_HAL_DEVICE.
Code: Select all
#if !defined(FATFS_HAL_DEVICE) || defined(__DOXYGEN__)
//this board requires SDCD2 not SDCD1
#define FATFS_HAL_DEVICE SDCD2
#endif
Moving on. I can create folders and files (empty files).
When writting data to the files, the file content - depite the size is correct - is always garbled. Either rubbish content or unrelated strings that I can recognize as bits of data that exist on the code.
I can see that the file size is correct. If I later open that SD Card on the PC and open the file in a binary editor, the file size is correct too, but the content is rubbish.
I've tried set the write buffer to a malloced pointer and to a constant string in flash. All this trying to determine if any chache or DMA issues could be explain this (being an F7).
The test code is as simple as this:
Code: Select all
if(f_puts("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", &file) == 445)
{
// expected number of bytes written
operationResult = FR_OK;
}
// close file
f_close(&file);
I've step in the calls to f_puts and f_close and the calls inside all seem to be OK and no errors are being missed.
If this helps, I've reformatted the SD cards with FAT32 both on the PC as in the device itself by calling f_mkfs.
I've also tried with two different cards: a 4GB SANDISK and a 2GB VERBATIN.
Where should I look further to debug this?
TIA!