0xFF's overwriting files, using adl_fs...() commands


#1

Data Logger:

  • Wakes up
  • Read burst of data UART ASYNC
  • Writes to new file, file system
  • Sends over GPRS
  • Sleep

Issue:

  • ~30KB Files are sometimes entirely overwritten in the file system, with 0xFF’s
  • Un-corrupt files are becoming overwritten
  • Eventually, most files in the file system become overwritten with 0xFF’s

Notes:

  • I see no 0xFF problems on the files that are sent over GPRS, they become 0xFF some point after transmission
  • Would like to append to a larger file and send this occasionally as opposed to frequently sending small files

Using the following sequence I have no problems with the files on the FTP server:

//DEVICE WAKES UP AND INITIALISES UART
adl_fsSubscribe();
adl_fsEnterFS();
adl_fsMountDrive(0, ADL_FS_INTERNAL_NOR, NULL);
adl_fsChDrive(0);

//ASYNC READ UART WITH 256 BYTES UNTIL EVENT
if(first run){
   (static) filehandle = adl_fsOpen(global_filename,"w");}

if(size > 0){
   adl_fsWrite(ptr,1,size,filehandle);}

if(no more data coming through){
   adl_fsClose(filehandle);
   adl_tmrSubscribe ( FALSE, 10, 100MS, sendDataFTP )
}

//SEND THE FILE GPRS
sendDataFTP(){
   //Subscribe to GPRS
   filehandle = adl_fsOpen(global_filename,"r");
   adl_fsRead(buffer, 1, MAX_FILE_SIZE, filehandle);
   adl_fsClose(filehandle);
   //SEND FILE etc etc
}

adl_fsUnmontDrive(0);
adl_fsReleaseFS();
adl_tmrSubscribe ( FALSE, 100, 100MS, goToSleep )

When I upload the files through SiWi development environment the majority are entirely overwritten with 0xFF, but appear on my FTP server without 0xFF’s.

The commands:
adl_fsUnmontDrive(0);
adl_fsReleaseFS();

seem to have no effect, the same issue remains even when I remove them entirely.

At one point I had the following code which should have failed, but it still sent the files over GPRS without issue:

if(no more data coming through){
   adl_fsClose(filehandle);
   adl_tmrSubscribe ( FALSE, 10, 100MS, sendDataFTP )
   adl_fsUnmontDrive(0);
   adl_fsReleaseFS();    //Should then fail to open when opening the file for GPRS but doesn't fail
}

Finally, when I try to append to an existing file (opening in “a” mode), I have blocks of 0xFF appearing in amongst the data, in blocks of data that are exactly divisible by 4KB. But the file is not entirely overwritten.

Have I missed something out with regards to the sequence of adl_fs…() commands?


#2

I have resolved the issue. Updating the firmware to the latest version has stopped all problems above.

I suspect the issue was either caused by:

  • the adl_fs commands + old firmware
    OR
  • using the SiWi development environment to enter the FS manually + old firmware