Hi All,
I am using FlashFS (MDK-ARM V4.22) with an SPI FLASH (Atmel AT45DB321C) and STM32F207.
My problem is that when I delete files using fdelete() the free space (as reported by ffree()) is _never_ recovered, even though the files disappear from the file list (as reported using repeated calls to finfo()). I can delete ALL the files, and NONE of the space is recovered.
I realise that the FLASH can only be erased a block at a time, and indeed the manual says:
"When the file content is modified, the old file content is invalidated and a new memory block is allocated. The Flash Block is erased when all the data stored in the Flash Block have been invalidated."
This is perfectly reasonable. However, this reclamation of space when an entire block is invalidated never seems to happen; ffree() only ever reports a decreasing amount of free space, and I never hit the breakpoint I set on the SPI driver EraseSector() function.
The only way to recover the space seems to be to call fformat() which, as expected, erases the whole FLASH.
Does anyone have any ideas as to what I might be doing wrong?
Thanks in advance,
Christopher Hicks ==
It occurs to me to mention one other thing. My implementation of the low-level SPI function SendBuf(U8 *buf, U32 sz) (which actually transmits data to the FLASH chip over SPI) overwrites buf.
The protoype supplied by Keil does not specify that buf is const, so I assume I am allowed to do this. I cannot be certain, but I think the problem with the free space not being recovered pre-dates this change I made to the implementation of SendBuf() anyway.
CH ==
> My implementation of the low-level SPI function SendBuf(U8 *buf, U32 sz) (which actually > transmits data to the FLASH chip over SPI) overwrites buf.
This was the problem. Keil documentation and code ask for my implentation of
BOOL SendBuf(U8 *buf, U32 n);
but actually needs
BOOL SendBuf(const U8 *buf, U32 n);
in order for the filesystem to work properly. Have reported this as a bug to Keil/ARM.
=> Has poilcy about distributing source for FlashFS changed in the last three years, or am I just not looking in the right place?
Policy changed.
http://www.keil.com/forum/18662/ http://www.keil.com/forum/18702/
Danny Curran, 27-Apr-2011 16:16 GMT ----------------------------------- NDA signed and returned was given a link to a zip file and downloaded it. About approx 12 new files and 4 or so changed in the Flash FS Not looked a the USB side but can see differances there as well.