Chapter 56. Tests and utilities

56.1. Unit and functional tests

The NAND library includes a number of tests. The most useful to driver writers are readwrite, rwbenchmark and sweccwalk; the others are only likely to be of interest to library maintainers.

readwrite

Performs a read-write-erase cycle on the first NAND device it finds, checking that its operations have had the expected effect on the device contents. This is a potentially destructive test; do not run it on a device containing data you care about!

rwbenchmark

A more involved version of readwrite, this is a timing test which performs multiple reads, writes and erases and applies statistical techniques to the results in the same way that tm_basic instruments the speed of various eCos kernel functions. This is a potentially destructive test; do not run it on a device containing data you care about!

sweccwalk

Repeatedly makes single-bit changes to a data buffer and checks that the software ECC implementation correctly repairs them.

[Tip]Tip

This test can be adapted to test out hardware ECC implementations. The test outputs the raw ECC codes as it goes, which is useful in confirming that the bits in the computed ECC are what you think they are.

nandunit

Some unit tests which do not require any NAND device: ECC known answer vectors, and OOB area packing/unpacking correctness.

readlimits

Attempts to read a block outside of a partition, confirming that it doesn't work.

There are some further tests of the library which require the synthetic NAND device.

56.2. Ancillary NAND utilities

The following utilities are included with the NAND library. They are standalone eCos applications; for convenience, you can set CYGBLD_IO_NAND_BUILD_UTILS in your eCos configuration and they will be built and placed into install/tests/io/nand/current/utils.

[Warning]Warning

It is particularly dangerous to run the utility erase_bbt_dangerous.c on a production device, as it is generally not possible to later reconstruct the list of factory-bad blocks. It is intended only as an aid to driver authors.

erasenand.c

Loops over all the blocks of a partition, erasing all the blocks [3] which are not marked as bad. The device and partition to erase are set by #define.

erase_bbt_dangerous.c[4]

Erases the NAND blocks comprising the primary and mirror bad-block tables of a device. The device to erase is set by #define. (The tables are detected by the library in the usual way. If none are present, the library will scan the device for factory-bad blocks to create such a table, then this code will immediately erase it.)



[3] This will not normally erase the Bad Block Table. This is because the BBT reports its own blocks as "Reserved" when queried via cyg_nand_bbt_query, which makes them inaccessible to applications. However, if CYGSEM_IO_NAND_USE_BBT is turned off, then any BBT present will not be detected and hence will be erased.

[4] Note the warning regarding running this on a production device