Main Site Documentation

Cerberus with SD Card issue


#1

I have been played around my Cerberus for few weeks. Recently, I started working on the SD card.
I have followed the tutorial mentioned in the SD card module. However I have run into a problem that I needed to reload the bootloader and firmware after downloading the program.

I connected the SD card module to socket 7 without the SD card first. Then I started the program. The number is printed every second as expected.
After I inserted the SD card, the program stopped. No response came from the Cerberus even in the .NET Micro Framework Deployment Tool. I have to reload the boot-loader (ver. 4.2.4.0) and the non-Ethernet firmware to get the board back to work.

Has anyone run into the same issue? How do I resolve the problem?

James


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;

namespace GadgeteerApp1
{
    public partial class Program
    {
        long i = 0;
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing 
            their name followed by a period, e.g.  button.  or  camera.
            
            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>
            
            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
            GT.Timer timer = new GT.Timer(1000);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);
            timer.Start();
        }

        void timer_Tick(GT.Timer timer)
        {
            Debug.Print("I: "+i++);
        }
        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("The SD card has been unmounted");
            Debug.Print("DO NOT try to access it without mounting it again first");
        }

        void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
        {
            Debug.Print("SD card has been successfully mounted. You can now read/write/create/delete files");
            Debug.Print("Unmount before removing");
        }
    }
}


#2

can you please update your user name so we are not just calling you User_11850?


#3

I was just too lazy to change the user name. Sorry about that. My profile has been updated. But I don’t know how to place the mark at the right location on the google map.

Men-Shen


#4

It should do it for you if you have you address information entered.


#5

I could not find the address field in the profile page. Never mind, I have put my web link. This should be enough to identify myself.


#6

I’ve just tested this with two SD cards, and the app works fine. I’m using a Cerberus rev 1.1 board with the latest 4.2.4.0 firmware (non-Ethernet)

First with a PQI microSD (2Gb) in a Sandisk uSD adapter. App works fine in detecting both inserted and removed media.
Second with a cheapie 8Gb card. App works fine in detecting the insert event, but can’t read from the card so fails to fully mount it, but then detects when I remove it and stops trying to mount it.

This was with a SD Card module, version 1.4.

Then I decided to try out my micro SD card module (ver 1.2). Without changing the deployed app, powered down the device, swapped SD for uSD module, and reconnected the device to the PC. I then used MFDeploy to connect and see the debug messages. Everything worked fine until I inserted the PQI uSD card into the holder. Then I got the same “app hung” behaviour. However, mine is not displaying the same behaviour in requiring the firmware to be redeployed. A simple press of the reset button and the app starts again. The app even detects unloading the uSD card if I restart with it inserted, but then on reinserting it, it will pause.

Typical output on uSD after a reset and then removing the uSD card, then trying to reinsert it.

I: 82
I: 83
The SD card has been unmounted
DO NOT try to access it without mounting it again first
I: 84
I: 85
I: 86
I: 87
I: 88

Gus/team, anything you’d like to try/know? It’s weird that the same uSD card behaves two different ways, once in the uSD module and one in the SD card adapter + SD module.


#7

OK, I took this code http://www.tinyclr.com/forum/topic?id=8508&page=1#msg96813 and tried it out too.

What is strange is that it worked ONCE using the uSD module and the uSD card; it was totally random and I haven’t been able to repro it now (I was thinking this was magic code but no).

I added a timer with 500msec period and just called PulseDebugLED() and the LED definitely stopped when the insert happens.

Edit: I found another uSD (generic 1Gb) and it works fine in the adapter in the full SD module, but fails in the uSD module


#8

What is equally interesting is with the fullsize SD card module, the LED flash stops at card insert time for somewhere around a second. On my dodgy / cheapie “elite pro” card that doesn’t work at all, the LED flash looks very strange - short flash followed by a long flash for up to 5 seconds.


#9

I tried a simpler code without the SD card inserted :


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;

namespace GadgeteerApp1
{
    public partial class Program
    {
        long i = 0;
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
//
            GT.Timer timer = new GT.Timer(1000);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);
            timer.Start();
        }

        void timer_Tick(GT.Timer timer)
        {
            if (i > 10)
                sdCard.MountSDCard();
            Debug.Print("I: "+i++);

        }
        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("The SD card has been unmounted");
            Debug.Print("DO NOT try to access it without mounting it again first");
        }

        void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
        {
            Debug.Print("SD card has been successfully mounted. You can now read/write/create/delete files");
            Debug.Print("Unmount before removing");
        }
    }
}

The outputs of the debugging window shows that the board hangs at the 10th tick. I have to press the reset button to get it back to work.


Pinging... TinyCLR
User Cancel...
Connecting to Cerb-Family_Gadgeteer...Error: No response from device
Failure - Device Cerb-Family_Gadgeteer is invalid or not responding
Connecting to Cerb-Family_Gadgeteer...Connected
I: 0
I: 1
I: 2
I: 3
I: 4
I: 5
I: 6
I: 7
I: 8
I: 9
I: 10
Pinging... NoConnection
Pinging... I: 0
I: 1
I: 2
I: 3
TinyCLR
I: 4
I: 5
I: 6
I: 7
I: 8
I: 9
I: 10
Pinging... NoConnection

The Output window shows:

Found debugger!

Create TS.

 Loading start at 805e940, end 808755c

   Assembly: mscorlib (4.2.0.0)     Assembly: Microsoft.SPOT.Native (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware (4.2.0.0)  
   Assembly: Microsoft.SPOT.Graphics (4.2.0.0)     Assembly: Microsoft.SPOT.TinyCore (4.2.0.0)  
   Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0)     Assembly: Microsoft.SPOT.IO (4.2.0.0)  
   Assembly: System.IO (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware.OneWire (4.2.0.0)  
   Assembly: Microsoft.SPOT.Hardware.Usb (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1)  
   Assembly: Microsoft.SPOT.Net (4.2.0.0)     Assembly: System (4.2.0.0)  Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: Gadgeteer (2.42.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.SDCard (1.1.1.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.Gadgeteer.FEZCerberus (1.1.2.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Touch (4.2.0.0)  Attaching deployed file.

   Assembly: System.Http (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.OSHW.Hardware (4.2.4.0)  Attaching deployed file.

   Assembly: GadgeteerApp_SDtest (1.0.0.0)  Attaching deployed file.

   Assembly: System.Net.Security (4.2.0.0)  Resolving.

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.OneWire.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\SDCard\NETMF 4.2\le\GTM.GHIElectronics.SDCard.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI OSHW NETMF v4.2 SDK\Assemblies\le\GHI.OSHW.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZCerberus\NETMF 4.2\le\GHIElectronics.Gadgeteer.FEZCerberus.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Http.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'd:\users\tsai\documents\visual studio 2010\Projects\GadgeteerApp_SDtest\GadgeteerApp_SDtest\bin\Debug\le\GadgeteerApp_SDtest.exe', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZCerberus version 1.1
Program Started
I: 0
I: 1
I: 2
I: 3
I: 4
I: 5
I: 6
I: 7
I: 8
The thread '<No Name>' (0x3) has exited with code 0 (0x0).
I: 9
I: 10

No response even I inserted an SD card when i==10.

MS


#10

I would like to know what SD card module you have (uSD or full-size) and what revision it has stamped on it.


#11

I made the SD module myself based on the schematic shown on the web (local distributor does not carry the SD card module ). I have double checked the wiring to make sure they are connected correctly. Today, I made a second socket module and it worked. It turns out that one of the pin on the first SD card socket is broken (open circuit).

It would be nice if the mountSDCard() could print some messages, e.g., timeout rather than just freezing.
Thanks for all your help.

Men-Shen


#12

Nice! Share some pictures of your module, please.


#13

I like to share my photos. But I get some errors when I submit a post with photos!!!


#14

OK, so my suspicion is that there might be a hardware peculiarity that causes some of this behaviour; there were early issues with SD cards on things like Panda and Panda II, through decoupling power issues.

Gus and GHI, can you tell us if you’ve picked this up to investigate? I can repro reliably with the uSD module on a card that works fine in an adapter in the SD module.


#15

@ Brett - I thought it was broken pin on his module. :wink:


#16

Yes, that is true as well, but it doesn’t explain the symptoms I see - perfectly working card in one module then not in another


#17

Architect asked me to upload the photo of my home-made SD card module. The photo is in JPG format. I got “server not response” when I pressed the submit button.


#18

Sorry about that, we are moving tinyCLR to GHI main website so things are a bit broken


#19

Just bumping this back up. uSD card in adapter works fine on GHI SD card module but same uSD card directly in GHI uSD module doesn’t. Any thoughts?


#20

Same cable?