directory, file creation and writing not working on SD card

Chan Kim ckim at etri.re.kr
Tue Nov 15 09:18:37 UTC 2016




 

Hello rtems users,

Some time ago,  I have made a SD card driver for rtems for our proprietary SD card controller and the test program for read, writing and copying file on SD card runs ok. 


I've made an rtems application which calls a function that I tested on Linux. I called the function from rtems (rtems has all the same header files which were in Linux) and during the processing, the function tests if a directory called 'result' exists (using stat function, with <sys/stat.h>) and if not, calls mkdir function and open a file for write under the directory and fills it with text (printed floating point values) and closes. It does this(file open, filling, file close  many times looping for some numbers.  But after the program run(after file system unmount is done), I find there is no such 'result' directory and no files created under there in the SD card. I tried running with existing 'result' directory, but no created files either.. (But the previous SD card file system test program creates files with correct data).

I tried adding almost all header files that I used in my test program (for testing file system on SD card, which runs ok) , but the problem persists. In the previous test program, I don't use 'mkdir' function but just opens the file with write priviledge.

In what circumstances can this happen? (the mkdir returns 0 and fopen(.."w") returns some non-zero value).

By the way, another difference is that in the previous program, I used fputc to write char by char but in the current program I'm using fprintf(file, "%f ", val);. I could add fprintf("PI = %f\n", 3.1415); in the old program and saw it was correctly written in the file.

Any suggestion would be deeply appreciated. I'm using fat32.

Thanks!

Chan Kim / ETRI


More information about the users mailing list