Folks;
Does anyone know definitively whether the APIs:
StorageDevice.Unmount()
and
StorageDevice.MountSD()
do or do not work on the Neduino Plus 2? From experience?
Here is a test app that, for me, fails attempting to Unmount().
//testing StorageDevice.Unmount and StorageDevice.MountSD on the NP2using System;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.IO; //NOTE: you will need to add reference SecretLabs.NETMFIO.IOusing Microsoft.SPOT.IO; //NOTE: you will need to add reference Microsoft.SPOT.IOnamespace NP2VolumeMountTest{ public class Program { public static void Main() { bool bJoy = false; try { //first, get mounted volume names as a sanity check Debug.Print("listing mounted volumes..."); VolumeInfo[] volumes = VolumeInfo.GetVolumes(); foreach (VolumeInfo volumeInfo in volumes) { Debug.Print("volume: " + volumeInfo.Name); } Debug.Print("finished listing mounted volumes"); //now, we will try to unmount and re-mount the SD card Debug.Print("attempting to unmount SD card..."); StorageDevice.Unmount(@"SD"); Debug.Print("unmount success!"); //from schematic //using cpu spi module 3, /CS is B0, /CARDPRESENT is B5, /POWERCTL is B1 //from firmware .DeviceCodeTargetsNativeSTM32ManagedCodeHardwareCPU.cs //public const Cpu.Pin GPIO_PIN_B_0 = (Cpu.Pin)16; //public const Cpu.Pin GPIO_PIN_B_1 = (Cpu.Pin)17; //public const Cpu.Pin GPIO_PIN_B_5 = (Cpu.Pin)21; Debug.Print("attempting to re-mount SD card..."); StorageDevice.MountSD(@"SD", SPI.SPI_module.SPI3, (Cpu.Pin)16, (Cpu.Pin)21); Debug.Print("re-mount success!"); bJoy = true; } catch (SystemException e) { Debug.Print("failure; exception: " + e); Debug.Print(e.StackTrace); } Debug.Print("Test application main() terminating. " + ( bJoy ? "Have a nice day." : "It will be a long day." ) ); } }}
Let me know if there is a change that will make it work, and ideally what firmware version you are using. I myself have tested on firmware versions 4.2.1.0, 4.2.1.1, 4.2.1.2, 4.2.2.0, 4.2.2.1, 4.2.2.2.
While looking into a different problem (that of filesystem flushing), I started with the often-suggested workaround of doing an Unmount(). Of course, one would want to remount, right? Which was the motivation for this test: to figure out the MountSD parameters, but then I discovered that Unmount fails beforehand.
FWIW, I also tried fiddling with the "SD", trying upper, lower, leading slash, trailing slash, and null. (Examining the source, I didn't really expect those to help, but now you know I did try anyway).
Any confirmation that Unmount/MountSD do in fact work on the NP2 is useful, along with whatever beyond what I showed above that is necessary to make those calls work.
-knave