auto-format of microSD and boot with no microSD

456 views
Skip to first unread message

Andrew Tridgell

unread,
Feb 6, 2015, 3:14:21 AM2/6/15
to drones-...@googlegroups.com
Hi All,

After some discussions with Randy and Jon today I have pushed some
changes to master to how we handle missing or corrupt microSD on
Pixhawk.

We now do the following:

1) we try to mount the microSD at boot. If that works then we boot
normally

2) if we can't mount the microSD then we try to format the microSD as a
FAT filesystem. Duing the formatting we play a distinctive tune. If
the formatting succeeds then we mount it and boot normally.

3) if we can't format and mount the microSD (or no microSD is inserted)
then we check if there is a USB cable connected. If there is a USB
cable connected then we start a NuttX nsh shell on the USB port
(this matches previous behaviour of what we did if no microSD was
inserted)

4) if we can't format/mount the microSD and there is no USB cable
connected then we start the flight code anyway, but there is an
arming check that will by default refuse to arm if logging is not
available (this has been added to plane, but not to rover or copter
yet). If you disable that arming check or have arming checks
disabled then you can fly with no microSD card. You'll know this is
happening due to some distinctive beeps at startup

The idea is to allow people to fly with no microSD if they really want
to, and to fix corrupted microSD cards automatically if possible. That
should save some pain for people who go out to the flying field and then
find they can't fly due to microSD corruption. It does mean that if the
microSD becomes corrupt that users will lose their old logs, but after
some discussion between Randy and myself we decided that is the best
option.

Note that building with this changes requires an update to both PX4NuttX
and PX4Firmware.

Cheers, Tridge

john...@gmail.com

unread,
Feb 6, 2015, 12:53:46 PM2/6/15
to drones-...@googlegroups.com, and...@tridgell.net
Would not a better question be why the memory cards get corrupted in the first place?
Is it just a result of the normal removing cards from the PC without unmounting that people tend to do?

Craig Elder

unread,
Feb 6, 2015, 2:50:10 PM2/6/15
to drones-discuss, Andrew Tridgell
It is normally the result of chopping the power to the Pixhawk by disconnecting the battery and not allowing the AP to close the file system properly.  Some SD cards handle that scenario better than others but the odds of corruption happening at some point are fairly high.

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Pittenger

unread,
Feb 6, 2015, 6:22:03 PM2/6/15
to drones-...@googlegroups.com, Andrew Tridgell
>>It is normally the result of chopping the power to the Pixhawk by disconnecting the battery and not allowing the AP to close the file system properly.

I must have missed something here: Is there a proper SD card shutdown procedure that everyone is supposed to be following? Cutting power seems to me like something that is done on a regular basis by... everyone?

-TomP

Andrew Tridgell

unread,
Feb 6, 2015, 8:26:21 PM2/6/15
to Tom Pittenger, drones-...@googlegroups.com
Hi Tom,

> I must have missed something here: Is there a proper SD card shutdown
> procedure that everyone is supposed to be following? Cutting power seems to
> me like something that is done on a regular basis by... everyone?

Unfortunately there is no safe shutdown mechanism that is guaranteed to
prevent FAT filesystem corruption. You can disarm, which will reduce the
writes due to logging and that helps, but some writes can still happen.

Cheers, Tridge

Andy Lee Robinson

unread,
Feb 6, 2015, 9:53:29 PM2/6/15
to drones-...@googlegroups.com, magi...@gmail.com, and...@tridgell.net
Perhaps a small supercapacitor could be added to allow for a graceful shutdown? Retrofit?

As a bonus it could help to reduce the incidence of brownouts, and if one is detected the FC could throttle back to reduce demand.

In December, I suffered an expensive brownout on a 4km mission that I have previously run several times successfully.
On that occasion, the quad was trying to go 10ms against a 10ms wind after 3km with less than half a battery remaining.
The logs ended abruptly, motors were saturated and the video shows it suddenly keeling over and falling out of the sky with no motor noise.
Was grounded for a month, needed new gimbal, camera, joints, props and significant repair time. :(

I'd rather this not happen too often, so suggest that keeping the FC alive should have a higher priority than user/mission demands!

Cheers,
Andy.

Linus Casassa

unread,
Feb 7, 2015, 1:32:57 PM2/7/15
to drones-...@googlegroups.com
Instead of formatting automatically, can we have a user input to accept the format? what if the user wants to connect it to a computer an recover the previous log for example?

Can we bib if the sd card is bad and then accept the format by taking out the sd and putting it again, the pixhawk will get the corrupted error again and can format it. Or maybe use the arm button, press it for 5 seconds or a radio command like arm twice?


It seams a little invasive to do it automatically, isn't it?


Cheers, Tridge

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Linus Casassa
Fono: 56-9-97776941
Reply all
Reply to author
Forward
0 new messages