Widen page count field in blockinfo to allow lots of pages per block
[yaffs/.git] / Documentation / yaffs-rootfs-howto.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <HTML>
3 <HEAD>
4         <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
5         <TITLE></TITLE>
6         <META NAME="GENERATOR" CONTENT="StarOffice/5.2 (Linux)">
7         <META NAME="AUTHOR" CONTENT=" ">
8         <META NAME="CREATED" CONTENT="20021126;22092300">
9         <META NAME="CHANGEDBY" CONTENT=" ">
10         <META NAME="CHANGED" CONTENT="20021126;22222800">
11 </HEAD>
12 <BODY>
13 <H1>Brief HOWTO on incorporating yaffs as a root fs.</H1>
14 <H4>By N C Bane &lt;nick@cecomputing.co.uk&gt;</H4>
15 <H3>Document status</H3>
16 <P>This document is very much work in progress. It has been edited by
17 different people with no attempt to keep a consistent style. Beauty
18 will come with age.</P>
19 <H2>What is yaffs?</H2>
20 <P>Yaffs stands for Yet Another Flash Filing System.</P>
21 <P>It is a journaling filesystem designed to run on NAND flash with
22 special reference to embedded systems.</P>
23 <P><BR><BR>
24 </P>
25 <H2>Why would I want to use it?</H2>
26 <P>NAND flash (SmartMedia cards are repackaged raw NAND chips) is
27 cheap and has a fast erase time as compared with NOR flash.</P>
28 <P>The NAND physical interface is very simple.</P>
29 <P>The small size and low current requirements make it very suitable
30 for embedded systems.</P>
31 <P>However, NAND has its problems. These are mainly due to bad block
32 management as blocks of memory can be bad when the device is shipped
33 and further blocks can become unusable over time.</P>
34 <P>Power can die unpredictably in embedded systems leading to data
35 loss and possibly file system corruption.</P>
36 <P>This is where yaffs comes in; it handles bad blocks and uses
37 formats which are resistant to corruption.</P>
38 <P><BR><BR>
39 </P>
40 <H2>What do I need to know?</H2>
41 <P>It is assumed that the reader has a development system with direct
42 access to NAND flash (ie not a CF/SmartMedia adaptor which).</P>
43 <P>The user should be familiar with building linux kernels and
44 patching build trees.</P>
45 <P>It is strongly suggested that you also read more about NAND flash
46 on the Linux mtd site.</P>
47 <P><BR><BR>
48 </P>
49 <H3>Assumptions:</H3>
50 <P>You have already downloaded the yaffs sources from the cvs at
51 Aleph1.</P>
52 <P>You have mtd code that exposes NAND as an mtdblock device.</P>
53 <P><BR><BR>
54 </P>
55 <H3>Nand interface:</H3>
56 <P>For yaffs to function, it must be able to be the only code that
57 writes to the oob area on the NAND device.</P>
58 <P>The existing NAND driver in kernel 2.4.19 assumes that it will do
59 the ecc/oob management for the host fs. For yaffs, this is quite
60 wrong.</P>
61 <P>You can disable ecc/oob calculations either by hand patching the
62 mtd code to bypass ecc calculations or by merging the latest mtd cvs.</P>
63 <P>The patches at http://www.toby-churchill.org have done the latter.</P>
64 <P><BR><BR>
65 </P>
66 <H3>Including yaffs as a kernel fs:</H3>
67 <P>1) Create [linux]/fs/yaffs directory in your kernel test source.</P>
68 <P>2) Copy devextras.h yaffs_fs.c yaffs_gets.c yaffs_guts.h
69 yaffs_mtdif.c yaffs_mtdif.h yaffsinterface.h and yportenv.h from the
70 yaffs sources to that directory.</P>
71 <P>3) Copy the Makefile from either the yaffs sources
72 (Makefile.kernel) or the Balloon download site below to
73 [linux]/fs/yaffs/Makefile.</P>
74 <P>3) Modify [linux]/fs/Config.in to include the 3 lines</P>
75 <P><BR><BR>
76 </P>
77 <P STYLE="margin-left: 2cm; font-weight: medium"><FONT SIZE=3>i<FONT FACE="Courier, monospace">f
78 [ &quot;CONFIG_MTD_NAND&quot; = &quot;y&quot; ]; then</FONT></FONT></P>
79 <P STYLE="margin-left: 2cm; font-weight: medium"><FONT FACE="Courier, monospace"><FONT SIZE=3>
80    tristate &quot;Yaffs filesystem on NAND&quot; CONFIG_YAFFS_FS</FONT></FONT></P>
81 <P STYLE="margin-left: 2cm; font-weight: medium"><FONT FACE="Courier, monospace"><FONT SIZE=3>fi</FONT></FONT></P>
82 <P>4) Configure the kernel to include (not modules) all the mtd nand
83 code (incl nand_ecc and mtdblock device) and yaffs fs.</P>
84 <P><BR><BR>
85 </P>
86 <P>You should now be able to build a kernel with yaffs as a root fs
87 using the normal tools.</P>
88 <P><BR><BR>
89 </P>
90 <H3>Creating a bootable yaffs partition:</H3>
91 <P>You can</P>
92 <P>1) Create the partition by mounting it from a running linux os and
93 copying the data there. The mkyaffs utility in the yaffs source
94 simply erases a NAND mtdblock device without removing bad block data.</P>
95 <P>2) Make and download a filesystem image. The mkyaffsimage utility
96 that came with the sources will create a YAFFS block list in a file
97 from a root tree. This is a list of 512+16 byte blocks that need to
98 be placed (in any order) on a NAND device.</P>
99 <P>You will need to write code to copy these data blocks and add in
100 the block numbers in the oob areas.</P>
101 <P>Examples of a modified handhelds.org bootldr for the Balloon board
102 can be found on the toby-churchill.org website.</P>
103 <P><BR><BR>
104 </P>
105 <H3>Booting into yaffs:</H3>
106 <P>Modify your bootloader to pass a  command line to linux to
107 specifying the mtdblock/n that refers to the root partition.</P>
108 <P><BR><BR>
109 </P>
110 <H3>Further Information:</H3>
111 <P>Yaffs page at Aleph1
112 http://www.aleph1.co.uk/armlinux/projects/yaffs/index.html</P>
113 <P>Balloon page at http://www.toby-churchill.org.uk</P>
114 <P>Yaffs mailing list - to join send an email to
115 yaffs-request@toby-churchill.org with the text &quot;subscribe&quot;
116 (no quotes) as the subject</P>
117 <P>Linux MTD http://www.linux-mtd.infradead.org/</P>
118 <P>$Id: yaffs-rootfs-howto.html,v 1.1 2002-11-26 09:32:08 charles Exp $</P>
119 <P><BR><BR>
120 </P>
121 </BODY>
122 </HTML>