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

fopen leads to os_error

Hi everybody,

I work on an Project which based on a LPC1758 with RTX (use µVision v4.60). During os_sys_init i initialize the filesystem with finit (work with SD-Card on SPI). After that I open two files and load some Settings (Close this files when finished).
Code Looks similar to this:

__task void Init(void){
 finit(NULL);
 setupdatei = fopen(file,"r");
 //Read ...
 fclose(setupdatei);
 ...
}

Until now everything works well. To ensure the right function I must use a higher stacksize for the init Routine:

static U64 stk1[2000/8];

int main (void) {
 os_sys_init_user (Init, 200, &stk1, sizeof(stk1));
 while(1);
}

During my following program I create some additional tasks and call "fopen" again. There are my Problem - No matter what I try the RTX run into an os_error and signals stack-overflow for the Task which call fopen. But the debuger indicates a stack load of less then 25%!!! I try out different Settings for stack size (up to 4096 Bytes!) and a lot more without any success!

Any ideas?

Parents
  • Not sure what your exact problem is - if the OS layer somehow remembers some information from the other thread. But anyway, I would recommend that you use a single thread for all file accesses. You can start this thread early and have it perform the file accesses you do in your init code. After that, it can go to sleep and wait for other threads to request file system support.

    With a single thread, you know that you don't get into troubles with thread safety in the library. And you only need one stack dimensioned for this kind of task.

Reply
  • Not sure what your exact problem is - if the OS layer somehow remembers some information from the other thread. But anyway, I would recommend that you use a single thread for all file accesses. You can start this thread early and have it perform the file accesses you do in your init code. After that, it can go to sleep and wait for other threads to request file system support.

    With a single thread, you know that you don't get into troubles with thread safety in the library. And you only need one stack dimensioned for this kind of task.

Children
No data