FAT32 Library Bad Sector question

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

FAT32 Library Bad Sector question

#1 Post by nealet » 10 Feb 2014 07:09

Hi
I loaded and am using the following FAT32 library "1366882048_fat32_library_mikroc_pic32.mpkg".

It works well and I have no complaints in general. My projects saves a lot a data (1kByte) on a contineous real time basis, once every 5 minutes. The data is essentially related to voltages, currents, temperatures, running totals etc etc related to a site I am monitoring. Some of the data is actually just zeros, and so when I open the file on a windows app i see data and of course for the zeros, I just see long columns of zeros, or mostly...!
What I have noticed in some of the "zero" columns, is that sometimes a column of zeros will suddenly become non-zero and display values that should not be there.
My Question about the above mentioned library is as follows:

1) Does the FAT32 library take into consideration "bad" or "corrupt" sectors on the SDHC card?

My suspicion is that I am reading a value in a sector that is actually bad and did not accept the "zero" I originally wrote to it, and is giving me the corrupt value in the faulty SDHC card?

Thanks for your assistance, I am looking forward to your response.
Regards
Nealet

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: FAT32 Library Bad Sector question

#2 Post by marina.petrovic » 10 Feb 2014 16:31

Hi,

The behavior that you describe is very unusual.
I believe that very FAT32 Library is not making a problem that you describe.

Please, can you send me a log file that you using with marked corrupted data,
so I can try to find source of the problem?

Also, please, check the length of the file (whether fits into logging time),
precisely, whether it is shorter or longer than it should be.

Best regards,
Marina

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: FAT32 Library Bad Sector question

#3 Post by nealet » 11 Feb 2014 10:41

Hi
Thank you for your response :).
The files that I have are quite large (almost 7MB), covering about 25 days of data written every 5 minutes at 1024 bytes a time into the file "STATION1 25days.dat" . I use an app called Hex editor Neo V5.14 to read this file and it shows me the binary nature of the file when viewed on a PC. (which is of academic importance because I was blocked from uploading the .dat file to you in this response :) ) Just after the .dat file I write another file with the same data but in ascii format in a .csv file (I was also unable to upload this file :) ).
So basically i have two identical files;
the .dat file has variables that fill up a line (or sector) of bytes on the SD card to exactly 1024 bytes. There is some spare space at the end of each sector which is padded with zeros to make the sector exactly 1024 bytes long. I have verified that this is the case with the Hex editor.
The second file is a .csv file that has exactly the same variables but in ascii text form so that they can easily pulled into Excell for graphing purposes.

If i go through the process of identifying in each of the two files the exact same location, the data agrees ( this is quite laborious so i have only done it for a few entries ). If I could I guess I should try and find a location where they differ. That would show me at least a unique location on the SD card that was different. Two locations that are faulty would seem less likely.
What I do is in some of my columns of data is just write "1's" repetatively for the entire 25 days. What I find is that every now and again the value is "0" leading me to think that maybe the intrinsic errors on the SD card are possibly the cause of the problem. I don't see that fault as being on the FAT32 library side (i.e. the fault is not caused by the library) but I am wondering if the FAT32 library does what PC based disk writes routines do and that is to take account of bad sectors on the media.

You asked me:
"Also, please, check the length of the file (whether fits into logging time),
precisely, whether it is shorter or longer than it should be."
I am not quite sure what you are asking here but if it helps, the main loop that includes the disk write routines completes its work before returning control to the main loop. I use not INterrupts in this code and so the process is not interupted in any way. Each sector is exactly 1024 bytes long and there are no "mis-alignments". Even after 25 days of data, the file length is an exact multiple of 1024!

I think it would help you if I could send my log files. I will try and attach a screen print of the .csv file in Excell. What it shows in "orange" are two cells that should be "1" but are "0" instead.
This file has 6977 rows of data and each row goes up to column "FO" which is in excess of 156 columns of data.
Whatever help you can give is appreciated.

Again my question is still: Does the FAT32 library take account of bad sectors on the media?
To me ALL media will surely always have at least one location among its 32GB of space (in the case of a 32GB SD card) that is faulty?
This is a picture of the file opened in excell
This is a picture of the file opened in excell
Xecell.png (176.42 KiB) Viewed 3804 times

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: FAT32 Library Bad Sector question

#4 Post by nealet » 20 Feb 2014 09:44

Hi There
Please could someone have a look at this issue, I need some resolution so that I can know how to move forward.
Thank you
Regards
Nealet

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: FAT32 Library Bad Sector question

#5 Post by marina.petrovic » 21 Feb 2014 16:58

Hi,

Sorry for the late replay.

When FAT32 Library "comes" to the bad sector it should skip it (does not take that sector into account),
but, library does not check whether the sector is bad or not.

I believe that Windows or application that you use for formatting the SD card, marks the bad sectors on SD card.

Best regards,
Marina

Post Reply

Return to “Library Development Discussion”