Main Site Documentation

SD card weird behaviour


#1

When I have a large amount of data on an SD card I have trouble accessing the files. I define large as about 4GB of greater, but I don’t know exactly where the threshold is.

The behaviour is difficult to reproduce. I can create 2 identical (make, model format) cards and copy the exact same set of files across and one will seem to function correctly and the other may not. I can then reformat the cards and copy the files and get a different result.

I had thought that it was due to the number files that existed, but have drastically slimmed this down to around 70 files with sizes ranging from a few KB to ~300MB. The size of the file doesn’t seem to make a difference. E.g. I might be able to read the 300MB file and not the 3KB file.

I can list all the files on the card with no problem.

I can check that the file exists.

I create a FileStream using …



... and fs reports the correct file size. In this case 3131 bytes for my xml file.

I then try and read the file into a byte array and the whole thing crashes

```cs]   byte[] data =new byte [(int)fs.Length
; 
   fs.Position = 0;
   fs.Read(data, 0, (int)data.Length);   //This line either crashes or the data is wrong

The last Read either crashes or the data is completely wrong.

I am leaning to the conclusion that the order in which the files are copied matters, but haven’t been able to conclusively prove it. It does seem that if I copy my small xml file first and my large files after that the xml file works and the problem then occurs on one of the other files.

My file structure can be recreated using DummyFileCreator (http://www.mynikko.com/dummy/) and using the following batch file :-

[quote]G:\SD\config.xml 3131 1
G:\SD\DATA\1\FAFB.dat 265644 1
G:\SD\DATA\12\12FFA21FFB.dat 441386 1
G:\SD\DATA\12\19FFA12FFB.dat 158190529 1
G:\SD\DATA\12\19FFA13FFB.dat 157010263 1
G:\SD\DATA\12\21FFA13FFB.dat 539781 1
G:\SD\DATA\12\25FFA1FFFB.dat 346541 1
G:\SD\DATA\12\2FFFA12FFB.dat 170723431 1
G:\SD\DATA\12\2FFFA13FFB.dat 213353417 1
G:\SD\DATA\12\32FFA29FFB.dat 344476 1
G:\SD\DATA\15\161FFA11FFFB.dat 57930344 1
G:\SD\DATA\15\161FFA1F6FFB.dat 105372147 1
G:\SD\DATA\15\161FFA1F7FFB.dat 285912288 1
G:\SD\DATA\15\161FFA1F8FFB.dat 262783174 1
G:\SD\DATA\15\161FFA1F9FFB.dat 257257637 1
G:\SD\DATA\15\162FFA11FFFB.dat 50902380 1
G:\SD\DATA\15\162FFA1F6FFB.dat 105491749 1
G:\SD\DATA\15\162FFA1F7FFB.dat 263617447 1
G:\SD\DATA\15\162FFA1F8FFB.dat 263843305 1
G:\SD\DATA\15\162FFA1F9FFB.dat 268003743 1
G:\SD\DATA\15\163FFA11FFFB.dat 41378344 1
G:\SD\DATA\15\163FFA1F6FFB.dat 98526067 1
G:\SD\DATA\15\163FFA1F7FFB.dat 260392718 1
G:\SD\DATA\15\163FFA1F8FFB.dat 268020879 1
G:\SD\DATA\15\163FFA1F9FFB.dat 268553681 1
G:\SD\DATA\15\164FFA11FFFB.dat 6701579 1
G:\SD\DATA\15\164FFA1F6FFB.dat 29271453 1
G:\SD\DATA\15\164FFA1F7FFB.dat 88734953 1
G:\SD\DATA\15\164FFA1F8FFB.dat 87919439 1
G:\SD\DATA\15\164FFA1F9FFB.dat 86913141 1
G:\SD\DATA\15\169FFA1F8FFB.dat 536259 1
G:\SD\DATA\15\16FFFA11FFFB.dat 20451057 1
G:\SD\DATA\15\16FFFA1F6FFB.dat 34573607 1
G:\SD\DATA\15\16FFFA1F7FFB.dat 92988689 1
G:\SD\DATA\15\16FFFA1F8FFB.dat 86299179 1
G:\SD\DATA\15\16FFFA1F9FFB.dat 73359646 1
G:\SD\DATA\15\257FFA239FFB.dat 347947 1
G:\SD\DATA\16\322FFA215FFB.dat 8335468 1
G:\SD\DATA\16\322FFA216FFB.dat 173722981 1
G:\SD\DATA\16\323FFA215FFB.dat 1442407 1
G:\SD\DATA\16\323FFA216FFB.dat 28397065 1
G:\SD\DATA\16\324FFA215FFB.dat 1057016 1
G:\SD\DATA\16\327FFA217FFB.dat 1005686 1
G:\SD\DATA\16\338FFA217FFB.dat 557085 1
G:\SD\DATA\16\514FFA479FFB.dat 350843 1
G:\SD\DATA\17\644FFA433FFB.dat 6270167 1
G:\SD\DATA\17\645FFA433FFB.dat 5713724 1
G:\SD\DATA\17\646FFA432FFB.dat 4706995 1
G:\SD\DATA\17\647FFA432FFB.dat 522648 1
G:\SD\DATA\17\649FFA431FFB.dat 1109354 1
G:\SD\DATA\18\1292FFA865FFB.dat 1006223 1
G:\SD\DATA\18\1293FFA864FFB.dat 4261995 1
G:\SD\DATA\18\1293FFA865FFB.dat 2653008 1
G:\SD\DATA\18\1294FFA864FFB.dat 657347 1
G:\SD\DATA\18\1299FFA862FFB.dat 328809 1
G:\SD\DATA\18\1299FFA863FFB.dat 829879 1
G:\SD\DATA\2\FAFB.dat 555256 1
G:\SD\DATA\3\FAFB.dat 1638781 1
G:\SD\DATA\4\FAFB.dat 5402735 1
G:\SD\DATA\5\FAFB.dat 16037887 1
G:\SD\DATA\6\FAFB.dat 53035705 1
G:\SD\DATA\8\1FFA1FFB.dat 135760071 1
G:\SD\DATA\8\1FFA2FFB.dat 1421896 1
G:\SD\DATA\8\1FFAFB.dat 170846868 1
G:\SD\DATA\8\2FFA1FFB.dat 64992164 1
G:\SD\DATA\8\2FFA2FFB.dat 5035971 1
G:\SD\DATA\8\2FFAFB.dat 104903410 1
G:\SD\DATA\8\FA1FFB.dat 101475896 1
G:\SD\DATA\8\FA2FFB.dat 7586510 1
G:\SD\DATA\8\FAFB.dat 157065206 1[/quote]

Note you need to create the directories manually. The batch file format is FILENAME[TAB]FILESIZE[TAB]randomdataflag

I am only ever using the card in a read only mode. I can access the data correctly via any PC without issue.

I am currently using the G120 on 4.3.3.0. There are no power related issues with the card reader and I have tried all sorts of different SD clock speeds.