Daniel Beer Atom | RSS | About

Dhara

9 Dec 2013

Dhara is a small flash translation layer designed to be used in resource-constrained systems for managing NAND flash. It provides a mutable block interface with standard read and write operations. It has the following additional features:

The implementation makes minimal assumptions regarding the underlying NAND chip. It can be used with almost any chip available, and can take advantage of extra hardware features where available. In particular:

The implementation consists of the files in the dhara/ subdirectory, plus the NAND layer implementation, which you must provide. The top-level interface is the set of functions described in map.h (see the comments in the header file for more details):

To provide the NAND layer, implement the set of functions described in nand.h (see comments for details). In summary, you must provide the following operations:

Check the datasheet for your chip for information on these operations. In most cases, the manufacturer will specify a preferred layout scheme for the ECC and bad block markers in the OOB region. Pay particular attention to the marker used for factory-marked bad blocks!

Note that bad blocks need only be queried one at a time. It’s not necessary to maintain a bad-block table – just the standard OOB marking scheme is fine, and preserves the performance guarantees of the map layer.

Also note that when implementing partial read, you must read enough of the page that you’re able to apply ECC and check for uncorrectable errors. Uncorrectable errors must be detected in order for the data integrity guarantees to be valid. This may require the use of a checksum in addition to ECC. If this is done, ensure that the checksum bytes are also protected by ECC!

Implementations of two popular ECC mechanisms (Hamming and BCH) can be found in the ecc/ subdirectory. Each implements ECC over variable-sized chunks (256 or 512 bytes are typical sizes). Multiple ECC chunks may be required per page.

Download

Obtain the source from Github:

git clone https://github.com/dlbeer/dhara.git

License

Copyright (C) Daniel Beer 2013 <>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.