Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Embedded Systems

Drive Salvage


Camera Crash

My digital camera crashed while taking pictures at the annual Family Christmas Gathering. Unlike the episode I described in the December 2004 column, the camera popped up a MEMORY STICK ERROR after snapping the 44th picture of the day. I inserted another Memory Stick and continued the mission.

Back home, I inserted the crashed Memory Stick into a USB card reader and found that, while it was recognized as a USB Mass Storage device, it had no partition table. I used dd to copy the entire 128-MB Memory Stick to an image file.

Browsing through that file with khexedit showed that the camera had zeroed much of the partition table and trashed some of the FAT area, but left the JPG files intact. The block of binary zeros at the start of the file evidently confused the grep text-searching utility into returning offsets that didn't match up at all with the values shown by khexedit.

Running the file through strings -t x MemStick.bin | grep Exif returned the correct offsets. As before, I imported those lines into a spreadsheet, rounded the values down to multiples of the 512-byte sector size, produced dd commands that extracted 3-MB hunks of Memstick.bin into separate JPG files, then fed them to ImageMagick's convert utility to extract the JPG images.

The first 43 images were perfect, the bottom of the 44th image was missing, and 8 deleted images from a previous session also appeared. The fact that deleting a file doesn't actually remove its data sometimes comes back to haunt folks with something to hide, but in this case it was okay.

Those restored pictures went out on a CD of the Gathering and all was well.

Continuing Education

Any embedded system large enough to require an operating system also uses a filesystem to organize external storage. Smaller, data-intensive systems without a formal OS, such as a single-chip MP3 player with a voice recorder, may write sound files into the same large Flash memory used for read-only music. Even deeply embedded systems without removable storage generally have a filesystem of some sort on their Flash program memory.

Below the level of the filesystem, partitions divide storage into chunks that resemble disk drives. For example, the cfdisk utility lists nearly 100 different partition types from Amoeba through XENIX, some of which you'll actually find in contemporary systems.

Understanding how all this works may not be on your to-do list, but knowing how to rebuild a filesystem or recover critical data from a crashed Flash device may well come in very, very handy. With the Linux kernel worming its way into embedded systems, knowing how to drive UNIX-oid tools and work with Windows filesystems can also be valuable. Just start with SRCd and work your way up.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.