Digital Signal Processing Reference
In-Depth Information
16.14 Testing Flash Memory
Flash memory is organized into blocks of data and is accessed in a different
manner than SRAM and SDRAM. The Nios II HAL interface includes memory
access functions for Flash devices that conform to the Common Flash Memory
Interface (CFI) standard. The functions alt_flash_open_dev , alt_read_flash ,
alt_write_flash , and alt_flash_close_dev provide an interface that is very
similar to file I/O. These subroutines and more lower-level functions are all
declared in the sys/alt_flash.h header file.
Flash memory write operations happen at the block level meaning that to write
a block or any portion of a block (down to a single byte of data) requires the
entire block of data to be erased and overwritten. When writing to a partial
block of data, the user is responsible for reading the portion of the block that is
not to be overwritten, storing it, and passing it with the new data as a complete
block to be written. Also, keep in mind that Flash memory typically has a life
expectancy of 100,000 write cycles. Because of the overhead involved in
writing partial blocks of data and the finite number of write cycles for a given
Flash memory device, it is best to buffer data until a full block can be written to
Flash memory.
The code for test_flash is shown in Figure 16.17. The data to be written to
flash is buffered in the in_buff array located in data memory. Once is it full, the
entire buffer is sent to the alt_flash_write command which partitions it into
blocks of data and writes the full blocks to Flash memory. Depending on the
total length of the in_buff array the final block written may be a partial block,
but at least it will only get written once. You will also notice that this code
expects the constant value FLASH_MAX_WORDS to be defined. Add a
definition for this constant to your rpds_de_test.h header file and set it equal
to 1000 .
Search WWH ::




Custom Search