This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FS FLASH failing to write data to files but does creat them possible cure

the hardware is a STM32F2 using the SDIO driver
the tool chain is V4.54 and assocaited RLARM libs

Its a RTX application running 15 task s with 3 seperate tasks where data is written to a file to store data and help debug and problem trace.

the tasks are
1) logging CAN data from an ECU/BCM
2) logging performance data from the system.
2) logging serial data send and received from a GSM/GPRS module
3) logging GPS NEMA data from a GPS module
4) logging serial data send and received from a WLAN module

if the GSM task cannot communicate with a TCP server it buffers the performance data first to RAM then to a file. the idea is to have a LIFO buffer and everything else is stored on file unil the GSM module can contact the server again and send all the missed data.

Each task has a file routine that buffers the data to a array of 512 bytes and then when it has more than 512 bytes it writes a compelete sector of data. The buffer array is then manipulated to position the unwrittn data at the beginning of the array and we continue to fill it again till we have more than 512 bytes

the complete sector is written as follows

I open a file for append
checked file handler was valid
wrote to the file
flushed the file system
closed the file

At the end of the day ( using a RTC ) all files are closed and new ones are openned with the name based on the date etc.

eg

M0:\COMM\M08Y12\D16.txt
M0:\GSM\M08Y12\D16.txt
M0:\GPS\M08Y12\D16.txt
M0:\WLAN\M08Y12\D16.txt

What ever the contents of the file buffers are (as > 0 bytes ) its written to the data file when the file is closed deliberately.

But this is what I am seeing

when the system starts up the system writes to the files no problem but at a roll over of the RTC the files are closed and written and new files are created but from then on nothing is written to any file

I tried putting tasklock and taskunlock in each task where any file manipulation takes place but this did not stop the problem.

After contacting support ( dont have the FS source code so totally dependant on them telling me why its failing to write) it was suggested the heap in the startup.s file was too small

It needs apparently 512 bytes for each file plus 80 bytes for each file that is openned.

So after setting the heap from 0x800 to 0x1200 I was still seeing problems but then taking a leap on the wild side and putitng the heap to 0x2000 it looks like system is behaving more as it should. ( Still under test but does seem okay at the mo)

hope this helps others as I am seeing more threads about files being empty after a write operation.

0