2017-09-27 03:36 PM
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 #stm32f4692017-09-27 05:21 PM
I just built a cache and implemented at the diskio.c level....
You'd need to make sure you have two instances of the FATFS structure, and _VOLUMES (FF_VOLUMES R.013) set to two
2017-09-28 01:06 AM
Hi Clive, thanks for your answer. Currently I have an array that stores the two FATFS structures. And I have set the number of volumes to 2. There isn't any over writing.
What about the cache? How do you use it?Thanks
2017-09-28 02:22 AM
Uhm, that is correct, 8.3 names were allowed only. And now I am thinking if there is a conflict between the two file systems. The USE_LFN definition should be global but I am not sure if the library switches if one file system doesn't support it. What I noticed is that files are correctly created in the Ramdisk with a long name, even if the FAT12 isn't supposed to do that. The name should be modified somehow to the 8.3 format...
I will do some tests... thank you for the memory
:)
2017-09-28 03:15 AM
If memory serves me, Fat12 allowed 8.3 file/directory names only.
I was fortunate to not have a 'compatible' PC when this FS was en vogue.
2017-09-28 02:30 PM
Probably I understood the problem...
Originally I put the two file systems FATFS into an array. Since I have two drives I declared:FATFS FileSystems[FF_VOLUMES];Instead, I tried to declare two different structures like:
FATFS FileSystemSD;FATFS FileSystemRAM;Everything worked perfectly. The copy between the two volumes is OK now.
So If I use those structures inside an array, somehow, somewhere, data are messed up if we access to files on different volumes at once.I checked the indexes in the code but I didn't notice anything wrong.So for now I can't figure out what is going on, I will do more tests but this solved the problem.