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");
}
}
}
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.
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.
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
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.
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
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.
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.
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.