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

HD SD card and 4.2 RC3


  • Please log in to reply
9 replies to this topic

#1 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 05 November 2011 - 08:58 AM

Hi
Hoping for some ideas on why my SD card no longer reads or writes after my upgrade to Firmware_NetduinoPlus_4.2.0.0_RC3.

I am using a 4gig HD SD card that worked with the same source code on a later version of 4.1, in fact its been logging data and running a threaded web server for about a month without this problem.

Today, after the upgrade, my code no longer works, so to try to debug it I have been using someones test code that reproduces the same fault. See below.(Thanks for the demo code)

Firstly an exception gets thrown as the first line runs. This has been mentioned in the forums and after about 30 seconds the code continues.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Secret Labs\Netduino SDK\Assemblies\v4.2\le\SecretLabs.NETMF.Hardware.NetduinoPlus.dll', Symbols loaded.
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.SPOT.Native.dll

(I am not sure if this is part of the main problem, I just included it for completeness, apparently it will be suppressed in the release build. All I can say is that waiting 30 seconds or so is annoying.)

The real problem happens when an exception gets thrown on Directory.SetCurrentDirectory(root);

A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.IO.dll
A first chance exception of type 'System.IO.IOException' occurred in System.IO.dll

If I dig deeper into the exception I get
ErrorCode DirectoryNotFound System.IO.IOException.IOExceptionErrorCode

There is also m_HResult -486539264 int

There clearly is a directory here because the previous line
System.IO.Directory.GetDirectories(@"\") returns an array of which element the first element is "\\SD";

Other things to bear in mind are I installed the RC3 in the correct order as per the instructions and all the referenced .net micro framework assemblies have a version of 4.2 and a runtime version of v4.0.30319 (Although I dont know what the difference is)


Here is the full test code.
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace MicroSdTest
{
    public class Program
    {
        private static System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

        const String root = "\\SD";

        public static void Main()
        {
            try
            {
                System.IO.Directory.GetDirectories(@"\");
                Directory.SetCurrentDirectory(root);

                String[] files = Directory.GetFiles(".");
                foreach (String file in files)
                {
                    Debug.Print(file);
                }

                String dir = Directory.GetCurrentDirectory();
                String fileName = "testsdcard4gig.txt";
                Debug.Print(fileName);

                String testWrite = "Hejsan hoppsan i lingonskogen!";
                File.WriteAllBytes(fileName, encoding.GetBytes(testWrite));

                byte[] testRead = File.ReadAllBytes(fileName);
                Debug.Print(new String(encoding.GetChars(testRead)));

                Thread.Sleep(100000);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }


        }
    }
}

STEFF Shield High Powered Led Driver shield.

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 November 2011 - 09:05 AM

Hi Magpie, Very interesting. Thanks for the details. The .NET MF team updated the SD card driver dramatically with 4.2, including a re-implementation of "SD 2.0" support...so some tweaks may need to be made to get your card working again. Could you please open a work item on this at netduino.codeplex.com? I'm guessing that the delay is an SD-related delay and not a general NETMF 4.2-related delay. If you pull out the SD card, does that delay go away? If you deploy a simpler program like "blinky" does the delay also go away then? Chris

#3 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 05 November 2011 - 09:18 AM

Both removing the card and running blinky means the debugger skips pass the delay, although the exception is still thrown in both cases. I will open a work item on this at netduino.codeplex.com ps. the Card is Lexar 4gb.
STEFF Shield High Powered Led Driver shield.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 November 2011 - 09:21 AM

ps. the Card is Lexar 4gb.

Thanks for all the great debug info.

BTW, 4GB MicroSD cards are the most likely SD cards to cause trouble. The original MMC/SD standard was implemented fairly standard through 2GB cards...but then a few approaches were used by card manufacturers trying to build 4GB cards. Most of the 4GB cards today use the "2.0" standard. Some stretched within the "1.0" standard to make 4GB work. And others may have created their own solutions entirely.

Chris

#5 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 05 November 2011 - 09:28 AM

I'll never buy 4gb again, but it has been working for a month without a problem, logging every 5 minutes to give 1.2 MB of data. So it can't be too bad. Also thanks for the quick response.
STEFF Shield High Powered Led Driver shield.

#6 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 05 November 2011 - 09:40 AM

Both removing the card and running blinky means the debugger skips pass the delay, although the exception is still thrown in both cases.


I will open a work item on this at netduino.codeplex.com

ps. the Card is Lexar 4gb.



Correction:

Blinky running without card inserted has no delay.

Blinky running with card inserted has the delay.
STEFF Shield High Powered Led Driver shield.

#7 tracstarr

tracstarr

    Member

  • Members
  • PipPip
  • 14 posts

Posted 05 November 2011 - 10:09 PM

Just to help out I gave it a run since i'm on 4.2. No issues here using a 2gb or 8gb card. No 4gb card to try with.

#8 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 07 November 2011 - 10:40 PM

Just to help out I gave it a run since i'm on 4.2. No issues here using a 2gb or 8gb card. No 4gb card to try with.


Well I took the advice offered and now own a 2gb micro sd (non HD) card, the good news is that now everything works.

So just to spell out the Moral of this story, "Dont buy a 4 gb micro SD card, they might not be HD standards compliant".

Now I'll go back to my real hobby, which at the moment seems to be digging holes under the house.
STEFF Shield High Powered Led Driver shield.

#9 skysoft

skysoft

    New Member

  • Members
  • Pip
  • 1 posts

Posted 13 November 2011 - 08:44 PM

Just for the records, i have a kingston 4GB. print on card : microsd HC 4GB SDC4/4GB10 same problem ! time to order 2 GB. thanx, M

#10 Serkan Polat

Serkan Polat

    Member

  • Members
  • PipPip
  • 17 posts

Posted 13 December 2011 - 12:38 PM

Just to help out I gave it a run since i'm on 4.2. No issues here using a 2gb or 8gb card. No 4gb card to try with.



so is there any limitation on 4.2?
i mean i want to use 8 or 16gb for playling mp3..




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.