This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to read NAND Flash through Linux on DM355

Hi,

I am wondering how I can write a program to go through the contents of the NAND Flash on the DM355 EVM that can run as a diagnostic check.  I want to have a program that does this after Montavista Linux is on board.  I want to have a simple read of a block or memory and write the same context back to the memory and then read that memory back.

How do I go about this? Thanks in advance

  • Once Linux is up and running, your NAND device will be represented by partition devices such as /dev/mtdblock3.  You can use normal character driver APIs (open, read, write, iotcl, mmap, close) to access these partitions.  However, be careful in overwritting any part of the OS you may have stored in these partitions.  Also, keep in mind that Linux uses virtual memory addresses at the application level and the MMU (not your application) will ultimately determine when data is written and read from memory.

  • Juan is correct, Linux already has drivers in place to access NAND, though this is only accessing partitions that are meant for storage so it is abstracting the actual interface for you. If you wanted to do a hard read/write/read to every single byte in the NAND, you would have to write a new driver, or modify the existing flash drivers, to give you such direct access, I do not believe the memory check you are seeking is built in to Linux anywhere.

    This actually sounds like something that you would be better off doing as a stand alone program loaded from a JTAG debugger as opposed to within Linux, assuming you mean to just do this as a one time check of the NAND flash integrity (see here for some examples of stand alone board tests for the EVM).

  • Hi, 

    You can read/write nand from uboot using the nand write and nand dump commands or you can build yourself a set of user space tools (i.e. MTD utilities) to read and write nand from the command line.

    Hope this helps.

    Wil