Re: A question about SD-Card write on MSP-EXP430F5529

Daniel Beer <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.user
Message-ID <[email protected]>
On Wed, Jun 05, 2013 at 07:33:31PM -0700, ravim wrote:
> Our application writes a data packet  to SD-Card as soon as it receive on
> EXP board. The packet size is 40Bytes and may increase more. The binary data
> is stored in files on SD card which we later run through our interpreter.
> Now if someone pulls the SD-Card in midst of write operation what will
> happen?
> 
> I wanted to ask -  is it possible that portion of data packet may be written
> to file when SD card is suddenly pulled out? Because if this happens the
> whole series of binary data will not make any sense or may give us totally
> wrong information.
> 
> If this happens how do we handle it? Is there a way to make this write
> operation atomic??

If you mean that you're writing a sequence sectors to an SD-card, you
could ensure that your sectors contain a checksum. If the write fails,
the checksum will (with high probability) not match, and you can ignore
the sector.

This assumes that a write failure affects only the sector to which
you're writing. A sensible flash translation layer would hopefully
provide this guarantee.

If you're writing to a file on a VFAT filesystem, it's different. You
might be able to implement a transaction system by making use of the
redundant FAT copies and doing shadow-paging with unused clusters. This
would only guarantee consistency when reading from your own application
though.

Cheers,
Daniel

-- 
Daniel Beer <[email protected]>    www.dlbeer.co.nz
IRC: inittab (Freenode)    PGP key: 2048D/160A553B

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.