A weird problem in CF card

  • Thread starter Thread starter Leo Peng
  • Start date Start date
L

Leo Peng

Hi all:
My XPE system is running on a 512M CF card,which was divided into 2
partitions,and I protected the C: partition by using ewf.(Btw,C: is FAT FS
and D: is NTFS compressed FS,CF card connected to IDE interface).
Later I run a program which is only receiving data from net and writing it
to D driver.A weird problem happened.I am sure the data received is right
but partial can be saved correctly,the rest data on disk was filled with
number 0.But when I try the same program on XPE based on harddisk,every
thing worked perfectly.
Is there a big difference between CF card and HD?
Thanks in advance.
 
This question seem very familiar.
Have you created thread called "help! A Write File Error??" two days ago?
If you have then why new thread with same info.
If not read that thread and give us more info.

Regards,
Slobodan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Tell
Microsoft!
https://www.windowsembeddedeval.com/community/newsgroups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Hi Slobodan Brcin:
I have read that thread you mentioned.It seems to be the same problem.;-)
In fact I call the SDK API WriteFile to implement my "save data"
function.Also the returned value is OK.
It confused me why the harddisk can be writen back successfully but CF card
can not.Especially, when the data
need writing is more ,the error happened frequently.
 
Hi Leo,

Someone else should try to answer you what is happening, I have never seen
this problem (This is very very very strange. I don't want to say impossible
since I have seen my share of different errors).

You should try giving us as much as you can information's about your
hardware, XPe configuration, etc.
Also answer and check all points from other thread.

Especially try to use copy function to see if error is happening.

Regards,
Slobodan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Tell
Microsoft!
https://www.windowsembeddedeval.com/community/newsgroups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Leo,

Does it only happen when you app use WriteFile API? Make sure that the data you are getting over network is correct.
If you use Explorer to copy a big file over network to your device's CF, do you see the data transferred and saved being corrupted?

Try to narrow down the problem - use FAT/FAT32 on the second partition. Or use uncompressed NTFS, etc. and see if the problem is
still there.

Also, this may be a stupid idea but just to run FileMon and DiskMon tools from www.sysinternals.com while you run your application
and it is trying to save a file. If won't give you much info but at least you may see if disk/file access activity happens for the
entire file.
 
Hi fellows:
I finally catch the bugs.As you known,the FS need some time to flush its
buffer to disk,the time for hard disk is so short that we generally ignore
it,but it shold absolutely be considered if the disk is CF card.
So I delay a little more time before I do other operations on the file just
written to the disk.Now everthing is OK.

Thanks all fellows help me!

Leo
KM said:
Leo,

Does it only happen when you app use WriteFile API? Make sure that the
data you are getting over network is correct.
If you use Explorer to copy a big file over network to your device's CF,
do you see the data transferred and saved being corrupted?
Try to narrow down the problem - use FAT/FAT32 on the second partition. Or
use uncompressed NTFS, etc. and see if the problem is
still there.

Also, this may be a stupid idea but just to run FileMon and DiskMon tools
from www.sysinternals.com while you run your application
and it is trying to save a file. If won't give you much info but at least
you may see if disk/file access activity happens for the
 
Leo,

I am glad you could work your problem out.
Btw, you may also want to take a look at FlushFileBuffers API to avoid any hard-coded sleeps in the code.
 
Hi KM
I have tried the API but the result is disappointed,even the API returned
successfully.(BTW ,I found the LED to indicate the I/O process would blink
for seconds after the API returned )
I guess the FlushFileBuffers API only flush data only from the buffer in
FS to the buffer in device ,and when or how the device really store the data
depend on the device itself,even OS can not interven. So I must wait till
that store operation completed.(I mean the I/O LED does not blink)
 
Leo,

If you go to your disk properties, Hardware page-->Properties, Policies
page, Write caching.
Have you tried to [un]check "Enable write caching on the disk" option? Does
it help?

KM
 
Hi Leo,

Read this thread:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=Od2Pd0D4
DHA.360%40TK2MSFTNGP12.phx.gbl&rnum=1&prev=/groups%3Fq%3D%2522NFTS%2Bbehavio
ur%2522%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3DOd2Pd0D4DHA.360
%2540TK2MSFTNGP12.phx.gbl%26rnum%3D1

Also:
1. Try not using the file compression on NTFS.
2. Try FAT for test purposes only.
3. Try closing and opening file.

Assuming that you are not disconnecting power to your device:
FS should guarantee writes to file in any case CF, HDD or what ever medium
that you have. You should not worry about writes flushes etc.
If it is not working then it is strange, you should make sure that your
application is ok. And if you can make test case and app that will
demonstrate this behavior, then you should let the MS know about the problem
(this would be serious problem in FS).

Regards,
Slobodan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Tell
Microsoft!
https://www.windowsembeddedeval.com/community/newsgroups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Back
Top