Hello,
I want to use the Keil RTX and the FFS on a STR9.
My problem is: Without RTX, my example code works. With RTX it works not.
My Code:
if(0 == finit()) { char acBuffer[100] = {0}; int rv; // Test-Code -Begin fFileStream = fopen("TEST7.TXT", "r"); rv = fread(acBuffer, sizeof(char), 100, fFileStream); fclose(fFileStream); fFileStream = fopen("TEST7.TXT", "w"); rv = fwrite("Hello World!", 1, 12, fFileStream); fclose(fFileStream); // Test-Code -End }
The first part reads out the file and can verify my write commands (the second part).
If I call this code before the RTOS starts, everything works perfect. But if I call this code within a task (At this point only one task is running) the fopen("...", "w") method returns a NULL pointer. A call with fopen("...", "a") returns me a valid pointer but by data bytes are not written. If I open the file in the next turn fread() returns the written size, but all of the read data are 0.
Even when I call the ffind() method, my program runs into the data abort handler.
What I have done: - Heap size: 0x0000 1000 - Task Stack Size: 800 Bytes
What have I forgotten?
1. try to increase stack - I don't remember if 800 bytes were enough. use the search engine, it was posted (also by me) a few months ago. 2. have you tried to disable the scheduler ('tsk_lock') when accessing the file system or to use a mutex (FFS should be task safe) ? don't forget to enable it again with 'tsk_unlock'. 3. did you place your 'finit' in the first task launched by your program?
1. I increased the task stack to 1200 byte. (now its bigger than user stack of 1024 byte) - same error
2. 'tsk_lock' & 'tsk_unlock' - same error
3. 'finit' is called within my init task. This is the first task and at this point no other task is started.
do you enough heap? as far as I remember you need some heap as well.