Still have some troubles with some usb memory sticks

Hello all

I don’t know why but some memory sticks can not be readable:

Device connected…
ID: 2694788704, Interface: 0, Type: 6
USB Mass Storage detected…
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (3) ####
#### Message:
#### Microsoft.SPOT.IO.NativeIO::GetAttributes [IP: 0000] ####
#### System.IO.Directory::Exists [IP: 0015] ####
#### System.IO.Directory::GetChildren [IP: 000a] ####
#### System.IO.Directory::GetFiles [IP: 0008] ####
#### MFConsoleApplication1.Program::DeviceConnectedEvent [IP: 008a] ####
#### GHI.Premium.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHI.Premium.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHI.Premium.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####
Une exception de première chance de type ‘System.NotSupportedException’ s’est produite dans Microsoft.SPOT.IO.dll
#### Exception System.IO.IOException - CLR_E_DIRECTORY_NOT_FOUND (3) ####
#### Message:
#### System.IO.Directory::GetChildren [IP: 0017] ####
#### System.IO.Directory::GetFiles [IP: 0008] ####
#### MFConsoleApplication1.Program::DeviceConnectedEvent [IP: 008a] ####
#### GHI.Premium.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHI.Premium.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHI.Premium.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####
Une exception de première chance de type ‘System.IO.IOException’ s’est produite dans System.IO.dll
Une exception non gérée du type ‘System.IO.IOException’ s’est produite dans System.IO.dll

Here’s the code:

using System;
using Microsoft.SPOT;
using System.IO;

using System.Threading;
using GHI.Premium.System;
using GHI.Premium.USBHost;
using Microsoft.SPOT;
using GHI.Premium.IO;

namespace MFConsoleApplication1
{
    public class Program
    {
        public static PersistentStorage USBps;

        public static void Main()
        {
            // Subscribe to USBH events.
            USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
            USBHostController.DeviceDisconnectedEvent += DeviceDisconnectedEvent;
            // Sleep forever
            Thread.Sleep(Timeout.Infinite);

        }

        static void DeviceConnectedEvent(USBH_Device device)
        {
            Debug.Print("Device connected...");
            Debug.Print("ID: " + device.ID + ", Interface: " + device.INTERFACE_INDEX + ", Type: " + device.TYPE);
            if (device.TYPE == USBH_DeviceType.MassStorage)
            {
                Debug.Print("USB Mass Storage detected...");
                Thread.Sleep(1000);
                USBps = new PersistentStorage(device);
                Thread.Sleep(1000);
                USBps.MountFileSystem();
                Thread.Sleep(1000);
                string[] pth = Directory.GetFiles("\\USB\\");
                for (int i = 0; i < pth.Length; i++)
                {
                    Debug.Print(pth[i]);
                }
            }
        }

        static void DeviceDisconnectedEvent(USBH_Device device)
        {
            Debug.Print("Device disconnected...");
            Debug.Print("ID: " + device.ID + ", Interface: " +
                     device.INTERFACE_INDEX + ", Type: " + device.TYPE);
        }
    }
}

[edit] This happens with a 64Gb MemoryStick

Did you try to format (not quick format) your Drive? Try to forma on a PC and on NETMF?

I did it in the past but was using 4.2.10SDK and I have noticed that the format method have change in the last SDK . I will give it a try…

In fact the 64GB memory stick is formatted as NTFS. That may be the reason…

let’s go for a new format process (2-3h ours each). This time in order to force fat32 I will use : http://www.ridgecrop.demon.co.uk/guiformat.exe

May you know what should be the allocation unit size?

@ leforban - Also, it seems as though the 64GB class is split between SDHC and SDXC. Some have HC models, but the better ones are XC models. What does your card state?

This is a USB memory stick, how to know what kind of memory it is? is there a tool that gives that?

Any way, I succeed with the tool available on the previously provided link to format the USB memory stick as FAT file system and I can read files on it. Still need to make the same process with the other usb memory stick to see if there’s still some cases where it does not work.