Committing File to SD Card - Page 2 - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
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

Committing File to SD Card

File Write Commit SD

  • Please log in to reply
36 replies to this topic

#21 zeroaviation

zeroaviation

    Member

  • Members
  • PipPip
  • 28 posts

Posted 13 July 2013 - 07:43 PM

Tried all of the above - nothing works.  N2+ 4.3 and 4.2.2. 

 

Same here, this is very frustrating. Especially since i just spent $70 on  N+2 not even 40min ago.

 

Common guys.



#22 Grumpy Old Fool

Grumpy Old Fool

    New Member

  • Members
  • Pip
  • 2 posts

Posted 22 July 2013 - 05:34 PM

I ran into the same problem and here is how I fixed it on my Netduino Plus 2 (v4.2.2.2)

 

I was writing an SDTest.txt dummy file to a 2GB micro SD as the first thing in my Main(), and it didn't work - then after the board had been in active for a while the file was there - even after reset.

So I start the program with Thread.Sleep(10000); and now it just Works - files are created with content, deleted etc instantly. I suspect the SD interface takes a while to fully initialize in debug mode.

 

I can fully recreate the original bug. It's quite persistent on this hardware.

 

Hope this helps.



#23 sevenares

sevenares

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 August 2013 - 03:49 AM

I experience the same problem on firmware 4.2.2.2 N2P While the software is running, i can access the files and contents i have written before. The moment i turn off the netduino, everything is gone. In some cases, some or all files stay on the sd card. ( but i have no idea why.. same code, 1 out of 20 times ) Different to others, it doesn't matter if i am in debug mode or in release mode. Everything works fine on firmware 4.2.1.1  !! ( but i can't use it because of the streamreader.readline peak overflow-bug )

And its't not working on 4.2.2.2 and 4.3 beta1. I have three Netduino 2 plus here. one of them with 4.2.1.1. two with 4.2.2.2. The same code works on 4.2.1.1 and won't write a file to 4.2.2.2 (I am using vb.net ) I really would need a fix for that ( or at least an explanation, workaround etc ). Regards, Alex



#24 mcfd

mcfd

    Member

  • Members
  • PipPip
  • 11 posts

Posted 26 September 2013 - 05:00 AM

I have encountered the exact same problem. Secret Labs should address this non-trivial issue.



#25 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 26 September 2013 - 05:09 AM

Me too



#26 mcfd

mcfd

    Member

  • Members
  • PipPip
  • 11 posts

Posted 26 September 2013 - 07:40 AM

I also tried all of the above on my N2+ 4.2.2, and none of them worked. Putting it in release mode did not work either.

 

Tried all of the above - nothing works.  N2+ 4.3 and 4.2.2. 



#27 ryNetDuino

ryNetDuino

    New Member

  • Members
  • Pip
  • 4 posts

Posted 12 November 2013 - 04:37 AM

So I am new the NetDuino and just purchased a N+2 and was told after my first post (where I was having trouble getting started) to search the forums for solutions and read the MS MF help files.  

 

This tread, among many other on this forum, proves that SL is very lacking in support for their new products.  I wonder if if is because they are deep into development to production of the Agent Watch, which looks very cool BTW.  However, prototype boards like the NetDuino (and Arduino), in my opinion, are to allow us developers/engineers to build/create solutions/products, not go deep driving into framework source code to figure out why it does work.   As much as I would rather do my work in C# and VS, my may have to return to C/C++ with Arduino to continue working on my modbus project and get my $70 back for the N+2.

 

So back to the topic... I tried all the suggestions above and I cannot get a file to actually be saved on the N+2 either. 

Frustrated.



#28 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 12 November 2013 - 07:04 AM

Hi everyone

 

Does this help as a workaround?

 

[font="consolas;"][color=#0000FF;]new[/color][/font] Microsoft.SPOT.IO.[font="consolas;"][color=rgb(43,145,175);]VolumeInfo[/color][/font][font="consolas;"][color=#000000;]([/color][/font][font="consolas;"][color=rgb(163,21,21);]"SD"[/color][/font][font="consolas;"][color=#000000;]).FlushAll();[/color][/font]

 

Best regards

 

Cuno



#29 martinarcher

martinarcher

    Member

  • Members
  • PipPip
  • 16 posts

Posted 12 November 2013 - 04:10 PM

Hello all.  I am seeing the same issues.  I originally thought it was a bug in the FTP server I am running as I have changed several things in the server as I have found a few issues, but the SD issue seems a bit deeper.

 

One observation I have found is after receiving a file via FTP (the server creates a file on the SD, writes the bytes received to the file, flushes, closes etc).  I check the SD card with a FTP client and the file "exists" to the FTP client.  I assume at this point the file is in RAM and not yet committed to the card.  If I power off the Netduino (+2) and reapply power the file is gone.  I have checked the card with power off as well as via the FTP server after it comes back online and in either case the file is MIA.  

 

The curious part is, if I repeat the test above, but wait a few minutes before dropping power to the Netduino, the file will actually be written to the SD card.  I assume there is some delay or time period that the Netduino firmware waits to commit data in RAM to the SD to prevent excess writing to the card, but the time is much too long IMO.

 

Cheers!



#30 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 12 November 2013 - 09:08 PM

wait a few minutes before dropping power to the Netduino, the file will actually be written to the SD card.  I assume there is some delay or time period that the Netduino firmware waits to commit data in RAM to the SD to prevent excess writing to the card, but the time is much too long IMO.

Yes, we have seen the same effect on our Mountaineer boards. Either it is an explicit delay for the reason you mentioned, or it is a bug (e.g. the flush may later be triggered by the finalization phase of a garbage collection run).

 

Anyway, the workaround in my previous post seems to work for Mountaineer boards. As the problem is probably in the porting kit and not Netduino-specific, it should also work on Netduinos. I have posted an issue here: http://netmf.codeple...m/workitem/2149

 

Cuno



#31 martinarcher

martinarcher

    Member

  • Members
  • PipPip
  • 16 posts

Posted 13 November 2013 - 12:26 AM

Cuno,

 

Thanks so much.  That works like a champ.  I added that into the FTP server after any file operation and it works great.

 

I really appreciate your quick work around.  Hopefully the Netduino folks will get a built in fix for the issue in the future but it's great to have a quick workaround for my product.  

 

Thanks again!



#32 gddnCode

gddnCode

    New Member

  • Members
  • Pip
  • 2 posts

Posted 23 January 2014 - 08:25 PM

Hi everyone

 

Does this help as a workaround?

 

[font="consolas;"][color=#0000FF;]new[/color][/font] Microsoft.SPOT.IO.[font="consolas;"][color=rgb(43,145,175);]VolumeInfo[/color][/font][font="consolas;"][color=#000000;]([/color][/font][font="consolas;"][color=rgb(163,21,21);]"SD"[/color][/font][font="consolas;"][color=#000000;]).FlushAll();[/color][/font]

 

Best regards

 

Cuno

 

This worked for me. Using a Netduino plus 2 firmware v4.2.2.2



#33 ncos

ncos

    New Member

  • Members
  • Pip
  • 1 posts

Posted 29 January 2014 - 02:50 AM

Does anyone know if this problem has been resolved?  I have worked through a ton of examples and honestly it seems hit or miss on weather the file is visible.

 

Nelson



#34 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 29 January 2014 - 07:07 PM

@ncos: does this mean the workaround does not work for you?

The issue is on Codeplex (issue 2149 - I can't paste the link, paste command seems to be broken), but not resolved yet.

 

Cuno



#35 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 27 May 2014 - 07:24 PM

it's an essential problem. I just wonder to buy N+2, but after read this thread....  I think twice, maybe it's ok to keep develop my project using N+  :wacko:



#36 600mL

600mL

    Member

  • Members
  • PipPip
  • 20 posts

Posted 28 May 2014 - 03:07 AM

it's an essential problem. I just wonder to buy N+2, but after read this thread....  I think twice, maybe it's ok to keep develop my project using N+  :wacko:

 

It works fine if you flush afterwards, eg:

        public void writeToFile(string data)
        {
            using (FileStream filestream = new FileStream(filename, FileMode.Append))
            {
                using (StreamWriter write = new StreamWriter(filestream))
                {
                    write.WriteLine(DateTime.Now + "," + data);
                }
            }
                        
            VolumeInfo.GetVolumes()[0].FlushAll();      // Force write to sd card
        }

In any case, even if you do not flush, the card will be written to eventually. I believe the data is buffered in memory and then written to when it reaches a certain level. I think this is to avoid too many short read/write operations to the SD Card which will probably impact on performance.



#37 DanielK

DanielK

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 19 June 2014 - 04:58 PM

600mL... you made my day! Thank you very much for this precious line of code:

 

VolumeInfo.GetVolumes()[0].FlushAll();  

 

I really was about to throw my N+2 out of the window... but now it gets a second chance ;) After having a lot of trouble with the GPS module, SD card was the next big problem. But that looks good now as well.

Let´s see what comes next ;)

 

Daniel






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.