Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

SD card file corruption

SD

  • Please log in to reply
4 replies to this topic

#1 PhilG

PhilG

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationMaine

Posted 04 May 2013 - 04:05 PM

I am having a problem with SD card file corruption when the power is cycled.  If I write to the card and then later interrupt the power, the file is set to 0kB.  The problem does not seem to happen if no writes have occurred since the last power up.

philG

 

Here's the write routine:

 

public static void writeAllSettingsToSD(ArrayList settings)   {   if (!VolumeExist())   {   SDError = SDCardError.NoSDCard;   throw new IOException("NO SD card");   }   if (settings != null)   {   if (settings.Count != 0)   {   try   {   using (StreamWriter file = new StreamWriter(ROOTPATH + SETTINGSPATH, !append)) //fix this   {   foreach (string setting in settings)   {   file.WriteLine(setting);   }   file.Flush();   file.Close();   }   }   catch (IOException)   {   SDError = SDCardError.FileWriteError;   throw new IOException("SD Settings WRITE problem");   }   } //end if settings count != 0   } //end if settings != null   } //end writeToSD

 



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 04 May 2013 - 06:45 PM

yes that happens to me too.

 

you have to call call unmount before you power it down.

 

when you write more data you will see it, and also see how much is lost (like write 100 lines, some will be lost)



#3 PhilG

PhilG

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationMaine

Posted 05 May 2013 - 05:20 PM

Noom,

Ok. Does the Netduino Plus have the abiltiy to notify my program of  brownout or power down to allow me to take the appropriate action?  And, do I have program control over mounting and unmounting?  Should I mount, write and unmount each time?



#4 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 20 May 2013 - 07:52 AM

yes that happens to me too.

 

you have to call call unmount before you power it down.

 

when you write more data you will see it, and also see how much is lost (like write 100 lines, some will be lost)

I remembered that Chris said NP2 would auto mount&unmount SD card,this semms not neccessary process for NP2.



#5 davegeei

davegeei

    New Member

  • Members
  • Pip
  • 1 posts

Posted 29 May 2013 - 11:50 AM

I would suggest you to try third party software to recover data from your corruted SD card. Here are some well known data recovery software.

 

RecoveryFix for Windows Data Recovery

Kernel Windows Data recovery

Stellar

systool Info

 

 

Thanks







Also tagged with one or more of these keywords: SD

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.