UFFS: Ultra-low-cost Flash File System
Project: http://uffs.sf.net/ Blog: http://all-about-uffs.blogspot.com/ Q/A: http://groups.google.com/group/uffs/
Author: Ricky Zheng
UFFS is a nand flash file system designed for embedded system.
UFFS have some unique and advanced features:
Low cost: e.g. it needs only 41K bytes RAM for 64MB NAND flash (page size 2048).
Fast booting: it reads only a few spares from each block, typically mounting a fully filled file system (Gbits) within one second.
Superb Reliability:
Fast file create/read/write/seek.
Bad-block tolerant, ECC enable and good ware-leveling.
There is no garbage collection needed for UFFS.
Support multiple NAND flash class in one system.
Support bare flash hardware, no operating system needed.
Support static memory allocation (works without 'malloc').
Fully simulated on PC (Windows/Linux) platform.
Disadvantage:
Memory consuming example:
For page size = 512:
[VARY]Tree nodes: 16 * total_blocks
[CONST]Page Bufs: MAX_CACHED_BUFFERS(10) * (40 + pageSize(512)) = 5.4K
[CONST]Block Info caches: (24 + 14 * pages_per_block (32)) * MAX_CACHED_BLOCK_INFO (10) = 4.6K
Example 1: 128M bytes NAND, 8192 blocks, total memory cost:
(16 * 8192)128K + 5.4K + 4.6K = 138K bytes.
Example 2: 32M Bytes NAND, 2048 blocks, total memory cost:
(16 * 2048)32K + 5.4K + 4.6K = 42K bytes.
Example 3: 16M bytes NAND, 1024 blocks, total memory cost:
(16 * 1024)16K + 5.4K + 4.6K = 26K bytes.
For page size = 2048:
[VARY]Tree nodes: 16 * total_blocks
[CONST]Page Bufs: MAX_CACHED_BUFFERS(10) * (40 + pageSize(2048)) = 20.4K
[CONST]Block Info caches: (24 + 14 * pages_per_block (32)) * MAX_CACHED_BLOCK_INFO (10) = 4.6K
Example 1: 512M bytes NAND, 8192 blocks, total memory cost:
(16 * 8192)128K + 20.4K + 4.6K = 153K bytes.
Example 2: 128M Bytes NAND, 2048 blocks, total memory cost:
(16 * 2048)32K + 20.4K + 4.6K = 57K bytes.
Example 3: 64M bytes NAND, 1024 blocks, total memory cost:
(16 * 1024)16K + 20.4K + 4.6K = 41K bytes.
From V1.2.0, build uffs simulator requires 'cmake'. 'cmake' can be downloaded from: http://www.cmake.org/
or, under Debian/Ubuntu: sudo apt-get install cmake
1) create a 'build' dir:
mkdir -p ~/build/uffs
2) create Makefiles and build: cd ~/build/uffs cmake make
5) run simulator (interactive mode): src/utils/mkuffs
1) create a 'build' dir along with uffs source dir, d:\build\uffs
2) Create VC project files: cd build\uffs cmake
3) Open uffs.dsw (or uffs.sln for VC > 6 ), compile & run.
You can get the latest source code from git repository: git clone git://uffs.git.sourceforge.net/gitroot/uffs/uffs
UFFS 0.1.x is a working version on PC simulator, also has been ported to uBase embedded OS as a 'real world' product for thousands of copies, it works fine so far.
UFFS 0.2.0 implementes full directory.
UFFS 1.0.0 is the first stable release at sf.net.
UFFS 1.1.0: support NAND flash with large page size (up to 2K).
UFFS 1.1.1: bug fixes. a tool for making uffs disk image.
UFFS 1.1.2: bug fixes. add more Flash Class. change Licence from GNU GPLv2 to GNU LGPLv2
UFFS 1.2.0:
UFFS 1.2.1:
UFFS 1.3.0:
UFFS v1.3.1:
UFFS v1.3.2:
UFFS v1.3.3:
UFFS v1.3.4
From v1.2.1, UFFS is released under a modified GNU GPLv2. (the same as eCos Licence) The full licence text can be found in the header of source files:
UFFS is free software; you can redistribute it and/or modify it under
the GNU Library General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
UFFS is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
or GNU Library General Public License, as applicable, for more details.
You should have received a copy of the GNU General Public License
and GNU Library General Public License along with UFFS; if not, write
to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
As a special exception, if other files instantiate templates or use
macros or inline functions from this file, or you compile this file
and link it with other works to produce a work based on this file,
this file does not by itself cause the resulting work to be covered
by the GNU General Public License. However the source code for this
file must still be made available in accordance with section (3) of
the GNU General Public License v2.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
UFFS can be tested with sqlite3 regression test cases (on Linux).
1) install tcl8.5-dev on host PC:
apt-get install tcl8.5 tcl8.5-dev
# make sure your Linux is using tcl8.5 as the default tclsh:
sudo update-alternatives --config tclsh
(select "tclsh8.5" from the list.)
2) build uffs:
mkdir -p ~/build/uffs
cd ~/build/uffs
cmake <path_to_uffs>
3) build sqlite3:
cd <path_to_uffs>/src/test/sqlite3/sqlite-src-3070900
./configure # create some build support files
git checkout -f Makefile config.h # restore modified Makefile and config.h
make test # start build 'testfixture' program.
# now you'll see something like:
Connect: Connection refused
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
make: *** [test] Error 1
4) run test cases:
Open two terminals.
on termional A:
cd ~/build/uffs
src/utils/mkuffs -t 1024
#on uffs simulator command line, enter:
format /
apisrv
on terminal B:
cd <path_to_uffs>/src/test/sqlite3/sqlite-src-3070900
./test-uffs.sh
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.
The test will take 1~4 hours, depends on how fast your Linux box is.
Special thanks for your contributions to: (list in no particular order)