Problems with FATFS and copy between Ramdisk(FMC) and SD(SPI) on STM32F4
Hello,
I am trying to solve this problem. I am using FATFS13 on my custom STM32F469 board and I am using the Standard Peripheral library.
I have connected 1MB of SRAM over the FMC bus, and an SD card over the SPI bus. I can mount on both hardware a FAT file system, FAT12 on the RAM and FAT32 on the SD. I tested SD cards up to 32GB so I can say that everything is working. It's possible to manage files on each volume. I named them RAMDISK and SDCARD in the ffconf.h
Basically, I want two drives so that the user can copy graphics files in the SRAM for a faster access during the execution of programs.
The problem is that when I try to copy a file from one drive to the other, it's copied only the first chunk of data. A single cycle: - read from
- read from source
- copy to dest - read from
- read from source -> Error 9 on the source ((9) The file/directory object is invalid).
I tried to dig into the code, and with the debugger, I noticed that after the write to the destination file when it's time to read the second chunk of data, the 'obj->fs->fs_type' of the source file is set to 0. So the validation fails.
I can't figure out why. Did you have a similar experience?
In order to avoid this error I need to have only one file opened a time, so I temporary solved the problem with this sequence: - open source - read
- open source - read
- read chunck of data at offset - close source -
- close source -
- open destination for append - save a chunk of data - close destination.
- save a chunk of data - close destination.
- close destination.
In your experience is there a particular way to perform a correct copy on different volumes?
Thank you.
#spi #fatfs #fmc #ram #stm32f469