Cerberus & SD Card

Hi all,

I can use sd card with Hydra, but with same code it doesn’t work on Cerbrus. SD Card has 512Mb size, 512b block size and formatted as FAT32.

Debug.Print("SD Mounted");
//sdCard.MountSDCard();
VolumeInfo vi = sdCard.GetStorageDevice().Volume;
Debug.Print(vi.Name);
Debug.Print(vi.IsFormatted.ToString());
Debug.Print(vi.FileSystem);
Debug.Print(vi.TotalFreeSpace.ToString());

string root = sdCard.GetStorageDevice().RootDirectory;
Debug.Print("Root: "+ root);

Hydra output:
SD (Name)
True (IsFormatted)
FAT (FileSystem)
485508096 (TotalFreeSpace)
Root: \SD (RootDirectory)

Cerberus output:
Using mainboard GHI Electronics FEZCerberus version 1.1
Program Started
The thread ‘’ (0x3) has exited with code 0 (0x0).
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?

Thanks a lot for your help…

The SD drivers on cerb-family could use some improvement. We should get to is in near future and any contribution is welcome as well.

Thank you for your reply.
The product page of Cerberus says “4-bit SD/MMC Memory card interface”. And lots of people say “If your module has ‘?’ socket, and your board also has ‘?’ socket, than you can use that module with your board” in this forum. I bought 2 pieces of Cerberus, SD, Music Modules. What can I do now? I don’t have neither enough knowledge to change firmware code nor enough time to order new material. Can I handle this with .NET Framework?

Thanks.

All SD cards we have tested worked fine. Check for a good power source and maybe try a different card please.

The code you posted above works fine for me on 3 different Cerberus boards that I have, two SD modules and two microSD modules, 2 two different cards each. They work with FAT or FAT32 formatting.

My output on the last test:


Program Started
SD Mounted
SD
True
FAT
4006084608
Root: \SD
Program Finished

Some basic things to try:

Are you using a powered hub to connect the Mini-USB to your PC, or plugging it straight in?
Have you tried another cable or USB port?
Speaking of which, are you using a USB 2.0 or 3.0 port, and are you trying on Windows 7 or Windows 8?
Do you get the same results on both of your Cerberus boards?

Here is the entire Program.cs that works just fine for me:


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT.IO;

namespace SDCard_debug
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            Debug.Print("SD Mounted");
            //sdCard.MountSDCard();
            VolumeInfo vi = sdCard.GetStorageDevice().Volume;
            Debug.Print(vi.Name);
            Debug.Print(vi.IsFormatted.ToString());
            Debug.Print(vi.FileSystem);
            Debug.Print(vi.TotalFreeSpace.ToString());

            string root = sdCard.GetStorageDevice().RootDirectory;
            Debug.Print("Root: " + root);
            Debug.Print("Program Finished");
        }
    }
}


Here is some revised code that will let you know if for some reason your card isn’t mounting automatically. If I remove my card from the reader and start the debug session, I get the following:


Program Started
SD should be auto-mounted
SD Card Failed to mount!
The thread '<No Name>' (0x3) has exited with code 0 (0x0).

The code:


        void ProgramStarted()
        {
            Debug.Print("Program Started");
            Debug.Print("SD should be auto-mounted");
            //sdCard.MountSDCard();
            if (sdCard.IsCardMounted)
            {
                VolumeInfo vi = sdCard.GetStorageDevice().Volume;
                Debug.Print(vi.Name);
                Debug.Print(vi.IsFormatted.ToString());
                Debug.Print(vi.FileSystem);
                Debug.Print(vi.TotalFreeSpace.ToString());

                string root = sdCard.GetStorageDevice().RootDirectory;
                Debug.Print("Root: " + root);
                Debug.Print("Program Finished");
            }
            else
            {
                Debug.Print("SD Card Failed to mount!");
            }
        }

@ stevepresley - thanks a million for trying this on your end.

Glad to help - hopefully we can get his issue figured out. Nothing worse than trying to get stuff to work and not sure why you’re stuck. :wink:

@ stevepresley, thanks a lot.

I connect it to the USB 2.0 with USB SP & USB DP. Windows 7 Home EN, Visual Studio 2010 Pro EN.
I saw some earlier post in this forum that says “June 22 SDK has some issues with Cerberus and SD”. I use 10-24-2012 by the way…

What NETMF version are you using and what GHI SDK release? I may switch back to it.

I tired it on Hydra, worked fine. I didn’t update 2nd Cerberus firmware yet. But I’ll try on it soon.

It’s nice to hear that works on some configuration. It shows it can be done somehow.

Thanks.

the 24th October SDK is still a release candidate wasn’t it? The currently available SDK release from 29th November is a full release so I think you should move to that to try to debug further. No real point looking for behaviours that may only be evident in an old release - this will lighten the load on debugging this

I downloaded and installed 29, updated firmware, but it gives same output =(
SDK release notes says:
“On Cerb-family devices, SD card is not very stable. Possible improvement by next release.”
“Cerb-family SD card support is over-all functional but needs some improvements.”

If it’s functional, I may try some other SD cards.

I’m on the 4.2 10-24 release, I will update to the latest 11-29 release (which I didn’t see until just now to get a link) and verify that it still works on all of my boards.

If it works fine on the Hydra, I don’t think it’s the card. I think it may be a power issue. Is the USB cable you are using plugged straight into the PC, into a regular hub, or a powered hub?

I thought that the allocation unit size may cause some problems. But I tried all possible (512, 1023, 2048, 4096) values, but same result =(

@ semicolon - do you have a shorter Gadgeteer cable to try?

Dont bother. The Cerberus / SD Card problem is deeper than cables or power sources. I spent three months trying to get it to work. No matter what I did the Cerberus eventually locked up.

Its not the power. The Cerberus still locked up when powered via a USB Client DP Module with a Sola SDN 2.5-24-100P 24 volt power supply and an isolation transformer on the primary side.

It locked up after I shortened the Gadgeteer cable to 3/4.

It locked up no matter which SD card I tried…Scandisk / Kingston / PNY… 2GB / 4GB/8GB/16GB

It locked up with every Code example I could find.

I tried five separate Cerberus boards with five different SD Card Modules. Each one of them eventually locked up.

I thought I was onto something when I removed the SD Card from the Program.gadeteer diagram. The Cerberus actually ran for 3 days before it froze. I suspect there may be a conflict between the SDCard Class and StorageDev… but could never locate it.

I finally gave up when I read the November 29th release notes. - SD driver may cause a system lock up. I was out of time and GHI seems to have put the problem on the back burner.

In a last ditch effort to save my job I switched to the Spider… but couldnt get it to work at all with .NET Micro 4.2. Desperate, I rolled back the Spiders firmware and tweaked my code for 4.1. Its been running flawlessly for 19 days straight.

Ironically, I assumed that getting the Cerberus to read and write to Modbus registers was going to be the tricky part. Pish-Posh. It was gravey compaired to saving to the SD Card!

@ globe engineering - Cerberus SD drivers at not perfect today but they worked fine with cards we tested. We will be revisiting that very soon. But there are no known issues with spider 4.2 so please let us know if you see any issues.

Hopefully this will not give you a bad impression of our quality. Please remember you have used a beta software for those months. The non-beta software was release very recently with clear indication of SD driver issues. This is not because it is on back burner, but because we want you to be aware of problems we are still working on.

@ Gus; Do you sell these cards =) My project’s deadline is 27th, and I’m desperate right now =) If so I’ll buy 3 more Cerberus, 3 SD Card Modules with 5 SD Cards, 3 Music Modules…

Edit: Can you give info about your cards? What model, what size, what allocation size…

I’m using Sandisk and Kingston 2, 4 and 8gb cards.

Edit: and I’ve tested with one Amazon Basics 2gb card.

Thanks a lot for your efforts. I will try disabling sd card and music module for now.
I have about 40 monochrome bitmap to print from thermal printer. I embed 1 of them as resourse while developing and it works fine. I will embed others. And for mp3, I think I can use cheap mp3 player. Song starts when power is up and never changes, just repeats. I will try to figure out switching mp3 player on and making it play.