1
0

README 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. UFFS: Ultra-low-cost Flash File System
  2. Project: http://uffs.sf.net/
  3. Blog: http://all-about-uffs.blogspot.com/
  4. Q/A: http://groups.google.com/group/uffs/
  5. Author: Ricky Zheng <ricky_gz_zheng@yahoo.co.nz>
  6. INTRODUCTION
  7. ------------
  8. UFFS is a nand flash file system designed for embedded system.
  9. UFFS have some unique and advanced features:
  10. * Low cost: e.g. it needs only 41K bytes RAM for 64MB NAND flash (page size 2048).
  11. * Fast booting: it reads only a few spares from each block, typically
  12. mounting a fully filled file system (Gbits) within one second.
  13. * Superb Reliability:
  14. - The file system is designed for the embedded system which may
  15. frequently lost power/reset without care.
  16. - Journal file system, the file system will automatically rollback
  17. to the last state when lost power on the middle of flash programing.
  18. - When 'write' return without error, the data is guarenteed been
  19. saved on flash.
  20. * Fast file create/read/write/seek.
  21. * Bad-block tolerant, ECC enable and good ware-leveling.
  22. * There is no garbage collection needed for UFFS.
  23. * Support multiple NAND flash class in one system.
  24. * Support bare flash hardware, no operating system needed.
  25. * Support static memory allocation (works without 'malloc').
  26. * Fully simulated on PC (Windows/Linux) platform.
  27. Disadvantage:
  28. * space inefficency for small files: UFFS use at least one
  29. 'block'(the minial erase unit for NAND flash, e.g. 16K ) for a file.
  30. * maximum supported blocks: 2^16 = 65535
  31. Memory consuming example:
  32. For page size = 512:
  33. [VARY]Tree nodes: 16 * total_blocks
  34. [CONST]Page Bufs: MAX_CACHED_BUFFERS(10) * (40 + pageSize(512)) = 5.4K
  35. [CONST]Block Info caches: (24 + 14 * pages_per_block (32)) * MAX_CACHED_BLOCK_INFO (10) = 4.6K
  36. Example 1: 128M bytes NAND, 8192 blocks, total memory cost:
  37. (16 * 8192)128K + 5.4K + 4.6K = 138K bytes.
  38. Example 2: 32M Bytes NAND, 2048 blocks, total memory cost:
  39. (16 * 2048)32K + 5.4K + 4.6K = 42K bytes.
  40. Example 3: 16M bytes NAND, 1024 blocks, total memory cost:
  41. (16 * 1024)16K + 5.4K + 4.6K = 26K bytes.
  42. For page size = 2048:
  43. [VARY]Tree nodes: 16 * total_blocks
  44. [CONST]Page Bufs: MAX_CACHED_BUFFERS(10) * (40 + pageSize(2048)) = 20.4K
  45. [CONST]Block Info caches: (24 + 14 * pages_per_block (32)) * MAX_CACHED_BLOCK_INFO (10) = 4.6K
  46. Example 1: 512M bytes NAND, 8192 blocks, total memory cost:
  47. (16 * 8192)128K + 20.4K + 4.6K = 153K bytes.
  48. Example 2: 128M Bytes NAND, 2048 blocks, total memory cost:
  49. (16 * 2048)32K + 20.4K + 4.6K = 57K bytes.
  50. Example 3: 64M bytes NAND, 1024 blocks, total memory cost:
  51. (16 * 1024)16K + 20.4K + 4.6K = 41K bytes.
  52. BUILD SIMULATOR REQUIREMENT
  53. ---------------------------
  54. From V1.2.0, build uffs simulator requires 'cmake'.
  55. 'cmake' can be downloaded from: http://www.cmake.org/
  56. or, under Debian/Ubuntu:
  57. sudo apt-get install cmake
  58. BUILD SIMULATOR ON LINUX
  59. ------------------------
  60. 1) create a 'build' dir:
  61. mkdir -p ~/build/uffs
  62. 2) create Makefiles and build:
  63. cd ~/build/uffs
  64. cmake <path_to_uffs>
  65. make
  66. 5) run simulator (interactive mode):
  67. src/utils/mkuffs
  68. BUILD SIMULATOR ON WINDOWS
  69. --------------------------
  70. 1) create a 'build' dir along with uffs source dir,
  71. d:\build\uffs
  72. 2) Create VC project files:
  73. cd build\uffs
  74. cmake <path_to_uffs>
  75. 3) Open uffs.dsw (or uffs.sln for VC > 6 ), compile & run.
  76. LATEST SOURCE CODE
  77. ------------------
  78. You can get the latest source code from git repository:
  79. git clone git://uffs.git.sourceforge.net/gitroot/uffs/uffs
  80. CURRENT STATUS
  81. --------------
  82. UFFS 0.1.x is a working version on PC simulator, also has been ported to
  83. uBase embedded OS as a 'real world' product for thousands of copies,
  84. it works fine so far.
  85. UFFS 0.2.0 implementes full directory.
  86. UFFS 1.0.0 is the first stable release at sf.net.
  87. UFFS 1.1.0: support NAND flash with large page size (up to 2K).
  88. UFFS 1.1.1: bug fixes. a tool for making uffs disk image.
  89. UFFS 1.1.2: bug fixes. add more Flash Class. change Licence from GNU GPLv2 to GNU LGPLv2
  90. UFFS 1.2.0:
  91. - eliminate 'current path' and relatives. Now you should use absolute path in all
  92. uffs APIs. For dir, the fullname should end with '/'.
  93. - allow using static memory allocation, 'malloc' is no longer needed.
  94. - using cmake for building simulator.
  95. - bug fixes & minor changes.
  96. UFFS 1.2.1:
  97. - improve bad block management
  98. - bug fixes
  99. - change Licence to modified GNU GPLv2.
  100. UFFS 1.3.0:
  101. - improved flash interface
  102. - support hardware ECC
  103. - support user defined spare layout (for customized NAND flash controller)
  104. - support 4K page size
  105. - no partial page program required, support MLC NAND flash
  106. - reduced buffer flushes by grouping buffers
  107. - structual improvments and bug fixes
  108. UFFS v1.3.1:
  109. - Tidy up three memory allocators: static, native and system.
  110. - Fix bugs in flash interface example.
  111. - Fix memory allocation bugs when using static memory allocator.
  112. - Add flash driver interface 'WriteFullPage()'.
  113. - Fix compilation errors for BlackFin DSP compiler.
  114. UFFS v1.3.2:
  115. - Add POSIX like file system APIs.
  116. - Bug fixes.
  117. UFFS v1.3.3:
  118. - Change Flash Interface, simplify interface.
  119. - Improved bad block handling.
  120. - Better support for MLC NAND flash.
  121. - Added hardware ECC and RS-ECC controller emulator.
  122. - Bug fixes.
  123. UFFS v1.3.4
  124. - New UO_NOECC option for skipping ECC (fast reading).
  125. - POSIX compliance uffs_seek().
  126. - Improved unclean page detection (add new 'seal' byte in spare area).
  127. - Optional page data CRC.
  128. - Bug fixes.
  129. - Other improvements.
  130. LICENCE
  131. -------
  132. From v1.2.1, UFFS is released under a modified GNU GPLv2. (the same as eCos Licence)
  133. The full licence text can be found in the header of source files:
  134. UFFS is free software; you can redistribute it and/or modify it under
  135. the GNU Library General Public License as published by the Free Software
  136. Foundation; either version 2 of the License, or (at your option) any
  137. later version.
  138. UFFS is distributed in the hope that it will be useful, but WITHOUT
  139. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  140. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  141. or GNU Library General Public License, as applicable, for more details.
  142. You should have received a copy of the GNU General Public License
  143. and GNU Library General Public License along with UFFS; if not, write
  144. to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  145. Boston, MA 02110-1301, USA.
  146. As a special exception, if other files instantiate templates or use
  147. macros or inline functions from this file, or you compile this file
  148. and link it with other works to produce a work based on this file,
  149. this file does not by itself cause the resulting work to be covered
  150. by the GNU General Public License. However the source code for this
  151. file must still be made available in accordance with section (3) of
  152. the GNU General Public License v2.
  153. This exception does not invalidate any other reasons why a work based
  154. on this file might be covered by the GNU General Public License.
  155. TESTING UFFS WITH SQLITE3 REGRESSION TEST CASES
  156. -----------------------------------------------
  157. UFFS can be tested with sqlite3 regression test cases (on Linux).
  158. 1) install tcl8.5-dev on host PC:
  159. apt-get install tcl8.5 tcl8.5-dev
  160. # make sure your Linux is using tcl8.5 as the default tclsh:
  161. sudo update-alternatives --config tclsh
  162. (select "tclsh8.5" from the list.)
  163. 2) build uffs:
  164. mkdir -p ~/build/uffs
  165. cd ~/build/uffs
  166. cmake <path_to_uffs>
  167. 3) build sqlite3:
  168. cd <path_to_uffs>/src/test/sqlite3/sqlite-src-3070900
  169. ./configure # create some build support files
  170. git checkout -f Makefile config.h # restore modified Makefile and config.h
  171. make test # start build 'testfixture' program.
  172. # now you'll see something like:
  173. Connect: Connection refused
  174. Assert (uffs_ret == ret && ret == bak_ret) fail at /home/.../src/test/api_test/os_uffs.c:os_unlink:329: unlink("/home/.../src/test/sqlite3/sqlite-src-3070900/./test.db-journal"), unix return 0, uffs return -1, bak return -1
  175. make: *** [test] Error 1
  176. 4) run test cases:
  177. Open two terminals.
  178. on termional A:
  179. cd ~/build/uffs
  180. src/utils/mkuffs -t 1024
  181. #on uffs simulator command line, enter:
  182. format /
  183. apisrv
  184. on terminal B:
  185. cd <path_to_uffs>/src/test/sqlite3/sqlite-src-3070900
  186. ./test-uffs.sh
  187. Note: if you want to run mkuffs on another PC, for example, a Windows PC, you need to specify the IP address in test-uffs.sh.
  188. The test will take 1~4 hours, depends on how fast your Linux box is.
  189. ACKNOWLEDGMENT
  190. ---------------
  191. Special thanks for your contributions to:
  192. (list in no particular order)
  193. * Chen Jun <chj@nlscan.com>
  194. * Michail <digiolog@mail.ru>
  195. * Sjpu <sjpu@163.com>
  196. * RobertGray <xennex@hotmail.com>
  197. * Dongbo <dongbo@ftsafe.com>
  198. * Cag <seucag@hotmail.com>
  199. * Sergey <s_sazonov@m2m-t.ru>
  200. * Chris Conrad <chris.conrad@halliburton.com>
  201. * Vladimir <decoder@rambler.ru>
  202. * Thien Pham <thienpham2008@yahoo.com>
  203. * Emmanuel Blot <eblot.ml@gmail.com>
  204. * Michael <yowong2@gmail.com>
  205. * Mick D <mick-eng@sourceforge.net>
  206. * Paul <paulr227@gmail.com>
  207. * Rogerz <rogerz.zhang@gmail.com>