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

Netduino 1 Firmware v4.1.1 BETA 1


  • Please log in to reply
42 replies to this topic

#21 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 08 April 2011 - 05:39 AM

Hi Chris,
The StorageDevice.MountSD() calls is generally the one throwing the exceptions. If that doesn't crash, the first I/O call throws the same exception:

using (var reader = new StreamReader(SdMountPoint + @"\" + resourceManifest)) {...}

You can see the source code that I'm using here http://netduinohelpe...sourceLoader.cs
or this one for basic regression testing:
http://netduinohelpe...Test/Program.cs

I was using the 'Beta 1' version of the SecretLabs.NETMF.IO.dll, along with firmware 4.1.1 Beta 1 after I re-flashing the netduino from scratch with SAM-BA 2.0.

Cheers,
-Fabien.

#22 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2011 - 05:43 AM

Hi Fabien, We'll dig into this. BTW, are you using @"\SD\filename.ext" to access files...or @"SD\filename.ext"? It looks like the code is using the latter...I'd highly recommend using an absolute path (including the initial backslash) if possible. Not sure that has anything to do with the issue at hand or not though. Chris

#23 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2011 - 05:49 AM

Hi Fabien, One more thing really quick. As of v4.1.1 beta 1, the "chip select" and "spi module" properties passed into the MountSD card are used. Before, we had it hardcoded to "SPI1...pins D11-D13" and "SPI_CS on pin D10". Would it be possible to have you attach a small repro project which shows the exact issue at hand...and also list which shield or accessory you're using to connect MicroSD? [A Fritzing diagram would also be wonderful--but I know that's asking a lot.] When we first switched over to beta 1, we found that quite a few users were using "Cpu.Pin.###10" instead of "Pins.###_D10", etc. etc. So it's possible (though not certain) that this is a configuration issue. Chris

#24 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 08 April 2011 - 06:42 AM

I forgot to mention that CLR_E_VOLUME_NOT_FOUND occured as well on the MoutSD() call.

#25 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 08 April 2011 - 06:45 AM

Hi Fabien,

We'll dig into this.

BTW, are you using @"\SD\filename.ext" to access files...or @"SD\filename.ext"? It looks like the code is using the latter...I'd highly recommend using an absolute path (including the initial backslash) if possible. Not sure that has anything to do with the issue at hand or not though.

Chris


No, the path is not the issue here. The same code works on one build but not the other.

#26 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 08 April 2011 - 06:51 AM

Hi Fabien,

One more thing really quick.

As of v4.1.1 beta 1, the "chip select" and "spi module" properties passed into the MountSD card are used. Before, we had it hardcoded to "SPI1...pins D11-D13" and "SPI_CS on pin D10".

Would it be possible to have you attach a small repro project which shows the exact issue at hand...and also list which shield or accessory you're using to connect MicroSD? [A Fritzing diagram would also be wonderful--but I know that's asking a lot.]

When we first switched over to beta 1, we found that quite a few users were using "Cpu.Pin.###10" instead of "Pins.###_D10", etc. etc. So it's possible (though not certain) that this is a configuration issue.

Chris



That's a good thought but the pin assignment is not the issue either.
The SD card reader is attached to SPI through pin 10 to 13 on the netduino.
I've attached the project that I've been using to do the regression testing along with the file being read by the test.

I hope this helps.

Attached Files



#27 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 08 April 2011 - 03:37 PM

Chris,
Out of curiosity, has SecretLabs tested with the AdaFruit microSD card reader? http://www.adafruit....products_id=254


-Fabien.

#28 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 09 April 2011 - 04:10 AM

Chris, I have found a repro which works 100% of the time with Alpha 7. Before I go into too much details, I have two questions: what is the configuration of SPI for SD I/O in Alpha 7 and Beta 1? Are you aware of possible issues when other SPI devices are configured differently than the StorageDevice class? On the netduino SPI bus, beside the SD card reader, I'm using a MAX7219 LED driver (using Pin D8 for chip select) which makes use of ExtendedSpiConfiguration for 16 bit I/O @ 10 MHz. I'm beginning to suspect a potential problem between the two but I have not validated that theory yet. Thanks, -Fabien.

#29 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 April 2011 - 05:07 AM

Hi Fabien,

Out of curiosity, has SecretLabs tested with the AdaFruit microSD card reader? http://www.adafruit....products_id=254

Yes, this is actually our test platform for making sure MicroSD is working on Netduino Mini. We have also tested it with the regular Netduino.

I have found a repro which works 100% of the time with Alpha 7. Before I go into too much details, I have two questions: what is the configuration of SPI for SD I/O in Alpha 7 and Beta 1? Are you aware of possible issues when other SPI devices are configured differently than the StorageDevice class?

Ah, very interesting. There could be an issues with .NET MF switching back and forth between the two. Perhaps something we need to tweak in the SD or SPI drivers, etc.

We can certainly pick up a MAX7219 LED driver to do some more in-depth testing if you have a bit of repro code. [If/when you post it, please verify that the code _does_ work with v4.1.1 a7 but no with v4.1.1 b1.]

Thanks, Fabien!

[BTW, I'm headed to Microsoft MIX. I'll be checking into the forums a bit while I'm gone...but coordinating firmware updates and such will be a bit delayed for 3-4 days...]

Chris

#30 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 09 April 2011 - 09:25 PM

Hi Chris,

I've been narrowing down the SD card issues that I've been observing, starting with 4.1.1 Alpha 7.

Test setup (see attached picture)
  • netduino mini
  • firmware 4.1.1 a7
  • a 64 MB SD card
  • a 1GB micro SD card + SD adapter
  • a Futurlec SD card reader
  • resources.txt : a file with a few lines of random text located at the root of each SD card
Test code

        public static void Main()
        {
#if NETDUINO_MINI
            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_13);
#else
            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
#endif

            using (var filestream = new FileStream(@"SD\resources.txt", FileMode.Open))
            {
                StreamReader reader = new StreamReader(filestream);
                Debug.Print(reader.ReadToEnd());
                reader.Close();
            }

            using (var filestream = new FileStream(@"SD\dontpanic.txt", FileMode.Create))
            {
                StreamWriter streamWriter = new StreamWriter(filestream);
                streamWriter.WriteLine("This is a test of the SD card support on the netduino...This is only a test...");
                streamWriter.Close();
            }

            StorageDevice.Unmount("SD");
        }


Test steps:
  • Insert the 1GB micro SD card in the SD adapter
  • Insert the SD adapter into the SD card reader
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test succeeds and the content of 'resources.txt' is displayed
  • Swap out the SD adapter with the 1GB micro SD card for the 64 MB SD card
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test fails with #### Exception System.IO.IOException - CLR_E_VOLUME_NOT_FOUND (1) #### on the following call: StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
  • Pull the 64 MB SD card out of the SD card reader
  • Re-insert the 64 MB SD card out of the SD card reader (note: on occasions, steps 8, 9 & 10 must be repeated a few times for step 11 to succeed)
  • Execute the test code again
  • Observe the results in the output window -> the test succeeds and the content of 'resources.txt' is displayed
  • Repeating this test consistently produces the same results.
Conclusion
  • On a netduino mini running firmware 4.1.1 a7, it appears that swapping between different types of SD cards, specifically going from a 1GB microSD card mounted in an SD card adapter to a regular 64MB SD card causes the netduino to fail recognizing the card every single time. Re-inserting the 64 MB card appears to resolve the issue most of the time.
  • Is the .Net MF on the netduino mini preserving some state about the SD device and file system being mounted when it should not?
My next step will be to repeat this same test with a regular netduino and an AdaFruit SD card reader. Stay tuned.

Attached Files



#31 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 09 April 2011 - 09:54 PM

Test setup (see attached picture)
  • netduino
  • firmware 4.1.1 a7
  • a 1GB micro SD card + SD adapter
  • an AdaFruit microSD card reader
  • resources.txt : a file with a few lines of random text located at the root of each SD card
Test code


        public static void Main()
        {

#if NETDUINO_MINI
            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_13);
#else
            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
#endif

            using (var filestream = new FileStream(@"SD\resources.txt", FileMode.Open))
            {
                StreamReader reader = new StreamReader(filestream);
                Debug.Print(reader.ReadToEnd());
                reader.Close();
            }

            using (var filestream = new FileStream(@"SD\dontpanic.txt", FileMode.Create))
            {
                StreamWriter streamWriter = new StreamWriter(filestream);
                streamWriter.WriteLine("This is a test of the SD card support on the netduino...This is only a test...");
                streamWriter.Close();
            }

            StorageDevice.Unmount("SD");
        }

Test steps:
  • Insert the 1GB micro SD card in the AdaFruit microSD card reader
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test fails with #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) #### on the following line: using (var filestream = new FileStream(@"SD\resources.txt", FileMode.Open))
  • Eject the micro SD card from the AdaFruit reader
  • Re-insert the microSD card into the AdaFruit reader
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test fails with #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) #### on the following line: using (var filestream = new FileStream(@"SD\resources.txt", FileMode.Open)). The test will continue to fail no matter how many times the microSD card gets ejected / re-inserted into the AdaFruit reader.
  • Eject the microSD card from the AdaFruit reader
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test fails with #### Exception System.IO.IOException - CLR_E_VOLUME_NOT_FOUND (1) #### on line StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10); which is expected.
  • Re-insert the microSD card into the AdaFruit reader
  • Execute the test code under the debugger
  • Observe the results in the output window -> the test succeeds and the content of 'resources.txt' is displayed


Note: in this test, switching between two different types of microSD cards did not cause the test to succeed.


Conclusion
  • On a regular netduino running 4.1.1 Alpha 7, reading a 1GB microSD card using an AdaFruit microSD reader will always fails until a CLR_E_VOLUME_NOT_FOUND exception occurs. Subsequent attempts to read / write to the microSD card will succeed after that.
  • What kind of state is being reset by the .Net MF on the netduino when a CLR_E_VOLUME_NOT_FOUND exception occurs?
My next step is to repeat this test with firmware 4.1.1 Beta 1 on a regular netduino and a netduino mini. Stay tuned.

Update: This test results in the same exact behavior under 4.1.1 Beta 1 on a regular netduino.


Additional data point: attempting to run this test sequence outside of the debugger, using the reset button of the netduino after an exception occurs and ejecting/re-inserting the microSD card, always fails.

Attached Files



#32 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 17 April 2011 - 09:35 PM

Hi Chris, Are these tests helpful? Was someone @ SecretLabs able to get a repro? -Fabien.

#33 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 24 May 2011 - 07:51 PM

Hi Chris, I was wondering about the status of the microSD card bugs that I reported above: was there traction @ SecretLabs on repro'ing / resolving them? Thanks, -Fabien.

#34 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 May 2011 - 04:48 PM

Hi Fabien, You have mail. Chris

#35 Mati

Mati

    New Member

  • Members
  • Pip
  • 9 posts
  • LocationIsrael

Posted 30 May 2011 - 05:43 PM

Hi Chris!

I've got myself into troubles today with my Netduino.

Got the 4.1.1 b1 firmware. The Echo app worked well, so I moved to the Keyboard sample.
I think I've followed all the steps as posted, but for some reason it didn't work.

I got the message that I should reconnect the USB. After reconnecting, it still was stuck in the
status polling loop. I never got a "Running" PortState, got "Attached" and then it turned to "Suspended" for some
reason.

After that problem, I couldn't deploy via serial anymore. Each attempt would get VS stuck (I did had external AC and all
the requirements as posted here). MFDeploy also couldn't ping the device through Serial or USB.

My only solution was to use the erase pad and reprogram with SAM-BA.

Didn't tried it again though, hope it won't reproduce. I'll be glad if someone could
explain what happened to my board. Is it a common faulty behavior?

I've noticed that in the "Safely Remove Hardware" (win xp sp3) I had a device called
"USB Serial Converter" - trying to remove it caused my OS to stuck for a while. Also, trying disabling it through the
Device manager - made the mmc console to crash lol. Hard reset solved everything :). I'm wondering if that device could
make the netduino not recognized as a HID? I'm thinking that the "converter device" mentioned above is related to my FTDI 3.3v basic breakout board which required special VCP drivers. After restarting it didn't appeared again and everything was back to normal.

I wish the MSDN could be more informative about that PortState enumeration. Here you can see how funny it's documented.
Windows XP SP3, Q6600.

#36 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 May 2011 - 06:06 PM

Hi Mati, If you have a chance to try this again, could you reboot your computer once? It sounds like the Windows driver stack may have been hung up and couldn't get around to enumerating the Netduino as a device... Chris

#37 Niko

Niko

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationSlovenia

Posted 30 December 2011 - 10:43 AM

Hi, I have tried to read/write to micro SD card using several code examples but unfortunately none worked using Adafruit micro SD breakout board and kinkston micro SD card 4GB (FAT32 format). I upgraded the firmware, downloaded SecretLabs.NETMF.IO_beta library and couldn't succesfully run any program. By the way, at first,when the firmware was upgraded but haven't included the newer (beta) SecretLabs.NETMF.IO library I could debug the program but it threw an exception. Then when I added the beta library I couldn't debug the program. After that I tried to remove the reference and add it again and sice then every time I try to build the project it throws an error: "An error has occured: please check your hardware". To fix the problem I tried to connect and disconnect the Netduino, run MFDeploy->Erase, but just couldn't fix the problem. I would be very thankful for any advice on how to enable SD card reading/writing using Adafruit micro SD breakout board. Regards, Niko

#38 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 December 2011 - 04:24 PM

Hi Niko, 4GB cards are particularly problematic. Many went into production when the 2GB limitation on SD card sizes was still in place...and there were several "custom" implementations. Do you have a <=2GB card you can try by any chance? Or even a larger 8GB/16GB card? Chris

#39 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 13 January 2012 - 09:58 PM

Version: 4.1.1 BETA 1 (version 4.1.1.0 b1)



Is source available for this version of the firmware? I couldn't find a link for it...

#40 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 January 2012 - 03:56 AM

Hi ajcg1973,

Is source available for this version of the firmware? I couldn't find a link for it...

It should be on CodePlex. Go to the Source page...then select the v4.1.1.x branch.

Chris




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.