I am using the below code to mount an SD card on startup.
Code Language: C#
while (!PersistentStorage.DetectSDCard()) System.Threading.Thread.Sleep(50);
ps = new PersistentStorage(“SD”);
ps.MountFileSystem();
The issue I have is that, the line ps.MountFileSystem() will hang until i pause and then resume the visual studio debugger. once i do this the SD card mounts and works fine.
My sequence of events:
run debug from visual studio.
open up a terminal program and connect to the serial port (through usbcdc with debugger)
when no response comes from the FEZ, i swap back to the debugger and press pause
This pauses the solution on ps.MountFileSystem();
If i then click resume
the sd card mounts, and program execution proceeds
the serial port command previously written runs as expected.
There is no breakpoints set until after this point.
Now you’ve posted with the additional info about a connected debugger, that reminds me…
Can I suggest that you explicitly remove the debugger from this equation? There’s a known behaviour on the older USBizi 4.1 devices with the later SDKs and USB drivers that “pauses” the running application when you pause in the debugger (which is NOT the expected behaviour; the running app should continue to run when you stop debugging).
I’ve posted about this behaviour before and I’ll see if I can dig up the old post. Simple way to test this would be to have a LED blink example code and deploy that, you’ll see the LED stop blinking when you stop debugging. How about you have a test app that mounts the SD card and flashes a LED on a timer at two different frequencies (mounted or unmounted) and just power the device externally and see if the mount works then?
I have tried to remove the debugger from the equation by deploying the debug version of the code but it still doesn’t proceed past the point in my program, based on no communication from the serial communication.
The issue isn’t that the debugger causes problems, but rather, allows code to continue executing after pausing in the debugger.
if by leaving the SD card, you mean it being inserted on boot. then this is how it is currently being done (i’ve not tested to see if it works with the SD not inserted at boot).
if I remove the sd detect loop, the same problem occurs.
I shall try with external power adapter when i get home.
So, i tried with an external power supply and nothing changed.
I removed the mount code and put it later and it still stopped on that line of code.
I’m still not sure what the actual problem is, but it seems to be associated with the USB CDC and Debugging interface. What i did was only execute the SD card code (it was in a constructor) and my program worked fine.
I then looked at where my code went and the only other line of code which was executed before it was the creation of the usb connection.
I swapped my object creation and usb constructor and now my program works as expected.