README.nand 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. NAND FLASH commands and notes
  2. # (C) Copyright 2003
  3. # Dave Ellis, SIXNET, dge@sixnetio.com
  4. #
  5. # See file CREDITS for list of people who contributed to this
  6. # project.
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation; either version 2 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. # MA 02111-1307 USA
  22. Commands:
  23. nand bad
  24. Print a list of all of the bad blocks in the current device.
  25. nand device
  26. Print information about the current NAND device.
  27. nand device num
  28. Make device `num' the current device and print information about it.
  29. nand erase off size
  30. nand erase clean [off size]
  31. Erase `size' bytes starting at offset `off'. Only complete erase
  32. blocks can be erased.
  33. If `clean' is specified, a JFFS2-style clean marker is written to
  34. each block after it is erased. If `clean' is specified without an
  35. offset or size, the entire flash is erased.
  36. This command will not erase blocks that are marked bad. There is
  37. a debug option in cmd_nand.c to allow bad blocks to be erased.
  38. Please read the warning there before using it, as blocks marked
  39. bad by the manufacturer must _NEVER_ be erased.
  40. nand info
  41. Print information about all of the NAND devices found.
  42. nand read addr ofs size
  43. Read `size' bytes from `ofs' in NAND flash to `addr'. If a page
  44. cannot be read because it is marked bad or an uncorrectable data
  45. error is found the command stops with an error.
  46. nand read.jffs2 addr ofs size
  47. Like `read', but the data for blocks that are marked bad is read as
  48. 0xff. This gives a readable JFFS2 image that can be processed by
  49. the JFFS2 commands such as ls and fsload.
  50. nand read.oob addr ofs size
  51. Read `size' bytes from the out-of-band data area corresponding to
  52. `ofs' in NAND flash to `addr'. This is limited to the 16 bytes of
  53. data for one 512-byte page or 2 256-byte pages. There is no check
  54. for bad blocks or ECC errors.
  55. nand write addr ofs size
  56. Write `size' bytes from `addr' to `ofs' in NAND flash. If a page
  57. cannot be written because it is marked bad or the write fails the
  58. command stops with an error.
  59. nand write.jffs2 addr ofs size
  60. Like `write', but blocks that are marked bad are skipped and the
  61. is written to the next block instead. This allows writing writing
  62. a JFFS2 image, as long as the image is short enough to fit even
  63. after skipping the bad blocks. Compact images, such as those
  64. produced by mkfs.jffs2 should work well, but loading an image copied
  65. from another flash is going to be trouble if there are any bad blocks.
  66. nand write.oob addr ofs size
  67. Write `size' bytes from `addr' to the out-of-band data area
  68. corresponding to `ofs' in NAND flash. This is limited to the 16 bytes
  69. of data for one 512-byte page or 2 256-byte pages. There is no check
  70. for bad blocks.
  71. Configuration Options:
  72. CFG_CMD_NAND
  73. A good one to add to CONFIG_COMMANDS since it enables NAND support.
  74. CONFIG_MTD_NAND_ECC_JFFS2
  75. Define this if you want the Error Correction Code information in
  76. the out-of-band data to be formatted to match the JFFS2 file system.
  77. CONFIG_MTD_NAND_ECC_YAFFS would be another useful choice for
  78. someone to implement.
  79. CFG_MAX_NAND_DEVICE
  80. The maximum number of NAND devices you want to support.
  81. NAND Interface:
  82. #define NAND_WAIT_READY(nand)
  83. Wait until the NAND flash is ready. Typically this would be a
  84. loop waiting for the READY/BUSY line from the flash to indicate it
  85. it is ready.
  86. #define WRITE_NAND_COMMAND(d, adr)
  87. Write the command byte `d' to the flash at `adr' with the
  88. CLE (command latch enable) line true. If your board uses writes to
  89. different addresses to control CLE and ALE, you can modify `adr'
  90. to be the appropriate address here. If your board uses I/O registers
  91. to control them, it is probably better to let NAND_CTL_SETCLE()
  92. and company do it.
  93. #define WRITE_NAND_ADDRESS(d, adr)
  94. Write the address byte `d' to the flash at `adr' with the
  95. ALE (address latch enable) line true. If your board uses writes to
  96. different addresses to control CLE and ALE, you can modify `adr'
  97. to be the appropriate address here. If your board uses I/O registers
  98. to control them, it is probably better to let NAND_CTL_SETALE()
  99. and company do it.
  100. #define WRITE_NAND(d, adr)
  101. Write the data byte `d' to the flash at `adr' with the
  102. ALE and CLE lines false. If your board uses writes to
  103. different addresses to control CLE and ALE, you can modify `adr'
  104. to be the appropriate address here. If your board uses I/O registers
  105. to control them, it is probably better to let NAND_CTL_CLRALE()
  106. and company do it.
  107. #define READ_NAND(adr)
  108. Read a data byte from the flash at `adr' with the
  109. ALE and CLE lines false. If your board uses reads from
  110. different addresses to control CLE and ALE, you can modify `adr'
  111. to be the appropriate address here. If your board uses I/O registers
  112. to control them, it is probably better to let NAND_CTL_CLRALE()
  113. and company do it.
  114. #define NAND_DISABLE_CE(nand)
  115. Set CE (Chip Enable) low to enable the NAND flash.
  116. #define NAND_ENABLE_CE(nand)
  117. Set CE (Chip Enable) high to disable the NAND flash.
  118. #define NAND_CTL_CLRALE(nandptr)
  119. Set ALE (address latch enable) low. If ALE control is handled by
  120. WRITE_NAND_ADDRESS() this can be empty.
  121. #define NAND_CTL_SETALE(nandptr)
  122. Set ALE (address latch enable) high. If ALE control is handled by
  123. WRITE_NAND_ADDRESS() this can be empty.
  124. #define NAND_CTL_CLRCLE(nandptr)
  125. Set CLE (command latch enable) low. If CLE control is handled by
  126. WRITE_NAND_ADDRESS() this can be empty.
  127. #define NAND_CTL_SETCLE(nandptr)
  128. Set CLE (command latch enable) high. If CLE control is handled by
  129. WRITE_NAND_ADDRESS() this can be empty.
  130. More Definitions:
  131. These definitions are needed in the board configuration for now, but
  132. may really belong in a header file.
  133. TODO: Figure which ones are truly configuration settings and rename
  134. them to CFG_NAND_... and move the rest somewhere appropriate.
  135. #define SECTORSIZE 512
  136. #define ADDR_COLUMN 1
  137. #define ADDR_PAGE 2
  138. #define ADDR_COLUMN_PAGE 3
  139. #define NAND_ChipID_UNKNOWN 0x00
  140. #define NAND_MAX_FLOORS 1
  141. #define NAND_MAX_CHIPS 1