Prevent corrupted SD card on deploy

For a while I was unsure of why the data on the SD would sometimes be corrupted.
I finally found the problem: If I’m writing on the SD (I’m unsure about reading) WHILE deploying the application, what happens is that there is a reboot done at that moment.

Would it be possible to unmount the SD Card before rebooting, OR maybe a Soft shutdown first (Maybe a DoBeforeShutdown event?)

For now what I do is, I try to never deploy while there might be operation on the SD card, but its not always possible.

To fix a corrupted SD Card, I have to put it in a PC, type chkdsk /f for it to fix the issues.

Also is there a function in netMF to fix a corrupted SD card (or to check it)?

Finally, on very rare occasion, I even had double filename in the same directory! This is very weird for example in windows explorer I see 2 log123.txt, then I have to delete both to fix that particular issue.

Which board are you using?

a G120, custom board using Cobra schematic.
But had the same issue with an EMX spider, and G120HDR.

You can only get information how it was reset (register RSID) but no way to be informed about it when it gets executed. I think this could be easily added to the firmware to raise some kind of NetMF event.

@ PhilM - Are you are saying that a program was writting to the sd when we’re deploying a new program.

a deploy will result in a reboot of the device so the device can go into debug mode. this is normal.

you will need to add a button or some other way of telling the program to stop writting and flush the file system to the sd, before deploying.

of course, you have the potential of the same problem should the power be removed from the device.

1 Like

@ Mike Yep that’s what I mean.

I understand that with a power loss, theres a chance to corrupt data on the SD card.
An even better solution would be a way to self check the sd card and repair files, but I’m not sure how complex that would be…

Power loss is not that frequent, the major issue is when we connect the the device, our program boots up, and loads all kind of stuff from the SD card, and often thats when we also want to deploy new code (you power up device, hit deploy).

Now each time I’m programming, I have to remember not to hit deploy right away, wait 30 seconds or so before doing so to prevent any data corruption.

A button is an idea, but I would prefer a software solution.
An event before shutdown, if that would be possible, would work I think^

My problem is that the my Spider-based system crashes seriously, if there is an error on the SD card. Moving it to windows and doing a chkdsk /f helps but its annoying that not even an exception is thrown, anyone with same experiences?

A method of checking for errors and file-consistency would be extremely helpful - as currently, and call to an SD-related function reboots the system.

@ PhilM - Since in normal operation, software deployment is not done very often, it would be difficult to convince MS that a debugger attached event is a priority issue.

There is the continual balance of functionality versus resources. Every feature added to the MF base must be very important to a large group of users, in order to justify the use of limited resources.

An easy workaround, like a button, removes the “essential” modifier from the feature. While it would be “nice”, it is unlikely to happen. Of course, if no one submits a request to MS for the feature, it will never happen.