('page',0,42,552,'und',0,'<h3>Current state of NAND MTD</h3>\r\n\r\n<p>The current NAND MTD supports basic read/write functions. The code is hard-wired to support the NAND devices on a SPIA board. The ECC code supports 256 byte sectors.</p>\r\n\r\n<p>There are 3 files:</p>\r\n\r\n<p>nand.c: nand support algorithms. Unfortunately there is no hardware abstraction (ie. the hardware is assumed to be the SPIA board). but this is relatively easy to add.</p>\r\n\r\n<p>spia.c: this initialises the spia hardware to set up the addresses for the hardware access.</p>\r\n\r\n<p>ecc.c: ECC for 256 byte pages.</p>\r\n\r\n<p>What needs to be done at this level:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Hardware abstraction of nand.c. This allows this code to be used with different hardware configurations.</p>\r\n	</li>\r\n	<li>\r\n	<p>The larger memory sizes use 512 byte pages. The memory sizes supported by 256-byte pages are obsolete. 512-byte pages are treated as two sub-pages of 256 bytes each. The Samsung code is calculation based (ie. maybe slow). The Toshiba code is table based and probably faster. Check if they are equivalent.</p>\r\n	</li>\r\n	<li>\r\n	<p>Write a software emulation for a NAND device. The purpose of the software emulator is:</p>\r\n\r\n	<ul>\r\n		<li>\r\n		<p>Allow debugging without the need for hardware.</p>\r\n		</li>\r\n		<li>\r\n		<p>NAND file systems need to be fault tolerant. The hardware can\'t be forced to fail to test out bad block detection/handling etc. A software emulator can be forced to fail.</p>\r\n		</li>\r\n	</ul>\r\n	</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>Overall flash system diagram<img alt=\"\" height=\"402\" src=\"/sites/yaffs.net/sv16516600.gif\" width=\"399\" /></h3>\r\n\r\n<p>A diagrammatic representation of support for SmartMedia, NAND and NOR as well as both FAT16 and JFFS2 might look like the above.</p>\r\n\r\n<p>The NAND flash sub-system uses common layers for:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>hardware access</p>\r\n	</li>\r\n	<li>\r\n	<p>ECC, bad block handling and low-level formatting. (based on Smart Media low-level specs). By using the same low level formatting and ECC as much as possible we gain some benefit in testing, reuse etc. The low-level formatting would differ in that fields used to store the LBA and reserved fields might be used for something else (??journaling tags??)</p>\r\n	</li>\r\n</ul>\r\n\r\n<h3>Concerns with using JFFS2 on NAND</h3>\r\n\r\n<p>There are some reasons why JFFS and NAND might not work together that well.</p>\r\n\r\n<p>Two particular concerns re booting</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>NAND devices are typically much larger than NOR (eg. 128MB is currently a large NAND chip while 16MB would be considered a large NOR chip), thus the data structures associated with flash management are likely to be much larger. Also, JFFS2 scans the media on boot to build data structures representing the nodes in the system. This increases the boot time.</p>\r\n	</li>\r\n	<li>\r\n	<p>NAND is not random access but must be read serially. This means that the scanning routine can\'t just merrily skip through the flash, instead the whole flash must be read and ECC\'d first. This slows scanning and hence booting.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Thus booting a 128MB NAND-based JFFS2 is likely to look something like this:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Read and ECC every last byte on the device even if we only need a few bytes per page for journaling headers and digest the contents. At say 5MB/second this will take ~25 seconds.</p>\r\n	</li>\r\n	<li>\r\n	<p>Each node requires a 16-byte structure (struct jffs2_raw_node_ref). If nodes were 512-bytes then that\'s 4MB of RAM!</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>These are probably unacceptable for the product being used. We therefore need to run something better than this.</p>\r\n\r\n<p>Two approaches spring to mind:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Just run FAT16. ie. Just treat all NAND as SmartMedia. Benefits: one code base. Down-side: reliability.</p>\r\n	</li>\r\n	<li>\r\n	<p>I\'m reluctant to store critical files in a FAT16 file system because these can be so unreliable. I\'m convinced that a journaling file system is superior. Maybe what we need is a light weight journaling file system (using common code with JFFS) modified in such a way as sidestep some of the nasty issues raised above.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>What I\'m working towards</h3>\r\n\r\n<p>Right now I\'m investigating the idea of trying to do something more appropriate. My current avenue of exploration is to use a journaling approach as follows:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>The journaling records are stored in fixed-size 512-byte pages.</p>\r\n	</li>\r\n	<li>\r\n	<p>The journaling tags are stored in the 16-byte-per-page \"management space\", semi-consistent with SmartMedia, using the 8 bytes of reserved space and LBA space to store journaling tags. ie something like:</p>\r\n	</li>\r\n	<li>\r\n	<p>20 bits of page id within inode</p>\r\n	</li>\r\n	<li>\r\n	<p>20 bits of inode id</p>\r\n	</li>\r\n	<li>\r\n	<p>9 bits length (bytes used in this page).</p>\r\n	</li>\r\n	<li>\r\n	<p>7 bits flags etc.</p>\r\n	</li>\r\n	<li>\r\n	<p>8 bits of hamming code on this area.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Each page id identifies where the page fits into the file. When a page is replaced (ie file data is overwritten) a new page with the same page id is written and the old one is wiped out. During garbage collection, the pages containing valid data are copied and the wiped out data is discarded.</p>\r\n\r\n<p>The benefits of this approach are:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>NAND-friendly since it works within the write limitations of NAND.</p>\r\n	</li>\r\n	<li>\r\n	<p>Less stuff to read to reconstruct file structures (only read management data).</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Down sides:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>No compression. But is that an issue considering the target data is already compressed and NAND is far less precious than NOR (thanks to higher densities and lower price).</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Still need to see if a new data structure is going to reduce the overhead of jffs2_raw_node_ref somewhat.</p>\r\n','<p>Details of Dec 2001 state of nand driver, and overview of how drivers fit together for use with different hardware and filesystems. Not really intended for public consumption, but a useful backgrounder and explanation of the evolution of YAFFS.</p>','filtered_html'),('page',0,42,573,'und',0,'<h3>Current state of NAND MTD</h3>\r\n\r\n<p>The current NAND MTD supports basic read/write functions. The code is hard-wired to support the NAND devices on a SPIA board. The ECC code supports 256 byte sectors.</p>\r\n\r\n<p>There are 3 files:</p>\r\n\r\n<p>nand.c: nand support algorithms. Unfortunately there is no hardware abstraction (ie. the hardware is assumed to be the SPIA board). but this is relatively easy to add.</p>\r\n\r\n<p>spia.c: this initialises the spia hardware to set up the addresses for the hardware access.</p>\r\n\r\n<p>ecc.c: ECC for 256 byte pages.</p>\r\n\r\n<p>What needs to be done at this level:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Hardware abstraction of nand.c. This allows this code to be used with different hardware configurations.</p>\r\n	</li>\r\n	<li>\r\n	<p>The larger memory sizes use 512 byte pages. The memory sizes supported by 256-byte pages are obsolete. 512-byte pages are treated as two sub-pages of 256 bytes each. The Samsung code is calculation based (ie. maybe slow). The Toshiba code is table based and probably faster. Check if they are equivalent.</p>\r\n	</li>\r\n	<li>\r\n	<p>Write a software emulation for a NAND device. The purpose of the software emulator is:</p>\r\n\r\n	<ul>\r\n		<li>\r\n		<p>Allow debugging without the need for hardware.</p>\r\n		</li>\r\n		<li>\r\n		<p>NAND file systems need to be fault tolerant. The hardware can\'t be forced to fail to test out bad block detection/handling etc. A software emulator can be forced to fail.</p>\r\n		</li>\r\n	</ul>\r\n	</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>Overall flash system diagram<img alt=\"\" height=\"402\" src=\"/sites/yaffs.net/sv16516600.gif\" width=\"399\" /></h3>\r\n\r\n<p>A diagrammatic representation of support for SmartMedia, NAND and NOR as well as both FAT16 and JFFS2 might look like the above.</p>\r\n\r\n<p>The NAND flash sub-system uses common layers for:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>hardware access</p>\r\n	</li>\r\n	<li>\r\n	<p>ECC, bad block handling and low-level formatting. (based on Smart Media low-level specs). By using the same low level formatting and ECC as much as possible we gain some benefit in testing, reuse etc. The low-level formatting would differ in that fields used to store the LBA and reserved fields might be used for something else (??journaling tags??)</p>\r\n	</li>\r\n</ul>\r\n\r\n<h3>Concerns with using JFFS2 on NAND</h3>\r\n\r\n<p>There are some reasons why JFFS and NAND might not work together that well.</p>\r\n\r\n<p>Two particular concerns re booting</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>NAND devices are typically much larger than NOR (eg. 128MB is currently a large NAND chip while 16MB would be considered a large NOR chip), thus the data structures associated with flash management are likely to be much larger. Also, JFFS2 scans the media on boot to build data structures representing the nodes in the system. This increases the boot time.</p>\r\n	</li>\r\n	<li>\r\n	<p>NAND is not random access but must be read serially. This means that the scanning routine can\'t just merrily skip through the flash, instead the whole flash must be read and ECC\'d first. This slows scanning and hence booting.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Thus booting a 128MB NAND-based JFFS2 is likely to look something like this:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Read and ECC every last byte on the device even if we only need a few bytes per page for journaling headers and digest the contents. At say 5MB/second this will take ~25 seconds.</p>\r\n	</li>\r\n	<li>\r\n	<p>Each node requires a 16-byte structure (struct jffs2_raw_node_ref). If nodes were 512-bytes then that\'s 4MB of RAM!</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>These are probably unacceptable for the product being used. We therefore need to run something better than this.</p>\r\n\r\n<p>Two approaches spring to mind:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Just run FAT16. ie. Just treat all NAND as SmartMedia. Benefits: one code base. Down-side: reliability.</p>\r\n	</li>\r\n	<li>\r\n	<p>I\'m reluctant to store critical files in a FAT16 file system because these can be so unreliable. I\'m convinced that a journaling file system is superior. Maybe what we need is a light weight journaling file system (using common code with JFFS) modified in such a way as sidestep some of the nasty issues raised above.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>What I\'m working towards</h3>\r\n\r\n<p>Right now I\'m investigating the idea of trying to do something more appropriate. My current avenue of exploration is to use a journaling approach as follows:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>The journaling records are stored in fixed-size 512-byte pages.</p>\r\n	</li>\r\n	<li>\r\n	<p>The journaling tags are stored in the 16-byte-per-page \"management space\", semi-consistent with SmartMedia, using the 8 bytes of reserved space and LBA space to store journaling tags. ie something like:</p>\r\n	</li>\r\n	<li>\r\n	<p>20 bits of page id within inode</p>\r\n	</li>\r\n	<li>\r\n	<p>20 bits of inode id</p>\r\n	</li>\r\n	<li>\r\n	<p>9 bits length (bytes used in this page).</p>\r\n	</li>\r\n	<li>\r\n	<p>7 bits flags etc.</p>\r\n	</li>\r\n	<li>\r\n	<p>8 bits of hamming code on this area.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Each page id identifies where the page fits into the file. When a page is replaced (ie file data is overwritten) a new page with the same page id is written and the old one is wiped out. During garbage collection, the pages containing valid data are copied and the wiped out data is discarded.</p>\r\n\r\n<p>The benefits of this approach are:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>NAND-friendly since it works within the write limitations of NAND.</p>\r\n	</li>\r\n	<li>\r\n	<p>Less stuff to read to reconstruct file structures (only read management data).</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Down sides:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>No compression. But is that an issue considering the target data is already compressed and NAND is far less precious than NOR (thanks to higher densities and lower price).</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Still need to see if a new data structure is going to reduce the overhead of jffs2_raw_node_ref somewhat.</p>\r\n','<p>Details of Dec 2001 state of nand driver, and overview of how drivers fit together for use with different hardware and filesystems. Not really intended for public consumption, but a useful backgrounder and explanation of the evolution of YAFFS.</p>','full_html'),('page',0,43,43,'und',0,'<p>Yaffs came about because Toby Churchill Ltd (TCL) needed a flash filing system for their devices. They wanted something reliable and one of their fundamental requirements was fast boot time. We looked at adding NAND support to the existing flash filesystems, JFFS and particularly JFFS2, but it became clear that the boot time and ram consumption (a 128MB NAND would use about 4MB RAM in node tables) were a problem, and adding NAND support wasn\'t trivial either (but has since been done). In the end we decided a different filing system explicitly for NAND was the way to go. The design was greatly simplified by not including compression in the FS - which makes sense as nearly all the large data files TCL used were compressed anyway, and the larger size of NAND devices makes compression less important. A cramfs filesystem can be mounted within Yaffs if you need to compress some of your data.</p><p>The original work was paid for by <a href=\"http://www.toby-churchill.com/\">Toby Churchill Ltd</a>, the project instigators, and <a href=\"http://www.brightstareng.com/\">Brightstar Engineering</a>.</p><p>Here is a collection of notable events and milestones in the history of Yaffs.</p><ul><li>2006.10 Yaffs updated to work properly with Linux 2.6.17+ MTD on 512B and 2K page NAND</li><li>2006.05.08 Checkpointing added - so start-up scanning time enormously reduced</li><li>2004.08.02 Linux kernel 2.6 support checked in.</li><li>2004.02 Yaffs presentation given at FOSDEM on embedded track</li><li><i>2003.06.21</i> Yaffs runs with Linux kernel 2.5.70.</li><li><i>2003.05</i> First two Yaffs/direct licencees.</li><li><i>2003.04</i> Yaffs/direct non-GPL license option created for those who can\'t use the GPL.</li><li><i>2003.03.07</i> ViewCVS installed to make CVS browsing much easier and help those behind CVS-blocking firewalls get access to the code.</li><li><i>2003.01</i> Yaffs Direct ported to pSOS.</li><li><i>2003.01.21</i> \'Yaffs Direct Interface\' checked in - a version of Yaffs designed for integration into lightweight RTOSs and embedded systems.</li><li><i>2003.01.21</i> Yaffs Bootloader example code checked in, so your bootloader can read directly from Yaffs.</li><li><i>2002.11.04</i> <a href=\"/drupal/yaffs/yaffs2.html\">Yaffs2 spec</a> announced for discussion.</li><li><i>2002.11.08</i> WinCE port code checked-in to CVS.</li><li><i>2002.09.23</i> Announced to the world.</li><li><i>2002.09.17</i> Header files relicensed under LGPL to make it easier to add Yaffs support to bootloaders or other non-free software.</li><li><i>2002.09.13</i> Stand-alone system using Yaffs root partition booted.</li><li><i>2002.08</i> WinCE Yaffs port working.</li><li><i>2002.05.20</i> MTD interface tested on hardware emulation and some real hardware.</li><li><i>2002.05.14</i> v0.1 release. MTD interface done and incorporated. This is essentially untested. yaffs.o provides two file systems (one to support internal RAM emulation [called yaffsram] and the other mtd [called yaffs]). Docs improved/updated. mkyaffs filesystem creator written.</li><li><i>2002.04.24</i> Now includes device contexts, (but as there is only one emulation instance this isn\'t any practical use yet), some bugs fixed and disk full handling. Still some VFS problems apparent in sub-directories. Statfs, attributes still to do, symlinks and hardlinks not yet wired to VFS layer.</li><li><i>2002.04.15</i> kernel module that runs as an fs on 2MB internal emulation. The core filing-system seems to work pretty well. Some problems remain in the VFS layer producing various odd effects. Only one instance of the fs supported</li><li><i>2002.04.03</i> Core fs runs on emulation layer (instead of real NAND), create/read/write/delte/resize/reanem files, create directories, scans media on startup, garbage collection.</li></ul><p>&nbsp;</p>','<p>A chronology and list of milestones in Yaffs development.</p>','full_html'),('page',0,43,543,'und',0,'<p>Yaffs came about because Toby Churchill Ltd (TCL) needed a flash filing system for their devices. They wanted something reliable and one of their fundamental requirements was fast boot time. We looked at adding NAND support to the existing flash filesystems, JFFS and particularly JFFS2, but it became clear that the boot time and ram consumption (a 128MB NAND would use about 4MB RAM in node tables) were a problem, and adding NAND support wasn\'t trivial either (but has since been done). In the end we decided a different filing system explicitly for NAND was the way to go. The design was greatly simplified by not including compression in the FS - which makes sense as nearly all the large data files TCL used were compressed anyway, and the larger size of NAND devices makes compression less important. A cramfs filesystem can be mounted within Yaffs if you need to compress some of your data.</p><p>The original work was paid for by <a href=\"http://www.toby-churchill.com/\">Toby Churchill Ltd</a>, the project instigators, and <a href=\"http://www.brightstareng.com/\">Brightstar Engineering</a>.</p><p>Here is a collection of notable events and milestones in the history of Yaffs.</p><ul><li>2006.10 Yaffs updated to work properly with Linux 2.6.17+ MTD on 512B and 2K page NAND</li><li>2006.05.08 Checkpointing added - so start-up scanning time enormously reduced</li><li>2004.08.02 Linux kernel 2.6 support checked in.</li><li>2004.02 Yaffs presentation given at FOSDEM on embedded track</li><li><i>2003.06.21</i> Yaffs runs with Linux kernel 2.5.70.</li><li><i>2003.05</i> First two Yaffs/direct licencees.</li><li><i>2003.04</i> Yaffs/direct non-GPL license option created for those who can\'t use the GPL.</li><li><i>2003.03.07</i> ViewCVS installed to make CVS browsing much easier and help those behind CVS-blocking firewalls get access to the code.</li><li><i>2003.01</i> Yaffs Direct ported to pSOS.</li><li><i>2003.01.21</i> \'Yaffs Direct Interface\' checked in - a version of Yaffs designed for integration into lightweight RTOSs and embedded systems.</li><li><i>2003.01.21</i> Yaffs Bootloader example code checked in, so your bootloader can read directly from Yaffs.</li><li><i>2002.11.04</i> <a href=\"/drupal/yaffs/yaffs2.html\">Yaffs2 spec</a> announced for discussion.</li><li><i>2002.11.08</i> WinCE port code checked-in to CVS.</li><li><i>2002.09.23</i> Announced to the world.</li><li><i>2002.09.17</i> Header files relicensed under LGPL to make it easier to add Yaffs support to bootloaders or other non-free software.</li><li><i>2002.09.13</i> Stand-alone system using Yaffs root partition booted.</li><li><i>2002.08</i> WinCE Yaffs port working.</li><li><i>2002.05.20</i> MTD interface tested on hardware emulation and some real hardware.</li><li><i>2002.05.14</i> v0.1 release. MTD interface done and incorporated. This is essentially untested. yaffs.o provides two file systems (one to support internal RAM emulation [called yaffsram] and the other mtd [called yaffs]). Docs improved/updated. mkyaffs filesystem creator written.</li><li><i>2002.04.24</i> Now includes device contexts, (but as there is only one emulation instance this isn\'t any practical use yet), some bugs fixed and disk full handling. Still some VFS problems apparent in sub-directories. Statfs, attributes still to do, symlinks and hardlinks not yet wired to VFS layer.</li><li><i>2002.04.15</i> kernel module that runs as an fs on 2MB internal emulation. The core filing-system seems to work pretty well. Some problems remain in the VFS layer producing various odd effects. Only one instance of the fs supported</li><li><i>2002.04.03</i> Core fs runs on emulation layer (instead of real NAND), create/read/write/delte/resize/reanem files, create directories, scans media on startup, garbage collection.</li></ul><p>&nbsp;</p>','<p>A chronology and list of milestones in Yaffs development.</p>','full_html'),('page',0,43,553,'und',0,'<p>Yaffs came about because Toby Churchill Ltd (TCL) needed a flash filing system for their devices. They wanted something reliable and one of their fundamental requirements was fast boot time. We looked at adding NAND support to the existing flash filesystems, JFFS and particularly JFFS2, but it became clear that the boot time and ram consumption (a 128MB NAND would use about 4MB RAM in node tables) were a problem, and adding NAND support wasn\'t trivial either (but has since been done). In the end we decided a different filing system explicitly for NAND was the way to go. The design was greatly simplified by not including compression in the FS - which makes sense as nearly all the large data files TCL used were compressed anyway, and the larger size of NAND devices makes compression less important. A cramfs filesystem can be mounted within Yaffs if you need to compress some of your data.</p><p>The original work was paid for by <a href=\"http://www.toby-churchill.com/\">Toby Churchill Ltd</a>, the project instigators, and <a href=\"http://www.brightstareng.com/\">Brightstar Engineering</a>.</p><p>Here is a collection of notable events and milestones in the history of Yaffs.</p><ul><li>2006.10 Yaffs updated to work properly with Linux 2.6.17+ MTD on 512B and 2K page NAND</li><li>2006.05.08 Checkpointing added - so start-up scanning time enormously reduced</li><li>2004.08.02 Linux kernel 2.6 support checked in.</li><li>2004.02 Yaffs presentation given at FOSDEM on embedded track</li><li><i>2003.06.21</i> Yaffs runs with Linux kernel 2.5.70.</li><li><i>2003.05</i> First two Yaffs/direct licencees.</li><li><i>2003.04</i> Yaffs/direct non-GPL license option created for those who can\'t use the GPL.</li><li><i>2003.03.07</i> ViewCVS installed to make CVS browsing much easier and help those behind CVS-blocking firewalls get access to the code.</li><li><i>2003.01</i> Yaffs Direct ported to pSOS.</li><li><i>2003.01.21</i> \'Yaffs Direct Interface\' checked in - a version of Yaffs designed for integration into lightweight RTOSs and embedded systems.</li><li><i>2003.01.21</i> Yaffs Bootloader example code checked in, so your bootloader can read directly from Yaffs.</li><li><i>2002.11.04</i> <a href=\"/drupal/yaffs/yaffs2.html\">Yaffs2 spec</a> announced for discussion.</li><li><i>2002.11.08</i> WinCE port code checked-in to CVS.</li><li><i>2002.09.23</i> Announced to the world.</li><li><i>2002.09.17</i> Header files relicensed under LGPL to make it easier to add Yaffs support to bootloaders or other non-free software.</li><li><i>2002.09.13</i> Stand-alone system using Yaffs root partition booted.</li><li><i>2002.08</i> WinCE Yaffs port working.</li><li><i>2002.05.20</i> MTD interface tested on hardware emulation and some real hardware.</li><li><i>2002.05.14</i> v0.1 release. MTD interface done and incorporated. This is essentially untested. yaffs.o provides two file systems (one to support internal RAM emulation [called yaffsram] and the other mtd [called yaffs]). Docs improved/updated. mkyaffs filesystem creator written.</li><li><i>2002.04.24</i> Now includes device contexts, (but as there is only one emulation instance this isn\'t any practical use yet), some bugs fixed and disk full handling. Still some VFS problems apparent in sub-directories. Statfs, attributes still to do, symlinks and hardlinks not yet wired to VFS layer.</li><li><i>2002.04.15</i> kernel module that runs as an fs on 2MB internal emulation. The core filing-system seems to work pretty well. Some problems remain in the VFS layer producing various odd effects. Only one instance of the fs supported</li><li><i>2002.04.03</i> Core fs runs on emulation layer (instead of real NAND), create/read/write/delte/resize/reanem files, create directories, scans media on startup, garbage collection.</li></ul><p>&nbsp;</p>','<p>A chronology and list of milestones in Yaffs development.</p>','full_html'),('page',0,44,44,'und',0,'<h3>Paid support&nbsp;</h3>    <p>Support for YAFFS and ARM Linux is available from Aleph One</p> <p> </p> <p>YAFFS is available both as free software, under the GNU GPL, and under the Aleph One Licence. We provide different support and consulting services on its use with particular hardware and OSes as described below. <br /> <br /> We provide YAFFS support and documentation at a negotiable price; guide prices in GBP are:</p>     <table border=\"0\">      <tbody><tr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YAFFS Product type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GPL YAFFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Licence YAFFS </tr>     <tr>     <td><u>BRONZE</u></td>    </tr>    <tr>    <td>One copy of USERS\' GUIDE TO YAFFS and one hour consultation by phone  or email but no Guarantee</td><td>&pound;100</td><td>&pound;1000</td>    </tr>    <tr>     <td><u>SILVER</u></td>    </tr>    <tr>     <td>USERS\' GUIDE TO YAFFS and 10 hours of support by phone and email within one month of purchase</td>     <td>&pound;500</td><td>[&pound;3000]</td>    </tr>   <tr>    <td><u>GOLD</u></td>   </tr>   <tr>    <td>Whatever Support is necessary to produce a satisfactory working integration of    YAFFS with your product.</td><td>Negotiable</td><td>Negotiable</td>   </tr>   </tbody></table>         <p>For the GOLD level please contact us with a description of the project. Our standard charge for short-period consulting time is GBP800 per day. If you would prefer to sign mutual Non-Disclosure Agreements before discussing your requirements with us, and do not have your own, we have a standard one which is usually suitable. You or we can sign and send by post.</p><p>Sustained serious work is the subject of negotiated contracts which describe exactly what are the tasks and&nbsp; the cost.&nbsp; Support for simpler matters can usually be obtained in exchange for a payment of GB&pound;50 to us through PayPal, for which sum we will spend time dealing with your questions by telephone or email.<br /> </p> <h3>Mailing list</h3>   <p>There is a <a href=\"http://aleph1.co.uk/mailman/listinfo/yaffs\">YAFFS mailing list</a> for the development and discussion of YAFFS. It\'s a fairly low-traffic list. You will be emailed and asked to confirm your subscription request. You can also browse and search the <a href=\"http://aleph1.co.uk/lurker/splash/index.en.html\">list archives</a>. </p>','Information on YAFFS support options.<br />','obsolete_tinymce'),('page',0,61,61,'und',0,'<p>Here is the text of a talk given by Wookey (Chief Nerd at Aleph One) to a meeting in Cambridge of Developers, Businesspeople and IP practioners, on June 5th 2003.</p>   <hr />  <h2>Introduction</h2>   <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and ARM-linux.</p>    <p>I\'ve been mugged into speaking against software patents this evening. Now I don\'t claim to be an expert - A few months ago I know nothing about this subject but after hearing Richard Stallman speak at the Cambridge Computer Lab, my interest was piqued, and with some reading the web and going to a conference about it in Brussels (Brussel/Bruxelles) I think I\'ve now got a reasonable grasp of the arguments. It\'s a big subject but I\'ll try and sumarize the main points here.</p>   <p>I\'m nominally representing the <a href=\"http://swpat.ffii.org/\">FFII viewpoint</a> here. They are a European (German-based) organisation campaigning for a free information infrastructure. They have amassed an amazing amount of information on their website.</p>   <h2>The basics</h2>   <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to preserve info so it doesn\'t get lost and to avoid the appropriation of inventions.</p>   <p>We\'ve got very used to them, But they are not a free market or a right or a natural state of things and need to be justified in a given sphere. Most people on the street will say \'yes patents are a good thing\' if asked, but at least in the sphere of software, that attitude needs to be challenged and some evidence produced for why.</p>   <p>First lets be clear about what is meant by being against \'software patents\'. This refers to things which are just software; it doesn\'t mean that you can\'t patent anything with some software in it. So computer-controlled industrial process is patentable, but JPEG compression is not.</p>   <h2>Copyright</h2>   <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To \'copy\' your program someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you\'ll have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next verion. Innovation, copyright and trade secrets (for propietary software) are all that are needed to protect software in the market.</p>   <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc.</p>   <p>The biggest problem with patents is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it\'s impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you have to ask a patent lawyer, and they generally charge several thousand pounds/dollars/euros per patent for an opinion. Examing thousands of patents every year to check whether you infringed is impossibly expensive and/or time-consuming for most SMEs, so they don\'t do it. In practice every day you write code you probably infringe a patent or two, so one day someone will turn up telling you you infringed. It literally makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>   <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if it wasn\'t published then the patent remains valid and others can be hassled with it. None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t they will one day find that they got big enough to sue.</p>   <p>&hellip;</p>   <p>The existing software market isn\'t broken - software and software companies developed just fine without patents (Microsoft never had any patents before it got be huge, for example), so the premise that they are necessary to encourage investment and innovation is clearly wrong. No-one had any before about 1982 and the floodgates didn\'t open until around 1994, and plenty of software got written. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>   <p>Patent lawyers always talk about this subject from legal perspective, not from social or economic - they believe all patents are are good thing per se and don\'t even consider the idea that they might not be. We, and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>   <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work occaisionally, in practice they seem to do exactly the opposite. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 140,000 signed the FFII petition for example.</p>   <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. They just buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development we wish to encourage?</p>   <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks are issued.</p>    <p>The US is a handy test case, being some 4 or 5 years ahead of us in software patent terms, and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. At the recent FTC hearings company after company said the situation was out of control and not helping at all. The FTC studies should be published in August and it would be a very good thing if the EU could be persuaded to wait till that evidence is in before completing the directive.</p>   <h2>Suggestions</h2>   <p>&quot;Trviality is the problem&quot;: just raise the non-obviousness requirement. The examination (of patent applications) problem is insoluble - There are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. The economics of patent offices also drives this process, because they want to give value for money to their customers.</p>   <p>Consider existing patents on software to see how trivial they are. Progress Bar, electronic shopping cart, Dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows.</p>   <p>&quot;America has patents - so we must too&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans have the opposite problem.... Most of the EU software patents are owned by US and japanese corporations - just look at the list of applications for recent EU software patents. Making them legal would simply hand a significant chunk of the EU software business to foreign companies.</p>   <p>Software patents are currently illegal in Europe according to the European patent convention, and have been since at least 1973. The legislation says quite clearly that ideas, art, algorithms and computer programs as such are not patentable. So how come we have 30,000 of them already? It\'s because patent lawyers at the European Patent Office (EPO) have twisted the words of the law out of all recognition, essentially saying a \'computer program as such\' is not the same as a \'computer program\' and that because software runs on hardware which has a \'physical effect\' (gets hot, uses electricity\') - it can be patented.</p>   <p>This \'physical effect\' logic is flawed because how the hardware behaves is irrelevant to software developers - it\'s like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Developers don\'t need to understand the hardware to write software in the same way that you don\'t need to know how your engine works in order to drive your car.</p>   <p>This so of logic is why you have to be really paranoid when considering the wording of legislation. The MEPs say they don\'t want software patents, or business methods, but then write legislation that will allow unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law.</p>    <h2>Drawing the line</h2>   <p>Allright, so how do we draw the line?<br /> This is quite a difficult thing to think about clearly.</p>   <p>A computer is a turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>   <p>The question  boils down to the two sides of the argument:</p>   <ol> <li>If physical processes are patentable, why should it make any difference whether they run on special hardware or on general purpose hardware?</li><li>If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper or with today\'s normal tool - a universal computer?</li> </ol>   <p>The 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line.</p>   <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy due to the absence of physical effects: your for loops will not overheat and melt a nearby function, neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and data processing.</p>   <p>There will always be borderline cases and FFII have set up a benchmarking suite of example patents against which legislation can be tested. Software is large collection of obvious things. Like a Recipie, or symphony. A cook takes a number of (obvious) things and combines them in an intersting way, yet no-one thinks that patenting a new way of slicing tomatoes is a good idea, or that whoever thinks of a chord first should be able to prevent anyone else using it.</p>    <h2>Standards</h2>   <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ber sure of avoiding existing patents. But now, 15 years later, a patent-troll has bought a relevant patent and is enforcing it. They got 22 million dollars out of a couple of Japanese companies last year, and when the president of the JPEG committee said that there was prior art they accused him <u>personally</u> of \'patent libel\'.</p>   <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safegards to stop things like the JPEG hijacking. There can be agreements amoungst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait untill afterwards to come and sue. \'Use it or lose it\', and interoperability defence.</p>   <h2>Free software</h2>   <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\' defence. It also makes it very easy to see if there has been an infringement so it\'s authors are particularly open to being sued. There is no mechanism to pay for licenses so it cannot use any patented algorithms or features. An interoperability clause is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cuase problems as they only allow using the code for the specified purpose, not anything else anyone might come up with later.</p>   <p>It seems to me that \'Independent invention\' should be a sufficient defence.</p>   <p>In principle, a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The various international agreements (TRIPS) say that patents must be 20 years for all fields of endeavour. This is clearly inapropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>   <p>One argument of the pro-patent lobyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>   <p>So far as I can see software patents are a bad thing and have almost no overall benefit to society or developers. In the long term I think they will have very bad effects. I don\'t want to sound too much like some kind of anti-globalisation eco-nutter, but they do seem to be little more than an effective tool to allow large businesses and lawyers to supress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership. However powerful forces - the ones who stand to benefit from this legislation, disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>','Presentation at Software Patent Discussion Meeting, Cambridge July 6th 2003 - Wookey presented the case against software patents. Aleph One believes that legislation making them legal in Europe will severely damage innovative small software businesses, especially those using Free Software.','obsolete_tinymce'),('page',0,61,539,'und',0,'<p>Here is the text of a talk given by Wookey (Chief Nerd at Aleph One) to a meeting in Cambridge of Developers, Businesspeople and IP practioners, on June 5th 2003.</p>   <hr />  <h2>Introduction</h2>   <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and ARM-linux.</p>    <p>I\'ve been mugged into speaking against software patents this evening. Now I don\'t claim to be an expert - A few months ago I know nothing about this subject but after hearing Richard Stallman speak at the Cambridge Computer Lab, my interest was piqued, and with some reading the web and going to a conference about it in Brussels (Brussel/Bruxelles) I think I\'ve now got a reasonable grasp of the arguments. It\'s a big subject but I\'ll try and sumarize the main points here.</p>   <p>I\'m nominally representing the <a href=\"http://swpat.ffii.org/\">FFII viewpoint</a> here. They are a European (German-based) organisation campaigning for a free information infrastructure. They have amassed an amazing amount of information on their website.</p>   <h2>The basics</h2>   <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to preserve info so it doesn\'t get lost and to avoid the appropriation of inventions.</p>   <p>We\'ve got very used to them, But they are not a free market or a right or a natural state of things and need to be justified in a given sphere. Most people on the street will say \'yes patents are a good thing\' if asked, but at least in the sphere of software, that attitude needs to be challenged and some evidence produced for why.</p>   <p>First lets be clear about what is meant by being against \'software patents\'. This refers to things which are just software; it doesn\'t mean that you can\'t patent anything with some software in it. So computer-controlled industrial process is patentable, but JPEG compression is not.</p>   <h2>Copyright</h2>   <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To \'copy\' your program someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you\'ll have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next verion. Innovation, copyright and trade secrets (for propietary software) are all that are needed to protect software in the market.</p>   <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc.</p>   <p>The biggest problem with patents is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it\'s impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you have to ask a patent lawyer, and they generally charge several thousand pounds/dollars/euros per patent for an opinion. Examing thousands of patents every year to check whether you infringed is impossibly expensive and/or time-consuming for most SMEs, so they don\'t do it. In practice every day you write code you probably infringe a patent or two, so one day someone will turn up telling you you infringed. It literally makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>   <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if it wasn\'t published then the patent remains valid and others can be hassled with it. None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t they will one day find that they got big enough to sue.</p>   <p>&hellip;</p>   <p>The existing software market isn\'t broken - software and software companies developed just fine without patents (Microsoft never had any patents before it got be huge, for example), so the premise that they are necessary to encourage investment and innovation is clearly wrong. No-one had any before about 1982 and the floodgates didn\'t open until around 1994, and plenty of software got written. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>   <p>Patent lawyers always talk about this subject from legal perspective, not from social or economic - they believe all patents are are good thing per se and don\'t even consider the idea that they might not be. We, and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>   <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work occaisionally, in practice they seem to do exactly the opposite. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 140,000 signed the FFII petition for example.</p>   <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. They just buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development we wish to encourage?</p>   <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks are issued.</p>    <p>The US is a handy test case, being some 4 or 5 years ahead of us in software patent terms, and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. At the recent FTC hearings company after company said the situation was out of control and not helping at all. The FTC studies should be published in August and it would be a very good thing if the EU could be persuaded to wait till that evidence is in before completing the directive.</p>   <h2>Suggestions</h2>   <p>&quot;Trviality is the problem&quot;: just raise the non-obviousness requirement. The examination (of patent applications) problem is insoluble - There are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. The economics of patent offices also drives this process, because they want to give value for money to their customers.</p>   <p>Consider existing patents on software to see how trivial they are. Progress Bar, electronic shopping cart, Dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows.</p>   <p>&quot;America has patents - so we must too&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans have the opposite problem.... Most of the EU software patents are owned by US and japanese corporations - just look at the list of applications for recent EU software patents. Making them legal would simply hand a significant chunk of the EU software business to foreign companies.</p>   <p>Software patents are currently illegal in Europe according to the European patent convention, and have been since at least 1973. The legislation says quite clearly that ideas, art, algorithms and computer programs as such are not patentable. So how come we have 30,000 of them already? It\'s because patent lawyers at the European Patent Office (EPO) have twisted the words of the law out of all recognition, essentially saying a \'computer program as such\' is not the same as a \'computer program\' and that because software runs on hardware which has a \'physical effect\' (gets hot, uses electricity\') - it can be patented.</p>   <p>This \'physical effect\' logic is flawed because how the hardware behaves is irrelevant to software developers - it\'s like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Developers don\'t need to understand the hardware to write software in the same way that you don\'t need to know how your engine works in order to drive your car.</p>   <p>This so of logic is why you have to be really paranoid when considering the wording of legislation. The MEPs say they don\'t want software patents, or business methods, but then write legislation that will allow unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law.</p>    <h2>Drawing the line</h2>   <p>Allright, so how do we draw the line?<br /> This is quite a difficult thing to think about clearly.</p>   <p>A computer is a turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>   <p>The question  boils down to the two sides of the argument:</p>   <ol> <li>If physical processes are patentable, why should it make any difference whether they run on special hardware or on general purpose hardware?</li><li>If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper or with today\'s normal tool - a universal computer?</li> </ol>   <p>The 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line.</p>   <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy due to the absence of physical effects: your for loops will not overheat and melt a nearby function, neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and data processing.</p>   <p>There will always be borderline cases and FFII have set up a benchmarking suite of example patents against which legislation can be tested. Software is large collection of obvious things. Like a Recipie, or symphony. A cook takes a number of (obvious) things and combines them in an intersting way, yet no-one thinks that patenting a new way of slicing tomatoes is a good idea, or that whoever thinks of a chord first should be able to prevent anyone else using it.</p>    <h2>Standards</h2>   <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ber sure of avoiding existing patents. But now, 15 years later, a patent-troll has bought a relevant patent and is enforcing it. They got 22 million dollars out of a couple of Japanese companies last year, and when the president of the JPEG committee said that there was prior art they accused him <u>personally</u> of \'patent libel\'.</p>   <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safegards to stop things like the JPEG hijacking. There can be agreements amoungst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait untill afterwards to come and sue. \'Use it or lose it\', and interoperability defence.</p>   <h2>Free software</h2>   <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\' defence. It also makes it very easy to see if there has been an infringement so it\'s authors are particularly open to being sued. There is no mechanism to pay for licenses so it cannot use any patented algorithms or features. An interoperability clause is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cuase problems as they only allow using the code for the specified purpose, not anything else anyone might come up with later.</p>   <p>It seems to me that \'Independent invention\' should be a sufficient defence.</p>   <p>In principle, a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The various international agreements (TRIPS) say that patents must be 20 years for all fields of endeavour. This is clearly inapropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>   <p>One argument of the pro-patent lobyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>   <p>So far as I can see software patents are a bad thing and have almost no overall benefit to society or developers. In the long term I think they will have very bad effects. I don\'t want to sound too much like some kind of anti-globalisation eco-nutter, but they do seem to be little more than an effective tool to allow large businesses and lawyers to supress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership. However powerful forces - the ones who stand to benefit from this legislation, disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>','Presentation at Software Patent Discussion Meeting, Cambridge July 6th 2003 - Wookey presented the case against software patents. Aleph One believes that legislation making them legal in Europe will severely damage innovative small software businesses, especially those using Free Software.','obsolete_tinymce'),('page',0,61,556,'und',0,'<p>Here is the text of a talk given by Wookey (Chief Nerd at Aleph One) to a meeting in Cambridge of Developers, Businesspeople and IP practioners, on June 5th 2003.</p>   <hr />  <h2>Introduction</h2>   <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and ARM-linux.</p>    <p>I\'ve been mugged into speaking against software patents this evening. Now I don\'t claim to be an expert - A few months ago I know nothing about this subject but after hearing Richard Stallman speak at the Cambridge Computer Lab, my interest was piqued, and with some reading the web and going to a conference about it in Brussels (Brussel/Bruxelles) I think I\'ve now got a reasonable grasp of the arguments. It\'s a big subject but I\'ll try and sumarize the main points here.</p>   <p>I\'m nominally representing the <a href=\"http://swpat.ffii.org/\">FFII viewpoint</a> here. They are a European (German-based) organisation campaigning for a free information infrastructure. They have amassed an amazing amount of information on their website.</p>   <h2>The basics</h2>   <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to preserve info so it doesn\'t get lost and to avoid the appropriation of inventions.</p>   <p>We\'ve got very used to them, But they are not a free market or a right or a natural state of things and need to be justified in a given sphere. Most people on the street will say \'yes patents are a good thing\' if asked, but at least in the sphere of software, that attitude needs to be challenged and some evidence produced for why.</p>   <p>First lets be clear about what is meant by being against \'software patents\'. This refers to things which are just software; it doesn\'t mean that you can\'t patent anything with some software in it. So computer-controlled industrial process is patentable, but JPEG compression is not.</p>   <h2>Copyright</h2>   <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To \'copy\' your program someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you\'ll have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next verion. Innovation, copyright and trade secrets (for propietary software) are all that are needed to protect software in the market.</p>   <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc.</p>   <p>The biggest problem with patents is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it\'s impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you have to ask a patent lawyer, and they generally charge several thousand pounds/dollars/euros per patent for an opinion. Examing thousands of patents every year to check whether you infringed is impossibly expensive and/or time-consuming for most SMEs, so they don\'t do it. In practice every day you write code you probably infringe a patent or two, so one day someone will turn up telling you you infringed. It literally makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>   <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if it wasn\'t published then the patent remains valid and others can be hassled with it. None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t they will one day find that they got big enough to sue.</p>   <p>&hellip;</p>   <p>The existing software market isn\'t broken - software and software companies developed just fine without patents (Microsoft never had any patents before it got be huge, for example), so the premise that they are necessary to encourage investment and innovation is clearly wrong. No-one had any before about 1982 and the floodgates didn\'t open until around 1994, and plenty of software got written. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>   <p>Patent lawyers always talk about this subject from legal perspective, not from social or economic - they believe all patents are are good thing per se and don\'t even consider the idea that they might not be. We, and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>   <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work occaisionally, in practice they seem to do exactly the opposite. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 140,000 signed the FFII petition for example.</p>   <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. They just buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development we wish to encourage?</p>   <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks are issued.</p>    <p>The US is a handy test case, being some 4 or 5 years ahead of us in software patent terms, and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. At the recent FTC hearings company after company said the situation was out of control and not helping at all. The FTC studies should be published in August and it would be a very good thing if the EU could be persuaded to wait till that evidence is in before completing the directive.</p>   <h2>Suggestions</h2>   <p>&quot;Trviality is the problem&quot;: just raise the non-obviousness requirement. The examination (of patent applications) problem is insoluble - There are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. The economics of patent offices also drives this process, because they want to give value for money to their customers.</p>   <p>Consider existing patents on software to see how trivial they are. Progress Bar, electronic shopping cart, Dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows.</p>   <p>&quot;America has patents - so we must too&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans have the opposite problem.... Most of the EU software patents are owned by US and japanese corporations - just look at the list of applications for recent EU software patents. Making them legal would simply hand a significant chunk of the EU software business to foreign companies.</p>   <p>Software patents are currently illegal in Europe according to the European patent convention, and have been since at least 1973. The legislation says quite clearly that ideas, art, algorithms and computer programs as such are not patentable. So how come we have 30,000 of them already? It\'s because patent lawyers at the European Patent Office (EPO) have twisted the words of the law out of all recognition, essentially saying a \'computer program as such\' is not the same as a \'computer program\' and that because software runs on hardware which has a \'physical effect\' (gets hot, uses electricity\') - it can be patented.</p>   <p>This \'physical effect\' logic is flawed because how the hardware behaves is irrelevant to software developers - it\'s like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Developers don\'t need to understand the hardware to write software in the same way that you don\'t need to know how your engine works in order to drive your car.</p>   <p>This so of logic is why you have to be really paranoid when considering the wording of legislation. The MEPs say they don\'t want software patents, or business methods, but then write legislation that will allow unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law.</p>    <h2>Drawing the line</h2>   <p>Allright, so how do we draw the line?<br /> This is quite a difficult thing to think about clearly.</p>   <p>A computer is a turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>   <p>The question  boils down to the two sides of the argument:</p>   <ol> <li>If physical processes are patentable, why should it make any difference whether they run on special hardware or on general purpose hardware?</li><li>If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper or with today\'s normal tool - a universal computer?</li> </ol>   <p>The 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line.</p>   <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy due to the absence of physical effects: your for loops will not overheat and melt a nearby function, neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and data processing.</p>   <p>There will always be borderline cases and FFII have set up a benchmarking suite of example patents against which legislation can be tested. Software is large collection of obvious things. Like a Recipie, or symphony. A cook takes a number of (obvious) things and combines them in an intersting way, yet no-one thinks that patenting a new way of slicing tomatoes is a good idea, or that whoever thinks of a chord first should be able to prevent anyone else using it.</p>    <h2>Standards</h2>   <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ber sure of avoiding existing patents. But now, 15 years later, a patent-troll has bought a relevant patent and is enforcing it. They got 22 million dollars out of a couple of Japanese companies last year, and when the president of the JPEG committee said that there was prior art they accused him <u>personally</u> of \'patent libel\'.</p>   <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safegards to stop things like the JPEG hijacking. There can be agreements amoungst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait untill afterwards to come and sue. \'Use it or lose it\', and interoperability defence.</p>   <h2>Free software</h2>   <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\' defence. It also makes it very easy to see if there has been an infringement so it\'s authors are particularly open to being sued. There is no mechanism to pay for licenses so it cannot use any patented algorithms or features. An interoperability clause is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cuase problems as they only allow using the code for the specified purpose, not anything else anyone might come up with later.</p>   <p>It seems to me that \'Independent invention\' should be a sufficient defence.</p>   <p>In principle, a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The various international agreements (TRIPS) say that patents must be 20 years for all fields of endeavour. This is clearly inapropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>   <p>One argument of the pro-patent lobyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>   <p>So far as I can see software patents are a bad thing and have almost no overall benefit to society or developers. In the long term I think they will have very bad effects. I don\'t want to sound too much like some kind of anti-globalisation eco-nutter, but they do seem to be little more than an effective tool to allow large businesses and lawyers to supress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership. However powerful forces - the ones who stand to benefit from this legislation, disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>','Presentation at Software Patent Discussion Meeting, Cambridge July 6th 2003 - Wookey presented the case against software patents. Aleph One believes that legislation making them legal in Europe will severely damage innovative small software businesses, especially those using Free Software.','obsolete_tinymce'),('page',0,62,62,'und',0,'    <div>    <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and GNU/linux on ARM processors, - those are the ones found in most mobile phones and PDAs.</p>        <p>I\'ve been asked to come and speak to you about software patents today. This is currently a hot topic because there is a directive going through the EU at the moment which could either make software patents illegal or legal, depending on its exact wording. This will set the programming legal environment for the next 10 or 20 years, so it\'s important that anyone working in the field of computing understands the issues and implications.</p>        <p>Now, I don\'t claim to be an expert in this area, but my interest was piqued some 18 months ago by hearing Richard Stallman of the Free Software Foundation speak on the subject, and since then I\'ve been to a conference in Brussels, and various discussions in and around Cambridge, talking to people on both sides of the debate, so I\'ve now got a reasonable grasp of the arguments, and I hope I can adequately explain them to you. It\'s a big subject, but I\'ll try and cover the main points here today, and leave time for some questions &amp; discussion. I\'ve recently been to a 1hr version of this talk and that\'s a bit much even for dedicated geeks, so this one will be more like half an hour.</p>        <p>This talk is not entirely neutral - after examining the arguments I\'ve come firmly to the conclusion that software patents &nbsp;are a very bad thing for society. The viewpoint I\'ll give today is essentially is that of the FFII - a European (German-based) organisation campaigning for a free information infrastructure, concentrating largely on software patents for the last 2 years. They have amassed an amazing amount of info on software patents on their website, and are an excellent resource should you wish to read further about this.</p>        <p>I\'ll be putting this talk on the web when I get back home in a week or so, so if you want to refer to it for URLs or references, just search for Wookey or Aleph One (and ignore Wookey Hole Caves, who beat me to the top Google spot).</p>        <p>The basics</p>        <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to promote inventive activity and preserve information so it doesn\'t get lost.</p>        <p>They are granted for inventions in a technical field, which are new, suitable for industrial use, and unobvious to an expert in the field.</p>        <p>There is an assumption of balance: that the width of protection granted is justified by the significance of the achievement. When a patent is granted - there is one winner who can exploit the invention exclusively, and potentially many losers who must forgo the invention, or buy a licence (if the patent owner chooses to sell them one). Where this balance holds, then the system is effective: the resources put into researching the invention justify the negative effects of the patent monopoly, as is often the case in pharmaceutical research. But software patents are very close to patents on pure ideas. The achievement is minor, and the research usually negligible, but the protection can be very wide, as a patent can affect an enormous number of pieces of software.</p>        <p>A patent only gives exclusive rights in the country of issue (unlike copyright, which automatically applies everywhere that has signed up to the Berne Convention), so a US patent only applies in the US, a French patent in France. The European Patent Office (the EPO) exists to simplify the process of getting numerous national patents in European countries. It deals with the examination process, and translations and the issuing of British, French, Polish, etc patents in the countries you have chosen to pay for patents in.</p>        <p>We\'ve got very used to patents, but they are not a free market, or a right, or a natural state of things, and need to be justified in a given sphere of activity. Most people on the street will say \'yes, patents are a good thing\' if asked, but at least in the sphere of software, the assumption that patents are good needs to be questioned and some evidence produced for why. </p>            <p>Copyright.</p>        <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To copy your program legally someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next version. Innovation, copyright and trade secrets (for proprietary software) are all that is needed to protect software in the market.</p>        <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc. Copyright is also free and automatic to obtain, and automatically applies internationally.</p>        <p>The biggest problem with patents, for programmers and businesses, is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it is impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you normally have to ask a patent lawyer, and they charge several thousand pounds per patent for an opinion. Examining thousands of patents every year to check if you infringed is impossibly expensive and/or time-consuming for most small to medium sized businesses (SMEs), so they don\'t do it. Thus, in practice, every day a programmer writes code she infringes a patent or two, and one day someone will turn up telling her she infringed. It makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>        <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if you didn\'t publish it then the patent remains valid and others can still be hassled with it?</p>        <p>None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t, they will one day find that they got big enough to sue.</p>        <p>...</p>        <p>The existing software market isn\'t broken - software and software companies developed just fine without patents, so the premise that they are necessary to encourage investment and innovation is clearly wrong. (For example Microsoft never had any patents before it got be huge, but now that it\'s a dominant incumbent it\'s buying hundreds of them). No-one had any before about 1982 and the floodgates didn\'t open (in the US) until around 1994, and plenty of software got written, some of it highly innovative. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>        <p>Patent lawyers always talk about this subject from a legal perspective, not from a social or economic one - they believe all patents are a good thing per se and don\'t even consider the idea that they might not be. We, and MPs and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>        <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work like this occasionally for software, in practice they seem to do exactly the opposite.</p>        <p>Having one patent on something is very little defence against a large corporation that wants to use your idea. Because any useful piece of software uses many many ideas and algorithms the corporation will just say, &quot;ah, yes we may be infringing your patent, but you\'re infringing six of ours &nbsp;- do you really want to go to court about it?&quot; IBM are masters of this strategy and there are many stories of cohorts of stony-faced lawyers turning up to give anyone threatening them with patent infringement a hard time.</p>        <p>So in practice, allowing software patents simply leads to a numbers game, where all the players need lots of patents and it doesn\'t matter if most of them are rubbish - they just need to cover as much of the field of computer science as possible. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 300,000 signatories, including 700 companies signed a FFII petition against them, for example.</p>        <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. These outfits buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development and innovation we wish to encourage?</p>        <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks and useful ideas are issued.</p>            <p>The US is a handy test case, being some 4 or 5 years ahead of us in swpat terms, &nbsp;and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. The Federal Trade Commission recently held hearings &nbsp;on the state of the patent system and company after company said the situation was out of control in the field of software and was not helping at all. That study was published in August 2003 and is a fine example of a very staid government body concluding that they are actively unhelpful.</p>        <p>Nevertheless, there is a lot of pressure from the US for the EU to legalise software patents. This comes primarily from large companies which stand to gain from them, but even companies that don\'t like software patents, realise that they will lose out unless we operate under the same restrictive regime, so they tend to support the idea of software patents in the EU too.</p>        <p>....</p>            <p>In principle the problems of software patents would be enormously reduced if they were only given for things that were genuinely complex or hard to invent, but the system itself encourages very low standards of examination. Patents are supposed to be \'not obvious to an expert in the field\'. But how many of you think that these typical European patents are not obvious: </p>        <p>Progress Bar, electronic shopping trolley, dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows, or transferring pupil data between computers over a wireless network. </p>        <p>These are all just the obvious way you would do something if asked to provide that functionality. And they are not particularly unrepresentative examples - if you look at the patent database and read through the legalese, nearly all software patents are this trivial. You can get a patent for almost any computing idea if it is dressed up in the right language. The FFII maintains a database of patents translated back into something software engineers can understand, to show the sort of ridiculous things that already get patents.</p>        <p>The problem is that there are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. And the economics of patent offices also drive this process, because they want to give value for money to their customers - people pay to be granted patents, not to be refused them, but the office has to do nearly the same amount of work in both cases. Th EPO charges more than any other patent office (several thousand pounds), but still grants all sorts of trivial patents. The US Patent office is much worse.</p>        <p>Another irony of the system is that in the days of the industrial revolution a patent included a technical drawing of the invention that could be used to build it - the \'publication\' side of the \'monopoly in exchange for knowledge\' balance I mentioned earlier. But software patents only include a description of the idea, not an actual implementation that could be used for someone to build on. There is no requirement to publish working source code, and indeed patent lawyers resist this idea, claiming that it is much clearer to have them re-write your program in patent-speak, which if you have ever tried to read a patent, clearly isn\'t true. This process just makes it easier for lawyers to keep the whole system under their control, as you need them to apply for patents and to interpret patents, and programmers find the published patents completely useless as a source of knowledge, even though that is supposed to be a major part of their purpose. </p>        <p>One of the main arguments given in favour of software patents is &quot;The Americans have them- so we must too, in order to compete&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans are finding it harder and harder (or at least increasingly expensive) to write software, and are liable to being sued at home.... There have already been a lot of software patents granted in the EU, despite their dubious legality, and most of them are owned by US and Japanese corporations. Making them legal would simply hand a significant chunk of the EU software business to foreign companies. </p>        <p>(Standards) </p>        <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ensure no patents were infringed. But now 15 years later a patent-troll has bought a relevant patent and is enforcing it. They got 22 Million dollars out of a couple of Japanese digital camera companies last year, and when the president of the JPEG committee said that there was prior art they accused him personally (not the JPEG committee, or his company) of \'patent libel\'. This claim has not put them off and they are still hassling businesses that write JPEGs. </p>        <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safeguards to stop things like the JPEG hijacking. There can be agreements amongst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait till afterwards to come and sue. A \'Use it or lose it\' provision, and and interoperability defence would both help here.</p>        <p>(Free software)</p>        <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\'</p>    <p>defence. It also makes it very easy to see if there has been an infringement so its authors are particularly open to being sued. As nearly all Free Software is distributed at no cost, there is no mechanism to pay for licenses so it can\'t use any patented algorithms or features. A clause in the law is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cause problems as they only allow using the code for the specified purpose, not any other possible use someone might come up with later.</p>        <p>It seems to me that \'Independent invention\', which happens all the time in software development, should be a sufficient defence, but that is anathema to the patent system.</p>        <p>In principle a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The international agreement (TRIPS) says that patents must be 20 years for all fields of endeavour. This is clearly inappropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. &nbsp;This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>        <p>One argument of the pro-patent lobbyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is the line taken by the UK government. But this reasoning is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>        <p>So where are we now?</p>        <p>Software patents are currently illegal in Europe according to the European patent convention, agreed in 1973. The legislation says quite clearly that a number of things are not patentable </p>    <p> * discoveries, scientific theories, mathematical methods,</p>    <p> * aesthetic creations, </p>    <p> * schemes rules and methods for performing mental acts, playing games or doing business</p>    <p> * presentations of information</p>    <p> * and computer programs</p>        <p>You can see from this list how software is filed alongside things which are essentially ideas, discoveries, and creative acts like writing a novel or a symphony.</p>        <p>We don\'t allow patents on the arrangement of words in a particular form of clause or story;</p>    <p>We don\'t allow the creation of a particular motif or structure in music to be patented, and;</p>    <p>We don\'t allow patentability of a new sort of provision in a legal contract.</p>        <p>We do allow the complete arrangement of notes or words in these things to be copyrighted. Software is like these - it is the bringing together of many small obvious components into a coherent whole, and this process is a creative act, not an invention in the sense of patent law.</p>    <p> </p>    <p>So how come we have 30,000 software patents in Europe already? It\'s because patent lawyers at the European Patent Office (EPO) have, over 20 years of case law, twisted the word and spirit of the law out of all recognition, essentially saying a \'computer program as such\' (the wording in the EPC) is not the same as a \'computer program\' and that because software runs on hardware which is inherently \'technical\' (gets hot, uses electricity\') - it can be patented.</p>        <p> This is why you have to be really paranoid when considering the wording of legislation. Nearly everyone involved says they don\'t want software patents, and they certainly don\'t want business method patents, but then write legislation that allows unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law to ensure that there are meaningful limits on what is and isn\'t patentable.</p>        <p>The legislative process</p>        <p>I need to step back a moment here and explain the legislative process in the EU. There is a tripartite system involving the European Commission, the European Parliament (your MEPs) and the Council of Ministers, (which is composed of representatives of each of the EU member governments). </p>        <p>Law is proposed by the Commission, amendments are proposed by committees and parliament, then voted on by the parliament. Next it goes to the Council of Ministers for a vote. With this particular piece of legislation (the directive on computer-implemented inventions), this is where we have currently got to. Next it goes back to the parliament where further amendments are possible, and finally back to the Council again for ratification.</p>        <p>The commission originally proposed a terrible directive, which effectively allowed unlimited software patentability. However, a huge lobbying campaign led by the FFII (which apparently produced the biggest petition the Parliament has yet been presented with) persuaded the Parliament to add a large number of amendments which put real limits on patentability, and included an interoperability clause. But then when the directive went on to the Council of Ministers, they discarded all of the Parliament\'s significant amendments and produced a version which was even worse than the Commission\'s original, as it included program claims too. (I\'ll explain what that means in a mo).</p>        <p>This was bizarrely described as a \'compromise position\', given that it totally ignored the democratically-elected parliament\'s position. This version was narrowly agreed two weeks ago by the Council, so now we go back to the Parliament. Unfortunately, second time round amendments are significantly harder to get passed as they need a majority of all MEPs, not just the ones present at the vote, and whilst that\'s not impossible, it won\'t happen unless your MEP hears from you that this is an important issue. It is also important to work on National governments. The UK has been at the forefront of those pushing for unlimited patentability via this directive, apparently driven by the UK Patent Office, and changing goverment policy is going to be very difficult, but many other European governments are getting rather nervous about this issue, and it is definately an argument that can still be won.</p>        <p>Key Issues</p>        <p>There are three key issues in the legislation:</p>    <p> * Program Claims</p>    <p> * Interoperability, and</p>    <p> * the meaning of the word &quot;technical&quot; - i.e. what is patentable.</p>        <p> &quot;Program Claims&quot; means that software patents can cover the publication of programs in machine-readable form, not just the use of those programs. This means that sending someone a file containing patented software becomes illegal without a license, and even discussing the software would become difficult, as there is nothing to say that discussing algorithms using code fragments (the way programmers normally discuss code) is allowed.</p>        <p>This is the provision that was added in the Council of Ministers draft, showing how the national patent offices (who obviously like this sort of maximisation of the reach of patent law) are currently controlling the views of our governments.</p>        <p>A \'fair use\' provision would at least offer an olive branch, but really the scope of patent protection should be kept to use of the invention, not extended to include information about the invention itself. Software is different from normal manufactured goods because it is just information - it is both the invention, and the description of it, in one thing. This is why Program claims make sense to Patent Lawyers, and equally explains why programmers believe software simply shouldn\'t be patentable at all, because it is information, not an industrial process.</p>        <p>Interoperability:</p>    <p>There is nothing in the proposed draft, short of a full-scale EU Competition Investigation, to prevent dominant patent owners preventing competitors from interoperating by refusing them licenses. The most obvious example is the recent patent Microsoft has been given on the particular XML format used in its newest Word documents. It must be possible for others to write software that is compatible without having to buy patent licenses, and this is the position backed by the European Parliament, which allowed automatic unfettered use.</p>        <p>The Danish parliment suggested a compromise of a fast-track procedure for courts to require compulsory RAND licensing - i.e. a paid licence, but available to all, and at the same cost. This would work for proprietary software but is not much use for Free Software. Should it be illegal for Openoffice to read and write MS Word documents, or the Linux movie software Mplayer not to be able to play films you bought? </p>        <p>Your MP and MEP needs to hear that you consider interoperability essential.</p>        <p>Technical</p>        <p>As I said earlier - According to the European Patent Convention, computer programs are excluded from patentability, to the extent that the claimed invention relates to the computer program &quot;as such&quot;.</p>        <p>The new directive legislates for a framework in which the crucial test for patentability is whether the claimed &quot;computer-implemented invention&quot; has a &quot;technical effect&quot;.</p>        <p>This has given supporters of patentability a figleaf that &quot;pure software as such will not be patentable&quot;.</p>        <p>But what is &quot;software&quot;, and what is &quot;technical&quot;</p>        <p>There are essentially three views:</p>        <p>1) &nbsp;There is general agreement that newly invented physical processes should be patentable, regardless of whether software control is needed for the process to be achievable. &nbsp;The classic example is an anti-lock braking system, if a particular non-obvious process of applying the brakes has a particular physical benefit.</p>        <p>This was the view taken by the parliament, and is supported by the German government - the characteristic wording is that &quot;control of the forces of nature&quot; is technical, but that internal processing of data is not technical.</p>        <p>2) UK case law goes further than this. So whilst processing of generic data is not generally patentable, the invention becomes &quot;technical&quot; if the data has technological relevance, so things like image-enhancement software is patentable because the image data is \'technical\'.</p>        <p>Because the UK has been giving software patents like this for some years now the goverment is steadfastly refusing any stricter definition of technical because it will invalidate existing patents.</p>        <p>3) The EPO has gone further still and takes the position that all computing is inherently technical and so anything that has practical usefulness makes a &quot;technical contribution&quot;. Thus they say that a new algorithm &quot;as such&quot; is not patentable, but any algorithm with any identifiable practical usefulness (runs faster, uses less memory) is patentable.</p>        <p>This third option is what the Council of Ministers draft proposes, and is what UK ministers are backing despite saying &quot;nothing shall be patentable which is not patentable already&quot;.</p>        <p>Here\'s a few more examples of what the EPO has already decided is \'technical\' (and granted patents for):</p>        <p> - emailing the recipient of a gift, to ask where they would like their gift delivered (Amazon gift ordering)</p>    <p>- using the same data without retying to update both a sales ledger and stock control</p>    <p>- Tabbed windows (making more efficient use of screen space)</p>        <p>This laughable list is, unfortunately, almost endless.</p>        <p>This \'computing is technical, so software should be patentable\' argument is like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Software ideas are independent from the hardware in the same way that music is independent of the reproduction equipment.</p>        <p>Here is another way to look at why the \'controllable forces of nature\' definition of \'technical\' makes sense:</p>    <p> </p>    <p>A computer is a Turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>        <p>The question &nbsp;boils down to the two sides of the argument:</p>    <p>a) If physical processes are patentable, why should it make any difference whether they run on special hardware for that process or on general purpose hardware (i.e. a computer)?</p>        <p>b) If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper, or with today\'s normal tool - a universal computer?</p>        <p>Both these apparently-logical arguments cannot be right, and in fact the 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line between what is and isn\'t patentable.</p>        <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy. Your for loops will not overheat and melt a nearby function, and neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and rules of organisation and calculation.</p>        <p>There will always be borderline cases and FFII have set up a</p>    <p>benchmarking suite of example patents against which legislation can be tested.</p>        <p>Advances in software are like advances in science. Everyone is building on the work of those who went before by making small improvements - \'standing on the shoulders of giants\'. Free publication and re-use of ideas is an essential component of this development. Would having to pay a licensing fee for the use of every idea or reference in your PhD thesis increase your innovation? Where would we be if Newton or Einstein, or any others of a host of scientists in the last 200 years had patented their ideas? </p>        <p>The Free software movement has shown in the last 15 years that a co-operative model of software writing is more efficient than a closed, proprietary one, at least within the commodity zone of general-purpose software such as operating systems, data protocols and office software. The internet has become a remarkably pervasive thing over that same time period, precisely because it runs on open, patent-free standards. Everyone can use it on an equal footing and write interesting applications for it without payments or legal restrictions.</p>        <p>If Tim Berners-Lee had patented HTTP back in 1987 the whole world would be a great deal poorer. We wouldn\'t have the web in the ubiquitous form we have it today - perhaps we wouldn\'t have it at all. And he probably wouldn\'t even be better off as he\'s just won a prize of a million dollars for his contribution to mankind. He would have struggled to make that much money from a patented, and thus stangled-at-birth web. Just because something is a good idea, doesn\'t mean it must be patented, or even patentable.</p>        <p>So far as I can see software patents are a bad thing and have no overall benefit to society or developers. In the long term, all the evidence shows that they will constrain development, reduce innovation, and prevent Free Software and small businesses from competing on a level playing field. &nbsp;They seem to be little more than an effective tool to allow large businesses and lawyers to suppress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership.</p>        <p>However, powerful forces - the ones who stand to benefit from this legislation - disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>   </div>','An updated, 30 minute, version of the shorter Cambridge talk, describing the problems with software patents and the current state of EU legislation covering this issue. This presentation was given to Lancaster University Phd Computer Science students, on the Isle of Man, on 2nd July 2004.','obsolete_tinymce'),('page',0,62,538,'und',0,'    <div>    <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and GNU/linux on ARM processors, - those are the ones found in most mobile phones and PDAs.</p>        <p>I\'ve been asked to come and speak to you about software patents today. This is currently a hot topic because there is a directive going through the EU at the moment which could either make software patents illegal or legal, depending on its exact wording. This will set the programming legal environment for the next 10 or 20 years, so it\'s important that anyone working in the field of computing understands the issues and implications.</p>        <p>Now, I don\'t claim to be an expert in this area, but my interest was piqued some 18 months ago by hearing Richard Stallman of the Free Software Foundation speak on the subject, and since then I\'ve been to a conference in Brussels, and various discussions in and around Cambridge, talking to people on both sides of the debate, so I\'ve now got a reasonable grasp of the arguments, and I hope I can adequately explain them to you. It\'s a big subject, but I\'ll try and cover the main points here today, and leave time for some questions &amp; discussion. I\'ve recently been to a 1hr version of this talk and that\'s a bit much even for dedicated geeks, so this one will be more like half an hour.</p>        <p>This talk is not entirely neutral - after examining the arguments I\'ve come firmly to the conclusion that software patents &nbsp;are a very bad thing for society. The viewpoint I\'ll give today is essentially is that of the FFII - a European (German-based) organisation campaigning for a free information infrastructure, concentrating largely on software patents for the last 2 years. They have amassed an amazing amount of info on software patents on their website, and are an excellent resource should you wish to read further about this.</p>        <p>I\'ll be putting this talk on the web when I get back home in a week or so, so if you want to refer to it for URLs or references, just search for Wookey or Aleph One (and ignore Wookey Hole Caves, who beat me to the top Google spot).</p>        <p>The basics</p>        <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to promote inventive activity and preserve information so it doesn\'t get lost.</p>        <p>They are granted for inventions in a technical field, which are new, suitable for industrial use, and unobvious to an expert in the field.</p>        <p>There is an assumption of balance: that the width of protection granted is justified by the significance of the achievement. When a patent is granted - there is one winner who can exploit the invention exclusively, and potentially many losers who must forgo the invention, or buy a licence (if the patent owner chooses to sell them one). Where this balance holds, then the system is effective: the resources put into researching the invention justify the negative effects of the patent monopoly, as is often the case in pharmaceutical research. But software patents are very close to patents on pure ideas. The achievement is minor, and the research usually negligible, but the protection can be very wide, as a patent can affect an enormous number of pieces of software.</p>        <p>A patent only gives exclusive rights in the country of issue (unlike copyright, which automatically applies everywhere that has signed up to the Berne Convention), so a US patent only applies in the US, a French patent in France. The European Patent Office (the EPO) exists to simplify the process of getting numerous national patents in European countries. It deals with the examination process, and translations and the issuing of British, French, Polish, etc patents in the countries you have chosen to pay for patents in.</p>        <p>We\'ve got very used to patents, but they are not a free market, or a right, or a natural state of things, and need to be justified in a given sphere of activity. Most people on the street will say \'yes, patents are a good thing\' if asked, but at least in the sphere of software, the assumption that patents are good needs to be questioned and some evidence produced for why. </p>            <p>Copyright.</p>        <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To copy your program legally someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next version. Innovation, copyright and trade secrets (for proprietary software) are all that is needed to protect software in the market.</p>        <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc. Copyright is also free and automatic to obtain, and automatically applies internationally.</p>        <p>The biggest problem with patents, for programmers and businesses, is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it is impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you normally have to ask a patent lawyer, and they charge several thousand pounds per patent for an opinion. Examining thousands of patents every year to check if you infringed is impossibly expensive and/or time-consuming for most small to medium sized businesses (SMEs), so they don\'t do it. Thus, in practice, every day a programmer writes code she infringes a patent or two, and one day someone will turn up telling her she infringed. It makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>        <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if you didn\'t publish it then the patent remains valid and others can still be hassled with it?</p>        <p>None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t, they will one day find that they got big enough to sue.</p>        <p>...</p>        <p>The existing software market isn\'t broken - software and software companies developed just fine without patents, so the premise that they are necessary to encourage investment and innovation is clearly wrong. (For example Microsoft never had any patents before it got be huge, but now that it\'s a dominant incumbent it\'s buying hundreds of them). No-one had any before about 1982 and the floodgates didn\'t open (in the US) until around 1994, and plenty of software got written, some of it highly innovative. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>        <p>Patent lawyers always talk about this subject from a legal perspective, not from a social or economic one - they believe all patents are a good thing per se and don\'t even consider the idea that they might not be. We, and MPs and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>        <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work like this occasionally for software, in practice they seem to do exactly the opposite.</p>        <p>Having one patent on something is very little defence against a large corporation that wants to use your idea. Because any useful piece of software uses many many ideas and algorithms the corporation will just say, &quot;ah, yes we may be infringing your patent, but you\'re infringing six of ours &nbsp;- do you really want to go to court about it?&quot; IBM are masters of this strategy and there are many stories of cohorts of stony-faced lawyers turning up to give anyone threatening them with patent infringement a hard time.</p>        <p>So in practice, allowing software patents simply leads to a numbers game, where all the players need lots of patents and it doesn\'t matter if most of them are rubbish - they just need to cover as much of the field of computer science as possible. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 300,000 signatories, including 700 companies signed a FFII petition against them, for example.</p>        <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. These outfits buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development and innovation we wish to encourage?</p>        <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks and useful ideas are issued.</p>            <p>The US is a handy test case, being some 4 or 5 years ahead of us in swpat terms, &nbsp;and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. The Federal Trade Commission recently held hearings &nbsp;on the state of the patent system and company after company said the situation was out of control in the field of software and was not helping at all. That study was published in August 2003 and is a fine example of a very staid government body concluding that they are actively unhelpful.</p>        <p>Nevertheless, there is a lot of pressure from the US for the EU to legalise software patents. This comes primarily from large companies which stand to gain from them, but even companies that don\'t like software patents, realise that they will lose out unless we operate under the same restrictive regime, so they tend to support the idea of software patents in the EU too.</p>        <p>....</p>            <p>In principle the problems of software patents would be enormously reduced if they were only given for things that were genuinely complex or hard to invent, but the system itself encourages very low standards of examination. Patents are supposed to be \'not obvious to an expert in the field\'. But how many of you think that these typical European patents are not obvious: </p>        <p>Progress Bar, electronic shopping trolley, dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows, or transferring pupil data between computers over a wireless network. </p>        <p>These are all just the obvious way you would do something if asked to provide that functionality. And they are not particularly unrepresentative examples - if you look at the patent database and read through the legalese, nearly all software patents are this trivial. You can get a patent for almost any computing idea if it is dressed up in the right language. The FFII maintains a database of patents translated back into something software engineers can understand, to show the sort of ridiculous things that already get patents.</p>        <p>The problem is that there are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. And the economics of patent offices also drive this process, because they want to give value for money to their customers - people pay to be granted patents, not to be refused them, but the office has to do nearly the same amount of work in both cases. Th EPO charges more than any other patent office (several thousand pounds), but still grants all sorts of trivial patents. The US Patent office is much worse.</p>        <p>Another irony of the system is that in the days of the industrial revolution a patent included a technical drawing of the invention that could be used to build it - the \'publication\' side of the \'monopoly in exchange for knowledge\' balance I mentioned earlier. But software patents only include a description of the idea, not an actual implementation that could be used for someone to build on. There is no requirement to publish working source code, and indeed patent lawyers resist this idea, claiming that it is much clearer to have them re-write your program in patent-speak, which if you have ever tried to read a patent, clearly isn\'t true. This process just makes it easier for lawyers to keep the whole system under their control, as you need them to apply for patents and to interpret patents, and programmers find the published patents completely useless as a source of knowledge, even though that is supposed to be a major part of their purpose. </p>        <p>One of the main arguments given in favour of software patents is &quot;The Americans have them- so we must too, in order to compete&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans are finding it harder and harder (or at least increasingly expensive) to write software, and are liable to being sued at home.... There have already been a lot of software patents granted in the EU, despite their dubious legality, and most of them are owned by US and Japanese corporations. Making them legal would simply hand a significant chunk of the EU software business to foreign companies. </p>        <p>(Standards) </p>        <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ensure no patents were infringed. But now 15 years later a patent-troll has bought a relevant patent and is enforcing it. They got 22 Million dollars out of a couple of Japanese digital camera companies last year, and when the president of the JPEG committee said that there was prior art they accused him personally (not the JPEG committee, or his company) of \'patent libel\'. This claim has not put them off and they are still hassling businesses that write JPEGs. </p>        <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safeguards to stop things like the JPEG hijacking. There can be agreements amongst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait till afterwards to come and sue. A \'Use it or lose it\' provision, and and interoperability defence would both help here.</p>        <p>(Free software)</p>        <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\'</p>    <p>defence. It also makes it very easy to see if there has been an infringement so its authors are particularly open to being sued. As nearly all Free Software is distributed at no cost, there is no mechanism to pay for licenses so it can\'t use any patented algorithms or features. A clause in the law is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cause problems as they only allow using the code for the specified purpose, not any other possible use someone might come up with later.</p>        <p>It seems to me that \'Independent invention\', which happens all the time in software development, should be a sufficient defence, but that is anathema to the patent system.</p>        <p>In principle a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The international agreement (TRIPS) says that patents must be 20 years for all fields of endeavour. This is clearly inappropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. &nbsp;This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>        <p>One argument of the pro-patent lobbyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is the line taken by the UK government. But this reasoning is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>        <p>So where are we now?</p>        <p>Software patents are currently illegal in Europe according to the European patent convention, agreed in 1973. The legislation says quite clearly that a number of things are not patentable </p>    <p> * discoveries, scientific theories, mathematical methods,</p>    <p> * aesthetic creations, </p>    <p> * schemes rules and methods for performing mental acts, playing games or doing business</p>    <p> * presentations of information</p>    <p> * and computer programs</p>        <p>You can see from this list how software is filed alongside things which are essentially ideas, discoveries, and creative acts like writing a novel or a symphony.</p>        <p>We don\'t allow patents on the arrangement of words in a particular form of clause or story;</p>    <p>We don\'t allow the creation of a particular motif or structure in music to be patented, and;</p>    <p>We don\'t allow patentability of a new sort of provision in a legal contract.</p>        <p>We do allow the complete arrangement of notes or words in these things to be copyrighted. Software is like these - it is the bringing together of many small obvious components into a coherent whole, and this process is a creative act, not an invention in the sense of patent law.</p>    <p> </p>    <p>So how come we have 30,000 software patents in Europe already? It\'s because patent lawyers at the European Patent Office (EPO) have, over 20 years of case law, twisted the word and spirit of the law out of all recognition, essentially saying a \'computer program as such\' (the wording in the EPC) is not the same as a \'computer program\' and that because software runs on hardware which is inherently \'technical\' (gets hot, uses electricity\') - it can be patented.</p>        <p> This is why you have to be really paranoid when considering the wording of legislation. Nearly everyone involved says they don\'t want software patents, and they certainly don\'t want business method patents, but then write legislation that allows unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law to ensure that there are meaningful limits on what is and isn\'t patentable.</p>        <p>The legislative process</p>        <p>I need to step back a moment here and explain the legislative process in the EU. There is a tripartite system involving the European Commission, the European Parliament (your MEPs) and the Council of Ministers, (which is composed of representatives of each of the EU member governments). </p>        <p>Law is proposed by the Commission, amendments are proposed by committees and parliament, then voted on by the parliament. Next it goes to the Council of Ministers for a vote. With this particular piece of legislation (the directive on computer-implemented inventions), this is where we have currently got to. Next it goes back to the parliament where further amendments are possible, and finally back to the Council again for ratification.</p>        <p>The commission originally proposed a terrible directive, which effectively allowed unlimited software patentability. However, a huge lobbying campaign led by the FFII (which apparently produced the biggest petition the Parliament has yet been presented with) persuaded the Parliament to add a large number of amendments which put real limits on patentability, and included an interoperability clause. But then when the directive went on to the Council of Ministers, they discarded all of the Parliament\'s significant amendments and produced a version which was even worse than the Commission\'s original, as it included program claims too. (I\'ll explain what that means in a mo).</p>        <p>This was bizarrely described as a \'compromise position\', given that it totally ignored the democratically-elected parliament\'s position. This version was narrowly agreed two weeks ago by the Council, so now we go back to the Parliament. Unfortunately, second time round amendments are significantly harder to get passed as they need a majority of all MEPs, not just the ones present at the vote, and whilst that\'s not impossible, it won\'t happen unless your MEP hears from you that this is an important issue. It is also important to work on National governments. The UK has been at the forefront of those pushing for unlimited patentability via this directive, apparently driven by the UK Patent Office, and changing goverment policy is going to be very difficult, but many other European governments are getting rather nervous about this issue, and it is definately an argument that can still be won.</p>        <p>Key Issues</p>        <p>There are three key issues in the legislation:</p>    <p> * Program Claims</p>    <p> * Interoperability, and</p>    <p> * the meaning of the word &quot;technical&quot; - i.e. what is patentable.</p>        <p> &quot;Program Claims&quot; means that software patents can cover the publication of programs in machine-readable form, not just the use of those programs. This means that sending someone a file containing patented software becomes illegal without a license, and even discussing the software would become difficult, as there is nothing to say that discussing algorithms using code fragments (the way programmers normally discuss code) is allowed.</p>        <p>This is the provision that was added in the Council of Ministers draft, showing how the national patent offices (who obviously like this sort of maximisation of the reach of patent law) are currently controlling the views of our governments.</p>        <p>A \'fair use\' provision would at least offer an olive branch, but really the scope of patent protection should be kept to use of the invention, not extended to include information about the invention itself. Software is different from normal manufactured goods because it is just information - it is both the invention, and the description of it, in one thing. This is why Program claims make sense to Patent Lawyers, and equally explains why programmers believe software simply shouldn\'t be patentable at all, because it is information, not an industrial process.</p>        <p>Interoperability:</p>    <p>There is nothing in the proposed draft, short of a full-scale EU Competition Investigation, to prevent dominant patent owners preventing competitors from interoperating by refusing them licenses. The most obvious example is the recent patent Microsoft has been given on the particular XML format used in its newest Word documents. It must be possible for others to write software that is compatible without having to buy patent licenses, and this is the position backed by the European Parliament, which allowed automatic unfettered use.</p>        <p>The Danish parliment suggested a compromise of a fast-track procedure for courts to require compulsory RAND licensing - i.e. a paid licence, but available to all, and at the same cost. This would work for proprietary software but is not much use for Free Software. Should it be illegal for Openoffice to read and write MS Word documents, or the Linux movie software Mplayer not to be able to play films you bought? </p>        <p>Your MP and MEP needs to hear that you consider interoperability essential.</p>        <p>Technical</p>        <p>As I said earlier - According to the European Patent Convention, computer programs are excluded from patentability, to the extent that the claimed invention relates to the computer program &quot;as such&quot;.</p>        <p>The new directive legislates for a framework in which the crucial test for patentability is whether the claimed &quot;computer-implemented invention&quot; has a &quot;technical effect&quot;.</p>        <p>This has given supporters of patentability a figleaf that &quot;pure software as such will not be patentable&quot;.</p>        <p>But what is &quot;software&quot;, and what is &quot;technical&quot;</p>        <p>There are essentially three views:</p>        <p>1) &nbsp;There is general agreement that newly invented physical processes should be patentable, regardless of whether software control is needed for the process to be achievable. &nbsp;The classic example is an anti-lock braking system, if a particular non-obvious process of applying the brakes has a particular physical benefit.</p>        <p>This was the view taken by the parliament, and is supported by the German government - the characteristic wording is that &quot;control of the forces of nature&quot; is technical, but that internal processing of data is not technical.</p>        <p>2) UK case law goes further than this. So whilst processing of generic data is not generally patentable, the invention becomes &quot;technical&quot; if the data has technological relevance, so things like image-enhancement software is patentable because the image data is \'technical\'.</p>        <p>Because the UK has been giving software patents like this for some years now the goverment is steadfastly refusing any stricter definition of technical because it will invalidate existing patents.</p>        <p>3) The EPO has gone further still and takes the position that all computing is inherently technical and so anything that has practical usefulness makes a &quot;technical contribution&quot;. Thus they say that a new algorithm &quot;as such&quot; is not patentable, but any algorithm with any identifiable practical usefulness (runs faster, uses less memory) is patentable.</p>        <p>This third option is what the Council of Ministers draft proposes, and is what UK ministers are backing despite saying &quot;nothing shall be patentable which is not patentable already&quot;.</p>        <p>Here\'s a few more examples of what the EPO has already decided is \'technical\' (and granted patents for):</p>        <p> - emailing the recipient of a gift, to ask where they would like their gift delivered (Amazon gift ordering)</p>    <p>- using the same data without retying to update both a sales ledger and stock control</p>    <p>- Tabbed windows (making more efficient use of screen space)</p>        <p>This laughable list is, unfortunately, almost endless.</p>        <p>This \'computing is technical, so software should be patentable\' argument is like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Software ideas are independent from the hardware in the same way that music is independent of the reproduction equipment.</p>        <p>Here is another way to look at why the \'controllable forces of nature\' definition of \'technical\' makes sense:</p>    <p> </p>    <p>A computer is a Turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>        <p>The question &nbsp;boils down to the two sides of the argument:</p>    <p>a) If physical processes are patentable, why should it make any difference whether they run on special hardware for that process or on general purpose hardware (i.e. a computer)?</p>        <p>b) If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper, or with today\'s normal tool - a universal computer?</p>        <p>Both these apparently-logical arguments cannot be right, and in fact the 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line between what is and isn\'t patentable.</p>        <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy. Your for loops will not overheat and melt a nearby function, and neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and rules of organisation and calculation.</p>        <p>There will always be borderline cases and FFII have set up a</p>    <p>benchmarking suite of example patents against which legislation can be tested.</p>        <p>Advances in software are like advances in science. Everyone is building on the work of those who went before by making small improvements - \'standing on the shoulders of giants\'. Free publication and re-use of ideas is an essential component of this development. Would having to pay a licensing fee for the use of every idea or reference in your PhD thesis increase your innovation? Where would we be if Newton or Einstein, or any others of a host of scientists in the last 200 years had patented their ideas? </p>        <p>The Free software movement has shown in the last 15 years that a co-operative model of software writing is more efficient than a closed, proprietary one, at least within the commodity zone of general-purpose software such as operating systems, data protocols and office software. The internet has become a remarkably pervasive thing over that same time period, precisely because it runs on open, patent-free standards. Everyone can use it on an equal footing and write interesting applications for it without payments or legal restrictions.</p>        <p>If Tim Berners-Lee had patented HTTP back in 1987 the whole world would be a great deal poorer. We wouldn\'t have the web in the ubiquitous form we have it today - perhaps we wouldn\'t have it at all. And he probably wouldn\'t even be better off as he\'s just won a prize of a million dollars for his contribution to mankind. He would have struggled to make that much money from a patented, and thus stangled-at-birth web. Just because something is a good idea, doesn\'t mean it must be patented, or even patentable.</p>        <p>So far as I can see software patents are a bad thing and have no overall benefit to society or developers. In the long term, all the evidence shows that they will constrain development, reduce innovation, and prevent Free Software and small businesses from competing on a level playing field. &nbsp;They seem to be little more than an effective tool to allow large businesses and lawyers to suppress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership.</p>        <p>However, powerful forces - the ones who stand to benefit from this legislation - disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>   </div>','An updated, 30 minute, version of the shorter Cambridge talk, describing the problems with software patents and the current state of EU legislation covering this issue. This presentation was given to Lancaster University Phd Computer Science students, on the Isle of Man, on 2nd July 2004.','obsolete_tinymce'),('page',0,62,557,'und',0,'    <div>    <p>Hi, I\'m Wookey, Chief Nerd at Aleph One, a small software and hardware producer in Cambridge. We do both free and proprietary software, these days largely around embedded systems and GNU/linux on ARM processors, - those are the ones found in most mobile phones and PDAs.</p>        <p>I\'ve been asked to come and speak to you about software patents today. This is currently a hot topic because there is a directive going through the EU at the moment which could either make software patents illegal or legal, depending on its exact wording. This will set the programming legal environment for the next 10 or 20 years, so it\'s important that anyone working in the field of computing understands the issues and implications.</p>        <p>Now, I don\'t claim to be an expert in this area, but my interest was piqued some 18 months ago by hearing Richard Stallman of the Free Software Foundation speak on the subject, and since then I\'ve been to a conference in Brussels, and various discussions in and around Cambridge, talking to people on both sides of the debate, so I\'ve now got a reasonable grasp of the arguments, and I hope I can adequately explain them to you. It\'s a big subject, but I\'ll try and cover the main points here today, and leave time for some questions &amp; discussion. I\'ve recently been to a 1hr version of this talk and that\'s a bit much even for dedicated geeks, so this one will be more like half an hour.</p>        <p>This talk is not entirely neutral - after examining the arguments I\'ve come firmly to the conclusion that software patents &nbsp;are a very bad thing for society. The viewpoint I\'ll give today is essentially is that of the FFII - a European (German-based) organisation campaigning for a free information infrastructure, concentrating largely on software patents for the last 2 years. They have amassed an amazing amount of info on software patents on their website, and are an excellent resource should you wish to read further about this.</p>        <p>I\'ll be putting this talk on the web when I get back home in a week or so, so if you want to refer to it for URLs or references, just search for Wookey or Aleph One (and ignore Wookey Hole Caves, who beat me to the top Google spot).</p>        <p>The basics</p>        <p>Patents are a bargain between state and public - a monopoly granted in exchange for publication of information. This is intended to promote inventive activity and preserve information so it doesn\'t get lost.</p>        <p>They are granted for inventions in a technical field, which are new, suitable for industrial use, and unobvious to an expert in the field.</p>        <p>There is an assumption of balance: that the width of protection granted is justified by the significance of the achievement. When a patent is granted - there is one winner who can exploit the invention exclusively, and potentially many losers who must forgo the invention, or buy a licence (if the patent owner chooses to sell them one). Where this balance holds, then the system is effective: the resources put into researching the invention justify the negative effects of the patent monopoly, as is often the case in pharmaceutical research. But software patents are very close to patents on pure ideas. The achievement is minor, and the research usually negligible, but the protection can be very wide, as a patent can affect an enormous number of pieces of software.</p>        <p>A patent only gives exclusive rights in the country of issue (unlike copyright, which automatically applies everywhere that has signed up to the Berne Convention), so a US patent only applies in the US, a French patent in France. The European Patent Office (the EPO) exists to simplify the process of getting numerous national patents in European countries. It deals with the examination process, and translations and the issuing of British, French, Polish, etc patents in the countries you have chosen to pay for patents in.</p>        <p>We\'ve got very used to patents, but they are not a free market, or a right, or a natural state of things, and need to be justified in a given sphere of activity. Most people on the street will say \'yes, patents are a good thing\' if asked, but at least in the sphere of software, the assumption that patents are good needs to be questioned and some evidence produced for why. </p>            <p>Copyright.</p>        <p>Copyright already exists for software and is well-suited. It stops wholesale copying of your implementation, but it doesn\'t stop someone making something that does the same job. To copy your program legally someone will have to re-implement it - that\'s about the same amount of work as it took you, which is fair enough, and you have a head start of however long it took. By the time they\'ve caught up you\'ll be on the next version. Innovation, copyright and trade secrets (for proprietary software) are all that is needed to protect software in the market.</p>        <p>Patent lawyers will say copyright is only for poetry and the like, but in fact it works quite well for music scores, music sound, pictures, films etc. Copyright is also free and automatic to obtain, and automatically applies internationally.</p>        <p>The biggest problem with patents, for programmers and businesses, is uncertainty: You can easily run your business so you don\'t trip over copyright - just don\'t plagiarise. But it is impossible to run it such that you are safe from unexpected attack by patent lawyers. Patents are written in a special language which even experts in a field find difficult to understand. In order to decide if you infringe a patent you normally have to ask a patent lawyer, and they charge several thousand pounds per patent for an opinion. Examining thousands of patents every year to check if you infringed is impossibly expensive and/or time-consuming for most small to medium sized businesses (SMEs), so they don\'t do it. Thus, in practice, every day a programmer writes code she infringes a patent or two, and one day someone will turn up telling her she infringed. It makes software writing into a minefield - suddenly one day a patent mine will blow up under you or your company - and the costs could easily destroy it, whether or not you really did infringe - 2 or 3 such attacks will almost certainly be fatal.</p>        <p>In practice patent lawsuits generally cost about half a million dollars. Those involved in real cases said that even when the accusations were obviously frivolous, it was still cheaper to just pay up than go to court and try to prove them wrong or demonstrate prior art. And do you realise that if you had invented the relevant technique prior to the patent then that might get you off the hook, but if you didn\'t publish it then the patent remains valid and others can still be hassled with it?</p>        <p>None of this helps companies write software and innovate. If they play the game they need to employ some lawyers and spend a lot of engineer time writing patent applications. If they don\'t, they will one day find that they got big enough to sue.</p>        <p>...</p>        <p>The existing software market isn\'t broken - software and software companies developed just fine without patents, so the premise that they are necessary to encourage investment and innovation is clearly wrong. (For example Microsoft never had any patents before it got be huge, but now that it\'s a dominant incumbent it\'s buying hundreds of them). No-one had any before about 1982 and the floodgates didn\'t open (in the US) until around 1994, and plenty of software got written, some of it highly innovative. To change the software legal environment in this fundamental way needs some very good reasons and evidence. And that evidence simply doesn\'t exist. You can find lots of legal argument promoting the idea but almost no economic arguments or studies.</p>        <p>Patent lawyers always talk about this subject from a legal perspective, not from a social or economic one - they believe all patents are a good thing per se and don\'t even consider the idea that they might not be. We, and MPs and MEPs, must consider the overall economic, social and innovation effects to see if they really are a good idea.</p>        <p>The classical idea of patents is that they protect individual inventors with great ideas from large corporations, and whilst they may work like this occasionally for software, in practice they seem to do exactly the opposite.</p>        <p>Having one patent on something is very little defence against a large corporation that wants to use your idea. Because any useful piece of software uses many many ideas and algorithms the corporation will just say, &quot;ah, yes we may be infringing your patent, but you\'re infringing six of ours &nbsp;- do you really want to go to court about it?&quot; IBM are masters of this strategy and there are many stories of cohorts of stony-faced lawyers turning up to give anyone threatening them with patent infringement a hard time.</p>        <p>So in practice, allowing software patents simply leads to a numbers game, where all the players need lots of patents and it doesn\'t matter if most of them are rubbish - they just need to cover as much of the field of computer science as possible. Only large corporations can absorb the costs and get lots of software patents and use them to stifle competition from innovative startups. It\'s largely big corporations, lawyers who make a living from them, and parasitic companies that use patents for extortion but never invent anything, that promote software patents. The vast majority of software developers and SMEs are not in favour of them. 300,000 signatories, including 700 companies signed a FFII petition against them, for example.</p>        <p>The only evidence that does suggest SMEs benefit from patents in the US includes in its definition of SMEs companies which do no research or development of their own at all - so-called \'patent-trolls\'. These outfits buy up patents from defunct companies and then go round suing other companies which are making real products. Is this the sort of development and innovation we wish to encourage?</p>        <p>Patenting works reasonably well where one patent corresponds to one product, as in chemistry and pharmaceuticals. But every program of any significance has thousands of ideas in it, and thus can be affected by thousands of patents. Avoiding them all becomes increasingly difficult as more and more patents on fundamental building-blocks and useful ideas are issued.</p>            <p>The US is a handy test case, being some 4 or 5 years ahead of us in swpat terms, &nbsp;and the evidence clearly shows that patents cause plenty of problems. The longer the patent-grab game goes on the worse it gets. The Federal Trade Commission recently held hearings &nbsp;on the state of the patent system and company after company said the situation was out of control in the field of software and was not helping at all. That study was published in August 2003 and is a fine example of a very staid government body concluding that they are actively unhelpful.</p>        <p>Nevertheless, there is a lot of pressure from the US for the EU to legalise software patents. This comes primarily from large companies which stand to gain from them, but even companies that don\'t like software patents, realise that they will lose out unless we operate under the same restrictive regime, so they tend to support the idea of software patents in the EU too.</p>        <p>....</p>            <p>In principle the problems of software patents would be enormously reduced if they were only given for things that were genuinely complex or hard to invent, but the system itself encourages very low standards of examination. Patents are supposed to be \'not obvious to an expert in the field\'. But how many of you think that these typical European patents are not obvious: </p>        <p>Progress Bar, electronic shopping trolley, dynamically extensible webserver (CGI scripts), controlling one computer from another (RPC, telnet, client-server), displaying objects in overlapping windows, or transferring pupil data between computers over a wireless network. </p>        <p>These are all just the obvious way you would do something if asked to provide that functionality. And they are not particularly unrepresentative examples - if you look at the patent database and read through the legalese, nearly all software patents are this trivial. You can get a patent for almost any computing idea if it is dressed up in the right language. The FFII maintains a database of patents translated back into something software engineers can understand, to show the sort of ridiculous things that already get patents.</p>        <p>The problem is that there are so many areas of expertise needed that it is now impossible to have patent examiners proficient in every sphere of software, so trivial patents will always get through. And the economics of patent offices also drive this process, because they want to give value for money to their customers - people pay to be granted patents, not to be refused them, but the office has to do nearly the same amount of work in both cases. Th EPO charges more than any other patent office (several thousand pounds), but still grants all sorts of trivial patents. The US Patent office is much worse.</p>        <p>Another irony of the system is that in the days of the industrial revolution a patent included a technical drawing of the invention that could be used to build it - the \'publication\' side of the \'monopoly in exchange for knowledge\' balance I mentioned earlier. But software patents only include a description of the idea, not an actual implementation that could be used for someone to build on. There is no requirement to publish working source code, and indeed patent lawyers resist this idea, claiming that it is much clearer to have them re-write your program in patent-speak, which if you have ever tried to read a patent, clearly isn\'t true. This process just makes it easier for lawyers to keep the whole system under their control, as you need them to apply for patents and to interpret patents, and programmers find the published patents completely useless as a source of knowledge, even though that is supposed to be a major part of their purpose. </p>        <p>One of the main arguments given in favour of software patents is &quot;The Americans have them- so we must too, in order to compete&quot;. This is a barmy argument. The EU currently has an advantage because European companies can write software without tripping over patents all the time. They can still get US patents if they want to use them in the US, but are safe at home. Americans are finding it harder and harder (or at least increasingly expensive) to write software, and are liable to being sued at home.... There have already been a lot of software patents granted in the EU, despite their dubious legality, and most of them are owned by US and Japanese corporations. Making them legal would simply hand a significant chunk of the EU software business to foreign companies. </p>        <p>(Standards) </p>        <p>Patents are making it increasingly difficult to set standards. JPEG was specifically created as a patent-free standard, even forgoing a few percent of speed to ensure no patents were infringed. But now 15 years later a patent-troll has bought a relevant patent and is enforcing it. They got 22 Million dollars out of a couple of Japanese digital camera companies last year, and when the president of the JPEG committee said that there was prior art they accused him personally (not the JPEG committee, or his company) of \'patent libel\'. This claim has not put them off and they are still hassling businesses that write JPEGs. </p>        <p>The MPEG2000 standard is probably already dead in the water due to arguments about patents. Anything that does legalise them must have strong safeguards to stop things like the JPEG hijacking. There can be agreements amongst those involved in the discussions but it\'s very difficult to do anything about people who don\'t join in and wait till afterwards to come and sue. A \'Use it or lose it\' provision, and and interoperability defence would both help here.</p>        <p>(Free software)</p>        <p>Free software has both advantages and particular problems with respect to patents. The fact that it is all published is a useful \'prior art\'</p>    <p>defence. It also makes it very easy to see if there has been an infringement so its authors are particularly open to being sued. As nearly all Free Software is distributed at no cost, there is no mechanism to pay for licenses so it can\'t use any patented algorithms or features. A clause in the law is essential to allow free software to interoperate, and even \'royalty-free\' patent agreements in standards could cause problems as they only allow using the code for the specified purpose, not any other possible use someone might come up with later.</p>        <p>It seems to me that \'Independent invention\', which happens all the time in software development, should be a sufficient defence, but that is anathema to the patent system.</p>        <p>In principle a much shorter period for patents (3-5 years?) would help reduce the bad effects, but this is legally extremely difficult to do. The international agreement (TRIPS) says that patents must be 20 years for all fields of endeavour. This is clearly inappropriate for software - imagine having to write all your software using only ideas from when the ZX-spectrum was the state of the art. 20 years is an eternity when most software products have a life of around 18 months. &nbsp;This 20 yrs-or-nothing aspect is actually a good argument for nothing.</p>        <p>One argument of the pro-patent lobbyists is that we can\'t cause trouble with the EPO or pass laws that would invalidate existing patents. This is the line taken by the UK government. But this reasoning is simply caving in to the EPO who have pushed the current status quo miles beyond what the law states. It\'s not our fault that clarifying the situation to a sensible state will mean a lot of patents have been issued on very shaky ground. They are mostly worthless anyway and should be treated as such.</p>        <p>So where are we now?</p>        <p>Software patents are currently illegal in Europe according to the European patent convention, agreed in 1973. The legislation says quite clearly that a number of things are not patentable </p>    <p> * discoveries, scientific theories, mathematical methods,</p>    <p> * aesthetic creations, </p>    <p> * schemes rules and methods for performing mental acts, playing games or doing business</p>    <p> * presentations of information</p>    <p> * and computer programs</p>        <p>You can see from this list how software is filed alongside things which are essentially ideas, discoveries, and creative acts like writing a novel or a symphony.</p>        <p>We don\'t allow patents on the arrangement of words in a particular form of clause or story;</p>    <p>We don\'t allow the creation of a particular motif or structure in music to be patented, and;</p>    <p>We don\'t allow patentability of a new sort of provision in a legal contract.</p>        <p>We do allow the complete arrangement of notes or words in these things to be copyrighted. Software is like these - it is the bringing together of many small obvious components into a coherent whole, and this process is a creative act, not an invention in the sense of patent law.</p>    <p> </p>    <p>So how come we have 30,000 software patents in Europe already? It\'s because patent lawyers at the European Patent Office (EPO) have, over 20 years of case law, twisted the word and spirit of the law out of all recognition, essentially saying a \'computer program as such\' (the wording in the EPC) is not the same as a \'computer program\' and that because software runs on hardware which is inherently \'technical\' (gets hot, uses electricity\') - it can be patented.</p>        <p> This is why you have to be really paranoid when considering the wording of legislation. Nearly everyone involved says they don\'t want software patents, and they certainly don\'t want business method patents, but then write legislation that allows unlimited patentability of ideas (business methods in computer program terms) either through ignorance or mendacity. The existing 1973 text is pretty clear - if that doesn\'t work we have to be astonishingly careful in the wording of new law to ensure that there are meaningful limits on what is and isn\'t patentable.</p>        <p>The legislative process</p>        <p>I need to step back a moment here and explain the legislative process in the EU. There is a tripartite system involving the European Commission, the European Parliament (your MEPs) and the Council of Ministers, (which is composed of representatives of each of the EU member governments). </p>        <p>Law is proposed by the Commission, amendments are proposed by committees and parliament, then voted on by the parliament. Next it goes to the Council of Ministers for a vote. With this particular piece of legislation (the directive on computer-implemented inventions), this is where we have currently got to. Next it goes back to the parliament where further amendments are possible, and finally back to the Council again for ratification.</p>        <p>The commission originally proposed a terrible directive, which effectively allowed unlimited software patentability. However, a huge lobbying campaign led by the FFII (which apparently produced the biggest petition the Parliament has yet been presented with) persuaded the Parliament to add a large number of amendments which put real limits on patentability, and included an interoperability clause. But then when the directive went on to the Council of Ministers, they discarded all of the Parliament\'s significant amendments and produced a version which was even worse than the Commission\'s original, as it included program claims too. (I\'ll explain what that means in a mo).</p>        <p>This was bizarrely described as a \'compromise position\', given that it totally ignored the democratically-elected parliament\'s position. This version was narrowly agreed two weeks ago by the Council, so now we go back to the Parliament. Unfortunately, second time round amendments are significantly harder to get passed as they need a majority of all MEPs, not just the ones present at the vote, and whilst that\'s not impossible, it won\'t happen unless your MEP hears from you that this is an important issue. It is also important to work on National governments. The UK has been at the forefront of those pushing for unlimited patentability via this directive, apparently driven by the UK Patent Office, and changing goverment policy is going to be very difficult, but many other European governments are getting rather nervous about this issue, and it is definately an argument that can still be won.</p>        <p>Key Issues</p>        <p>There are three key issues in the legislation:</p>    <p> * Program Claims</p>    <p> * Interoperability, and</p>    <p> * the meaning of the word &quot;technical&quot; - i.e. what is patentable.</p>        <p> &quot;Program Claims&quot; means that software patents can cover the publication of programs in machine-readable form, not just the use of those programs. This means that sending someone a file containing patented software becomes illegal without a license, and even discussing the software would become difficult, as there is nothing to say that discussing algorithms using code fragments (the way programmers normally discuss code) is allowed.</p>        <p>This is the provision that was added in the Council of Ministers draft, showing how the national patent offices (who obviously like this sort of maximisation of the reach of patent law) are currently controlling the views of our governments.</p>        <p>A \'fair use\' provision would at least offer an olive branch, but really the scope of patent protection should be kept to use of the invention, not extended to include information about the invention itself. Software is different from normal manufactured goods because it is just information - it is both the invention, and the description of it, in one thing. This is why Program claims make sense to Patent Lawyers, and equally explains why programmers believe software simply shouldn\'t be patentable at all, because it is information, not an industrial process.</p>        <p>Interoperability:</p>    <p>There is nothing in the proposed draft, short of a full-scale EU Competition Investigation, to prevent dominant patent owners preventing competitors from interoperating by refusing them licenses. The most obvious example is the recent patent Microsoft has been given on the particular XML format used in its newest Word documents. It must be possible for others to write software that is compatible without having to buy patent licenses, and this is the position backed by the European Parliament, which allowed automatic unfettered use.</p>        <p>The Danish parliment suggested a compromise of a fast-track procedure for courts to require compulsory RAND licensing - i.e. a paid licence, but available to all, and at the same cost. This would work for proprietary software but is not much use for Free Software. Should it be illegal for Openoffice to read and write MS Word documents, or the Linux movie software Mplayer not to be able to play films you bought? </p>        <p>Your MP and MEP needs to hear that you consider interoperability essential.</p>        <p>Technical</p>        <p>As I said earlier - According to the European Patent Convention, computer programs are excluded from patentability, to the extent that the claimed invention relates to the computer program &quot;as such&quot;.</p>        <p>The new directive legislates for a framework in which the crucial test for patentability is whether the claimed &quot;computer-implemented invention&quot; has a &quot;technical effect&quot;.</p>        <p>This has given supporters of patentability a figleaf that &quot;pure software as such will not be patentable&quot;.</p>        <p>But what is &quot;software&quot;, and what is &quot;technical&quot;</p>        <p>There are essentially three views:</p>        <p>1) &nbsp;There is general agreement that newly invented physical processes should be patentable, regardless of whether software control is needed for the process to be achievable. &nbsp;The classic example is an anti-lock braking system, if a particular non-obvious process of applying the brakes has a particular physical benefit.</p>        <p>This was the view taken by the parliament, and is supported by the German government - the characteristic wording is that &quot;control of the forces of nature&quot; is technical, but that internal processing of data is not technical.</p>        <p>2) UK case law goes further than this. So whilst processing of generic data is not generally patentable, the invention becomes &quot;technical&quot; if the data has technological relevance, so things like image-enhancement software is patentable because the image data is \'technical\'.</p>        <p>Because the UK has been giving software patents like this for some years now the goverment is steadfastly refusing any stricter definition of technical because it will invalidate existing patents.</p>        <p>3) The EPO has gone further still and takes the position that all computing is inherently technical and so anything that has practical usefulness makes a &quot;technical contribution&quot;. Thus they say that a new algorithm &quot;as such&quot; is not patentable, but any algorithm with any identifiable practical usefulness (runs faster, uses less memory) is patentable.</p>        <p>This third option is what the Council of Ministers draft proposes, and is what UK ministers are backing despite saying &quot;nothing shall be patentable which is not patentable already&quot;.</p>        <p>Here\'s a few more examples of what the EPO has already decided is \'technical\' (and granted patents for):</p>        <p> - emailing the recipient of a gift, to ask where they would like their gift delivered (Amazon gift ordering)</p>    <p>- using the same data without retying to update both a sales ledger and stock control</p>    <p>- Tabbed windows (making more efficient use of screen space)</p>        <p>This laughable list is, unfortunately, almost endless.</p>        <p>This \'computing is technical, so software should be patentable\' argument is like saying that music should be patentable because playing it in a stereo system produces physical effects in the loudspeaker. Software ideas are independent from the hardware in the same way that music is independent of the reproduction equipment.</p>        <p>Here is another way to look at why the \'controllable forces of nature\' definition of \'technical\' makes sense:</p>    <p> </p>    <p>A computer is a Turing machine - programs are logically equivalent to maths, and that is why they should remain unpatentable. As soon as you allow algorithms to be patented, then ideas and everything in human endeavour follows, including voting systems and social organisation methods.</p>        <p>The question &nbsp;boils down to the two sides of the argument:</p>    <p>a) If physical processes are patentable, why should it make any difference whether they run on special hardware for that process or on general purpose hardware (i.e. a computer)?</p>        <p>b) If rules of organisation and calculation are not patentable why should it make any difference whether I run them in my head, with pencil and paper, or with today\'s normal tool - a universal computer?</p>        <p>Both these apparently-logical arguments cannot be right, and in fact the 2nd argument is right because the economic argument comes in here: abstract ideas, regardless of their applicability, are produced without experimentation cost, applicable to an infinite number of problems and are replicated at zero cost, with no overhead to which patent costs could be added. This is the right place to draw the line between what is and isn\'t patentable.</p>        <p>Ideas should not be patentable. The FFII proposals distinguish between mind and matter and invention and implementation. In the real world making complex systems that work is difficult - in software it is easy. Your for loops will not overheat and melt a nearby function, and neither will an array cause electrical interference in your hash function. So patents are applicable to the industrial world of \'controllable forces of nature\', not to the world of algorithms and rules of organisation and calculation.</p>        <p>There will always be borderline cases and FFII have set up a</p>    <p>benchmarking suite of example patents against which legislation can be tested.</p>        <p>Advances in software are like advances in science. Everyone is building on the work of those who went before by making small improvements - \'standing on the shoulders of giants\'. Free publication and re-use of ideas is an essential component of this development. Would having to pay a licensing fee for the use of every idea or reference in your PhD thesis increase your innovation? Where would we be if Newton or Einstein, or any others of a host of scientists in the last 200 years had patented their ideas? </p>        <p>The Free software movement has shown in the last 15 years that a co-operative model of software writing is more efficient than a closed, proprietary one, at least within the commodity zone of general-purpose software such as operating systems, data protocols and office software. The internet has become a remarkably pervasive thing over that same time period, precisely because it runs on open, patent-free standards. Everyone can use it on an equal footing and write interesting applications for it without payments or legal restrictions.</p>        <p>If Tim Berners-Lee had patented HTTP back in 1987 the whole world would be a great deal poorer. We wouldn\'t have the web in the ubiquitous form we have it today - perhaps we wouldn\'t have it at all. And he probably wouldn\'t even be better off as he\'s just won a prize of a million dollars for his contribution to mankind. He would have struggled to make that much money from a patented, and thus stangled-at-birth web. Just because something is a good idea, doesn\'t mean it must be patented, or even patentable.</p>        <p>So far as I can see software patents are a bad thing and have no overall benefit to society or developers. In the long term, all the evidence shows that they will constrain development, reduce innovation, and prevent Free Software and small businesses from competing on a level playing field. &nbsp;They seem to be little more than an effective tool to allow large businesses and lawyers to suppress competition from small ones and individuals, and to move fundamental ideas and algorithms from the public domain to private ownership.</p>        <p>However, powerful forces - the ones who stand to benefit from this legislation - disagree with this and are largely getting their own way in legislation-land at the moment. So, if you don\'t want to see everything under the sun patented, then you need to say so very clearly to your representatives right now.</p>   </div>','An updated, 30 minute, version of the shorter Cambridge talk, describing the problems with software patents and the current state of EU legislation covering this issue. This presentation was given to Lancaster University Phd Computer Science students, on the Isle of Man, on 2nd July 2004.','full_html'),('page',0,73,73,'und',0,'<p><img alt=\"The Old Courthouse\" class=\"image _original\" src=\"/sites/yaffs.net/files/images/OldCrt.jpg\" style=\"text-align: right; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; float: right; width: 400px; height: 300px; \" title=\"The Old Courthouse\"></p><dl><dt><strong style=\"text-align: left; \">Telephone</strong></dt><dd style=\"text-align: left; \">+44 (0)1223 811679</dd><dt style=\"text-align: left; \">&nbsp;</dt><dt style=\"text-align: left; \"><strong>Email</strong> -<a href=\"mailto:info@aleph1.co.uk\"> info@aleph1.co.uk</a></dt><dt style=\"text-align: left; \"><strong>Post</strong></dt><dd style=\"text-align: left; \">The Old Courthouse<br>123 High Street<br>Bottisham<br>Cambridge<br>CB25 9BA<br>United Kingdom.</dd></dl><p style=\"text-align: -webkit-auto;\">&nbsp;</p><h2 style=\"text-align: left;\">Public Transport - Buses</h2><p style=\"text-align: left;\">You can reach us by bus from the bus station on Drummer Street in the centre of Cambridge, in 20 minutes. Buses run two or three times an hour much of the day. Click for <a href=\"http://www.stagecoachbus.com/cambridge\" target=\"_self\" title=\"Bus Times\"> timetables </a> and under Bus Timetable Lookup enter 10 or 11 in the Service No. box.<br>Look at the map below</p><p style=\"text-align: left;\">&nbsp;The Number 10 bus enters the village from the East end and passes Westwards along the High Street. Get off at the bus shelter on the South side of the High Street about 500 metres after leaving the main (A1303) road to enter the village. The Courthouse is a further 100 metres West and on the other (North) side of the road.</p><p style=\"text-align: left;\">The Number 10 buses leave Drummer Street at the hour and half hour and take 20 minutes.<br><br>The Number 11 bus leaves at 15 and 45 minutes past each hour and travels along the main A1303 road to Newmarket (and them Bury St Edmunds), passing the East end of Bottisham.&nbsp; Get off at the bus shelter on the main road, and walk back past First Copy, (the former White Swan pub) on the High Street; continue about 450 metres West along the High Street towards the centre of Bottisham. The Courthouse is on the North side of the High Street.</p><p style=\"text-align: left;\"><strong>If coming to visit please make an appointment before setting out.</strong></p><p style=\"text-align: left;\"><a href=\"?q=node/323\">Click here for a page with only these maps, for printing out</a>.</p><p style=\"text-align: left;\">This shows the location of Aleph One within Bottisham. Park in the layby on the South side of the road. We are opposite in a large building with three arched windows. There are doors on either side of the building, and you may need to try both to get a response.</p><center><img alt=\"Bottisham map\" src=\"/sites/yaffs.net/files/images/Bottisham.jpg\" style=\"border: 0;\" title=\"Bottisham map\" border=\"0\"></center><p>&nbsp;</p><p>Map below shows where we are in relation to Cambridge and the surrounding roads.</p><center><img alt=\"How to get to Aleph One\" src=\"/sites/yaffs.net/files/images/Cambridge.jpg\" style=\"border: 0;\" title=\"How to get to Aleph One\" border=\"0\"></center>','Everything needed to get in touch with us or visit.','full_html'),('book',0,77,77,'und',0,'Slides fom YAFFS - A NAND-flash filesystem. This was presented at FOSDEM 2004 (February 23rd), as part of the Embedded Track, and describes the YAFFS filesystem - its origins, how it works, explains the differences between NAND and NOR flash and thus why a specialised NAND-flash filesystem is appropriate. It also covers embedded-system use with Yaffs Direct, presents some performance stats, and a comparison with JFFS2, and looks at supporting next-generation NAND with YAFFS2.','Slides fom YAFFS - A NAND-flash filesystem. This was presented at FOSDEM on 23 February 2004, as part of the Embedded Track, and describes the YAFFS filesystem - it\'s origins, how it works, explains the differences between NAND and NOR flash and thus why a specialised NAND-flash filesystem is appropriate. It also covers embedded-system use with Yaffs Direct, presents some performance stats, and a comparison with JFFS2, and looks at supporting next-generation NAND with YAFFS2.','obsolete_tinymce'),('book',0,77,473,'und',0,'<p>This info is significantly out of date, and we have removed it. You might be interested in one of these:</p><ul><li><a href=\"/documents/how-yaffs-works\">How Yaffs Works</a>&nbsp;</li><li><a style=\"border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 18px; border-width: 0px; padding: 0px; margin: 0px;\" href=\"/documents/yaffs-nand-flash-failure-mitigation\">Yaffs&nbsp;<span class=\"caps\" style=\"border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 0.9em; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; background-position: initial initial; background-repeat: initial initial; border-width: 0px; padding: 0px; margin: 0px;\">NAND</span>&nbsp;Failure Mitigation</a></li><li><a href=\"yaffs-talk-pdf-slides-celf-2007\">Slides from CELF 2007</a></li></ul>','<p>This info has been removed. Formerly it contained:</p><p>Slides fom YAFFS - A NAND-flash filesystem. This was presented at FOSDEM on 23 February 2004, as part of the Embedded Track, and describes the YAFFS filesystem - it&#39;s origins, how it works, explains the differences between NAND and NOR flash and thus why a specialised NAND-flash filesystem is appropriate. It also covers embedded-system use with Yaffs Direct, presents some performance stats, and a comparison with JFFS2, and looks at supporting next-generation NAND with YAFFS2.</p>','obsolete_tinymce'),('book',0,79,79,'und',0,'<div class=\"image\"><a href=\"/drupal/?q=node/110\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_1.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_1.preview.jpg\" /></a><div class=\"caption\">&nbsp;</div> </div>\r\n','YAFFS\r\n','full_html'),('book',0,110,110,'und',0,'<div class=\"image\"><a href=\"/?q=node/111\"><img width=\"640\" height=\"480\" border=\"0\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_2.preview.jpg\" alt=\"yaffs_talk_2.jpg\" /></a><div class=\"caption\">&nbsp;</div> </div> <p>The areas covered by this talk: who\'s involved in the work on YAFFS, and how it got to the current stage, an explanation of the differences between NOR and NAND flash, then we\'ll look at the filesystem itself, covering the filesystem design,&nbsp; licencing, what you need to do to port it to a new OS.</p><p>We\'ll finish with some performance comparisons and the changes present in YAFFS2.&nbsp;</p>','<!-- none -->','full_html'),('book',0,111,111,'und',0,'<div class=\"image\"><a href=\"/drupal/?q=node/112\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_3.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_3.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->','full_html'),('book',0,112,112,'und',0,'<div class=\"image\"><a href=\"?q=node/113\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_4.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_4.preview.jpg\" /></a><div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->','obsolete_tinymce'),('book',0,113,113,'und',0,'<div class=\"image\"><a href=\"/drupal/?q=node/114\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_5.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_5.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->\r\n','full_html'),('book',0,114,114,'und',0,'<div class=\"image\">   <a href=\"?q=node/115\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_6.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_6.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->','obsolete_tinymce'),('book',0,115,115,'und',0,'<div class=\"image\">   <a href=\"?q=node/116\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_7.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_7.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->','obsolete_tinymce'),('book',0,116,116,'und',0,'<div class=\"image\">   <a href=\"?q=node/117\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_8.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_8.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->','obsolete_tinymce'),('book',0,117,117,'und',0,'<div class=\"image\">   <a href=\"?q=node/118\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_9.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_9.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->\r\n','obsolete_tinymce'),('book',0,118,118,'und',0,'<div class=\"image\">   <a href=\"?q=node/119\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_10.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_10.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>\r\n','<!-- none -->\r\n','obsolete_tinymce'),('book',0,119,119,'und',0,'<div class=\"image\">   <a href=\"?q=node/120\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_11.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_11.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,120,120,'und',0,'<div class=\"image\">   <a href=\"?q=node/121\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_12.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_12.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,121,121,'und',0,'<div class=\"image\">   <a href=\"?q=node/122\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_13.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_13.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,122,122,'und',0,'<div class=\"image\">   <a href=\"?q=node/123\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_14.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_14.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,123,123,'und',0,'<div class=\"image\">   <a href=\"?q=node/124\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_15.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_15.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->\r\n','obsolete_tinymce'),('book',0,124,124,'und',0,'<div class=\"image\">   <a href=\"?q=node/125\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_16.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_16.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,125,125,'und',0,'<div class=\"image\">   <a href=\"?q=node/126\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_17.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_17.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,126,126,'und',0,'<div class=\"image\">   <a href=\"?q=node/127\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_18.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_18.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,127,127,'und',0,'<div class=\"image\">   <a href=\"?q=node/128\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_19.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_19.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,128,128,'und',0,'<div class=\"image\">   <a href=\"?q=node/129\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_20.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_20.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,129,129,'und',0,'<div class=\"image\">   <a href=\"?q=node/130\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_21.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_21.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,130,130,'und',0,'<div class=\"image\">   <a href=\"?q=node/131\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_22.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_22.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,131,131,'und',0,'<div class=\"image\">   <a href=\"?q=node/132\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_23.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_23.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,132,132,'und',0,'<div class=\"image\">   <a href=\"?q=node/133\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_24.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_24.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,133,133,'und',0,'<div class=\"image\">   <a href=\"?q=node/134\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_25.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_25.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,134,134,'und',0,'<div class=\"image\">   <a href=\"?q=node/135\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_26.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_26.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,135,135,'und',0,'<div class=\"image\">   <a href=\"?q=node/136\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_27.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_27.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,136,136,'und',0,'<div class=\"image\">   <a href=\"?q=node/137\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_28.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_28.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,137,137,'und',0,'<div class=\"image\">   <a href=\"?q=node/77\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"yaffs_talk_29.jpg\" src=\"sites/yaffs.net/files/images/content/yaffs_talk_29.preview.jpg\" /></a>   <div class=\"caption\">&nbsp;</div> </div>','<!-- none -->','obsolete_tinymce'),('book',0,169,169,'und',0,'<div class=\"image\"><a href=\"?q=node/170\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"talk_emdebsys_1.jpg\" src=\"sites/yaffs.net/files/images/content/talk_emdebsys_1.jpg\" /></a><div class=\"caption\">&nbsp;</div></div>\r\n','<div class=\"image\"><a href=\"?q=node/170\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"talk_emdebsys_1.jpg\" src=\"/files/yaffs.net/images/content/talk_emdebsys_1.jpg\" /></a><div class=\"caption\">&nbsp;</div></div>\r\n','obsolete_tinymce'),('book',0,196,196,'und',0,'<div class=\"image\"><a href=\"?q=node/197\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"talk_arm_general_1.jpg\" src=\"sites/yaffs.net/files/images/content/talk_arm_general_1.jpg\" /></a><div class=\"caption\">&nbsp;</div></div>\r\n','<div class=\"image\"><a href=\"?q=node/170\"><img width=\"640\" height=\"480\" border=\"0\" alt=\"talk_arm_general_1.jpg\" src=\"/files/yaffs.net/images/content/talk_arm_general_1.jpg\" /></a><div class=\"caption\">&nbsp;</div></div>\r\n','obsolete_tinymce'),('book',0,265,265,'und',0,'<p>If you want to boot your system off a CF disk, you need to repartition it. You will need a reasonably sized CF though (over 16MB).</p> <p>First, you boot into <tt class=\"FILENAME\">initrds3.gz</tt> with a kernel that supports CF disks. When this has booted up, you need to execute <b class=\"COMMAND\">fdisk /dev/hda</b>. You can then repartition your    system. Ideally you should make a 4-6MB Fat16 partition as /dev/hda1,   and then assigning the rest for Linux (/dev/hda2). When you have done this,  boot into EPOC and format the CF. Install Arlo, a kernel and an initrd in the  root of this partition. Now you don\'t have to re-install Arlo every time you  reboot.</p> <p>To boot a CF based system, you need to pass the appropriate option into  the kernel (see <a href=\"http://www.aleph1.co.uk../../../armlinux/book/x977.html#PASSING\">the section called <i>Passing Additional Parameters into the Kernel</i></a>), alternatively, you will need to  use the <b class=\"COMMAND\">rdev</b> command to alter the flags in your homebrew  kernel before you glue it.</p> ','<p>If you want to boot your system off a CF disk, you need to repartition it. You will need a reasonably sized CF though (over 16MB).</p> <p>First, you boot into <tt class=\"FILENAME\">initrds3.gz</tt> with a kernel that supports CF disks. When this has booted up, you need to execute <b class=\"COMMAND\">fdisk /dev/hda</b>. You can then repartition your    system. Ideally you should make a 4-6MB Fat16 partition as /dev/hda1,   and then assigning the rest for Linux (/dev/hda2). When you have done this,  boot into EPOC and format the CF. Install Arlo, a kernel and an initrd in the  root of this partition. Now you don\'t have to re-install Arlo every time you  reboot.</p> <p>To boot a CF based system, you need to pass the appropriate option into  the kernel (see <a href=\"http://www.aleph1.co.uk../../../armlinux/book/x977.html#PASSING\">the section called <i>Passing Additional Parameters into the Kernel</i></a>), alternatively, you will need to  use the <b class=\"COMMAND\">rdev</b> command to alter the flags in your homebrew  kernel before you glue it.</p> ','obsolete_tinymce'),('book',0,271,271,'und',0,'<p>Uploading can be achieved via the JTAG port using software such a Jflash and Jflash-linux. Usage for Windows or GNU/Linux host is essentially identical. The examples given here use GNU/Linux syntax.</p> <div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN1447\">Using JTAG and Jflash-linux</a></h2><p>In order to use the JTAG programmer, you need to connect the parallel port of your computer to the JTAG port of the device you want to program. The details of this vary from device to device - see the relevant install chapter. Ensure the device is powered up. Jflash and Jflash-linux both autosense for available parallel ports so it shouldn\'t matter where you plug it in.</p><p>You can then issue the following command as root:</p><p class=\"LITERALLAYOUT\"><b class=\"COMMAND\">./Jflash-linux blob-1.0.7b</b></p><p>and you should see something like the following (this example is using the blob-1.08-pre2 binary on the CD on a LART). After uploading the device will reset itself before running Blob.</p><table width=\"100%\" border=\"0\" bgcolor=\"#e0e0e0\"><tbody><tr><td><pre class=\"SCREEN\">using printer port at 378<br />Seems to be a pair of 28F160F3, bottom boot. Good. <br /><br />Starting erase for    c8e bytes<br />Erasing block   0   <br />Erasing done                                           <br />Starting programming<br />Writing flash at hex address      1b0, 13.44% done    <br />Writing flash at hex address      3d0, 30.37% done    <br />Writing flash at hex address      5f0, 47.29% done    <br />Writing flash at hex address      810, 64.22% done    <br />Writing flash at hex address      a30, 81.14% done <br />Writing flash at hex address      c50, 98.07% done <br />Programming done                                            <br />Starting verify<br />Verifying flash at hex address      643, 49.88% done    <br />Verification successful!                           </pre></td></tr></tbody></table><div class=\"NOTE\"><blockquote class=\"NOTE\"><p><b>Note: </b>If something is wrong you will see error messages like the following:</p></blockquote></div><table width=\"100%\" border=\"0\" bgcolor=\"#e0e0e0\"><tbody><tr><td><pre class=\"SCREEN\">error, failed to read device ID<br />ACT: 0000 0000000000000000 00000000000 0<br />EXP: X001 0001000010000100 00000110101 1<br /><br />failed to read device ID for the SA-1100</pre></td></tr></tbody></table><p>or</p><table width=\"100%\" border=\"0\" bgcolor=\"#e0e0e0\"><tbody><tr><td><pre class=\"SCREEN\">error, failed to read device ID<br />ACT: 1111 1111111111111111 11111111111 1<br />EXP: X001 0001000010000100 00000110101 1<br /><br />failed to read device ID for the SA-1100</pre></td></tr></tbody></table><p>or</p><table width=\"100%\" border=\"0\" bgcolor=\"#e0e0e0\"><tbody><tr><td><pre class=\"SCREEN\">error, failed to read device ID<br />ACT: 1001 1010000111001011 01011000111 1<br />EXP: X001 0001000010000100 00000110101 1<br /><br />failed to read device ID for the SA-1100</pre></td></tr></tbody></table><p>There are a number of possible causes. If you get all 1\'s then you maybe using the wrong parallel port, or the cable or dongle is not plugged in, or the device is not powered up. If you get all zeros then you may be using the wrong version of JFlash-linux, or (on a LART) you may be suffering from the \'JTAG reset problem\', see <a href=\"http://www.aleph1.co.uk../../../armlinux/book/x350.html#LARTJTAGPROB\">the section called <i>LART JTAG reset problem</i> in Chapter 3</a>. If you get random numbers some of the time and zeros the rest of the time then you are almost certainly using the wrong version of JFlash-linux.</p></div> ','<p>Uploading can be achieved via the JTAG port using software such a Jflash and Jflash-linux. Usage for Windows or GNU/Linux host is essentially identical. The examples given here use GNU/Linux syntax.</p> <div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN1447\">Using JTAG and Jflash-linux</a></h2><p>In order to use the JTAG programmer, you need to connect the parallel port of your computer to the JTAG port of the device you want to program. The details of this vary from device to device - see the relevant install chapter. Ensure the device is powered up. Jflash and Jflash-linux both autosense for available parallel ports so it shouldn\'t matter where you plug it in.</p>','obsolete_tinymce'),('book',0,274,274,'und',0,'<div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN1555\">Obtaining the Kernel Source</a></h2><p>To compile your own kernel you need the source and the right set of patches. For all cases you need the base source tree and the ARM kernel patch. The SA1100 patches are usually a good idea too, and are necessary for SA1100 or later processors. For some devices, especially newly-supported ones, you may need a further patch for that device. </p><dl><p><b>Kernel Source</b></p><dt>Base source tree</dt><dd><p><tt class=\"FILENAME\">linux-2.4.1-tar.bz2</tt></p><p>or <tt class=\"FILENAME\">linux-2.4.1-tar.gz</tt></p></dd><dt>ARM kernel (Russell King) patch</dt><dd><p><tt class=\"FILENAME\">patch-2.4.1-rmk1.gz</tt></p></dd><dt>SA1100 (Nico Pitre) patch</dt><dd><p><tt class=\"FILENAME\">diff-2.4.0-rmk1-np2.gz</tt></p></dd></dl><p>Each applied patch adds a suffix to the kernel name, so a kernel made with the 2.4.1 source with the rmk1 ARM kernel patch and the np2 SA1100 patch would be called zImage-2.4.1-rmk1-np2. The letters indicate the patch source. In the above cases they are the names of the patch maintainers Russell King and Nico Pitre respectively. Note that although they use different naming conventions, both patch files are of the same type.</p><p>The kernel source is normally available in both gzipped and bzip2 form. The latter is significantly smaller so that is normally the better one to download. You will need the bzip2 utility to decompress bzip2 files.</p><p>All these are on the CD but you will need to copy them into your development directory. Alternatively, obtain the latest version of kernel base, ARM kernel and SA1100 patches from these ftp sites but remember to use your local mirror, e.g. ftp://ftp.uk.kernel.org/ for the UK mirror.</p><dl><p><b>Kernel Source - Current Version</b></p><dt>Kernel Base</dt><dd><p><a target=\"_top\" href=\"ftp://ftp.kernel.org/pub/linux/kernel/v2.4/\">ftp://ftp.kernel.org/pub/linux/kernel/v2.4/</a></p></dd><dt>ARM kernel Patch</dt><dd><p><a target=\"_top\" href=\"ftp://ftp.arm.linux.org.uk/pub/linux/arm/source/kernel-patches/v2.4/\">ftp://ftp.arm.linux.org.uk/pub/linux/arm/source/kernel-patches/v2.4/</a></p></dd><dt>SA1100 Patch</dt><dd><p><a target=\"_top\" href=\"ftp://ftp.arm.linux.org.uk/pub/linux/arm/people/nico/\">ftp://ftp.arm.linux.org.uk/pub/linux/arm/people/nico/</a></p></dd></dl><p>The source tree can then be unpacked into your development source directory. You can put this anywhere you like, but it must be kept separate from your native source tree in /usr/src/linux. This is because many systems expect the version of headers in /usr/src/linux to correspond to the version of the kernel and glibc being run on the host machine. This is usually different from the version you are using for ARMLinux development. We recommend putting your ARM kernel source tree in <tt class=\"FILENAME\">/usr/arm-linux/linux</tt> (this is alongside the toolchain in a cross-compilation environment). Note that you need a fair amount of disk space free. The unpacked 2.4.1 source is a little over 100MB, and you should have two copies of it, and configuring and compiling only makes it bigger.</p><p>In your development directory enter the following command to unpack the source:</p><p><b class=\"COMMAND\">tar -xzvf linux-2.4.1.tar.gz</b></p><p>Or if you have the bzipped version, use these options:</p><p><b class=\"COMMAND\">tar -xIvf linux-2.4.1.tar.bz2</b></p><p>Finally, unzip/untar the source before applying the ARM and SA1100 patches to give you a new kernel source tree. Using patch -p0 can confuse various versions of patch so its best to cd into the linux directory and use p1, thus:</p><p>  </p><p class=\"LITERALLAYOUT\"><b class=\"COMMAND\">cd linux</b><br /> <b class=\"COMMAND\">zcat ../patch-2.4.0-rmk1.gz | patch -p1</b>&nbsp;<br /> <b class=\"COMMAND\">zcat ../diff-2.4.0-rmk1-np2.gz | patch -p1</b>&nbsp;</p><div class=\"SECT3\"><h3 class=\"SECT3\"><a name=\"AEN1625\">Kernel source mangement</a></h3><p>If you are intending to work on the kernel, the first thing you should do is take a copy of the pristine tree. This is so that you can generate patches against it after you have made changes. The simplest way to do this is simply to do:</p><p class=\"LITERALLAYOUT\"><b class=\"COMMAND\">cp</b>&nbsp;<tt class=\"OPTION\">-a</tt>&nbsp;linux&nbsp;linux-2.4.1.orig</p><p>However, as in practice you will only ever change a few files and having two copies of the whole thing, 99% of which are going to remain untouched, means that you may prefer to use hard links to create the copy as then only the changed files take up space. This method relies on the editor creating a new file after every save so that the original is preserved. If you have need of such an editor, take a look at Micro<span class=\"ACRONYM\">Emac</span>s or <span class=\"ACRONYM\">GNU</span> <span class=\"ACRONYM\">Emac</span>\'s <i class=\"EMPHASIS\">back-up-when-copying-when-linked</i> facility. To create a hard-linked source copy do this:</p><p class=\"LITERALLAYOUT\"><b class=\"COMMAND\">cp</b>&nbsp;<tt class=\"OPTION\">-a</tt>&nbsp;<tt class=\"OPTION\">-l</tt>&nbsp;linux&nbsp;linux-2.4.1.orig</p><p>Alternatively, you can use CVS to control your source versions, but that is not covered here.</p></div></div> <div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN1641\">Making a Kernel</a></h2><p>First you should tidy up the source to get rid of old files and stale dependencies, especially if you have previously configured for a different device with <b class=\"COMMAND\">make mrproper</b>. You should then issue the appropriate <b class=\"COMMAND\">make <i class=\"EMPHASIS\">target-device</i>_config</b> command to set up a default configuration file for your target device. The list of possibilties for <i class=\"EMPHASIS\">target-device</i> is found in <tt class=\"FILENAME\">linux/arch/arm/def-configs/</tt>. You will then need to set up a kernel configurations file using the defaults which have just been created. This can be accomplished with the <b class=\"COMMAND\">make oldconfig</b> command. Finally, <b class=\"COMMAND\">make dep</b> sets up kernel dependencies and sub-configuration files on the basis of the specified config whilst <b class=\"COMMAND\">make zImage</b> builds the kernel image. The kernel should consequently appear in <tt class=\"FILENAME\">linux/arch/arm/boot/zImage</tt>. So, to summarise:</p><p class=\"LITERALLAYOUT\"><b class=\"COMMAND\">make mrproper</b><br /> <b class=\"COMMAND\">make <i class=\"EMPHASIS\">target-device</i>_config</b><br /> <b class=\"COMMAND\">make oldconfig</b><br /> <b class=\"COMMAND\">make dep</b><br /> <b class=\"COMMAND\">make zImage</b></p></div> ','<div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN1555\">Obtaining the Kernel Source</a></h2><p>To compile your own kernel you need the source and the right set of patches. For all cases you need the base source tree and the ARM kernel patch. The SA1100 patches are usually a good idea too, and are necessary for SA1100 or later processors. For some devices, especially newly-supported ones, you may need a further patch for that device. </p><dl><p><b>Kernel Source</b></p><dt>Base source tree</dt><dd><p><tt class=\"FILENAME\">linux-2.4.1-tar.bz2</tt></p><p>or <tt class=\"FILENAME\">linux-2.4.1-tar.gz</tt></p>','obsolete_tinymce'),('book',0,285,285,'und',0,'<p>In order to provide you with a working knowledge of the Linux filesystem, the following topics will be introduced in this section.</p><ol type=\"1\"><li><p>The Linux Root Filesystem</p></li><li><p>Permissions</p></li><li><p>Alternative Filesystems</p></li></ol><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN2664\">Overview</a></h2><p>The filesystem is made up of <i class=\"EMPHASIS\">files</i> and <i class=\"EMPHASIS\">folders</i> or directories. The top level folder is called the <i class=\"EMPHASIS\">root</i> folder and contains all of the files that are pertinent to your system. Each file within this system is allotted a name and a path on the basis of where it lies in relation to the root folder. Thus a sample file -<tt class=\"FILENAME\">alephlinux.txt</tt>- may be found at <tt class=\"FILENAME\">/home/letters/alephlinux.txt</tt> where the forward slash <span class=\"QUOTE\">&quot;/&quot;</span> before <i class=\"EMPHASIS\">home</i> denotes root. </p><div class=\"IMPORTANT\"><blockquote class=\"IMPORTANT\"><p><b>Important: </b>The new user must also appreciate that the filesystem is case-sensitive and therefore distinguishes between <tt class=\"FILENAME\">ALEPHLINUX.txt</tt> and <tt class=\"FILENAME\">alephlinux.txt</tt>.</p></blockquote></div><p>Linux also provides support for long filenames although you should avoid the use of symbols like <span class=\"QUOTE\">&quot;@&quot;</span> within filenames, as they are used for other purposes.</p></div><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN2685\">The Linux Root Filesystem</a></h2><p>The following schematic provides a simple representation of the most important directories and files which make up the root filesystem whilst the subsequent sub-section provides a brief description of the filesystem\'s structure. For more information about the root filesystem, enter <b class=\"COMMAND\">man hier</b> at the prompt for a full description.</p><div class=\"FIGURE\"><a name=\"LINUX-ROOT-FILESYSTEM\" /><p><b>Figure 9-1. Linux Root Filesystem</b></p><div class=\"MEDIAOBJECT\"><p><div class=\"photo\">\r\n<a href=\"?q=node/284\"><img src=\"?q=img_assist/gen/284\" width=\"545\" height=\"304\" alt=\"Linux - Root filesystem\" />\r\n<div class = \"caption\">Linux - Root filesystem\r\n</div></a>\r\n</div>\r\n</p></div></div></div><dl><p><b>Directories</b></p><dt><tt class=\"FILENAME\">/usr</tt></dt><dd><p>Contains files and sub-directories which may be shared between machines. Important sub-directories include:</p><ul><li><p><tt class=\"FILENAME\">/usr/lib</tt> which contains programming and language libraries</p></li><li><p><tt class=\"FILENAME\">/usr/local</tt> which provides the location for user-specific programs and files</p></li><li><p><tt class=\"FILENAME\">/usr/include</tt> for C #include files</p></li></ul></dd><dt><tt class=\"FILENAME\">/etc</tt></dt><dd><p>all configuration files should be in here (often in subdirectories)</p></dd><dt><tt class=\"FILENAME\">/home</tt></dt><dd><p>contains home directories for all users on the system. <tt class=\"FILENAME\">/home/paul</tt> would therefore be the home directory for user <i class=\"EMPHASIS\">paul</i>.</p></dd><dt><tt class=\"FILENAME\">/bin</tt></dt><dd><p>contains fundamental executable files (commands or programs) used by users. Only the basic ones are here, most are in /usr/local/bin, but usually a user doesn\'t care where the executable is actually stored. <b class=\"COMMAND\">which &lt;commandname&gt;</b> will tell you where an executable actually resides.</p></dd><dt><tt class=\"FILENAME\">/sbin</tt></dt><dd><p>includes executable files which are for system administration, as opposed to programs used by users. An example of this would be the <b class=\"COMMAND\">shutdown</b> command which closes the system down properly.</p></dd><dt><tt class=\"FILENAME\">/mnt</tt></dt><dd><p>location for <i class=\"EMPHASIS\">mounting</i> filesystems. For supplementary information, consult <a href=\"http://www.aleph1.co.uk../../../armlinux/book/x2654.html#ALTFILESYS\">the section called <i>Alternative Filesystems</i></a></p></dd><dt><tt class=\"FILENAME\">/tmp</tt></dt><dd><p>a directory which provides the temporary location for different programs. <tt class=\"FILENAME\">/tmp</tt> files tend to be deleted when the system is re-booted.</p></dd><dt><tt class=\"FILENAME\">/dev</tt></dt><dd><p>contains special <i class=\"EMPHASIS\">pseudo</i> files which give access to devices like the keyboard - /dev/kbd - and the virtual terminals - /dev/console, /dev/tty0 and /dev/tty1.     </p></dd><dt><tt class=\"FILENAME\">/var</tt></dt><dd><p>a directory which contains files which can grow through usage. Typical examples include email message files and system accounting files. </p><ul><li><p><tt class=\"FILENAME\">/var/adm</tt> for per-process accounting records</p></li><li><p><tt class=\"FILENAME\">/var/tmp</tt> for temporary files which are not deleted at re-boot time.</p></li><li><p><tt class=\"FILENAME\">/var/spool</tt> for running system processes. /var/spool/mail would be a typical file in this sub-directory </p></li></ul></dd></dl></div><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN2820\">Permissions</a></h2><p>Although you should now have some appreciation of the Linux filesystem it is important to realise that Linux can be used in a multi-user or networked environment. It is therefore sensible to learn about the various types of <i class=\"EMPHASIS\">role</i> and <i class=\"EMPHASIS\">permission</i> which can be associated with a file so that the file <i class=\"EMPHASIS\">owner</i> can decide exactly who has access to files.</p><p>Any user may consequently fit into any one of three roles which include:</p><ol type=\"1\"><li><p>the <i class=\"EMPHASIS\">ownership</i> role</p></li><li><p>the <i class=\"EMPHASIS\">group</i> role</p></li><li><p>the <i class=\"EMPHASIS\">other</i> role</p></li></ol><p>The <i class=\"EMPHASIS\">owner</i> of a file can change file permissions at will. Moreover, a file may be associated with a <i class=\"EMPHASIS\">group</i> which is useful in a collaborative project context in which file access can be restricted to group members. Finally, the <i class=\"EMPHASIS\">other</i> role applies to a user who is neither the owner of the file nor the member of the group which is associated with the file.</p><p>In a similar vein, for every Linux file, three types of permission can be applied to each of the three roles. These permission <i class=\"EMPHASIS\">switches</i> are as follows</p><ol type=\"1\"><li><p><span class=\"ABBREV\">R</span> (Read): enables the user to read files, or (for a directory) to list files on the system</p></li><li><p><span class=\"ABBREV\">W</span> (Write): allows for the alteration or deletion of files, or (for a directory) deleting, adding and renameing of files</p></li><li><p><span class=\"ABBREV\">Execute</span> (Execute): allows for the execution of a file where it is an executable or for changing directories.</p></li></ol><p>In order to clarify matters, this information can be most effectively presented in tabular form. Note that a dash in the line of text denotes the absence of a permission whilst <span class=\"ABBREV\">r</span>, <span class=\"ABBREV\">w</span> or <span class=\"ABBREV\">e</span> indicates that one of the three types of switch is activated.</p><div class=\"TABLE\"><p><b>Table 9-3. Permissions by Role</b></p><table border=\"1\" class=\"CALSTABLE\"><tbody><tr><th valign=\"top\" align=\"left\">Owner</th><th valign=\"top\" align=\"left\">Group</th><th valign=\"top\" align=\"left\">Other</th></tr><tr><td valign=\"top\" align=\"left\">r w x</td><td valign=\"top\" align=\"left\">r w x</td><td valign=\"top\" align=\"left\">r - x</td></tr></tbody></table></div><p>To illustrate all of the above, consider a situation where we want to know the permissions which apply to a particular file. After invoking the <b class=\"COMMAND\">ls -l</b> &lt;filename&gt; command, our hypothetical output might look some thing like the following:</p><p class=\"LITERALLAYOUT\">&mdash;rw&mdash;r&mdash;&mdash;r&mdash;&mdash;&nbsp;1&nbsp;paul&nbsp;paul&nbsp;388&nbsp;June&nbsp;10&nbsp;09:30&nbsp;notes.txt</p><p>Reading across the listing from left to right, the first character position show the file\'s filetype which in this example is a normal file. Other possibilities include:</p><ol type=\"1\"><li><p>d for a directory</p></li><li><p>c for a device</p></li><li><p>b for a socket</p></li><li><p>s for a pipe</p></li></ol><p>The remaining nine bits apply to the user, group and other roles respectively with three bits being alotted to each of the roles. Thus our hypothetical output shows that the user has <i class=\"EMPHASIS\">read</i> and <i class=\"EMPHASIS\">write</i> permissions whilst the <i class=\"EMPHASIS\">group</i> and <i class=\"EMPHASIS\">other</i> roles have read permission only. Note also that a dash denotes the absence of a permission.</p><p>If however, it becomes necessary to change file permissions, this can be accomplished by:</p><ol type=\"1\"><li><p>setting file permissions with octal numbers</p></li><li><p>setting file permissions with a combination of symbols</p></li><li><p>setting the setuid, setgid and sticky bits</p></li></ol><p>To alter a file\'s permissions with numbers, Linux uses four numbers which determine permission types including:</p><ol type=\"1\"><li><p>4: read permissions</p></li><li><p>2: write permissions</p></li><li><p>1: execute permissions</p></li><li><p>0: no permissions</p></li></ol><p>Therefore, to alter the permissions status of our hypothetical file so that the <i class=\"EMPHASIS\">group</i> has <i class=\"EMPHASIS\">read</i> and <i class=\"EMPHASIS\">write</i> permissions, we would add 4 (read permission) and 2 (write permission) together before issuing the following command:</p><p><b class=\"COMMAND\">chmod 664 notes.txt</b> </p><p>The following table summarises the situation thus far:</p><div class=\"TABLE\"><p><b>Table 9-4. Permissions by Numbers</b></p><table border=\"1\" class=\"CALSTABLE\"><tbody><tr><th valign=\"top\" align=\"left\">Role</th><th valign=\"top\" align=\"left\">Permission</th><th valign=\"top\" align=\"left\">Calculation</th></tr><tr><td valign=\"top\" align=\"left\">Owner</td><td valign=\"top\" align=\"left\">6</td><td valign=\"top\" align=\"left\">4+2+0 (r+w+e)</td></tr><tr><td valign=\"top\" align=\"left\">Group</td><td valign=\"top\" align=\"left\">6</td><td valign=\"top\" align=\"left\">4+2+0 (r+w)</td></tr><tr><td valign=\"top\" align=\"left\">Other</td><td valign=\"top\" align=\"left\">4</td><td valign=\"top\" align=\"left\">4+0+0 (r)</td></tr></tbody></table></div><p>In a situation where it is necessary to set permissions one role and one permission at a time, the <i class=\"EMPHASIS\">symbolic permission</i> notation can be used. In order to make use of this facility, the user need only remember that permissions may be granted or denied by using the following three symbols in conjunction with the read, write and execute switches that we have already encountered:</p><ol type=\"1\"><li><p>u signifies the user/owner role</p></li><li><p>g represents the group role</p></li><li><p>o signifies the other role</p></li></ol><p>Therefore, in order to allocate a group read and write permissions for the file <tt class=\"FILENAME\">notes.txt</tt> using symbolic notation, the user could enter the following command:</p><p><b class=\"COMMAND\">chmod g+rw notes.txt</b> </p><p>Because many permutations are possible when using this method, the table below gives some indication of how permissions may be alterred. Note that <span class=\"QUOTE\">&quot;+&quot;</span> means that <i class=\"EMPHASIS\">permission is granted</i> whilst <span class=\"QUOTE\">&quot;-&quot;</span> shows that <i class=\"EMPHASIS\">permission is denied</i>.</p><div class=\"TABLE\"><p><b>Table 9-5. Permissions by Symbols</b></p><table border=\"1\" class=\"CALSTABLE\"><tbody><tr><th width=\"33%\" valign=\"top\" align=\"left\">Granted/Denied</th><th width=\"33%\" valign=\"top\" align=\"left\">Permissions</th><th width=\"33%\" valign=\"top\" align=\"left\">String</th></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user, group, other</td><td width=\"33%\" valign=\"top\" align=\"left\">read, write, execute</td><td width=\"33%\" valign=\"top\" align=\"left\">ugo+rwx</td></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user, group, other</td><td width=\"33%\" valign=\"top\" align=\"left\">read, write, execute</td><td width=\"33%\" valign=\"top\" align=\"left\">ugo-rwx</td></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user, group</td><td width=\"33%\" valign=\"top\" align=\"left\">read, write</td><td width=\"33%\" valign=\"top\" align=\"left\">ug+rw</td></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user, group</td><td width=\"33%\" valign=\"top\" align=\"left\">read, write</td><td width=\"33%\" valign=\"top\" align=\"left\">ug-rw</td></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user</td><td width=\"33%\" valign=\"top\" align=\"left\">read</td><td width=\"33%\" valign=\"top\" align=\"left\">u+r</td></tr><tr><td width=\"33%\" valign=\"top\" align=\"left\">user</td><td width=\"33%\" valign=\"top\" align=\"left\">read</td><td width=\"33%\" valign=\"top\" align=\"left\">u-r</td></tr></tbody></table></div><p>Of course, there is much more that could be said about permissions but for further details on the specifics of topics like sticky bits, shadow passwords and filesystem maintenance, consult the relevant <b class=\"COMMAND\">man</b> page. Refer to <a href=\"http://www.aleph1.co.uk../../../armlinux/book/hlp.html\">the section called <i>Help!</i></a> for advice on using <b class=\"COMMAND\">man</b>.</p><p>The important thing to remember is that if you are having a problem with <i class=\"EMPHASIS\">missing files</i> or some other mysterious error, it is very often due to incorrect permissions somewhere in the system. Always remember to check.</p></div><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"ALTFILESYS\">Alternative Filesystems</a></h2><p>ARMLinux can similarly make use of a range of filesystems in addition to its own Second Extended filesystem (ext2fs). </p><p>   Under Linux the user will however have to <i class=\"EMPHASIS\">mount a device</i> before it can be accessed and used. This is done with the <b class=\"COMMAND\">mount</b> command but you will initially have to edit the <tt class=\"FILENAME\">/etc/fstab</tt> file as the root user in order to avail of this facility. This file is also used to specify which filesystems should be mounted automatically at boot time. To edit this file - which is just a text file - use <span class=\"APPLICATION\">Vim</span> to open the file with the following command:</p><p><b class=\"COMMAND\">vim /etc/fstab</b></p><p> If your file doesn\'t include a line like the following: </p><p class=\"LITERALLAYOUT\">/dev/hda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/adfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;noauto,user&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;0</p><p>then you should add one in order to be able to read your RISC OS drive from ARMLinux. Note that if your RISC OS drive is RISC OS 4 with long filenames then this is not supported at the time of writing so you can skip this section. The format of this file is explained in <b class=\"COMMAND\">man fstab</b>.Save and quit by depressing the <b class=\"KEYCAP\">ESC</b> key, waiting for a beep and then typing <b class=\"COMMAND\">:wq /etc/fstab</b>. Where this line is missing, type it in from scratch noting that there should be no spaces between <i class=\"EMPHASIS\">noauto</i> any punctuation and <i class=\"EMPHASIS\">user</i>. if you want this drive to be automatically mounted on boot then change the final 0 to a 1. You will then need to make a mount directory.</p><p><b class=\"COMMAND\">mkdir /adfs</b> </p><p>Congratulations, you are now in a position to mount your RISC OS filesystem with the following command:</p><p><b class=\"COMMAND\">mount /adfs</b> </p><p> You can now access your files from the <tt class=\"FILENAME\">/adfs</tt> directory.</p></div><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"PACKAGES\">Debian Package Management</a></h2><p>In order to take full advantage of Debian, you need to learn a little about the package management system which underpins it. Debian packages everything in .DEB files. These packages are controlled by a program called <span class=\"ACRONYM\">dpkg</span>, or from a friendlier front-end such as <span class=\"APPLICATION\">dselect</span> or <span class=\"APPLICATION\">apt</span>. The system is extremely powerful; every file on your system is known about by the system and it takes care of a great deal of complexity when installing, removing or upgrading software. It knows about the interdependencies between pieces of software and if you ask to install something it will also get the other things it needs. It knows which files are configuration files and will not overwrite them when upgrading a package. It can also upgrade a running system without breaking things and lets you find out what is on your system. To a large extent the package management system is what makes Debian special and once you understand it you will find it a marvellous facility.</p><p><span class=\"APPLICATION\">dselect</span> is the interface that you will first use. It was designed when Debian had 500 rather than 5000 packages and suffers a bit because of this, but it is quite straightforward to use and a good introduction to the package system. Later you will just use <span class=\"APPLICATION\">apt</span> to install new software. Once <span class=\"APPLICATION\">apt</span> has been taught where to get software (usually off the CD and off the net) you can say things like <b class=\"COMMAND\">apt-get install &lt;software&gt;</b> and it will go away and get it for you, then install it, install anything else necessary and configure them all, often without asking you any further questions apart from telling you which CD to insert or if the download size is OK.</p><p>It is important to understand however that if you want to install software that is not in the Debian archive then everything is not taken care of for you and you will have to understand what is going on and do some work yourself. For example, if obtaining a package from a distribution which is meant for x86-based <span class=\"ACRONYM\">PC</span>s, you will have to compile it from source as the binary versions supplied will not work on an ARM-based machine. Such a procedure is outside this manual\'s scope but - assuming that you want to use a package which is on the ARMLinux <span class=\"ACRONYM\">CD</span> or in the huge Debian archive - read on!</p><p><span class=\"ACRONYM\">dpkg</span> can for example be used to install a package by using the <tt class=\"OPTION\">i</tt> (or --install) switch.</p><p><b class=\"COMMAND\">dpkg -i /cdrom/debian/dists/potato/main/binary-arm/utils/mc&lt;TAB&gt;</b> </p><p>Note that the &lt;TAB&gt; above means press the TAB key, not type in those letters. This uses the shell\'s <i class=\"EMPHASIS\">filename expansion</i> facility to fill in the end of the filename. It\'s a marvellous facility. If it beeps then there is more than one possible answer - press &lt;TAB&gt; again to see the list. It even works on commands.</p><p>However, it is standard practice to use <span class=\"APPLICATION\">apt</span> instead to save typing long pathnames, like this:</p><p><b class=\"COMMAND\">apt-get install mc</b> </p><p>Here <span class=\"APPLICATION\">apt</span> knows where to look for packages, finds <span class=\"APPLICATION\">mc</span> and then uses <span class=\"APPLICATION\">dpkg</span> to actually do the installation, but saves you worrying about the actual location of the package.</p><p> What you have just done is to use <span class=\"ACRONYM\">dpkg</span> to install <span class=\"APPLICATION\">Midnight Commander</span> (<span class=\"ACRONYM\">mc</span>) - a visual shell which does not need X Windows - on your system. Conversely, you may choose to delete or uninstall a package which can be accomplished by using the <tt class=\"OPTION\">-r</tt> (or --remove) switch. The following command consequently removes <span class=\"ACRONYM\">mc</span>.</p><p><b class=\"COMMAND\">dpkg -r mc</b> </p><p>Don\'t be too hasty however. <span class=\"ACRONYM\">MC</span> is an excellent way of navigating the filesystem when used in conjunction with the shell. So why not learn a bit about it before using <span class=\"ACRONYM\">dpkg</span>\'s <tt class=\"OPTION\">-r</tt> switch?</p><p>Congratulations, you\'ve managed to mount your filesystem and have a look at some files. Before removing your <span class=\"ACRONYM\">CD-ROM</span>, you will need to use the <b class=\"COMMAND\">umount</b> command which can either be used to unmount the current filesystem or a specific directory. But please be careful with your typing and key in <tt class=\"USERINPUT\"><b>umount</b></tt> rather than <tt class=\"USERINPUT\"><b>unmount</b></tt>. If it tells you that the <tt class=\"COMPUTEROUTPUT\">filesystem is busy</tt> then your current directory is probably in the mounted filesystem. You need to change directory elsewhere before you can <b class=\"COMMAND\">umount</b>.</p><p><b class=\"COMMAND\">umount /dev/cdrom</b> </p><p>or</p><p><b class=\"COMMAND\">umount /cdrom</b></p><p>In order to find out about other filesystem types and the specifics of the <b class=\"COMMAND\">mount</b> and <b class=\"COMMAND\">umount</b> commands, you can take advantage of the range of commands and applications which are briefly described in <a href=\"http://www.aleph1.co.uk../../../armlinux/book/hlp.html\">the section called <i>Help!</i></a>.</p></div>','<p>In order to provide you with a working knowledge of the Linux filesystem, the following topics will be introduced in this section.</p><ol type=\"1\"><li><p>The Linux Root Filesystem</p></li><li><p>Permissions</p></li><li><p>Alternative Filesystems</p></li></ol><div class=\"SECT2\"><h2 class=\"SECT2\"><a name=\"AEN2664\">Overview</a></h2><p>The filesystem is made up of <i class=\"EMPHASIS\">files</i> and <i class=\"EMPHASIS\">folders</i> or directories. The top level folder is called the <i class=\"EMPHASIS\">root</i> folder and contains all of the files that are pertinent to your system. Each file within this system is allotted a name and a path on the basis of where it lies in relation to the root folder. Thus a sample file -<tt class=\"FILENAME\">alephlinux.txt</tt>- may be found at <tt class=\"FILENAME\">/home/letters/alephlinux.txt</tt> where the forward slash <span class=\"QUOTE\">&quot;/&quot;</span> before <i class=\"EMPHASIS\">home</i> denotes root. </p>','obsolete_tinymce'),('page',0,323,323,'und',0,'<p>This shows the location of Aleph One within Bottisham. Park in the layby on the South side of the road. We are opposite in a large building with three arched windows. There are doors on either side of the building, and you may need to try both to get a response.<br /></p> <center><img alt=\"Bottisham map\" border=\"0\" src=\"/sites/yaffs.net/files/images/Bottisham.jpg\" style=\"border: 0;\" title=\"Bottisham map\"></center> <p>Map below shows where we are in relation to Cambridge and the surrounding roads.<br /></p> <center><img alt=\"How to get to Aleph One\" border=\"0\" src=\"/sites/yaffs.net/files/images/Cambridge.jpg\" style=\"border: 0;\" title=\"How to get to Aleph One\"></center>','<p>Maps of our location for printing.</p>','obsolete_tinymce'),('page',0,325,325,'und',0,'<p>Yaffs is a product from Aleph One Ltd.</p><p>The company was started in 1971.&nbsp; The name Aleph One was chosen to be non-specific.&nbsp; We started selling computer products in 1984, when we were using Biofeedback instruments to control video games on Acorn BBC Microcomputers&nbsp;&nbsp; This led to the development of processor cards for Acorn computers (which had their own unique operating system) which could run the DOS and Windows operating systems. Acorn users ran Windows applications in a window!</p><p>When Acorn left the computer market in 1998 we used our knowledge of other operating systems to move into Linux and then into embedded Linux.&nbsp; We have developed the Yaffs File System specifically to provide a robust journalling file system for NAND Flash chips, and it is now widely used in high-volume products around the world.</p><h2>Visitors</h2><p>We are happy to welcome visitors, though our premises are not a shop. Please contact us to make an appointment and let us know what you would like to talk about or look at.&nbsp;</p><h2>Staff</h2><h3>Core Staff</h3><ul><li>Managing Director: Mr Laurie van Someren</li><li>Charles Manning: Chief Yaffs Architect</li><li>Jenny Hopkins: Tech Support</li></ul><h2>Our name</h2><p>Aleph is the name of the first letter of the Hebrew alphabet.</p><p>A German mathematician active in the mid-19th century, Georg Cantor (1845-1918), realised that infinities came in different sizes; more precisely he showed that the infinite set of all integers was smaller than the infinite set of all real numbers, and gave the labels Aleph Null to the smaller, and Aleph One to the larger set.</p><p>J W Dauben, writing in <em>Scientific American</em>, June 1983, 112-121, said <em>The choice </em>of Aleph as a label for transfinite sets<em> was particularly clever, as Cantor was pleased to admit, because the Hebrew Aleph was also a symbol for the number 1. Since the transfinite cardinals were themselves infinite unities, the Aleph could be taken to represent a new beginning for mathematics.</em></p><p>The concept of Alephs is the subject of a successful book by Amir D Aczel called THE MYSTERY OF THE ALEPH. Paperback about £10 in the UK, ISBN 0-7434-2299-6 (We do not sell it)</p><h3><a name=\"VAT\"></a>VAT</h3><p>We are not registered for VAT and so our prices do not include it.</p><p>&nbsp;</p>','<p>The company was started in 1971.&nbsp; The name Aleph One was chosen to be non-specific.&nbsp; We started selling computer products in 1984.</p><p>In 1984, we were using Biofeedback instruments to control video games on Acorn BBC Microcomputers&nbsp;&nbsp; This led to the development of processor cards for Acorn computers (which had their own operating system) which could run the DOS and Windows operating systems. Acorn users ran Windows applications in a window!</p><p>When Acorn left the computer market we used our knowledge of other operating systems to move into Linux and then into embedded Linux.&nbsp; We have developed the yaffs File System specifically to provide a robust journalling file system for NAND Flash chips, and it is now widely used in high-volume products.</p>','full_html'),('page',0,342,342,'und',0,'<p>DB FUEL and YAFFS team up to offer new generation of database and flash memory solutions for developers of Mobile Handsets and Consumer Electronics.</p><p>Revolutions in flash memory technology have greatly increased the practical uses of flash technology. Aleph One Ltd, a British company focusing on embedded device development, has released YAFFS, a superior file system for storing data on flash. ITTIA is partnering with Aleph One to provide the best data solution for embedded devices requiring persistent storage. The companies have confirmed compatibility between their product lines and will work together to promote the use of their technologies.</p><p>Mobile devices and embedded systems that need to store persistent information have a limited number of choices. The shock resistance, power usage and smaller form factor makes flash memory a superior storage medium in most cases. However, developers using flash face some unique challenges. For example, too many writes to the same location on the flash disk can render that location inoperable. Developers must take these and other characteristics into consideration. In order to help developers overcome these challenges, YAFFS can either be used as a filesystem driver in the operating system, or be linked directly with FUEL to bypass the operating system – even if no operating system is available. This arrangement ensures that data is stored in an optimal format to take advantage of flash memory.</p><p>“We developed YAFFS to provide a high reliability/high performance embedded file system on NAND flash and are delighted that YAFFS has been selected by ITTIA as a partner for their FUEL database,” said Laurie van Someren, Aleph One’s General Manager. “We believe the products combine to provide a highly effective embedded data storage solution and look forward to further cooperation and developments.”</p><p>FUEL has been designed with enough flexibility to support the unique circumstances faced by embedded developers, such as persistent storage on a battery-powered (unreliably powered) device. Because FUEL is fast and small-footprint, it is a perfect match for mobile devices and embedded systems.</p><p>ITTIA and Aleph One are a natural match for other reasons as well. Both companies have a commitment to provide top-notch support at whatever level the customer needs, and can provide development services and support to ensure an optimal solution. “We begin 2006 by emphasizing on meaningful business relationship and we are delighted to announce our solution offering with Aleph One,” said Sasan Montaseri, President of ITTIA, in Bellevue, WA. “Aleph One has served the embedded market for many years and our total solution add special value to our customers.”</p><p>For more information about FUEL, visit www.ITTIA.com/fuel/fuel.html.</p><p>For more information about YAFFS, visit www.yaffs.net</p>','<p>YAFFS and the new FUEL Database from ITTIA work together. ITTIA has released the first beta of an all-new database for mobile and embedded systems.&nbsp;</p>','filtered_html'),('page',0,342,548,'und',0,'<p>DB FUEL and YAFFS team up to offer new generation of database and flash memory solutions for developers of Mobile Handsets and Consumer Electronics.</p>\r\n\r\n<p>Revolutions in flash memory technology have greatly increased the practical uses of flash technology. Aleph One Ltd, a British company focusing on embedded device development, has released YAFFS, a superior file system for storing data on flash. ITTIA is partnering with Aleph One to provide the best data solution for embedded devices requiring persistent storage. The companies have confirmed compatibility between their product lines and will work together to promote the use of their technologies.</p>\r\n\r\n<p>Mobile devices and embedded systems that need to store persistent information have a limited number of choices. The shock resistance, power usage and smaller form factor makes flash memory a superior storage medium in most cases. However, developers using flash face some unique challenges. For example, too many writes to the same location on the flash disk can render that location inoperable. Developers must take these and other characteristics into consideration. In order to help developers overcome these challenges, YAFFS can either be used as a filesystem driver in the operating system, or be linked directly with FUEL to bypass the operating system – even if no operating system is available. This arrangement ensures that data is stored in an optimal format to take advantage of flash memory.</p>\r\n\r\n<p>“We developed YAFFS to provide a high reliability/high performance embedded file system on NAND flash and are delighted that YAFFS has been selected by ITTIA as a partner for their FUEL database,” said Laurie van Someren, Aleph One’s General Manager. “We believe the products combine to provide a highly effective embedded data storage solution and look forward to further cooperation and developments.”</p>\r\n\r\n<p>FUEL has been designed with enough flexibility to support the unique circumstances faced by embedded developers, such as persistent storage on a battery-powered (unreliably powered) device. Because FUEL is fast and small-footprint, it is a perfect match for mobile devices and embedded systems.</p>\r\n\r\n<p>ITTIA and Aleph One are a natural match for other reasons as well. Both companies have a commitment to provide top-notch support at whatever level the customer needs, and can provide development services and support to ensure an optimal solution. “We begin 2006 by emphasizing on meaningful business relationship and we are delighted to announce our solution offering with Aleph One,” said Sasan Montaseri, President of ITTIA, in Bellevue, WA. “Aleph One has served the embedded market for many years and our total solution add special value to our customers.”</p>\r\n\r\n<p>For more information about FUEL, visit www.ITTIA.com/fuel/fuel.html.</p>\r\n\r\n<p>For more information about YAFFS, visit www.yaffs.net</p>\r\n','<p>YAFFS and the new FUEL Database from ITTIA work together. ITTIA has released the first beta of an all-new database for mobile and embedded systems.&nbsp;</p>','filtered_html'),('page',0,342,574,'und',0,'<p>DB FUEL and YAFFS team up to offer new generation of database and flash memory solutions for developers of Mobile Handsets and Consumer Electronics.</p>\r\n\r\n<p>Revolutions in flash memory technology have greatly increased the practical uses of flash technology. Aleph One Ltd, a British company focusing on embedded device development, has released YAFFS, a superior file system for storing data on flash. ITTIA is partnering with Aleph One to provide the best data solution for embedded devices requiring persistent storage. The companies have confirmed compatibility between their product lines and will work together to promote the use of their technologies.</p>\r\n\r\n<p>Mobile devices and embedded systems that need to store persistent information have a limited number of choices. The shock resistance, power usage and smaller form factor makes flash memory a superior storage medium in most cases. However, developers using flash face some unique challenges. For example, too many writes to the same location on the flash disk can render that location inoperable. Developers must take these and other characteristics into consideration. In order to help developers overcome these challenges, YAFFS can either be used as a filesystem driver in the operating system, or be linked directly with FUEL to bypass the operating system – even if no operating system is available. This arrangement ensures that data is stored in an optimal format to take advantage of flash memory.</p>\r\n\r\n<p>“We developed YAFFS to provide a high reliability/high performance embedded file system on NAND flash and are delighted that YAFFS has been selected by ITTIA as a partner for their FUEL database,” said Laurie van Someren, Aleph One’s General Manager. “We believe the products combine to provide a highly effective embedded data storage solution and look forward to further cooperation and developments.”</p>\r\n\r\n<p>FUEL has been designed with enough flexibility to support the unique circumstances faced by embedded developers, such as persistent storage on a battery-powered (unreliably powered) device. Because FUEL is fast and small-footprint, it is a perfect match for mobile devices and embedded systems.</p>\r\n\r\n<p>ITTIA and Aleph One are a natural match for other reasons as well. Both companies have a commitment to provide top-notch support at whatever level the customer needs, and can provide development services and support to ensure an optimal solution. “We begin 2006 by emphasizing on meaningful business relationship and we are delighted to announce our solution offering with Aleph One,” said Sasan Montaseri, President of ITTIA, in Bellevue, WA. “Aleph One has served the embedded market for many years and our total solution add special value to our customers.”</p>\r\n\r\n<p>For more information about FUEL, visit www.ITTIA.com/fuel/fuel.html.</p>\r\n\r\n<p>For more information about YAFFS, visit www.yaffs.net</p>\r\n','<p>YAFFS and the new FUEL Database from ITTIA work together. ITTIA has released the first beta of an all-new database for mobile and embedded systems.&nbsp;</p>','full_html'),('page',0,344,344,'und',0,'<p>Yaffs is a filesystem designed specifically for the characteristics of NAND flash. Its well-proven primary features are:</p>\r\n\r\n<ul>\r\n	<li>Fast - typically much faster than alternatives</li>\r\n	<li>Easily ported (currently ported to GNU/Linux, WinCE, eCOS, pSOS, VxWorks, and various bare-metal systems)</li>\r\n	<li>Log structured, providing wear-levelling and making it very robust</li>\r\n	<li>Supports many flash geometries including 2K-Byte and 512-Byte page NAND flash chips</li>\r\n	<li>Supports MLC and SLC flash</li>\r\n	<li>Very fast mount - almost immediate startup</li>\r\n	<li>Typically uses less RAM than comparable File Systems</li>\r\n	<li>Flexible <a href=\"/yaffs-licensing-overview\">Licensing</a> suitable for most circumstances</li>\r\n</ul>\r\n\r\n<p>There is a great deal of information about Yaffs available on this site. This page indexes that information and provides an overview of the product.</p>\r\n\r\n<p>Yaffs is currently at version 2. Yaffs2 supports 2K-byte page flash as well as 512-byte page flash. (Yaffs1 only supports the original 512-byte page flash and is now in maintenance mode.) There is a minimal subset of the filesystem called Yaffs/Direct or the Yaffs Direct Interface which is intended to be used in embedded systems, and can be licensed for use in proprietary systems. Yaffs is available to all under the GPL for use or evaluation; full details of Git access are&nbsp;<a href=\"/download-yaffs-using-git\">available </a></p>\r\n\r\n<p>Yaffs 1 and 2 have both been deployed in numerous commercial applications, some in high volume. abd with large Flash arrays. It has been used in phones, most notably Android phones, GPS receivers, train controllers, speech synthesisers, VOIP chip development kits and other applications.</p>\r\n\r\n<p>We have a number of documents and papers describing how to use Yaffs, how to customise it for your particular hardware/system, and the original considerations and filesystem design of the two versions.</p>\r\n\r\n<h3>Backgrounder</h3>\r\n\r\n<p>The best overview information is currently this 28-slide presentation&nbsp; <a href=\"node/77\">What it Does and How it Does it</a></p>\r\n\r\n<p>A useful historical Timeline on development is<a href=\"node/43\"> here</a></p>\r\n\r\n<h3>Developer Documentation</h3>\r\n\r\n<p>Yaffs Direct Interface - <a href=\"node/349\">User Guide</a>, describing how to port Yaffs to an embedded environment or RTOS using the YDI \'personality\' module\'.</p>\r\n\r\n<p>Brief notes on <a href=\"node/40\">How to use it on GNU/Linux</a></p>\r\n\r\n<p>A <a href=\"node/348\">memory footprint analysis</a> putting some numbers on \'low memory footprint\'.</p>\r\n\r\n<p><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS embedded structure: YAFFS embedded structure\" height=\"376\" src=\"/sites/yaffs.net/files/images/yaffs-diagram.gif\" width=\"358\" /></a><br />\r\n<strong>Yaffs embedded structure</strong></p>\r\n\r\n<h3><a>Papers</a></h3>\r\n\r\n<p><a> </a></p>\r\n\r\n<p><a> </a></p>\r\n\r\n<p><a> </a></p>\r\n\r\n<ul>\r\n	<li><a>The </a><a href=\"node/42\">starting state of NAND MTD</a> which caused the Yaffs filesystem to be designed.</li>\r\n	<li><a href=\"node/37\">The Specifications</a> are available</li>\r\n	<li>Development Notes describing the <a href=\"node/39\">filesystem design decisions and data structures for Yaffs1</a></li>\r\n	<li><a href=\"node/38\">Yaffs2 Filesystem design</a>, covering changes from Yaffs1</li>\r\n	<li><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">Efficient Initialization and Crash Recovery for Log-based File Systems over Flash Memory</a>, describing a mechanism for avoiding full flash scans, even when not properly shut down. This is a likely future development.</li>\r\n</ul>\r\n\r\n<h3>Mailing list</h3>\r\n\r\n<p>There is a <a href=\"http://aleph1.co.uk//mailman/listinfo/yaffs\">Yaffs mailing list</a> for the development and discussion of Yaffs. It\'s a fairly low-traffic list. You will be emailed and asked to confirm your subscription request. You can also browse and search the <a href=\"http://aleph1.co.uk/lurker/splash/index.en.html\">Yaffs mailing list archives</a>.</p>\r\n\r\n\r\n','YAFFS is a filesystem designed specifically for the characteristics of NAND flash. This page gives an overview of the project - what is available, how it works, how to use it, developer resources, and licensing options.','filtered_html'),('page',0,344,575,'und',0,'<p>Yaffs is a filesystem designed specifically for the characteristics of NAND flash. Its well-proven primary features are:</p>\r\n\r\n<ul>\r\n	<li>Fast - typically much faster than alternatives</li>\r\n	<li>Easily ported (currently ported to GNU/Linux, WinCE, eCOS, pSOS, VxWorks, and various bare-metal systems)</li>\r\n	<li>Log structured, providing wear-levelling and making it very robust</li>\r\n	<li>Supports many flash geometries including 2K-Byte and 512-Byte page NAND flash chips</li>\r\n	<li>Supports MLC and SLC flash</li>\r\n	<li>Very fast mount - almost immediate startup</li>\r\n	<li>Typically uses less RAM than comparable File Systems</li>\r\n	<li>Flexible <a href=\"/yaffs-licensing-overview\">Licensing</a> suitable for most circumstances</li>\r\n</ul>\r\n\r\n<p>There is a great deal of information about Yaffs available on this site. This page indexes that information and provides an overview of the product.</p>\r\n\r\n<p>Yaffs is currently at version 2. Yaffs2 supports 2K-byte page flash as well as 512-byte page flash. (Yaffs1 only supports the original 512-byte page flash and is now in maintenance mode.) There is a minimal subset of the filesystem called Yaffs/Direct or the Yaffs Direct Interface which is intended to be used in embedded systems, and can be licensed for use in proprietary systems. Yaffs is available to all under the GPL for use or evaluation; full details of Git access are&nbsp;<a href=\"/download-yaffs-using-git\">available </a></p>\r\n\r\n<p>Yaffs 1 and 2 have both been deployed in numerous commercial applications, some in high volume. abd with large Flash arrays. It has been used in phones, most notably Android phones, GPS receivers, train controllers, speech synthesisers, VOIP chip development kits and other applications.</p>\r\n\r\n<p>We have a number of documents and papers describing how to use Yaffs, how to customise it for your particular hardware/system, and the original considerations and filesystem design of the two versions.</p>\r\n\r\n<h3>Backgrounder</h3>\r\n\r\n<p>The best overview information is currently this 28-slide presentation&nbsp; <a href=\"node/77\">What it Does and How it Does it</a></p>\r\n\r\n<p>A useful historical Timeline on development is<a href=\"node/43\"> here</a></p>\r\n\r\n<h3>Developer Documentation</h3>\r\n\r\n<p>Yaffs Direct Interface - <a href=\"node/349\">User Guide</a>, describing how to port Yaffs to an embedded environment or RTOS using the YDI \'personality\' module\'.</p>\r\n\r\n<p>Brief notes on <a href=\"node/40\">How to use it on GNU/Linux</a></p>\r\n\r\n<p>A <a href=\"node/348\">memory footprint analysis</a> putting some numbers on \'low memory footprint\'.</p>\r\n\r\n<p><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS embedded structure: YAFFS embedded structure\" height=\"376\" src=\"/sites/yaffs.net/files/images/yaffs-diagram.gif\" width=\"358\" /></a><br />\r\n<strong>Yaffs embedded structure</strong></p>\r\n\r\n<h3><a>Papers</a></h3>\r\n\r\n<p><a> </a></p>\r\n\r\n<p><a> </a></p>\r\n\r\n<p><a> </a></p>\r\n\r\n<ul>\r\n	<li><a>The </a><a href=\"node/42\">starting state of NAND MTD</a> which caused the Yaffs filesystem to be designed.</li>\r\n	<li><a href=\"node/37\">The Specifications</a> are available</li>\r\n	<li>Development Notes describing the <a href=\"node/39\">filesystem design decisions and data structures for Yaffs1</a></li>\r\n	<li><a href=\"node/38\">Yaffs2 Filesystem design</a>, covering changes from Yaffs1</li>\r\n	<li><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">Efficient Initialization and Crash Recovery for Log-based File Systems over Flash Memory</a>, describing a mechanism for avoiding full flash scans, even when not properly shut down. This is a likely future development.</li>\r\n</ul>\r\n\r\n<h3>Mailing list</h3>\r\n\r\n<p>There is a <a href=\"http://aleph1.co.uk//mailman/listinfo/yaffs\">Yaffs mailing list</a> for the development and discussion of Yaffs. It\'s a fairly low-traffic list. You will be emailed and asked to confirm your subscription request. You can also browse and search the <a href=\"http://aleph1.co.uk/lurker/splash/index.en.html\">Yaffs mailing list archives</a>.</p>\r\n','YAFFS is a filesystem designed specifically for the characteristics of NAND flash. This page gives an overview of the project - what is available, how it works, how to use it, developer resources, and licensing options.','full_html'),('page',0,344,576,'und',0,'<p>Yaffs is a filesystem designed specifically for the characteristics of NAND flash. Its well-proven primary features are:</p>\r\n\r\n<ul>\r\n	<li>Fast - typically much faster than alternatives</li>\r\n	<li>Easily ported (currently ported to GNU/Linux, WinCE, eCOS, pSOS, VxWorks, and various bare-metal systems)</li>\r\n	<li>Log structured, providing wear-levelling and making it very robust</li>\r\n	<li>Supports many flash geometries including 2K-Byte and 512-Byte page NAND flash chips</li>\r\n	<li>Supports MLC and SLC flash</li>\r\n	<li>Very fast mount - almost immediate startup</li>\r\n	<li>Typically uses less RAM than comparable File Systems</li>\r\n	<li>Flexible <a href=\"/yaffs-licensing-overview\">Licensing</a> suitable for most circumstances</li>\r\n</ul>\r\n\r\n<p>There is a great deal of information about Yaffs available on this site. This page indexes that information and provides an overview of the product.</p>\r\n\r\n<p>Yaffs is currently at version 2. Yaffs2 supports 2K-byte page flash as well as 512-byte page flash. (Yaffs1 only supports the original 512-byte page flash and is now in maintenance mode.) There is a minimal subset of the filesystem called Yaffs/Direct or the Yaffs Direct Interface which is intended to be used in embedded systems, and can be licensed for use in proprietary systems. Yaffs is available to all under the GPL for use or evaluation; full details of Git access are&nbsp;<a href=\"/download-yaffs-using-git\">available </a></p>\r\n\r\n<p>Yaffs 1 and 2 have both been deployed in numerous commercial applications, some in high volume. abd with large Flash arrays. It has been used in phones, most notably Android phones, GPS receivers, train controllers, speech synthesisers, VOIP chip development kits and other applications.</p>\r\n\r\n<p>We have a number of documents and papers describing how to use Yaffs, how to customise it for your particular hardware/system, and the original considerations and filesystem design of the two versions.</p>\r\n\r\n<h3>Backgrounder</h3>\r\n\r\n<p>The best overview information is currently this 28-slide presentation&nbsp; <a href=\"node/77\">What it Does and How it Does it</a></p>\r\n\r\n<p>A useful historical Timeline on development is<a href=\"node/43\"> here</a></p>\r\n\r\n<h3>Developer Documentation</h3>\r\n\r\n<p>Yaffs Direct Interface - <a href=\"node/349\">User Guide</a>, describing how to port Yaffs to an embedded environment or RTOS using the YDI \'personality\' module\'.</p>\r\n\r\n<p>Brief notes on <a href=\"node/40\">How to use it on GNU/Linux</a></p>\r\n\r\n<p>A <a href=\"node/348\">memory footprint analysis</a> putting some numbers on \'low memory footprint\'.</p>\r\n\r\n<p><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS embedded structure: YAFFS embedded structure\" height=\"376\" src=\"/sites/yaffs.net/files/images/yaffs-diagram.gif\" width=\"358\" /></a><br />\r\n<strong>Yaffs embedded structure</strong></p>\r\n\r\n<h3>Papers</h3>\r\n\r\n<p></p>\r\n\r\n<p></p>\r\n\r\n<p></p>\r\n\r\n<ul>\r\n	<li><a>The </a><a href=\"node/42\">starting state of NAND MTD</a> which caused the Yaffs filesystem to be designed.</li>\r\n	<li><a href=\"node/37\">The Specifications</a> are available</li>\r\n	<li>Development Notes describing the <a href=\"node/39\">filesystem design decisions and data structures for Yaffs1</a></li>\r\n	<li><a href=\"node/38\">Yaffs2 Filesystem design</a>, covering changes from Yaffs1</li>\r\n	<li><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">Efficient Initialization and Crash Recovery for Log-based File Systems over Flash Memory</a>, describing a mechanism for avoiding full flash scans, even when not properly shut down. This is a likely future development.</li>\r\n</ul>\r\n\r\n<h3>Mailing list</h3>\r\n\r\n<p>There is a <a href=\"http://aleph1.co.uk//mailman/listinfo/yaffs\">Yaffs mailing list</a> for the development and discussion of Yaffs. It\'s a fairly low-traffic list. You will be emailed and asked to confirm your subscription request. You can also browse and search the <a href=\"http://aleph1.co.uk/lurker/splash/index.en.html\">Yaffs mailing list archives</a>.</p>\r\n','YAFFS is a filesystem designed specifically for the characteristics of NAND flash. This page gives an overview of the project - what is available, how it works, how to use it, developer resources, and licensing options.','full_html'),('page',0,345,345,'und',0,'<p>Yaffs is available free of charge under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a> version 2. This free version comes with the obligation on the User to provide (access to) Source Code to anyone who uses their products. If you do not wish to disclose your Source Code to all your customers you can buy a Licence from Aleph One Ltd which is like the usual Software licence in not requiring you to disclose Source Code.&nbsp; An example of our typical Licence, which is for one product, is given <a href=\"/node/32\" target=\"_blank\" title=\"Licence details\">here.</a></p><p>Circumstances where you need to licence Yaffs other than under the GPL include:-</p><ul><li>If you want to run a statically-linked commercial RTOS on top of a Yaffs filesystem</li><li>if you want to sublicence Yaffs to your customers (under terms other than the GPL)</li><li>If you want to use Yaffs with WindowsCE version 4.&nbsp; WinCE version 3 can use GPL code but WinCE v.4 and later need an additional filesystem interface layer which is not part of Yaffs. This is available at extra cost; please contact us.</li></ul><p>While Yaffs is released under GPL we can provide standard support options, consulting in its application to your particular product, or development of specific features to suit your needs or hardware. Paid Licences are available in certain circumstances, for example Licences to redistribute Yaffs to your customers. The price is a matter of negotiation.</p><p>If you aren\'t sure whether your needs will be covered by the GPL version, <a href=\"/contact\">get in touch with us</a>.</p><p>Access to the free GPL code is through <a href=\"/using-git\" title=\"CVS use\">our Git server</a>.</p><p>Although the code is downloadable at no charge, buying this product allows you to express your appreciation of Yaffs. Alternatively you can make a Donation to Aleph One Ltd via PayPal. You can do this at <a href=\"http://www.paypal.com\" target=\"_blank\" title=\"PayPal\">PayPal </a>by sending any sum to sales@aleph1.co.uk&nbsp; We shall appreciate it!</p>','<p>Yaffs is available free of charge under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a> GPL version 2.&nbsp; This free version is suitable for use in contexts where the associated software has a GPL-compatible licence.</p><p>Access to the free GPL code is through <a href=\"/using-git\" target=\"_blank\" title=\"CVS use\">our Git server</a></p>','full_html'),('page',0,345,617,'und',0,'<p>Yaffs is the property of Aleph One Limited.</p>\r\n\r\n<ul>\r\n	<li>Yaffs is <a href=\"/get-yaffs\">available free of charge</a> under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a>&nbsp;version 2 (GPL).</li>\r\n	<li>Linking Yaffs to other software creates a derived work and our&nbsp;interpretation of linking includes dynamic and runtime linking;&nbsp;any use of Yaffs creates a derived work.&nbsp;</li>\r\n	<li>Under the GPL, you can test Yaffs with your product on your computers. Do not distribute this test version unless your product is normally licensed under the GPL. If you do not copy and distribute it, there are no requirement under the GPL regarding distribution of a derived work.&nbsp;&nbsp;</li>\r\n	<li>Derived works must be licensed using the GPL, under the terms of the GPL, unless&nbsp;you have a <a href=\"/commercial-licences\">Commercial Licence</a> for Yaffs.</li>\r\n	<li>When you distribute GPLed object code you must make the full source code available too, to anyone who uses your product.&nbsp;(Sections 3.a and 3.b of the GPL, and the sections that follow.)&nbsp;&nbsp;</li>\r\n</ul>\r\n\r\n<p>Circumstances where you need to licence Yaffs other than under the GPL include:-</p>\r\n\r\n<ul>\r\n	<li>If you want to use Yaffs, but want to distribute your code under your licence.</li>\r\n	<li>If you want to run a statically-linked commercial RTOS on top of a Yaffs filesystem.</li>\r\n	<li>if you want to sublicence Yaffs to your customers (under terms other than the GPL).</li>\r\n	<li>If you want to use Yaffs with WindowsCE version 4.&nbsp; WinCE version 3 can use GPL code but WinCE v.4 and later need an additional filesystem interface layer which is not part of Yaffs. This is available at extra cost; please contact us.</li>\r\n</ul>\r\n\r\n<p>While Yaffs is released under GPL we can provide standard support options, consulting in its application to your particular product, or development of specific features to suit your needs or hardware. Paid Licences are available in certain circumstances, for example Licences to redistribute Yaffs to your customers. The price is a matter of negotiation.</p>\r\n\r\n<p>If you aren\'t sure whether your needs will be covered by the GPL version, <a href=\"/contact\">get in touch with us</a>.</p>\r\n\r\n<p>Although the code is downloadable at no charge, buying this product allows you to express your appreciation of Yaffs. Alternatively you can make a Donation to Aleph One Ltd via PayPal. You can do this at <a href=\"http://www.paypal.com\" target=\"_blank\" title=\"PayPal\">PayPal </a>by sending any sum to sales@aleph1.co.uk&nbsp; We shall appreciate it!</p>\r\n','<p>Yaffs is available free of charge under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a> GPL version 2.&nbsp; This free version is suitable for use in contexts where the associated software has a GPL-compatible licence.</p><p>Access to the free GPL code is through <a href=\"/using-git\" target=\"_blank\" title=\"CVS use\">our Git server</a></p>','full_html'),('page',0,345,618,'und',0,'<p>Yaffs is the property of Aleph One Limited.</p>\r\n\r\n<ul>\r\n	<li>Yaffs is <a href=\"/get-yaffs\">available free of charge</a> under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a>&nbsp;version 2 (GPL).</li>\r\n	<li>Linking Yaffs to other software creates a derived work and our&nbsp;interpretation of linking includes dynamic and runtime linking;&nbsp;any use of Yaffs creates a derived work.&nbsp;</li>\r\n	<li>Under the GPL, you can test Yaffs with your product on your computers. Do not distribute this test version unless your product is normally licensed under the GPL. If you do not copy and distribute it, there are no requirement under the GPL regarding distribution of a derived work.&nbsp;&nbsp;</li>\r\n	<li>Under the terms of the GPL, derived works must be licensed using the GPL, unless&nbsp;you have a <a href=\"/commercial-licences\">Commercial Licence</a> for Yaffs.</li>\r\n	<li>When you distribute GPLed object code you must make the full source code available too, to anyone who uses your product.&nbsp;(Sections 3.a and 3.b of the GPL, and the sections that follow.)&nbsp;&nbsp;</li>\r\n</ul>\r\n\r\n<p>Circumstances where you need to licence Yaffs other than under the GPL include:-</p>\r\n\r\n<ul>\r\n	<li>If you want to use Yaffs, but want to distribute your code under your licence.</li>\r\n	<li>If you want to run a statically-linked commercial RTOS on top of a Yaffs filesystem.</li>\r\n	<li>if you want to sublicence Yaffs to your customers (under terms other than the GPL).</li>\r\n	<li>If you want to use Yaffs with WindowsCE version 4.&nbsp; WinCE version 3 can use GPL code but WinCE v.4 and later need an additional filesystem interface layer which is not part of Yaffs. This is available at extra cost; please contact us.</li>\r\n</ul>\r\n\r\n<p>While Yaffs is released under GPL we can provide standard support options, consulting in its application to your particular product, or development of specific features to suit your needs or hardware.&nbsp;</p>\r\n\r\n<p>If you aren\'t sure whether your needs will be covered by the GPL version, <a href=\"/contact\">get in touch with us</a>.</p>\r\n\r\n<p>Although the code is downloadable at no charge, buying this product allows you to express your appreciation of Yaffs. Alternatively you can make a Donation to Aleph One Ltd via PayPal. You can do this at <a href=\"http://www.paypal.com\" target=\"_blank\" title=\"PayPal\">PayPal </a>by sending any sum to sales@aleph1.co.uk&nbsp; We shall appreciate it!</p>\r\n','<p>Yaffs is available free of charge under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a> GPL version 2.&nbsp; This free version is suitable for use in contexts where the associated software has a GPL-compatible licence.</p><p>Access to the free GPL code is through <a href=\"/using-git\" target=\"_blank\" title=\"CVS use\">our Git server</a></p>','full_html'),('page',0,345,619,'und',0,'<p>Yaffs is the property of Aleph One Limited.</p>\r\n\r\n<ul>\r\n	<li>Yaffs is <a href=\"/get-yaffs\">available free of charge</a> under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a>&nbsp;version 2 (GPL).</li>\r\n	<li>Linking Yaffs to other software creates a derived work and our&nbsp;interpretation of linking includes dynamic and runtime linking;&nbsp;any use of Yaffs creates a derived work.&nbsp;</li>\r\n	<li>Under the GPL, you can test Yaffs with your product on your computers. Do not distribute this test version unless your product is normally licensed under the GPL. If you do not copy and distribute it, there are no requirement under the GPL regarding distribution of a derived work.&nbsp;&nbsp;</li>\r\n	<li>Under the terms of the GPL, derived works must be licensed using the GPL, unless&nbsp;you have a <a href=\"/commercial-licences\">Commercial Licence</a> for Yaffs.</li>\r\n	<li>When you distribute GPLed object code you must make the full source code available too, to anyone who uses your product.&nbsp;(Sections 3.a and 3.b of the GPL, and the sections that follow.)&nbsp;&nbsp;</li>\r\n</ul>\r\n\r\n<p>Circumstances where you need to licence Yaffs other than under the GPL include:-</p>\r\n\r\n<ul>\r\n	<li>If you want to use Yaffs, but want to distribute your code under your licence.</li>\r\n	<li>If you want to run a statically-linked commercial RTOS on top of a Yaffs filesystem.</li>\r\n	<li>if you want to sublicence Yaffs to your customers (under terms other than the GPL).</li>\r\n	<li>If you want to use Yaffs with WindowsCE version 4.&nbsp;WinCE version 3 can use GPL code but WinCE v.4 and later need an additional filesystem interface layer which is not part of Yaffs. This is available at extra cost; please contact us.</li>\r\n</ul>\r\n\r\n<p>In these cases, our <a href=\"/commercial-licences\">Commercial Licence</a> is appropriate.</p>\r\n\r\n<p>If you aren\'t sure whether your needs will be covered by the GPL version, <a href=\"/contact\">get in touch with us</a>.</p>\r\n\r\n<h2>Support</h2>\r\n\r\n<p>While Yaffs is released under GPL we can provide standard support options, consulting in its application to your particular product, or development of specific features to suit your needs or hardware.&nbsp;</p>\r\n\r\n<h2>Helping us to improve Yaffs</h2>\r\n\r\n<p>Although the code is downloadable at no charge, buying this product allows you to express your appreciation of Yaffs. Alternatively you can make a Donation to Aleph One Ltd via PayPal. You can do this at <a href=\"http://www.paypal.com\" target=\"_blank\" title=\"PayPal\">PayPal </a>by sending any sum to sales@aleph1.co.uk&nbsp; We shall appreciate it!</p>\r\n','<p>Yaffs is available free of charge under the <a href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_self\" title=\"Gnu Public Licence\">GNU General Public Licence,</a> GPL version 2.&nbsp; This free version is suitable for use in contexts where the associated software has a GPL-compatible licence.</p><p>Access to the free GPL code is through <a href=\"/using-git\" target=\"_blank\" title=\"CVS use\">our Git server</a></p>','full_html'),('book',0,347,347,'und',0,'Written by Charles Manning - Originally published at Linuxdevices.org Sept 20th 2002\r\n\r\n<h3>PHB Summary</h3>\r\nYAFFS stands for \"yet another flash file system\"(*). As far as I am aware, YAFFS is the only file system, under any operating system, that has been designed specifically for use with NAND flash. YAFFS is thus designed to work within the constraints of, and exploit the features of, NAND flash to maximise performance. YAFFS uses journaling, error correction and verification techniques tuned to the way NAND typically fails, to enhance robustness. The result is a file system that exploits low-cost NAND chips and is both fast and robust. YAFFS is highly portable and runs under Linux, ucLinux and Windows CE. YAFFS is an open source project.\r\n\r\n<h3>Why NAND flash?</h3>\r\n\r\nEmbedded and mobile systems are increasingly using NAND flash for storage because it has various advantages over other storage technologies. As always though, life is a compromise and those advantages come with some limitations that need to be addressed to provide a robust flash file system.\r\n\r\nHard disks are not a viable storage option for many embedded and handheld systems because they are too big, too fragile and use too much power. For some years now, people have been using common-old NOR flash for file system storage. JFFS and JFFS2 do an excellent job of this for Linux. For storage applications NOR flash is not that great because it is not very dense (ie. not much storage per chip), is costly and is slow to write. NAND flash, on the other hand, is low cost, dense and writes fast, but has other limitations. The most common consumer usage of NAND flash is on SmartMedia cards which are just NAND chips bonded to a carrier card. Consumer use of SmartMedia is driving down NAND prices while\r\ndriving up densities.\r\n\r\nThe standard SmartMedia file system is FAT based and is thus liable to corruptions due to power failures, crashes and other acts of demonic forces. This raises robustness concerns, particularly in embedded systems where a corrupted file system can kill the device. What\'s really needed is a journaling file system that is able to work around the limitations of NAND and exploit it for best performance.\r\n\r\n<h3>History</h3>\r\nThe lead-up to YAFFS started with an investigation into modifying the JFFS2 flash file system to work with NAND flash (**) for some Aleph One customers. It seemed reasonable that the best way to get a file system for NAND flash would be just \"tweaking\" an existing flash file system. On deeper investigation, it became apparent that designing a new file system specifically for NAND might have some benefits.\r\n<table width=\"568\" border=\"1\" bordercolor=\"#000000\" cellpadding=\"1\" cellspacing=\"0\"><col width=\"186\"><col width=\"187\"><col width=\"186\">\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p></p></td>\r\n <td width=\"187\"><p>NOR (typical, varies a lot)</p></td>\r\n <td width=\"186\"><p>NAND</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Density</p></td>\r\n <td width=\"187\"><p>Up to 32MB chips</p></td>\r\n <td width=\"186\"><p>Currently 256MB and growing.</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Cost per MB</p></td>\r\n <td width=\"187\"><p>$1-$2</p></td>\r\n <td width=\"186\"><p>25c</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Access</p></td>\r\n <td width=\"187\"><p>Random</p></td>\r\n <td width=\"186\"><p>Page oriented with spare area on each page. Sequential access within a page.</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Programmability</p></td>\r\n <td width=\"187\"><p>Can modify a single bit.</p></td>\r\n <td width=\"186\"><p>Very limited re-programming.</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Read speed</p></td>\r\n <td width=\"187\"><p>50-100nS</p></td>\r\n <td width=\"186\"><p>10uS page \"seek\" + 50nS per byte</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Program time</p></td>\r\n <td width=\"187\"><p>5uS per byte</p></td>\r\n <td width=\"186\"><p>200uS per page</p></td>\r\n</tr>\r\n<tr valign=\"top\">\r\n <td width=\"186\"><p>Erasure time</p></td>\r\n <td width=\"187\"><p>1s per 64kB block</p></td>\r\n <td width=\"186\"><p>2ms per 16kB block</p></td>\r\n</tr>\r\n<tr valign=\"top\"> \r\n <td width=\"186\"><p>Reliability</p></td> \r\n <td width=\"187\"><p>Relatively immune to corruption. No bad blocks.</p></td>\r\n <td width=\"186\"><p>Needs error correction. Bad blocks marked when shipped.</p></td>\r\n</tr>\r\n</table>\r\n\r\nDesigning an effective flash file system is a difficult task and you need to jump through many hoops of fire to get a useful system. Although both are called \"Flash\", NOR and NAND flash have very different properties. Thus, a flash file system that works with NOR incorporates various mechanisms that are not required for NAND, and NAND needs extra mechanisms not required for NOR.\r\n\r\nFor example, garbage collection performance is largely determined by the erasure time. NOR erases very slowly and thus an effective NOR garbage collection strategy is relatively complex and limits the design options. In comparison NAND erases very quickly; thus these limitations don\'t apply.\r\n\r\nAnother major difference is that NAND is shipped with marked bad blocks on the device, while NOR chips are shipped defect free. Thus, one expects to encounter some failures in NAND and should design accordingly.\r\n\r\nThis lead me to believe that it would be worth designing a file system specifically for NAND flash, exploiting the features of NAND to simplify the design and catering to NAND specific limitations directly, rather than trying to \"bend\" NAND to work with an existing file system architecture, or vice versa.\r\n\r\nThe first conceptual design for YAFFS was drawn up in late December 2001. Once the customers bought in to the idea, things progressed rapidly. The first line of code was cut in January 2002. By May 2002 we had the first publicly available CVS code. We now have at least six different companies using or experimenting with YAFFS in embedded or handheld systems. YAFFS is already very stable and is converging rapidly. We expect to see YAFFS-based products shipped before the end of the year.\r\n\r\n<h3>Design approach</h3>\r\nRather than develop and debug code inside the Linux kernel, I took the approach of developing the file system \"guts\" algorithms - the most complex part -- in a user space program. To achieve this, the code is split into four sections:\r\n<ul>\r\n<li>\r\n<p>yaffs_guts: The file system algorithms. This code is fully portable C.</p>\r\n</li>\r\n<li>\r\n<p>yaffs_fs.c: Interface layer to the Linux VFS. Can be replaced with a test harness for user space developing of yaffs_guts.c</p>\r\n</li>\r\n<li>\r\n<p>nand interface: wrapper layer between yaffs_guts and the NAND memory access functions. eg. calls Linux mtd layer or RAM emulation layer.</p>\r\n</li>\r\n<li>\r\n<p>Portability functions: wrapper functions for services such as memory allocation etc.</p>\r\n</li>\r\n</ul>\r\n\r\nThis modular design has provided a lot of flexibility for testing and development. A user space program and DDD is a far more rapid development environment than continually changing the Linux kernel. Also, a RAM-based NAND emulation layer provides an excellent way to debug the file system in-kernel without special hardware.\r\n\r\nA further spin-off has been that YAFFS is portable to other operating systems. For example, a port of YAFFS for Windows CE was readily achieved by writing a new wrapper layer to hook up to the WinCE file system manager and new NAND access layer. yaffs_guts.c remains 100% portable(***). YAFFS is thus likely to be easily portable to other OSs too.\r\n\r\n<h3>Results</h3>\r\n\r\nRemoving surplus constraints has lead to a simpler design that has improved performance and robustness as well and reduced development time.\r\n\r\nYAFFS reads and writes pretty fast. There is no significant hit due to garbage collection (ie. in most situations garbage collection overheads would not impact usage).</p>\r\n\r\nIt is difficult to give meaningful benchmarks given non-standard hardware. However herewith some results achieved on a StrongARM-based board with 128MB of NAND flash. Write speed is approx 800kB per second and read speed is approx 1.5MB per second. In a weekend stress test I wrote, triple-verified then deleted\r\n25gigabytes of file data without a single bit of file data being corrupted. 25GB exceeds the design lifetime of most embedded or handheld devices.\r\n\r\n<h3>Future</h3>\r\n\r\nAlthough YAFFS already performs well, there is still a lot of room for improvement. Development is continuing to enhance performance and robustness as well as add support software such as utilities, bootloader support and analysis tools.\r\n\r\nI expect to see ports to other OSs too. Increasing the user base of YAFFS is an important way to get more eyes over the code and test it under a wider set of scenarios.\r\n\r\nThe YAFFS development community is growing well with good involvement from people all over the world. YAFFS is realising all the benefits open source projects hope for and will, we expect, continue to grow.\r\n\r\n<h3>Resources</h3>\r\n\r\nThe YAFFS project home page is http://www.aleph1.co.uk/yaffs/\r\nThis provides further YAFFS documentation and instructions for GIT access and the YAFFS mailing list.</p>\r\n\r\n<h3>Footnotes:</h3>\r\n\r\n(*)The YAFFS name came from the first concept document proposing yet another flash file system. Some how that name just stuck.\r\n\r\n(**) NAND support has since been added to JFFS2 by others. The YAFFS, JFFS2 and mtd communities cooperate to provide a rich flexible set of solutions to draw from. As is the nature of open source projects, JFFS2 code was used as a reference for some parts of the YAFFS development, particularly for figuring out the VFS interface. Google for further info on JFFS2 and mtd.\r\n\r\n(***) Some features were added to the guts to enhance WinCE usage. For example, the string comparison function was made configurable to be either strcmp or scricmp because Windows file names are case insensitive.\r\n\r\n<h3>Bio</h3>\r\n\r\nCharles Manning (aka The Embedded Janitor) lives near Christchurch, New Zealand, and has been developing and mopping up embedded systems for twenty years. His hobbies include fly tying and spinning wool. Charles can be reached at <a href=\"mailto:charles@aleph1.co.uk\">charles@aleph1.co.uk</a>.\r\n','YAFFS stands for \"yet another flash file system\"(*). As far as I am aware, YAFFS is the only file system, under any operating system, that has been designed specifically for use with NAND flash. YAFFS is thus designed to work within the constraints of, and exploit the features of, NAND flash to maximise performance. YAFFS uses journaling, error correction and verification techniques tuned to the way NAND typically fails, to enhance robustness. The result is a file system that exploits low-cost NAND chips and is both fast and robust. YAFFS is highly portable and runs under Linux, ucLinux and Windows CE. YAFFS is an open source project.\r\n','full_html'),('book',0,348,348,'und',0,'<p>Yaffs claims a \'low memory footprint\', but what exactly does that mean? How low is low?</p>\r\n\r\n<p>Calculating an exact footprint is no easy task. There are many dependencies. Here is an approximation for Yaffs1 on Linux, assuming the standard block size of 512bytes per page and 16kB per block.</p>\r\n<ol>\r\n<li>Code size. This is dependent on various factors including CPU choice, optiomisation options etc. As a rough guide, the yaffs.o Linux module for x86 is around 55kBytes. This could be made smaller by stripping the debug text and ECC code if you don\'t need that.\r\n\r\n<li>Run-time data structures. Some of these are fixed size and others are generated in runtime and change as your file structures change. As a rough guide though I will give the following:\r\n<ol type=\"a\">\r\n <li>Each yaffs partition needs a device structure of less than 1kB + approx  2-4kB stack with the current implementation.\r\n <li>If shortOpCaches are enabled, then 524 bytes per cache entry (5 to 10 is a \r\ngood number).\r\n <li>About 120 bytes per file. (With short name caching enabled)\r\n <li>About 4 bytes per block of NAND (ie. about 128 bytes per MB of NAND).\r\n <li>About 4kBytes of RAM per MB of NAND for building the file TNode trees that \r\nare used to locate the data chunks.\r\n</ol>\r\n</ol>\r\n\r\n<p>Thus for a system using a 64MByte NAND and say 500 files you can budget on \r\napprox:</p>\r\n\r\n<ul>\r\n<li>1)    55kBytes\r\n<li>2a)    5kB\r\n<li>2b)   3kB (5 cache entries)\r\n<li>2c)   60kB\r\n<li>2d)  16kB\r\n<li>2e)   256kB\r\n</ul>\r\n<b>Total 410kBytes</b>\r\n\r\n<p>The last item, the tnodes, is the biggest expense in Yaffs. This can be \r\nreduced significantly by using a larger page size.</p>\r\n\r\n<p>There are some opportunities to tune some of these numbers so please feel \r\nfree to discusss further if required.</p>\r\n\r\n','Yaffs claims a \'low memory footprint\', but what exactly does that mean? How low is low? \r\n\r\n<p>Calculating an exact footprint is no easy task. There are many dependencies. Here is an approximation for Yaffs1 on Linux, assuming the standard block size of 512bytes per page and 16kB per block.','full_html'),('page',0,351,351,'und',0,'<h1>How to control debugging in yaffs</h1>\r\n\r\n<p>YAFFS provides a debugging mechanism which can be controlled at runtime if you have access to /proc, normally via a shell. If you need to trace things before you get to a shell, then you can set default trace options at compile time.</p>\r\n\r\n<h2>Available Trace Flags</h2>\r\n<table>\r\n <tr>\r\n  <th>name</th><th>C #define</th><th>bitmask value</th>\r\n </tr>\r\n <tr>\r\n  <td>error </td>       <td>YAFFS_TRACE_ERROR </td>           <td>0x00000001</td>\r\n </tr>\r\n <tr>\r\n  <td>os </td>          <td>YAFFS_TRACE_OS </td>              <td>0x00000002</td>\r\n </tr>\r\n <tr>\r\n  <td>allocate </td>    <td>YAFFS_TRACE_ALLOCATE </td>        <td>0x00000004</td>\r\n </tr>\r\n <tr>\r\n  <td>scan </td>        <td>YAFFS_TRACE_SCAN </td>            <td>0x00000008</td>\r\n </tr>\r\n <tr>\r\n  <td>bad_blocks </td>  <td>YAFFS_TRACE_BAD_BLOCKS </td>      <td>0x00000010</td>                                                     \r\n </tr>\r\n <tr>\r\n  <td>erase </td>       <td>YAFFS_TRACE_ERASE </td>           <td>0x00000020</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>gc </td>          <td>YAFFS_TRACE_GC </td>              <td>0x00000040</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>write </td>       <td>YAFFS_TRACE_WRITE </td>           <td>0x00000080</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>tracing </td>     <td>YAFFS_TRACE_TRACING </td>         <td>0x00000100</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>deletion </td>    <td>YAFFS_TRACE_DELETION </td>        <td>0x00000200</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>buffers </td>     <td>YAFFS_TRACE_BUFFERS </td>         <td>0x00000400</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>nandaccess </td>  <td>YAFFS_TRACE_NANDACCESS </td>      <td>0x00000800</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>gc_detail </td>   <td>YAFFS_TRACE_GC_DETAIL </td>       <td>0x00001000</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>scan_debug </td>  <td>YAFFS_TRACE_SCAN_DEBUG </td>      <td>0x00002000</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>mtd </td>         <td>YAFFS_TRACE_MTD </td>             <td>0x00004000</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>always </td>      <td>YAFFS_TRACE_ALWAYS </td>          <td>0x40000000</td>                                                      \r\n </tr>\r\n <tr>\r\n  <td>bug </td>         <td>YAFFS_TRACE_BUG </td>             <td>0x80000000</td>\r\n </tr>\r\n</table>\r\n\r\n<h2>Flag meanings</h2>\r\n<p>The flags cover possible debugging messages from various aspects of the filesystem - initial scanning, mtd interface, writing, nand access, garbage collection, OS interaction etc. Turning on everything results an awful lot of trace info, so it is usually best to just enable a few relevant flags.</p>\r\n\r\n<h2>Setting flags at runtime</h2>\r\n<p>The flags can be set or cleared by echoing the name of the flag into /proc/yaffs with a \'+\' or \'-\':<br />                                                                                                                                                                         \r\n  <tt>echo +os-write &gt; /proc/yaffs</tt></p>\r\n                                                                                                                                             <p>It can be set to to all or none using \'=\', and then flags can be added or removed:<br />\r\n  <tt>echo =none+os+write &gt; /proc/yaffs</tt></p>\r\n\r\n<p>And you can use numerical values, if you are so inclined (using standard C format):<br />\r\n  <tt>echo 0xf00001 &gt; /proc/yaffs</tt></p>\r\n                                                                                                                                          <p>So<br />\r\n  <tt>echo all &gt; /proc/yaffs</tt><br />\r\nwill turn all tracing on</p>\r\n\r\n<p><b>Note</b> that you only see the output showing you the current trace state if the \'always\' (YAFFS_TRACE_ALWAYS) flag is set, so to see what you are doing do this:<br />\r\n  <tt>echo +always &gt; /proc/yaffs</tt></p>                                                                                                                                                                                   \r\n\r\n<h2>Setting flags at compile time</h2>\r\n\r\n<p>Flags can be set in the code at compile-time by setting <tt>yaffs_traceMask</tt> in <tt>yaffs_fs.c</tt> (add new flags to <tt>always</tt> and <tt>bad_blocks</tt> which are set by default)</p>','<p>YAFFS provides a debugging mechanism which can be controlled at runtime, or set at build time. This page descirbes the options available and how to use them, for when you need to do some troubleshooting.</p>\r\n\r\n','full_html'),('page',0,353,353,'und',0,'<h3>Do we need a Licence for Yaffs ?</h3>\r\n\r\n<p>Yaffs is and will remain free of charge from <a href=\"/node/346\">our web site</a>.&nbsp; You can grab the latest version and work and test and play with it without charge.<br />\r\n<br />\r\nIt comes with a GNU General Public Public Licence, version 2,&nbsp; :&nbsp;<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">http://www.gnu.org/licenses/gpl-2.0.html</a>&nbsp;&nbsp; As usual with GPL work, if you sell or distribute work embodying Yaffs you also have an obligation to disclose your associated Source Code to anyone who asks.</p>\r\n\r\n<h3>What if we link other code to Yaffs ?</h3>\r\n\r\n<p>The GPL obligation is not affected by the kind of linking between Yaffs and any associated code, nor is it affected by your disclosure of modifications you make to the code and release back into the main line.&nbsp; For example if you use Yaffs under GPL with Linux you should treat it just the same as Linux code; if you want to publish a patched kernel please do.</p>\r\n\r\n<h3>We do not want to disclose Source Code</h3>\r\n\r\n<p>Because Aleph One Limited created and owns Yaffs we can sell you a Licence to use Yaffs which does not have the GNU GPLV2 obligations.&nbsp; Such a licence is always perpetual, world-wide, non-exclusive. and free of any continuing royalty obligations.&nbsp; It is paid for by a single fee at the time of signing a Licence Agreement between you and Aleph One.</p>\r\n\r\n<p>The fee depends on the number of distinct Products in which Yaffs will be used, and there is a base price of GBP £10,000.&nbsp; If more than one Product is included in the same Licence there is usually a reduction in the second fee.</p>\r\n\r\n<h3>What do we do next ?</h3>\r\n\r\n<p>Tell us some more about the product you will use Yaffs in.&nbsp; We like the Agreement to contain a brief description of the hardware involved and the part number or product name and any internal code name.&nbsp; If you want us to sign a Non-Disclosure Agreement before you give us these details, send it to us; we are used to signing them.&nbsp; We can send you a standard form if you do not have one.</p>\r\n\r\n<p>Then we will send a draft Agreement and price to you, and negotiate until we are both satisfied.&nbsp; Next we each sign and exchange copies of the Agreement and you pay us.</p>\r\n\r\n<h3>What happens when we sign a Licence ?</h3>\r\n\r\n<p>When we have both signed a Licence Agreement and you have paid us we provide you with a tarball of files whose headers show that this code is under a proprietary Licence which you have bought from us.&nbsp; You use these files to create the FS code you embed in your Products.</p>\r\n\r\n<h3>Is there more information about licensing?</h3>\r\n\r\n<p>Yes there is!</p>\r\n\r\n<ul>\r\n	<li>More detail about the <a href=\"/yaffs-licence-sample\">definition of a Product is given </a><a href=\"/node/32\">i</a><a href=\"/yaffs-licence-sample\">n our sample commercial licence</a>.&nbsp;</li>\r\n	<li>Notes which give&nbsp;<a href=\"/licences-more-background-and-detail\">further background and detail about our licensing</a>.</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>&nbsp;</p>\r\n','<p>Some questions about the commercial licence for Yaffs and how we arrive at one.</p>','filtered_html'),('page',0,353,577,'und',0,'<h3>Do we need a Licence for Yaffs ?</h3>\r\n\r\n<p>Yaffs is and will remain free of charge from <a href=\"/node/346\">our web site</a>.&nbsp; You can grab the latest version and work and test and play with it without charge.<br />\r\n<br />\r\nIt comes with a GNU General Public Public Licence, version 2,&nbsp; :&nbsp;<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">http://www.gnu.org/licenses/gpl-2.0.html</a>&nbsp;&nbsp; As usual with GPL work, if you sell or distribute work embodying Yaffs you also have an obligation to disclose your associated Source Code to anyone who asks.</p>\r\n\r\n<h3>What if we link other code to Yaffs ?</h3>\r\n\r\n<p>The GPL obligation is not affected by the kind of linking between Yaffs and any associated code, nor is it affected by your disclosure of modifications you make to the code and release back into the main line.&nbsp; For example if you use Yaffs under GPL with Linux you should treat it just the same as Linux code; if you want to publish a patched kernel please do.</p>\r\n\r\n<h3>We do not want to disclose Source Code</h3>\r\n\r\n<p>Because Aleph One Limited created and owns Yaffs we can sell you a Licence to use Yaffs which does not have the GNU GPLV2 obligations.&nbsp; Such a licence is always perpetual, world-wide, non-exclusive. and free of any continuing royalty obligations.&nbsp; It is paid for by a single fee at the time of signing a Licence Agreement between you and Aleph One.</p>\r\n\r\n<p>The fee depends on the number of distinct Products in which Yaffs will be used, and there is a base price of GBP £10,000.&nbsp; If more than one Product is included in the same Licence there is usually a reduction in the second fee.</p>\r\n\r\n<h3>What do we do next ?</h3>\r\n\r\n<p>Tell us some more about the product you will use Yaffs in.&nbsp; We like the Agreement to contain a brief description of the hardware involved and the part number or product name and any internal code name.&nbsp; If you want us to sign a Non-Disclosure Agreement before you give us these details, send it to us; we are used to signing them.&nbsp; We can send you a standard form if you do not have one.</p>\r\n\r\n<p>Then we will send a draft Agreement and price to you, and negotiate until we are both satisfied.&nbsp; Next we each sign and exchange copies of the Agreement and you pay us.</p>\r\n\r\n<h3>What happens when we sign a Licence ?</h3>\r\n\r\n<p>When we have both signed a Licence Agreement and you have paid us we provide you with a tarball of files whose headers show that this code is under a proprietary Licence which you have bought from us.&nbsp; You use these files to create the FS code you embed in your Products.</p>\r\n\r\n<h3>Is there more information about licensing?</h3>\r\n\r\n<p>Yes there is!</p>\r\n\r\n<ul>\r\n	<li>More detail about the <a href=\"/yaffs-licence-sample\">definition of a Product is given </a><a href=\"/node/32\">i</a><a href=\"/yaffs-licence-sample\">n our sample commercial licence</a>.&nbsp;</li>\r\n	<li>Notes which give&nbsp;<a href=\"/licences-more-background-and-detail\">further background and detail about our licensing</a>.</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>&nbsp;</p>\r\n','<p>Some questions about the commercial licence for Yaffs and how we arrive at one.</p>','basic_html'),('article',0,357,358,'und',0,'<p>Yaffs (Yet Another Flash File System) is an open-source file system specifically designed to be fast, robust and suitable for embedded use with NAND and NOR Flash.&nbsp; It is widely used with Linux, RTOSs, or no OS at all, in consumer devices. It is available under GNU Public License, GPL, or on commercial terms from Aleph One.</p>\r\n','','filtered_html'),('article',0,357,578,'und',0,'<p>Yaffs (Yet Another Flash File System) is an open-source file system specifically designed to be fast, robust and suitable for embedded use with NAND and NOR Flash.&nbsp; It is widely used with Linux, RTOSs, or no OS at all, in consumer devices. It is available under GNU Public License, GPL, or on commercial terms from Aleph One.</p>\r\n','','basic_html'),('article',0,358,359,'und',0,'The following documents will give you some insight into the internal history of YAFFS\r\n\r\n<ul>\r\n<li><a href=\"node/39\">YAFFS Development notes</a>.</li>\r\n<li><a href=\"node/42\">State of NAND MTD driver at start of project</a></li>\r\n<li><a href=\"node/42\">YAFFS History</a></li>\r\n</ul>','A brief look into the history of YAFFS through a look at the the internals.','obsolete_tinymce'),('article',0,358,544,'und',0,'The following archive documents will give you some insight into the internal history of YAFFS\r\n\r\n<ul>\r\n<li><a href=\"/node/39\">YAFFS Development notes</a>.</li>\r\n<li><a href=\"/node/42\">State of NAND MTD driver at start of project</a></li>\r\n<li><a href=\"/node/42\">YAFFS History</a></li>\r\n</ul>','A brief look into the history of YAFFS through a look at the the internals.','obsolete_tinymce'),('article',0,359,360,'und',0,'<div align=\"left\">On Friday 02 March 2007 10:59, Charles F Johnson wrote:</div><p align=\"left\">\"I\'m trying to understand the relative merits of JFFS2 vs YAFFS2. The response on the YAFFS mailing list is quite positive as far as leading me to believe that there are actual products shipping.\"</p><p align=\"left\"><br>Charles Manning replied:<br>At a technical level, it is very difficult to make X vs Y comparisons because there are many factors involved which manifest differently on different systems therefore \'your mileage will vary\'. But, as a general rule of thumb, the following might help:</p><p align=\"left\">1) YAFFS uses less run-time RAM to hold its state, so YAFFS scales better than JFFS2. There are quite a few systems using large NAND arrays (the largest partitions I know of are around the 6Gbyte mark).<br><br>2) YAFFS garbage collection is simpler and faster, typically making for better performance under hard writing.<br><br>3) YAFFS uses a whole page per file for headers, and does not provide compression. This means that JFFS2 is probably a better fit to small partitions. The flip side is that a lot of data (eg. MP3) does not compress very well, and enabling compression really hurts performance.<br><br>4) While YAFFS has been used on NOR, it does not fit very well (because YAFFS does not use erase suspend). Thus if you\'re using smaller NAND partitions and using JFFS2 on NOR, then a JFFS2-only solution is very appealing.<br><br>All the above can generally boil down to: If you\'re using less than about 64MB the pain vs gain might play in favour of JFFS2. As you increase partition size, YAFFS makes more and more sense.</p>','If you are trying to decide between Yaffs and JFFS2 then this note will give you an idea of the relative advantages of each.','filtered_html'),('article',0,359,534,'und',0,'<p>On Friday 02 March 2007 10:59, Charles F Johnson wrote:</p>\r\n\r\n<p>\"I\'m trying to understand the relative merits of JFFS2 vs YAFFS2. The response on the YAFFS mailing list is quite positive as far as leading me to believe that there are actual products shipping.\"</p>\r\n\r\n<p><br />\r\nCharles Manning replied:<br />\r\nAt a technical level, it is very difficult to make X vs Y comparisons because there are many factors involved which manifest differently on different systems therefore \'your mileage will vary\'. But, as a general rule of thumb, the following might help:</p>\r\n\r\n<p>1) YAFFS uses less run-time RAM to hold its state, so YAFFS scales better than JFFS2. There are quite a few systems using large NAND arrays (the largest partitions I know of are around the 6Gbyte mark).<br />\r\n<br />\r\n2) YAFFS garbage collection is simpler and faster, typically making for better performance under hard writing.<br />\r\n<br />\r\n3) YAFFS uses a whole page per file for headers, and does not provide compression. This means that JFFS2 is probably a better fit to small partitions. The flip side is that a lot of data (eg. MP3) does not compress very well, and enabling compression really hurts performance.<br />\r\n<br />\r\n4) While YAFFS has been used on NOR, it does not fit very well (because YAFFS does not use erase suspend). Thus if you\'re using smaller NAND partitions and using JFFS2 on NOR, then a JFFS2-only solution is very appealing.<br />\r\n<br />\r\nAll the above can generally boil down to: If you\'re using less than about 64MB the pain vs gain might play in favour of JFFS2. As you increase partition size, YAFFS makes more and more sense.</p>\r\n','If you are trying to decide between Yaffs and JFFS2 then this note will give you an idea of the relative advantages of each.','filtered_html'),('article',0,359,579,'und',0,'<p>On Friday 02 March 2007 10:59, Charles F Johnson wrote:</p>\r\n\r\n<p>\"I\'m trying to understand the relative merits of JFFS2 vs YAFFS2. The response on the YAFFS mailing list is quite positive as far as leading me to believe that there are actual products shipping.\"</p>\r\n\r\n<p><br />\r\nCharles Manning replied:<br />\r\nAt a technical level, it is very difficult to make X vs Y comparisons because there are many factors involved which manifest differently on different systems therefore \'your mileage will vary\'. But, as a general rule of thumb, the following might help:</p>\r\n\r\n<p>1) YAFFS uses less run-time RAM to hold its state, so YAFFS scales better than JFFS2. There are quite a few systems using large NAND arrays (the largest partitions I know of are around the 6Gbyte mark).<br />\r\n<br />\r\n2) YAFFS garbage collection is simpler and faster, typically making for better performance under hard writing.<br />\r\n<br />\r\n3) YAFFS uses a whole page per file for headers, and does not provide compression. This means that JFFS2 is probably a better fit to small partitions. The flip side is that a lot of data (eg. MP3) does not compress very well, and enabling compression really hurts performance.<br />\r\n<br />\r\n4) While YAFFS has been used on NOR, it does not fit very well (because YAFFS does not use erase suspend). Thus if you\'re using smaller NAND partitions and using JFFS2 on NOR, then a JFFS2-only solution is very appealing.<br />\r\n<br />\r\nAll the above can generally boil down to: If you\'re using less than about 64MB the pain vs gain might play in favour of JFFS2. As you increase partition size, YAFFS makes more and more sense.</p>\r\n','If you are trying to decide between Yaffs and JFFS2 then this note will give you an idea of the relative advantages of each.','basic_html'),('article',0,360,361,'und',0,'<p><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">This paper</a> proposes a method for efficient initialization and crash recovery for Flash-memory file systems. A log management scheme for the Flash-memory file systems is presented. The proposed log management method is implemented in a log-record manager and a logger. It was written by Chin-Hsein Wu, Tei-Wei Kuo and Li-Pen Change of the Department of Computer Science of National Taiwan University, Taipei, TAIWAN, and presented at an international SAC Conference in 2006. Copyright 2006 ACM 1-59593-108-2/06/0004</p>','<p>This provides a link to a PDF of a paper by Taiwanese scholars.</p>','filtered_html'),('article',0,360,540,'und',0,'<p><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">This paper</a> proposes a method for efficient initialization and crash recovery for Flash-memory file systems. A log management scheme for the Flash-memory file systems is presented. The proposed log management method is implemented in a log-record manager and a logger. It was written by Chin-Hsein Wu, Tei-Wei Kuo and Li-Pen Change of the Department of Computer Science of National Taiwan University, Taipei, TAIWAN, and presented at an international SAC Conference in 2006. Copyright 2006 ACM 1-59593-108-2/06/0004</p>\r\n','<p>This provides a link to a PDF of a paper by Taiwanese scholars.</p>','filtered_html'),('article',0,360,555,'und',0,'<p><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">This paper</a> proposes a method for efficient initialization and crash recovery for Flash-memory file systems. A log management scheme for the Flash-memory file systems is presented. The proposed log management method is implemented in a log-record manager and a logger. It was written by Chin-Hsein Wu, Tei-Wei Kuo and Li-Pen Change of the Department of Computer Science of National Taiwan University, Taipei, TAIWAN, and presented at an international SAC Conference in 2006. Copyright 2006 ACM 1-59593-108-2/06/0004</p>\r\n','<p>This provides a link to a PDF of a paper by Taiwanese scholars.</p>','filtered_html'),('article',0,360,580,'und',0,'<p><a href=\"http://www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf\">This paper</a> proposes a method for efficient initialization and crash recovery for Flash-memory file systems. A log management scheme for the Flash-memory file systems is presented. The proposed log management method is implemented in a log-record manager and a logger. It was written by Chin-Hsein Wu, Tei-Wei Kuo and Li-Pen Change of the Department of Computer Science of National Taiwan University, Taipei, TAIWAN, and presented at an international SAC Conference in 2006. Copyright 2006 ACM 1-59593-108-2/06/0004</p>\r\n','<p>This provides a link to a PDF of a paper by Taiwanese scholars.</p>','basic_html'),('page',0,365,366,'und',0,'You can pay us, as Aleph One Ltd, for an agreed product or service by clicking  <a href=\"http://www.aleph1.co.uk/other\"> HERE </a>\r\n','','obsolete_tinymce'),('image',0,366,367,'und',0,'YAFFS embedded structure','','obsolete_tinymce'),('page',0,367,368,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','filtered_html'),('page',0,367,536,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p>\r\n\r\n<p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>\r\n','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','filtered_html'),('page',0,367,537,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p>\r\n\r\n<p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>\r\n','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','filtered_html'),('page',0,367,554,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p>\r\n\r\n<p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>\r\n','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','filtered_html'),('page',0,367,581,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p>\r\n\r\n<p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>\r\n','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','basic_html'),('page',0,367,610,'und',0,'<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p>\r\n\r\n<p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>\r\n','<p>Attached is a PDF with slides from the Yaffs talk at CELF\'s Embedded Linux Conference Europe 2007. If you are able to view Ogg Theora video files, the talk is also <a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">online</a>. Ogg Theora is a Free video format. Free players are available for all platforms. See the list <a href=\"http://wiki.xiph.org/index.php/TheoraSoftwarePlayers\">here</a>. If in doubt, VLC is probably available for your operating system.</p><p>If you prefer to go straight to the .pdf if clides&nbsp; click <a href=\"http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf\">http://www.yaffs.net/sites/yaffs.net/files/yaffs.pdf</a></p>','basic_html'),('book',0,368,369,'und',0,'<b>Overview</b>\r\n<br />\r\n<br />\r\n<div align=\"left\">\r\nYAFFS is an Open Source flash file system used in many embedded applications \r\nsuch as mobile phones, PDAs, aerospace and point of sale. YAFFS is mainly used in Linux systems but is also used with other OSs.\r\nYAFFS is even used in the Google Android platform!\r\n<br />\r\n<br />\r\n<div align=\"left\">\r\nWe\'re looking for some bright minds interested in the GSoC concept - \r\n<a href=\"http://code.google.com/soc/2008\">Google 2008 Summer of Code</a>\r\n- to help make YAFFS even better.  The particular area of interst here is performance improvement, and enriching the YAFFS development environment with support tools.\r\n<p>\r\nWe strongly encourage student generated ideas, as well as further ideas from the YAFFS community.\r\n<br />\r\n<br />\r\n<b>Performance analysis</b>\r\n<br />\r\n</p>\r\n<div align=\"left\">\r\nPerformance is increasingly important in delivering high quality user experience on media-rich devices such as Google Android-based devices. High file system performance leads to slicker UI and faster data transfers. High performance also reduces flash memory read/writes which  reduces power consumption, meaning better battery life.\r\n<br />\r\n<br />\r\n<div align=\"left\">\r\nOur major focus for GSoC is to develop a  performance analysis framework and tools that will help to identify opportunities for improvement as well as evaluate the performance impact of code changes. It would be great if this performance toolkit could be generalised for other applications, but that\'s beyond the focus of what we want to achieve here. \r\n<br />\r\n<br />\r\n<div align=\"left\">\r\nWe have some ideas to seed this, but encourage students to think of their own \r\nideas too. \r\n</div>\r\n<div align=\"left\">\r\n* Develop an environment-neutral data gathering framework.\r\n</div>\r\n<div align=\"left\">\r\n* Write a FUSE wrapper for YAFFS to improve test scripting. Include the data gathering framework in the FUSE wrapper.\r\n</div>\r\n<div align=\"left\">\r\n* Extend the Android simulator with these tools, thus allowing performance analysis of Linux-based mobile devices.\r\n</div>\r\n<div align=\"left\">\r\n* Develop performance-analysis display tools to allow clear observation of gathered data.\r\n</div>\r\n<div align=\"left\">\r\n* Help in performance analysis.\r\n<br />\r\n<br />\r\n<b>Other ideas</b>\r\n<br />\r\n</div>\r\n<div align=\"left\">\r\nWe have some ideas of things we\'d like to see done, but are not sufficient for a GSoC project on their own. These could be included with other ideas to make sufficient scope for a GSoc project. These tasks  include:\r\n<br />\r\n<br />\r\n</div>\r\n<div align=\"left\">\r\n* If documentation is your delight we would love to have someone build on the \r\nexisting material and generate lucid new docs on How to integrate YAFFS, How it \r\nworks, YDI Interface details, and anything else your training or experience \r\nmakes clear our users would benefit from.\r\n</div>\r\n<div align=\"left\">\r\n* Develop developer-support tools such as unyaffs: a tool to take a yaffs image and unpack the files on the host device. <br>\r\n*Improve/rewrite mkyaffsimage and related mtdutils to make image  generation and extraction easier to do.\r\n<p>\r\n&nbsp;\r\n</p>\r\n</div>\r\n<div align=\"left\">\r\nGot some ideas of you own? Give us a yell!\r\n</div>\r\n</div>\r\n</div>\r\n</div>\r\n</div>\r\n','This describes YAFFS subject areas that need work done, in order to get the attention of those involved in Google\'s Summer of Code','obsolete_tinymce'),('page',0,369,370,'und',0,'<p>version 2.0</p><p>Last changed: rrw@kynesim.co.uk, 2009-03-20<br>&nbsp;</p><h3>Purpose</h3><p>The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.</p><p>Before we start you probably want to have the data sheet for the NAND chips you are using in front you so that you can refer to it as we go along.</p><h3>Background and NAND Flash Properties</h3><p>NAND flash is generally arranged in <em>pages</em> and <em>blocks</em>. A page contains a section of data bytes and then a section of out-of-band (<em>OOB</em>) data bytes. Blocks contain a number of pages .<br><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram\" class=\"image _original\" height=\"335\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_2de490f8.png\" title=\"YAFFS porting guide diagram\" width=\"783\"></a></p><p>The OOB section of each page is used keep track of various things like file system state, error correction data and bad block marking.</p><p>NAND flash is programmed (written to) and read on a largely page basis (though with some level of random access) and is erased on a block basis. That is, to erase a page, you must erase the rest of the containing block along with it.</p><p>When programming NAND flash only 1\'s can be programmed to 0\'s, so to change a byte containing 0x00 to 0xFF it must be erased, along with the rest of the block. However subsequent programs may still be made without an erase if no 0s are to be changed to 1s, this might be useful in a scenario where subsequent data might regularly have this property.</p><p>When manufactured NAND flash contains bad blocks, these are blocks that are not reliable and any data in them will commonly corrupt easily. These must be kept track of and the OOB data section is used to mark a bad block.</p><p>NAND in general is prone to bit errors and for that reason the OOB data is also used to write error correction codes (ECC) so that some errors can be corrected.</p><h3>Yaffs NAND Model</h3><p>It is probably a good thing to detail at this point how Yaffs2 expects the NAND to behave so that you are aware of what you have to provide in the NAND driver to get YAFF running. Yaffs uses some different terminology in that it refers to a page as a <em>chunk</em>.</p><p>Yaffs2 uses a fairly abstract model for NAND flash, this allows a lot of flexibility in the way Yaffs can be used. Yaffs is designed for NAND flash and makes the following assumptions and definitions:</p><ul><li>NAND flash is arranged in blocks. Each block is the same size and comprises an integer number of chunks. Each block is treated as a single erasable item.</li><li>A page (chunk) equates to the allocation units of flash.</li><li>All accesses (reads and writes) are page (chunk) aligned.</li><li>When programming a NAND flash, only the zero bits in the pattern being programmed are relevant, and one bits are \"don\'t care\". For example, if a byte already contains the binary pattern 1010, then programming 1001 will result in the pattern which is the logical AND of these two patterns i.e. 1000. This is different to NOR flash.</li></ul><p>Yaffs identifies blocks by their block number and chunks by their chunk Id. Yaffs treats a blank (0xFF filled) block as being free or erased. Thus, the equivalent of formatting for a Yaffs partition is to erase all the blocks that are not bad.</p><p>Therefore Yaffs minimally needs access to functions that enable it to erase blocks and to read and write on a page basis. It is also helpful to be able to read only OOB data as reading/writing a full page to only view/update OOB data will cost many serial read cycles over the bus. This is an overhead that can be avoided using the random access read and write features of some nand chips.</p><p>&nbsp;</p><h2>Writing a Driver for NAND flash Chips</h2><h3>Writing a Driver for the Samsung 628 K9F2G08U0M PCB0 on the Balloon Board (v3.01)</h3><p>For the Balloon board the NAND chips hang off the CPLD which is in turn hooked up to the system bus. This is quite board specific and in this case reading the VHDL code reveals how to change the values on the pins of the NAND chips. You may look at the code by downloading the balloon source code (Appendix A) and looking at balloon3.vhd and Balloon_nand.vhd in balloon/vhdl/fpga/.</p><p>It will be likely that this is significantly different on your platform and you should consult the relevant data sheets and documentation to determine how to access the NAND hardware on your board. I will present an example of the balloon board in order to give an overview of the kind of thing that is required.</p><p>On the Balloon the CPLD routes data on the bus with certain address to the logic on the CPLD that actually controls the flash chips. They are as follows:</p><p><code>NAND Data Bus : 0x10e00000</code> <code>NAND Control 2: 0x10e00010</code> <code>NAND Control : 0x10e00014</code></p><p>Sending data to the \'NAND Data Bus\' address will put that data onto the I/O pins of the NAND chips. All of the nand chips are hooked up to the same pins on the CPLD so writing to the \'NAND Data Bus\' address will put the value written on the I/O pins for <em>all</em> of the available flash chips. To isolate the chip you want to work with using the chip enable pin on each flash chip.</p><p>This is done by writing to the \'NAND Control\' (0x10e00014) address. When writing to \'NAND control\', the CPLD takes the data value on the bus and routes each bit to a different wire. This bit field is structured as follows:</p><p>&nbsp;</p><table border=\"1\" bordercolor=\"#000000\" cellpadding=\"4\" cellspacing=\"0\" width=\"643\"><colgroup><col width=\"312\"><col width=\"313\"></colgroup><tbody><tr valign=\"TOP\"><td bgcolor=\"#e6e6ff\" width=\"312\"><em>Pin Attached To</em></td><td bgcolor=\"#e6e6ff\" width=\"313\"><em>Bit in NAND Control value</em></td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">CLE (Control Latch Enable)</td><td bgcolor=\"#e6e6e6\" width=\"313\">0</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">ALE (Address Latch Enable)</td><td bgcolor=\"#e6e6e6\" width=\"313\">1</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nCE0 (not Chip Enable for chip 0)</td><td bgcolor=\"#e6e6e6\" width=\"313\">2</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nCE1 (for chip 1)</td><td bgcolor=\"#e6e6e6\" width=\"313\">3</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nCE2 (for chip 2)</td><td bgcolor=\"#e6e6e6\" width=\"313\">4</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nCE3 (for chip 3)</td><td bgcolor=\"#e6e6e6\" width=\"313\">5</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nSE (not Chip Enable for chip 0)</td><td bgcolor=\"#e6e6e6\" width=\"313\">6</td></tr><tr valign=\"TOP\"><td bgcolor=\"#e6e6e6\" width=\"312\">nWP (not Write Protect)</td><td bgcolor=\"#e6e6e6\" width=\"313\">7</td></tr></tbody></table><br><p>So for example bit 1 on the data lines is put onto the ALE pin on the physical chip. Bits prefixed with \'n\' are active low, for example chip 0 is selected when nCE0 is low and nCE1-3 are high.</p><p>So writing to \'NAND Control\' we can change the values of the pins on the flash. Again, CLE, ALE, nSE and nWP change the value of the corresponding pin on all the flash chips available, nCE[0-3] will select the chip you are using.</p><p>Finally, NAND flash typically comes in couple of flavours, 8 bit wide (x8) and 16 bit wide (x16). This means that x8 chips have 8 I/O pins and x16 have 16. The logic on the CPLD on the Balloon can handle both if you tell it which you are currently dealing with. Writing to \'NAND Control 2\' a value of 1 puts the CPLD logic for the NAND chips into x8 mode and 0 into x16 mode. I will assume for the rest of this document that there are only x8 chips connected to the balloon but it should be fairly trivial to extend it to support both.</p><h3>Using the Flash Chips</h3><p>The flash chips we\'re using have a number of commands, each triggered by a sequence of one or two command codes. You will want to refer to the data sheets for precise details of these functions, but I will briefly describe some of them in this document. The command set that we have for the particular chip we\'re using is table 1 on page 7 of the data sheet.</p><p>To input a command there is generally one or two command input cycles. For two cycle commands there is generally an initial command followed by some data needed to complete the command then another command cycle to notify that the relevant data has been input and to start execution. For example for read operations the command 0x00 is latched in followed by some address input cycles followed by the command 0x30 to start the operation. With this in mind I will now describe how to input commands, the \'Command Latch Cycle\'.</p><p>Note that for this section I have assumed that the bus is sufficiently slow that the set-up and hold times are not an issue, if you have a fast bus then you may have to wait for a small amount of time (refer to the data sheet) after changing values on the pins (by writing to the correct address) so that set-up and hold times are not violated.</p><h3>Command Latch Cycle</h3><p>For the command latch cycle you need to first select a chip by setting the relevant nCE low and then you need to set the CLE bit high, that means writing to the \'NAND Control\' address. ALE must also be low and should be set at the same time as CLE. It is then a case of putting the command value onto the I/O pins by writing to the \'NAND Data Bus\' address the value of the command you want. This will then latch in the command, afterwards you will need to clear the CLE bit again.</p><p>You will also notice from looking at the data sheet that something needs to be done with the nWE (not <strong>w</strong>rite <strong>e</strong>nable) pin (specifically it should be low while latching in the command), but that I have yet to describe a mechanism for changing its value. This is because it is dealt with by the logic in the CPLD and whenever data is sent to the data address the CPLD will toggle nWE appropriately. (This is also true of nRE (not <strong>r</strong>ead <strong>e</strong>nable) when reading). This process is implemented in the nand_chip_select and the send_command functions (flash.c).</p><h3>Address Latch Cycle and Addressing</h3><p>The process for the Address Latch Cycle is similar to that for command latching (with the sense of ALE and CLE reversed) and can be looked at in the data sheet and is implemented in send_address in flash.c. The addressing is done by row and column. There are 5 address cycles on the flash chips we\'re looking at. The first cycle contains bits 0-7 of the column address, the second bits 8-11 with the remaining bits of the byte to be sent low. The row address is over 3 more cycles in a similar fashion.</p><p>You may wish to chose to address the individual bytes of the chip with the OOB data not directly addressable. This has enabled me to lump several chips into the same address space and select the correct chip based on the address. Addresses then need to be converted to row and column. You should also check that they are page/block aligned in the relevant places if that\'s what your functions expect. It needn\'t be done this way any you could use page numbers instead of bytes just as easily.</p><p><br><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 2\" class=\"image _original\" height=\"209\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m11b1f893.png\" title=\"YAFFS porting guide diagram 2\" width=\"654\"></a></p><p>&nbsp;</p><p>The \'row\' is essentially the page index and the \'column\' is the index into to that page, so if you wanted to read from the start of page 213 you would send 0 for the column and 213 for the row. Conversely if you wanted just the OOB bytes from the same page you would send a column value of 2048 (given a page size of 2048+64 bytes).</p><p><br><a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 3\" class=\"image _original\" height=\"271\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m4650262f.png\" title=\"YAFFS porting guide diagram 3\" width=\"347\"></a></p><p>&nbsp;</p><h3>Finding Chip information</h3><p>You will then need to find out which chips are active (e.g. on the balloon there are 4 possible chips, not all of which will exist) and what type of chips they are. For this there is the \'Read ID\' operation. This operation is implemented in the read_ids function in flash.c. The result of the operation gives the manufacturer and device code of the chip and information about the chip (page size, block size, oob size etc). To find which chips are available, loop through the possible chips and start a Read ID command on each of them, if the expected data is returned then there is a chip at that location.</p><p>The operation is started by sending the command 0x90 and then one address cycle of 0x00. There are then 5 read cycles which give you data about the device. A description of how to unpack this information from the returned bytes is located on page 32 of the data sheet for the chip described here.</p><p>This then gives you how many chips you have and what layout the data in them has.</p><h3>Bad Block Checking</h3><p>Contained within a nand chip are blocks that the manufacturer will not guarantee the reliability of (this is to increase yield in manufacturing) and so bad blocks must be kept track of. The Samsung chips come with the first byte (or word for x16) of the first and second page of each bad block not programmed as 0xFF.</p><p>This bad block marking should be maintained and should be added to in the same way when a bad block is is discovered. Yaffs will expect you to provide a function it can call to mark a particular block as bad when yaffs decides it is necessary.</p><p>Yaffs keeps track of bad blocks itself so that the driver doesn\'t need to worry about masking out bad blocks.</p><h3>Erasing a Block</h3><p>An example of this operation is given in nand_erase_block in flash.c. If you are addressing the nand by bytes then you must first check that the address is aligned to the start of a block and then convert the address into a block number. If there is more than one chip this will involve working out which chip the address refers to and then selecting the correct chip. This can be seen in the select_chip function in flash.c. You must then send the first command cycle for the erase operation before sending 3 cycles of address and then finally the last command cycle.</p><p>For the erase operation the 3 address cycles are different than for the read/write operations. Only address bits A18 to A29 is valid (for x8) while A12 to A17 is ignored. In terms of the ordinary 5 cycles address input you only need to deal with the last 3 cycles and of those only the highest 2 bits of the 3<sup>rd</sup> cycle are used and the full 4<sup>th</sup> and 5<sup>th</sup> cycle are used.</p><p>Once the operation has been started the program can check the progress of the operation by sending a command of 70h. Each subsequent read will contain the read status. The driver should wait until the read is complete (by the read status operation), the read status operation also contains information about whether the erase failed and this information should be returned from the function doing the erase.</p><h3>Reading a Page</h3><p>Reading a page is performed by first selecting the correct chip and then converting the address to a row and column number. You can then sending the first command cycle for the read operation followed by 5 address cycles as described in the previous sections. The second command cycle then starts the read operation. The driver must then wait for the data to be retrieved into the data registers on the NAND before they can be read out over the bus. For the example chip this is 25us, consult the data sheet as this may differ. The data can then be read out sequentially byte by byte until all the data needed is obtained.</p><h3>Writing a Page</h3><p>Page program operations are performed by first selecting the correct chip converting the address to row and column numbers. The page program operation is initiated by the relevant fist command latch cycle (command 0x80) followed by an address latch cycle (as for read), serial data loading and then the second command latch cycle (command 0x10).</p><p>The serial data loading is done by serially writing data to the I/O pins. Up to 2112 bytes (x8) can be loaded into the data registers. Once the second command cycle is sent the program is initiated and there is then a programming period where the loaded data is programmed into the appropriate cell. The driver should wait for this to complete by issuing a read status command (0x70) and monitoring the R/nB (ready / not busy) bit. The R/nB flag is on I/O pin 6 and can be checked by repeatedly reading from the \'NAND Data Bus\' address. Once the operation is complete the Write Status Bit (I/O 0 ) may be checked to confirm that the operation was successful.</p><h2>Yaffs</h2><h3>How To Use Yaffs</h3><h3>Checking Out From Git</h3><p>The first thing to do is to obtain the source code for Yaffs. This can be done from CVS, details of the process can be found at <a href=\"http://www.yaffs.net/download-yaffs-using-git\">http://www.yaffs.net/download-yaffs-using-git</a>.</p><p>The following command will checkout the latest Git version using public read-only access, if you are using bash.</p><p><code>$&nbsp;</code>git clone git://www.aleph1.co.uk/yaffs2&nbsp;</p><h3>Making Some Tweaks to the Source Code</h3><p>As of the latest version from CVS in January 2009, you will need to make a small number of changes before you can compile the source code without errors and warnings. There is a patch file included with this document.</p><p>You will need to provide a definition of loff_t (in yaffs2/direct/ydirectenv.h) this is for holding the file size in bytes, you should make it big enough to hold the largest file size you wish to support. Unsigned long is probably a good place to start. You will need to edit yaffsfs.c to change a #if to a #ifdef. Then if you have the relevant warnings and -Werror switched on you will need to correct a couple of printf format strings to get the type right (changing a few \'%d\' to \'%ld\').</p><p><code>change yaffs/ydirectenv.h </code></p><p><code>+ typedef unsigned long loff_t; </code></p><p><code>change yaffs2/direct/yaffsfs.c ~line 1117 </code></p><p><code>- #if CONFIG_YAFFS_WINCE </code></p><p><code>+ #ifdef CONFIG_YAFFS_WINCE</code></p><h3>Relevant Files to the Direct Interface</h3><p>There are quite a few files that get checked out, not all of which you will need to get going with the yaffs direct interface. The ones you will actually need are listed bellow, you do not need to compile the rest in.</p><p><code><code>direct/yaffsfs.c </code></code></p><p><code><code>yaffs_guts.c </code></code></p><p><code><code>direct/yaffscfg.c </code></code></p><p><code><code>yaffs_nand.c </code></code></p><p><code><code>yaffs_tagsvalidity.c </code></code></p><p><code><code>yaffs_checkptrw.c </code></code></p><p><code><code>yaffs_qsort.c </code></code></p><p><code><code>yaffs_tagscompat.c </code></code></p><p><code><code>yaffs_ecc.c </code></code></p><p><code><code>yaffs_packedtags2.c</code></code></p><h3>Some Relevant Preprocessor Flags</h3><p>There are many different configuration options for yaffs, here are a few that you should be aware of for using the yaffs direct interface.</p><ul><li>CONFIG_YAFFS_DIRECT - Tell yaffs to use the direct interface.</li><li>CONFIG_YAFFS_YAFFS2 - Tell yaffs we want to use yaffs2</li><li>CONFIG_YAFFS_PROVIDE_DEFS - provides some definitions for file types and #includes linux/types.h, linux/fs.h, linux/stat.h (see yaffs2/devextras.h).</li><li>CONFIG_YAFFSFS_PROVIDE_VALUES - This may be used so that you can customise error values and constants like O_RDONLY to match the underlying system values, if itis not defined then it includes errno.h,sys/stat.h and fcntl.h (see yaffs2/direct/yaffsfs.h).</li></ul><p>Specify these options when compiling yaffs, i.e. -DCONFIG_YAFFS_DIRECT etc.</p><h3>Configuring</h3><p>You will then need to provide yaffs with configuration information. This includes details about the nand flash you are using and also tells yaffs which functions to call when when it wants to read/write/erase parts of the flash, these functions will form the bridge between yaffs and the underlying hardware driver. This customisation is done in yaffscfg.h. Within yaffscfg.h you will need to provide a number of operating-system-like functions and a function to initialise yaffs. For example providing functions for malloc and free. Here is a breakdown of those functions that need to be implemented.</p><h3>Operating System Functions</h3><p><code><code>void yaffsfs_SetError(int err); </code> </code></p><p>Report system errors, for example using errno if it exists.</p><p><code><code>void *yaffs_malloc(size_t size);</code> <code>void yaffs_free(void *ptr);</code> </code></p><p>As for the standard malloc and free functions, if they already exist on your system then you can just shim them.</p><p><code><code>void yaffsfs_LocalInitialisation(void);</code> <code>void yaffsfs_Lock(void);</code> <code>void yaffsfs_Unlock(void);</code> </code></p><p>Use yaffsfs_LocalInitalisation to initialise \"Real Time Operating System\" state, if the system is multi-threaded then it should initialise a semaphore/mutex for use by lock and unlock. Lock/unlock should use the semaphore set up in LocalInitialisation to lock yaffs from multi-threaded access.</p><p><code><code>__u32 yaffsfs_CurrentTime(void);</code> </code></p><p>This can be any time increment of use to the system. If this is not required, then it is fine to just use a function that returns zero.</p><h3>Yaffs Startup Function</h3><p><code><code>int yaffs_StartUp(void); </code> </code></p><p><code><code>Return value: YAFFS_OK or YAFFS_FAIL</code> </code></p><p>This functions should be used to provide yaffs with many details about the properties of the underlying nand device. Within this function you will need to set up a \'yaffs_Device\' (yaffs_guts.h) and a \'yaffsfs_DeviceConfiguration\' (direct/yaffscfg.h). How to set up a yaffs device will follow in the next section. Once you have set up the required yaffs_Device structures you should call yaffs_initialise (yaffs_guts.h) with a pointer to a null terminated array of yaffs_DeviceConfiguration structures. A yaffs_DeviceConfiguration structure contains a pointer to a yaffs_Device and the \'mount point\' string (prefix) that that device corresponds to.</p><h3>Yaffs Devices</h3><p>A yaffs device is a logical device that represents part of or a whole physical device. You might think of it as a \'partition\' on the nand. For example, it might cover the whole of the nand device or perhaps only claim half, with another yaffs_Device claiming the other half. It may also be used so that you can use a device other than a flash device (e.g. RAM) for testing purposes.</p><p>A yaffs_Device keeps track of the start and end block, so you may have more than one yaffs_Device corresponding to the same physical device by altering the start and end block of the yaffs device.</p><p>The fields on the yaffs_Device struct that you need to set up yourself are listed below, all other fields are setup automatically by yaffs.</p><p><code><code>int nDataBytesPerChunk</code> </code></p><p>As the name suggests this is the number of bytes per chunk, remembering that in yaffs terminology a page is referred to as a chunk, this is then the number of bytes per page. This is the number of data bytes, that is the number of bytes excluding the OOB byte data. E.g. if a page is 2048byte + 64bytes of OOB then set nDataBytesPerChunk to 2048.</p><p><code><code>int nChunksPerBlock </code> </code></p><p>Straightforwardly the number of chunks (pages on the nand) in each block on the physical nand device. Must be at least 2.</p><p><code><code>int spareBytesPerChunk</code></code><br>This is the size of the spare area, i.e. the number of OOB bytes per chunk (page)<code>. </code></p><p><code><code>int startBlock</code> </code></p><p>The block number (not the address in bytes) on the chip of the first block of this logical yaffs_Device. Beware, yaffs needs the first block to be free so you should not set this to 0, if it is then yaffs will add on one to it itself and also add on one to the end block which could be an issue if you wanted your device to start at block 0 and finish at the last block which might mean yaffs trying to write to a non-existent block.</p><p><code><code>int endBlock</code> </code></p><p>The block number on the chip of the last block for this logical yaffs_Device. If startBlock == 0 then yaffs will use endBlock+1. Must be at least startBlock + nReservedBlocks + 2.</p><p><code><code>int nReservedBlocks</code> </code></p><p>This is then number of erasable blocks that Yaffs must keep in reserve for garbage collection and to cover for block failures. This must be a minimum of 2, but 5 or so is better. If you are using a medium that is not expected to fail (eg. RAM for a RAM disk, or a host file system emulation then 2 is OK).</p><p><code><code>int nShortOpCaches</code> </code></p><p>This configures the number of entries in the Yaffs cache for this device. A value of zero defeats the cache. A value of 10 to 20 is recommended for most systems. Cannon be any bigger than YAFFS_MAX_SHORT_OP_CACHES.</p><p><code><code>int useNANDECC</code> </code></p><p>This is a flag that tells yaffs whether it should be doing ECC calculations or if it should be left to the driver.</p><p><code><code>void *genericDevice</code> </code></p><p>This is a pointer which should point to any data that the underlying nand driver will need to know to write and read from the physical device.</p><p><code><code>int isYaffs2</code> </code></p><p>Are we using Yaffs2? We only deal with Yaffs2 in this document.</p><p><code><code>int inbandTags</code> </code></p><p>Is there an OOB section? If not then this should be true. Only relevant to Yaffs2.</p><p><code><code>_u32 totalBytesPerChunk</code> </code></p><p>Possibly a misleading name, it should be equal to nDataBytesPerChunk not nDataBytesPerChunk + spareBytesPerChunk as the name might suggest. If inbandTags is true then yaffs sets nDataBytesPerChunk such that there is enough space for the data yaffs would normally store in the spare area.</p><p><code><code>write/readChunkWithTagsFromNAND, markNANDBlockBad, queryNANDBlock</code> </code></p><p>These are all pointers to functions that you shall provide to provide Yaffs with a method of writing/reading etc from the NAND.</p><h3>NAND access functions</h3><p>If you are using Yaffs2 you need to provide pointers to functions that Yaffs can call to write and read from the nand. Example implementations of these function can be seen in yaffs_mtdif.c, these are the functions written to do the same job for the linux mtd layer and provides the write and read functions. The following functions return YAFFS_OK on success and YAFFS_FAIL on failure.</p><p><code><code>int (*writeChunkWithTagsToNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, const __u8 * data,</code> <code>const yaffs_ExtendedTags * tags);</code> <code>dev: yaffs_Device to write to.</code> <code>chunkInNAND: Which page to write the chunk to.</code> <code>Data: Pointer to the data to write</code> <code>tags: Unpacked OOB data.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p><p>This function is to write pages (chunks) to the nand. In this function you will probably want to first retrive any useful data that you put in dev-&gt;genericDevice (in the yaffs_StartUp function) and use it to call the function you wrote previously to write data to the nand. For yaffs2 data and tags should never be NULL. chunkInNand is the page number of the page to write to, not an address so it will need converting if that\'s what your underling functions to write to the nand expect.</p><p>You will then need to pack the tags into a yaffs_PackedTags2 structure, this takes out the all relevant details from the yaffs_ExtendedTags tags structure and calculates ECC data on it before placing them in the packedtags2 structure. This structure is the OOB data you will want to write out to the nands spare area.</p><p>How you write these out to the OOB data depends on your architecture, nand chips and therefore how bad block marking is done. If for example the first byte is used for bad block marking then simply writing the tags out after the first byte is acceptable. The ECC data in packed tags only covers error correction and detection for the tags in the OOB data, if you want ECC on the data then you must do that yourself.</p><p>To perform ECC checks to the data bytes you may use the yaffs_ECCCalculate function which calculates ECC data for 256 byte sections of data. This function produces 3 bytes of ECC data per 256 bytes. Therefore for 2048 bytes of data in each page you would need (2048/256) * 3 = 8 * 3 = 24 extra bytes of ECC data. This can be written out after the bad block byte and packed tags data.<br>&nbsp;</p><p><code><code>int (*readChunkWithTagsFromNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, __u8 * data,</code> <code>yaffs_ExtendedTags * tags);</code> <code>dev: The yaffs_Device to read from.</code> <code>chunkInNAND: Which page to read from.</code> <code>Data: Pointer to a buffer to read data to.</code> <code>tags: Pointer to a buffer to unpacked OOB data into.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p><p>This function should do the opposite to the previous function. Firstly, read in the data and OOB bytes. Secondly place the data bytes in the area pointed to by data, then unpack the OOB bytes into into the pointer to tags using yaffs_UnpackTags2.</p><p>Once the tags have been unpacked you should then recalculate the ECC data on the data bytes you just read back, just as you did for the write operation. Then use the recalculated ECC and the ECC data read out of the OOB bytes with yaffs_ECCCorrect to correct the data.</p><p>Depending on the return value from yaffs_ECCCorrect you should set tags-&gt;eccResult to reflect whether anything was corrected or the correction failed. yaffs_UnpackTags2 also sets tags-&gt;eccResult so you should only update it if the result of the data correction is worse than is already there. i.e. if after the tags are unpacked and eccResult is YAFFS_ECC_RESULT_FIXED and ECC correction on the data read back resulted in no errors then you should leave unpackedtags2 and YAFFS_ECC_RESULT_FIXED and not set it to YAFFS_ECC_RESULT_NO_ERROR.</p><p><code><code>int (*markNANDBlockBad) (struct yaffs_DeviceStruct * dev, int blockNo);</code> <code>dev: yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code></code></p><p>This should mark the block bad. This probably means reading the OOB data and changing the relevant byte that marks the bad block, and writing the OOB data back.</p><p><code><code>int (*queryNANDBlock) (struct yaffs_DeviceStruct * dev, int blockNo,</code> <code>yaffs_BlockState * state, __u32 *sequenceNumber);</code> <code>dev: The yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>state: Upon returning this should be set to the relevant state of this particular block.</code> <code>Sequence number: The Sequence number of this block. 0 if the block is unused.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p><p>This should check whether or not the block is valid.</p><p>If the bad block marker is set in the OOB then *state should be set to YAFFS_BLOCK_STATE_DEAD *sequenceNumber set to 0, and return YAFFS_FAIL.</p><p>If the block is not bad then the tags should be unpacked. After the tags are unpacked, and it is found that chunk is used (see tags.chunkUsed) *sequenceNumber should be set to tags.sequenceNumber and *state to YAFFS_BLOCK_STATE_NEEDS_SCANNING, otherwise if the block is not used then *sequenceNumber should be 0 and *state should be set to YAFFS_BLOCK_STATE_EMPTY.</p><h3>Application Interface</h3><p>The yaffs provides a number of functions for applications to interface with it. These are mostly the same as the standard clib open/close etc prefixed with yaffs_ eg yaffs_open. These functions are defined in direct/yaffsfs.h.</p><p>To initialise yaffs so that reading and writing can be done, you must call yaffs mount for each yaffs device you would like to use, e.g. yaffs_mount(\"/boot\"). This could be done at system boot if there is an operating system present so that the application need to worry about this. You will also need to call yaffs_unmount when you have finished so that yaffs may write any state it needs to to disk.</p><p>If there is already an application interface for reading and writing files you may shim the relevant function calls with the related operating system calls.</p><p>E.g. simply doing #define open(path, oflag, mode) yaffs_open(path, oflag, mode)</p><p>Or having something more complex to provide redirection functions if there is more than one file system present.</p><p><code><code>For example: int open(const char *path,...)<br>{<br>//Determine which file system is being used </code> <code>if(it_is_a_yaffs_path(path)) {</code> <code> return yaffs_open(...);<br>} else {<br>// Do something else<br>}<br>}</code></code></p><h2>Appendices</h2><h3>Appendix A - Accessing the Balloon Source Code</h3><p>The latest source code for the balloon board can be checked out from SVN. There is different code for different balloon versions. Details of getting the source and setting up tool chains is decribed in the following page <a href=\"http://www.balloonboard.org/software.html\">http://www.balloonboard.org/software.html</a>. If you just want to take a look at the latest mainline code then the following will give you what you want.</p><p>svn checkout svn://balloonboard.org/balloon/trunk/</p><p>&nbsp;</p>','The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.','filtered_html'),('page',0,369,535,'und',0,'<p>version 2.0</p>\r\n\r\n<p>Last changed: rrw@kynesim.co.uk, 2009-03-20<br />\r\n&nbsp;</p>\r\n\r\n<h3>Purpose</h3>\r\n\r\n<p>The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.</p>\r\n\r\n<p>Before we start you probably want to have the data sheet for the NAND chips you are using in front you so that you can refer to it as we go along.</p>\r\n\r\n<h3>Background and NAND Flash Properties</h3>\r\n\r\n<p>NAND flash is generally arranged in <em>pages</em> and <em>blocks</em>. A page contains a section of data bytes and then a section of out-of-band (<em>OOB</em>) data bytes. Blocks contain a number of pages .<br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram\" height=\"335\" src=\"/sites/yaffs.net/files/images/yaffs_porting_guide_html_2de490f8.png\" width=\"783\" /></a></p>\r\n\r\n<p>The OOB section of each page is used keep track of various things like file system state, error correction data and bad block marking.</p>\r\n\r\n<p>NAND flash is programmed (written to) and read on a largely page basis (though with some level of random access) and is erased on a block basis. That is, to erase a page, you must erase the rest of the containing block along with it.</p>\r\n\r\n<p>When programming NAND flash only 1\'s can be programmed to 0\'s, so to change a byte containing 0x00 to 0xFF it must be erased, along with the rest of the block. However subsequent programs may still be made without an erase if no 0s are to be changed to 1s, this might be useful in a scenario where subsequent data might regularly have this property.</p>\r\n\r\n<p>When manufactured NAND flash contains bad blocks, these are blocks that are not reliable and any data in them will commonly corrupt easily. These must be kept track of and the OOB data section is used to mark a bad block.</p>\r\n\r\n<p>NAND in general is prone to bit errors and for that reason the OOB data is also used to write error correction codes (ECC) so that some errors can be corrected.</p>\r\n\r\n<h3>Yaffs NAND Model</h3>\r\n\r\n<p>It is probably a good thing to detail at this point how Yaffs2 expects the NAND to behave so that you are aware of what you have to provide in the NAND driver to get YAFF running. Yaffs uses some different terminology in that it refers to a page as a <em>chunk</em>.</p>\r\n\r\n<p>Yaffs2 uses a fairly abstract model for NAND flash, this allows a lot of flexibility in the way Yaffs can be used. Yaffs is designed for NAND flash and makes the following assumptions and definitions:</p>\r\n\r\n<ul>\r\n	<li>NAND flash is arranged in blocks. Each block is the same size and comprises an integer number of chunks. Each block is treated as a single erasable item.</li>\r\n	<li>A page (chunk) equates to the allocation units of flash.</li>\r\n	<li>All accesses (reads and writes) are page (chunk) aligned.</li>\r\n	<li>When programming a NAND flash, only the zero bits in the pattern being programmed are relevant, and one bits are \"don\'t care\". For example, if a byte already contains the binary pattern 1010, then programming 1001 will result in the pattern which is the logical AND of these two patterns i.e. 1000. This is different to NOR flash.</li>\r\n</ul>\r\n\r\n<p>Yaffs identifies blocks by their block number and chunks by their chunk Id. Yaffs treats a blank (0xFF filled) block as being free or erased. Thus, the equivalent of formatting for a Yaffs partition is to erase all the blocks that are not bad.</p>\r\n\r\n<p>Therefore Yaffs minimally needs access to functions that enable it to erase blocks and to read and write on a page basis. It is also helpful to be able to read only OOB data as reading/writing a full page to only view/update OOB data will cost many serial read cycles over the bus. This is an overhead that can be avoided using the random access read and write features of some nand chips.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h2>Writing a Driver for NAND flash Chips</h2>\r\n\r\n<h3>Writing a Driver for the Samsung 628 K9F2G08U0M PCB0 on the Balloon Board (v3.01)</h3>\r\n\r\n<p>For the Balloon board the NAND chips hang off the CPLD which is in turn hooked up to the system bus. This is quite board specific and in this case reading the VHDL code reveals how to change the values on the pins of the NAND chips. You may look at the code by downloading the balloon source code (Appendix A) and looking at balloon3.vhd and Balloon_nand.vhd in balloon/vhdl/fpga/.</p>\r\n\r\n<p>It will be likely that this is significantly different on your platform and you should consult the relevant data sheets and documentation to determine how to access the NAND hardware on your board. I will present an example of the balloon board in order to give an overview of the kind of thing that is required.</p>\r\n\r\n<p>On the Balloon the CPLD routes data on the bus with certain address to the logic on the CPLD that actually controls the flash chips. They are as follows:</p>\r\n\r\n<p><code>NAND Data Bus : 0x10e00000</code> <code>NAND Control 2: 0x10e00010</code> <code>NAND Control : 0x10e00014</code></p>\r\n\r\n<p>Sending data to the \'NAND Data Bus\' address will put that data onto the I/O pins of the NAND chips. All of the nand chips are hooked up to the same pins on the CPLD so writing to the \'NAND Data Bus\' address will put the value written on the I/O pins for <em>all</em> of the available flash chips. To isolate the chip you want to work with using the chip enable pin on each flash chip.</p>\r\n\r\n<p>This is done by writing to the \'NAND Control\' (0x10e00014) address. When writing to \'NAND control\', the CPLD takes the data value on the bus and routes each bit to a different wire. This bit field is structured as follows:</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td><em>Pin Attached To</em></td>\r\n			<td><em>Bit in NAND Control value</em></td>\r\n		</tr>\r\n		<tr>\r\n			<td>CLE (Control Latch Enable)</td>\r\n			<td>0</td>\r\n		</tr>\r\n		<tr>\r\n			<td>ALE (Address Latch Enable)</td>\r\n			<td>1</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE0 (not Chip Enable for chip 0)</td>\r\n			<td>2</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE1 (for chip 1)</td>\r\n			<td>3</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE2 (for chip 2)</td>\r\n			<td>4</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE3 (for chip 3)</td>\r\n			<td>5</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nSE (not Chip Enable for chip 0)</td>\r\n			<td>6</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nWP (not Write Protect)</td>\r\n			<td>7</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>So for example bit 1 on the data lines is put onto the ALE pin on the physical chip. Bits prefixed with \'n\' are active low, for example chip 0 is selected when nCE0 is low and nCE1-3 are high.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>So writing to \'NAND Control\' we can change the values of the pins on the flash. Again, CLE, ALE, nSE and nWP change the value of the corresponding pin on all the flash chips available, nCE[0-3] will select the chip you are using.</p>\r\n\r\n<p>Finally, NAND flash typically comes in couple of flavours, 8 bit wide (x8) and 16 bit wide (x16). This means that x8 chips have 8 I/O pins and x16 have 16. The logic on the CPLD on the Balloon can handle both if you tell it which you are currently dealing with. Writing to \'NAND Control 2\' a value of 1 puts the CPLD logic for the NAND chips into x8 mode and 0 into x16 mode. I will assume for the rest of this document that there are only x8 chips connected to the balloon but it should be fairly trivial to extend it to support both.</p>\r\n\r\n<h3>Using the Flash Chips</h3>\r\n\r\n<p>The flash chips we\'re using have a number of commands, each triggered by a sequence of one or two command codes. You will want to refer to the data sheets for precise details of these functions, but I will briefly describe some of them in this document. The command set that we have for the particular chip we\'re using is table 1 on page 7 of the data sheet.</p>\r\n\r\n<p>To input a command there is generally one or two command input cycles. For two cycle commands there is generally an initial command followed by some data needed to complete the command then another command cycle to notify that the relevant data has been input and to start execution. For example for read operations the command 0x00 is latched in followed by some address input cycles followed by the command 0x30 to start the operation. With this in mind I will now describe how to input commands, the \'Command Latch Cycle\'.</p>\r\n\r\n<p>Note that for this section I have assumed that the bus is sufficiently slow that the set-up and hold times are not an issue, if you have a fast bus then you may have to wait for a small amount of time (refer to the data sheet) after changing values on the pins (by writing to the correct address) so that set-up and hold times are not violated.</p>\r\n\r\n<h3>Command Latch Cycle</h3>\r\n\r\n<p>For the command latch cycle you need to first select a chip by setting the relevant nCE low and then you need to set the CLE bit high, that means writing to the \'NAND Control\' address. ALE must also be low and should be set at the same time as CLE. It is then a case of putting the command value onto the I/O pins by writing to the \'NAND Data Bus\' address the value of the command you want. This will then latch in the command, afterwards you will need to clear the CLE bit again.</p>\r\n\r\n<p>You will also notice from looking at the data sheet that something needs to be done with the nWE (not <strong>w</strong>rite <strong>e</strong>nable) pin (specifically it should be low while latching in the command), but that I have yet to describe a mechanism for changing its value. This is because it is dealt with by the logic in the CPLD and whenever data is sent to the data address the CPLD will toggle nWE appropriately. (This is also true of nRE (not <strong>r</strong>ead <strong>e</strong>nable) when reading). This process is implemented in the nand_chip_select and the send_command functions (flash.c).</p>\r\n\r\n<h3>Address Latch Cycle and Addressing</h3>\r\n\r\n<p>The process for the Address Latch Cycle is similar to that for command latching (with the sense of ALE and CLE reversed) and can be looked at in the data sheet and is implemented in send_address in flash.c. The addressing is done by row and column. There are 5 address cycles on the flash chips we\'re looking at. The first cycle contains bits 0-7 of the column address, the second bits 8-11 with the remaining bits of the byte to be sent low. The row address is over 3 more cycles in a similar fashion.</p>\r\n\r\n<p>You may wish to chose to address the individual bytes of the chip with the OOB data not directly addressable. This has enabled me to lump several chips into the same address space and select the correct chip based on the address. Addresses then need to be converted to row and column. You should also check that they are page/block aligned in the relevant places if that\'s what your functions expect. It needn\'t be done this way any you could use page numbers instead of bytes just as easily.</p>\r\n\r\n<p><br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 2\" height=\"209\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m11b1f893.png\" width=\"654\" /></a></p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>The \'row\' is essentially the page index and the \'column\' is the index into to that page, so if you wanted to read from the start of page 213 you would send 0 for the column and 213 for the row. Conversely if you wanted just the OOB bytes from the same page you would send a column value of 2048 (given a page size of 2048+64 bytes).</p>\r\n\r\n<p><br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 3\" height=\"271\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m4650262f.png\" width=\"347\" /></a></p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>Finding Chip information</h3>\r\n\r\n<p>You will then need to find out which chips are active (e.g. on the balloon there are 4 possible chips, not all of which will exist) and what type of chips they are. For this there is the \'Read ID\' operation. This operation is implemented in the read_ids function in flash.c. The result of the operation gives the manufacturer and device code of the chip and information about the chip (page size, block size, oob size etc). To find which chips are available, loop through the possible chips and start a Read ID command on each of them, if the expected data is returned then there is a chip at that location.</p>\r\n\r\n<p>The operation is started by sending the command 0x90 and then one address cycle of 0x00. There are then 5 read cycles which give you data about the device. A description of how to unpack this information from the returned bytes is located on page 32 of the data sheet for the chip described here.</p>\r\n\r\n<p>This then gives you how many chips you have and what layout the data in them has.</p>\r\n\r\n<h3>Bad Block Checking</h3>\r\n\r\n<p>Contained within a nand chip are blocks that the manufacturer will not guarantee the reliability of (this is to increase yield in manufacturing) and so bad blocks must be kept track of. The Samsung chips come with the first byte (or word for x16) of the first and second page of each bad block not programmed as 0xFF.</p>\r\n\r\n<p>This bad block marking should be maintained and should be added to in the same way when a bad block is is discovered. Yaffs will expect you to provide a function it can call to mark a particular block as bad when yaffs decides it is necessary.</p>\r\n\r\n<p>Yaffs keeps track of bad blocks itself so that the driver doesn\'t need to worry about masking out bad blocks.</p>\r\n\r\n<h3>Erasing a Block</h3>\r\n\r\n<p>An example of this operation is given in nand_erase_block in flash.c. If you are addressing the nand by bytes then you must first check that the address is aligned to the start of a block and then convert the address into a block number. If there is more than one chip this will involve working out which chip the address refers to and then selecting the correct chip. This can be seen in the select_chip function in flash.c. You must then send the first command cycle for the erase operation before sending 3 cycles of address and then finally the last command cycle.</p>\r\n\r\n<p>For the erase operation the 3 address cycles are different than for the read/write operations. Only address bits A18 to A29 is valid (for x8) while A12 to A17 is ignored. In terms of the ordinary 5 cycles address input you only need to deal with the last 3 cycles and of those only the highest 2 bits of the 3rd cycle are used and the full 4th and 5th cycle are used.</p>\r\n\r\n<p>Once the operation has been started the program can check the progress of the operation by sending a command of 70h. Each subsequent read will contain the read status. The driver should wait until the read is complete (by the read status operation), the read status operation also contains information about whether the erase failed and this information should be returned from the function doing the erase.</p>\r\n\r\n<h3>Reading a Page</h3>\r\n\r\n<p>Reading a page is performed by first selecting the correct chip and then converting the address to a row and column number. You can then sending the first command cycle for the read operation followed by 5 address cycles as described in the previous sections. The second command cycle then starts the read operation. The driver must then wait for the data to be retrieved into the data registers on the NAND before they can be read out over the bus. For the example chip this is 25us, consult the data sheet as this may differ. The data can then be read out sequentially byte by byte until all the data needed is obtained.</p>\r\n\r\n<h3>Writing a Page</h3>\r\n\r\n<p>Page program operations are performed by first selecting the correct chip converting the address to row and column numbers. The page program operation is initiated by the relevant fist command latch cycle (command 0x80) followed by an address latch cycle (as for read), serial data loading and then the second command latch cycle (command 0x10).</p>\r\n\r\n<p>The serial data loading is done by serially writing data to the I/O pins. Up to 2112 bytes (x8) can be loaded into the data registers. Once the second command cycle is sent the program is initiated and there is then a programming period where the loaded data is programmed into the appropriate cell. The driver should wait for this to complete by issuing a read status command (0x70) and monitoring the R/nB (ready / not busy) bit. The R/nB flag is on I/O pin 6 and can be checked by repeatedly reading from the \'NAND Data Bus\' address. Once the operation is complete the Write Status Bit (I/O 0 ) may be checked to confirm that the operation was successful.</p>\r\n\r\n<h2>Yaffs</h2>\r\n\r\n<h3>How To Use Yaffs</h3>\r\n\r\n<h3>Checking Out From Git</h3>\r\n\r\n<p>The first thing to do is to obtain the source code for Yaffs. This can be done from CVS, details of the process can be found at <a href=\"http://www.yaffs.net/download-yaffs-using-git\">http://www.yaffs.net/download-yaffs-using-git</a>.</p>\r\n\r\n<p>The following command will checkout the latest Git version using public read-only access, if you are using bash.</p>\r\n\r\n<p><code>$&nbsp;</code>git clone git://www.aleph1.co.uk/yaffs2&nbsp;</p>\r\n\r\n<h3>Making Some Tweaks to the Source Code</h3>\r\n\r\n<p>As of the latest version from CVS in January 2009, you will need to make a small number of changes before you can compile the source code without errors and warnings. There is a patch file included with this document.</p>\r\n\r\n<p>You will need to provide a definition of loff_t (in yaffs2/direct/ydirectenv.h) this is for holding the file size in bytes, you should make it big enough to hold the largest file size you wish to support. Unsigned long is probably a good place to start. You will need to edit yaffsfs.c to change a #if to a #ifdef. Then if you have the relevant warnings and -Werror switched on you will need to correct a couple of printf format strings to get the type right (changing a few \'%d\' to \'%ld\').</p>\r\n\r\n<p><code>change yaffs/ydirectenv.h </code></p>\r\n\r\n<p><code>+ typedef unsigned long loff_t; </code></p>\r\n\r\n<p><code>change yaffs2/direct/yaffsfs.c ~line 1117 </code></p>\r\n\r\n<p><code>- #if CONFIG_YAFFS_WINCE </code></p>\r\n\r\n<p><code>+ #ifdef CONFIG_YAFFS_WINCE</code></p>\r\n\r\n<h3>Relevant Files to the Direct Interface</h3>\r\n\r\n<p>There are quite a few files that get checked out, not all of which you will need to get going with the yaffs direct interface. The ones you will actually need are listed bellow, you do not need to compile the rest in.</p>\r\n\r\n<p><code><code>direct/yaffsfs.c </code></code></p>\r\n\r\n<p><code><code>yaffs_guts.c </code></code></p>\r\n\r\n<p><code><code>direct/yaffscfg.c </code></code></p>\r\n\r\n<p><code><code>yaffs_nand.c </code></code></p>\r\n\r\n<p><code><code>yaffs_tagsvalidity.c </code></code></p>\r\n\r\n<p><code><code>yaffs_checkptrw.c </code></code></p>\r\n\r\n<p><code><code>yaffs_qsort.c </code></code></p>\r\n\r\n<p><code><code>yaffs_tagscompat.c </code></code></p>\r\n\r\n<p><code><code>yaffs_ecc.c </code></code></p>\r\n\r\n<p><code><code>yaffs_packedtags2.c</code></code></p>\r\n\r\n<h3>Some Relevant Preprocessor Flags</h3>\r\n\r\n<p>There are many different configuration options for yaffs, here are a few that you should be aware of for using the yaffs direct interface.</p>\r\n\r\n<ul>\r\n	<li>CONFIG_YAFFS_DIRECT - Tell yaffs to use the direct interface.</li>\r\n	<li>CONFIG_YAFFS_YAFFS2 - Tell yaffs we want to use yaffs2</li>\r\n	<li>CONFIG_YAFFS_PROVIDE_DEFS - provides some definitions for file types and #includes linux/types.h, linux/fs.h, linux/stat.h (see yaffs2/devextras.h).</li>\r\n	<li>CONFIG_YAFFSFS_PROVIDE_VALUES - This may be used so that you can customise error values and constants like O_RDONLY to match the underlying system values, if itis not defined then it includes errno.h,sys/stat.h and fcntl.h (see yaffs2/direct/yaffsfs.h).</li>\r\n</ul>\r\n\r\n<p>Specify these options when compiling yaffs, i.e. -DCONFIG_YAFFS_DIRECT etc.</p>\r\n\r\n<h3>Configuring</h3>\r\n\r\n<p>You will then need to provide yaffs with configuration information. This includes details about the nand flash you are using and also tells yaffs which functions to call when when it wants to read/write/erase parts of the flash, these functions will form the bridge between yaffs and the underlying hardware driver. This customisation is done in yaffscfg.h. Within yaffscfg.h you will need to provide a number of operating-system-like functions and a function to initialise yaffs. For example providing functions for malloc and free. Here is a breakdown of those functions that need to be implemented.</p>\r\n\r\n<h3>Operating System Functions</h3>\r\n\r\n<p><code><code>void yaffsfs_SetError(int err); </code> </code></p>\r\n\r\n<p>Report system errors, for example using errno if it exists.</p>\r\n\r\n<p><code><code>void *yaffs_malloc(size_t size);</code> <code>void yaffs_free(void *ptr);</code> </code></p>\r\n\r\n<p>As for the standard malloc and free functions, if they already exist on your system then you can just shim them.</p>\r\n\r\n<p><code><code>void yaffsfs_LocalInitialisation(void);</code> <code>void yaffsfs_Lock(void);</code> <code>void yaffsfs_Unlock(void);</code> </code></p>\r\n\r\n<p>Use yaffsfs_LocalInitalisation to initialise \"Real Time Operating System\" state, if the system is multi-threaded then it should initialise a semaphore/mutex for use by lock and unlock. Lock/unlock should use the semaphore set up in LocalInitialisation to lock yaffs from multi-threaded access.</p>\r\n\r\n<p><code><code>__u32 yaffsfs_CurrentTime(void);</code> </code></p>\r\n\r\n<p>This can be any time increment of use to the system. If this is not required, then it is fine to just use a function that returns zero.</p>\r\n\r\n<h3>Yaffs Startup Function</h3>\r\n\r\n<p><code><code>int yaffs_StartUp(void); </code> </code></p>\r\n\r\n<p><code><code>Return value: YAFFS_OK or YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This functions should be used to provide yaffs with many details about the properties of the underlying nand device. Within this function you will need to set up a \'yaffs_Device\' (yaffs_guts.h) and a \'yaffsfs_DeviceConfiguration\' (direct/yaffscfg.h). How to set up a yaffs device will follow in the next section. Once you have set up the required yaffs_Device structures you should call yaffs_initialise (yaffs_guts.h) with a pointer to a null terminated array of yaffs_DeviceConfiguration structures. A yaffs_DeviceConfiguration structure contains a pointer to a yaffs_Device and the \'mount point\' string (prefix) that that device corresponds to.</p>\r\n\r\n<h3>Yaffs Devices</h3>\r\n\r\n<p>A yaffs device is a logical device that represents part of or a whole physical device. You might think of it as a \'partition\' on the nand. For example, it might cover the whole of the nand device or perhaps only claim half, with another yaffs_Device claiming the other half. It may also be used so that you can use a device other than a flash device (e.g. RAM) for testing purposes.</p>\r\n\r\n<p>A yaffs_Device keeps track of the start and end block, so you may have more than one yaffs_Device corresponding to the same physical device by altering the start and end block of the yaffs device.</p>\r\n\r\n<p>The fields on the yaffs_Device struct that you need to set up yourself are listed below, all other fields are setup automatically by yaffs.</p>\r\n\r\n<p><code><code>int nDataBytesPerChunk</code> </code></p>\r\n\r\n<p>As the name suggests this is the number of bytes per chunk, remembering that in yaffs terminology a page is referred to as a chunk, this is then the number of bytes per page. This is the number of data bytes, that is the number of bytes excluding the OOB byte data. E.g. if a page is 2048byte + 64bytes of OOB then set nDataBytesPerChunk to 2048.</p>\r\n\r\n<p><code><code>int nChunksPerBlock </code> </code></p>\r\n\r\n<p>Straightforwardly the number of chunks (pages on the nand) in each block on the physical nand device. Must be at least 2.</p>\r\n\r\n<p><code><code>int spareBytesPerChunk</code></code><br />\r\nThis is the size of the spare area, i.e. the number of OOB bytes per chunk (page)<code>. </code></p>\r\n\r\n<p><code><code>int startBlock</code> </code></p>\r\n\r\n<p>The block number (not the address in bytes) on the chip of the first block of this logical yaffs_Device. Beware, yaffs needs the first block to be free so you should not set this to 0, if it is then yaffs will add on one to it itself and also add on one to the end block which could be an issue if you wanted your device to start at block 0 and finish at the last block which might mean yaffs trying to write to a non-existent block.</p>\r\n\r\n<p><code><code>int endBlock</code> </code></p>\r\n\r\n<p>The block number on the chip of the last block for this logical yaffs_Device. If startBlock == 0 then yaffs will use endBlock+1. Must be at least startBlock + nReservedBlocks + 2.</p>\r\n\r\n<p><code><code>int nReservedBlocks</code> </code></p>\r\n\r\n<p>This is then number of erasable blocks that Yaffs must keep in reserve for garbage collection and to cover for block failures. This must be a minimum of 2, but 5 or so is better. If you are using a medium that is not expected to fail (eg. RAM for a RAM disk, or a host file system emulation then 2 is OK).</p>\r\n\r\n<p><code><code>int nShortOpCaches</code> </code></p>\r\n\r\n<p>This configures the number of entries in the Yaffs cache for this device. A value of zero defeats the cache. A value of 10 to 20 is recommended for most systems. Cannon be any bigger than YAFFS_MAX_SHORT_OP_CACHES.</p>\r\n\r\n<p><code><code>int useNANDECC</code> </code></p>\r\n\r\n<p>This is a flag that tells yaffs whether it should be doing ECC calculations or if it should be left to the driver.</p>\r\n\r\n<p><code><code>void *genericDevice</code> </code></p>\r\n\r\n<p>This is a pointer which should point to any data that the underlying nand driver will need to know to write and read from the physical device.</p>\r\n\r\n<p><code><code>int isYaffs2</code> </code></p>\r\n\r\n<p>Are we using Yaffs2? We only deal with Yaffs2 in this document.</p>\r\n\r\n<p><code><code>int inbandTags</code> </code></p>\r\n\r\n<p>Is there an OOB section? If not then this should be true. Only relevant to Yaffs2.</p>\r\n\r\n<p><code><code>_u32 totalBytesPerChunk</code> </code></p>\r\n\r\n<p>Possibly a misleading name, it should be equal to nDataBytesPerChunk not nDataBytesPerChunk + spareBytesPerChunk as the name might suggest. If inbandTags is true then yaffs sets nDataBytesPerChunk such that there is enough space for the data yaffs would normally store in the spare area.</p>\r\n\r\n<p><code><code>write/readChunkWithTagsFromNAND, markNANDBlockBad, queryNANDBlock</code> </code></p>\r\n\r\n<p>These are all pointers to functions that you shall provide to provide Yaffs with a method of writing/reading etc from the NAND.</p>\r\n\r\n<h3>NAND access functions</h3>\r\n\r\n<p>If you are using Yaffs2 you need to provide pointers to functions that Yaffs can call to write and read from the nand. Example implementations of these function can be seen in yaffs_mtdif.c, these are the functions written to do the same job for the linux mtd layer and provides the write and read functions. The following functions return YAFFS_OK on success and YAFFS_FAIL on failure.</p>\r\n\r\n<p><code><code>int (*writeChunkWithTagsToNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, const __u8 * data,</code> <code>const yaffs_ExtendedTags * tags);</code> <code>dev: yaffs_Device to write to.</code> <code>chunkInNAND: Which page to write the chunk to.</code> <code>Data: Pointer to the data to write</code> <code>tags: Unpacked OOB data.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This function is to write pages (chunks) to the nand. In this function you will probably want to first retrive any useful data that you put in dev-&gt;genericDevice (in the yaffs_StartUp function) and use it to call the function you wrote previously to write data to the nand. For yaffs2 data and tags should never be NULL. chunkInNand is the page number of the page to write to, not an address so it will need converting if that\'s what your underling functions to write to the nand expect.</p>\r\n\r\n<p>You will then need to pack the tags into a yaffs_PackedTags2 structure, this takes out the all relevant details from the yaffs_ExtendedTags tags structure and calculates ECC data on it before placing them in the packedtags2 structure. This structure is the OOB data you will want to write out to the nands spare area.</p>\r\n\r\n<p>How you write these out to the OOB data depends on your architecture, nand chips and therefore how bad block marking is done. If for example the first byte is used for bad block marking then simply writing the tags out after the first byte is acceptable. The ECC data in packed tags only covers error correction and detection for the tags in the OOB data, if you want ECC on the data then you must do that yourself.</p>\r\n\r\n<p>To perform ECC checks to the data bytes you may use the yaffs_ECCCalculate function which calculates ECC data for 256 byte sections of data. This function produces 3 bytes of ECC data per 256 bytes. Therefore for 2048 bytes of data in each page you would need (2048/256) * 3 = 8 * 3 = 24 extra bytes of ECC data. This can be written out after the bad block byte and packed tags data.<br />\r\n&nbsp;</p>\r\n\r\n<p><code><code>int (*readChunkWithTagsFromNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, __u8 * data,</code> <code>yaffs_ExtendedTags * tags);</code> <code>dev: The yaffs_Device to read from.</code> <code>chunkInNAND: Which page to read from.</code> <code>Data: Pointer to a buffer to read data to.</code> <code>tags: Pointer to a buffer to unpacked OOB data into.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This function should do the opposite to the previous function. Firstly, read in the data and OOB bytes. Secondly place the data bytes in the area pointed to by data, then unpack the OOB bytes into into the pointer to tags using yaffs_UnpackTags2.</p>\r\n\r\n<p>Once the tags have been unpacked you should then recalculate the ECC data on the data bytes you just read back, just as you did for the write operation. Then use the recalculated ECC and the ECC data read out of the OOB bytes with yaffs_ECCCorrect to correct the data.</p>\r\n\r\n<p>Depending on the return value from yaffs_ECCCorrect you should set tags-&gt;eccResult to reflect whether anything was corrected or the correction failed. yaffs_UnpackTags2 also sets tags-&gt;eccResult so you should only update it if the result of the data correction is worse than is already there. i.e. if after the tags are unpacked and eccResult is YAFFS_ECC_RESULT_FIXED and ECC correction on the data read back resulted in no errors then you should leave unpackedtags2 and YAFFS_ECC_RESULT_FIXED and not set it to YAFFS_ECC_RESULT_NO_ERROR.</p>\r\n\r\n<p><code><code>int (*markNANDBlockBad) (struct yaffs_DeviceStruct * dev, int blockNo);</code> <code>dev: yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code></code></p>\r\n\r\n<p>This should mark the block bad. This probably means reading the OOB data and changing the relevant byte that marks the bad block, and writing the OOB data back.</p>\r\n\r\n<p><code><code>int (*queryNANDBlock) (struct yaffs_DeviceStruct * dev, int blockNo,</code> <code>yaffs_BlockState * state, __u32 *sequenceNumber);</code> <code>dev: The yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>state: Upon returning this should be set to the relevant state of this particular block.</code> <code>Sequence number: The Sequence number of this block. 0 if the block is unused.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This should check whether or not the block is valid.</p>\r\n\r\n<p>If the bad block marker is set in the OOB then *state should be set to YAFFS_BLOCK_STATE_DEAD *sequenceNumber set to 0, and return YAFFS_FAIL.</p>\r\n\r\n<p>If the block is not bad then the tags should be unpacked. After the tags are unpacked, and it is found that chunk is used (see tags.chunkUsed) *sequenceNumber should be set to tags.sequenceNumber and *state to YAFFS_BLOCK_STATE_NEEDS_SCANNING, otherwise if the block is not used then *sequenceNumber should be 0 and *state should be set to YAFFS_BLOCK_STATE_EMPTY.</p>\r\n\r\n<h3>Application Interface</h3>\r\n\r\n<p>The yaffs provides a number of functions for applications to interface with it. These are mostly the same as the standard clib open/close etc prefixed with yaffs_ eg yaffs_open. These functions are defined in direct/yaffsfs.h.</p>\r\n\r\n<p>To initialise yaffs so that reading and writing can be done, you must call yaffs mount for each yaffs device you would like to use, e.g. yaffs_mount(\"/boot\"). This could be done at system boot if there is an operating system present so that the application need to worry about this. You will also need to call yaffs_unmount when you have finished so that yaffs may write any state it needs to to disk.</p>\r\n\r\n<p>If there is already an application interface for reading and writing files you may shim the relevant function calls with the related operating system calls.</p>\r\n\r\n<p>E.g. simply doing #define open(path, oflag, mode) yaffs_open(path, oflag, mode)</p>\r\n\r\n<p>Or having something more complex to provide redirection functions if there is more than one file system present.</p>\r\n\r\n<p><code><code>For example: int open(const char *path,...)<br />\r\n{<br />\r\n//Determine which file system is being used </code> <code>if(it_is_a_yaffs_path(path)) {</code> <code> return yaffs_open(...);<br />\r\n} else {<br />\r\n// Do something else<br />\r\n}<br />\r\n}</code></code></p>\r\n\r\n<h2>Appendices</h2>\r\n\r\n<h3>Appendix A - Accessing the Balloon Source Code</h3>\r\n\r\n<p>The latest source code for the balloon board can be checked out from SVN. There is different code for different balloon versions. Details of getting the source and setting up tool chains is decribed in the following page <a href=\"http://www.balloonboard.org/software.html\">http://www.balloonboard.org/software.html</a>. If you just want to take a look at the latest mainline code then the following will give you what you want.</p>\r\n\r\n<p>svn checkout svn://balloonboard.org/balloon/trunk/</p>\r\n\r\n<p>&nbsp;</p>\r\n','The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.','filtered_html'),('page',0,369,582,'und',0,'<p>version 2.0</p>\r\n\r\n<p>Last changed: rrw@kynesim.co.uk, 2009-03-20<br />\r\n&nbsp;</p>\r\n\r\n<h3>Purpose</h3>\r\n\r\n<p>The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.</p>\r\n\r\n<p>Before we start you probably want to have the data sheet for the NAND chips you are using in front you so that you can refer to it as we go along.</p>\r\n\r\n<h3>Background and NAND Flash Properties</h3>\r\n\r\n<p>NAND flash is generally arranged in <em>pages</em> and <em>blocks</em>. A page contains a section of data bytes and then a section of out-of-band (<em>OOB</em>) data bytes. Blocks contain a number of pages .<br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram\" height=\"335\" src=\"/sites/yaffs.net/files/images/yaffs_porting_guide_html_2de490f8.png\" width=\"783\" /></a></p>\r\n\r\n<p>The OOB section of each page is used keep track of various things like file system state, error correction data and bad block marking.</p>\r\n\r\n<p>NAND flash is programmed (written to) and read on a largely page basis (though with some level of random access) and is erased on a block basis. That is, to erase a page, you must erase the rest of the containing block along with it.</p>\r\n\r\n<p>When programming NAND flash only 1\'s can be programmed to 0\'s, so to change a byte containing 0x00 to 0xFF it must be erased, along with the rest of the block. However subsequent programs may still be made without an erase if no 0s are to be changed to 1s, this might be useful in a scenario where subsequent data might regularly have this property.</p>\r\n\r\n<p>When manufactured NAND flash contains bad blocks, these are blocks that are not reliable and any data in them will commonly corrupt easily. These must be kept track of and the OOB data section is used to mark a bad block.</p>\r\n\r\n<p>NAND in general is prone to bit errors and for that reason the OOB data is also used to write error correction codes (ECC) so that some errors can be corrected.</p>\r\n\r\n<h3>Yaffs NAND Model</h3>\r\n\r\n<p>It is probably a good thing to detail at this point how Yaffs2 expects the NAND to behave so that you are aware of what you have to provide in the NAND driver to get YAFF running. Yaffs uses some different terminology in that it refers to a page as a <em>chunk</em>.</p>\r\n\r\n<p>Yaffs2 uses a fairly abstract model for NAND flash, this allows a lot of flexibility in the way Yaffs can be used. Yaffs is designed for NAND flash and makes the following assumptions and definitions:</p>\r\n\r\n<ul>\r\n	<li>NAND flash is arranged in blocks. Each block is the same size and comprises an integer number of chunks. Each block is treated as a single erasable item.</li>\r\n	<li>A page (chunk) equates to the allocation units of flash.</li>\r\n	<li>All accesses (reads and writes) are page (chunk) aligned.</li>\r\n	<li>When programming a NAND flash, only the zero bits in the pattern being programmed are relevant, and one bits are \"don\'t care\". For example, if a byte already contains the binary pattern 1010, then programming 1001 will result in the pattern which is the logical AND of these two patterns i.e. 1000. This is different to NOR flash.</li>\r\n</ul>\r\n\r\n<p>Yaffs identifies blocks by their block number and chunks by their chunk Id. Yaffs treats a blank (0xFF filled) block as being free or erased. Thus, the equivalent of formatting for a Yaffs partition is to erase all the blocks that are not bad.</p>\r\n\r\n<p>Therefore Yaffs minimally needs access to functions that enable it to erase blocks and to read and write on a page basis. It is also helpful to be able to read only OOB data as reading/writing a full page to only view/update OOB data will cost many serial read cycles over the bus. This is an overhead that can be avoided using the random access read and write features of some nand chips.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h2>Writing a Driver for NAND flash Chips</h2>\r\n\r\n<h3>Writing a Driver for the Samsung 628 K9F2G08U0M PCB0 on the Balloon Board (v3.01)</h3>\r\n\r\n<p>For the Balloon board the NAND chips hang off the CPLD which is in turn hooked up to the system bus. This is quite board specific and in this case reading the VHDL code reveals how to change the values on the pins of the NAND chips. You may look at the code by downloading the balloon source code (Appendix A) and looking at balloon3.vhd and Balloon_nand.vhd in balloon/vhdl/fpga/.</p>\r\n\r\n<p>It will be likely that this is significantly different on your platform and you should consult the relevant data sheets and documentation to determine how to access the NAND hardware on your board. I will present an example of the balloon board in order to give an overview of the kind of thing that is required.</p>\r\n\r\n<p>On the Balloon the CPLD routes data on the bus with certain address to the logic on the CPLD that actually controls the flash chips. They are as follows:</p>\r\n\r\n<p><code>NAND Data Bus : 0x10e00000</code> <code>NAND Control 2: 0x10e00010</code> <code>NAND Control : 0x10e00014</code></p>\r\n\r\n<p>Sending data to the \'NAND Data Bus\' address will put that data onto the I/O pins of the NAND chips. All of the nand chips are hooked up to the same pins on the CPLD so writing to the \'NAND Data Bus\' address will put the value written on the I/O pins for <em>all</em> of the available flash chips. To isolate the chip you want to work with using the chip enable pin on each flash chip.</p>\r\n\r\n<p>This is done by writing to the \'NAND Control\' (0x10e00014) address. When writing to \'NAND control\', the CPLD takes the data value on the bus and routes each bit to a different wire. This bit field is structured as follows:</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td><em>Pin Attached To</em></td>\r\n			<td><em>Bit in NAND Control value</em></td>\r\n		</tr>\r\n		<tr>\r\n			<td>CLE (Control Latch Enable)</td>\r\n			<td>0</td>\r\n		</tr>\r\n		<tr>\r\n			<td>ALE (Address Latch Enable)</td>\r\n			<td>1</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE0 (not Chip Enable for chip 0)</td>\r\n			<td>2</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE1 (for chip 1)</td>\r\n			<td>3</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE2 (for chip 2)</td>\r\n			<td>4</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nCE3 (for chip 3)</td>\r\n			<td>5</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nSE (not Chip Enable for chip 0)</td>\r\n			<td>6</td>\r\n		</tr>\r\n		<tr>\r\n			<td>nWP (not Write Protect)</td>\r\n			<td>7</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>So for example bit 1 on the data lines is put onto the ALE pin on the physical chip. Bits prefixed with \'n\' are active low, for example chip 0 is selected when nCE0 is low and nCE1-3 are high.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>So writing to \'NAND Control\' we can change the values of the pins on the flash. Again, CLE, ALE, nSE and nWP change the value of the corresponding pin on all the flash chips available, nCE[0-3] will select the chip you are using.</p>\r\n\r\n<p>Finally, NAND flash typically comes in couple of flavours, 8 bit wide (x8) and 16 bit wide (x16). This means that x8 chips have 8 I/O pins and x16 have 16. The logic on the CPLD on the Balloon can handle both if you tell it which you are currently dealing with. Writing to \'NAND Control 2\' a value of 1 puts the CPLD logic for the NAND chips into x8 mode and 0 into x16 mode. I will assume for the rest of this document that there are only x8 chips connected to the balloon but it should be fairly trivial to extend it to support both.</p>\r\n\r\n<h3>Using the Flash Chips</h3>\r\n\r\n<p>The flash chips we\'re using have a number of commands, each triggered by a sequence of one or two command codes. You will want to refer to the data sheets for precise details of these functions, but I will briefly describe some of them in this document. The command set that we have for the particular chip we\'re using is table 1 on page 7 of the data sheet.</p>\r\n\r\n<p>To input a command there is generally one or two command input cycles. For two cycle commands there is generally an initial command followed by some data needed to complete the command then another command cycle to notify that the relevant data has been input and to start execution. For example for read operations the command 0x00 is latched in followed by some address input cycles followed by the command 0x30 to start the operation. With this in mind I will now describe how to input commands, the \'Command Latch Cycle\'.</p>\r\n\r\n<p>Note that for this section I have assumed that the bus is sufficiently slow that the set-up and hold times are not an issue, if you have a fast bus then you may have to wait for a small amount of time (refer to the data sheet) after changing values on the pins (by writing to the correct address) so that set-up and hold times are not violated.</p>\r\n\r\n<h3>Command Latch Cycle</h3>\r\n\r\n<p>For the command latch cycle you need to first select a chip by setting the relevant nCE low and then you need to set the CLE bit high, that means writing to the \'NAND Control\' address. ALE must also be low and should be set at the same time as CLE. It is then a case of putting the command value onto the I/O pins by writing to the \'NAND Data Bus\' address the value of the command you want. This will then latch in the command, afterwards you will need to clear the CLE bit again.</p>\r\n\r\n<p>You will also notice from looking at the data sheet that something needs to be done with the nWE (not <strong>w</strong>rite <strong>e</strong>nable) pin (specifically it should be low while latching in the command), but that I have yet to describe a mechanism for changing its value. This is because it is dealt with by the logic in the CPLD and whenever data is sent to the data address the CPLD will toggle nWE appropriately. (This is also true of nRE (not <strong>r</strong>ead <strong>e</strong>nable) when reading). This process is implemented in the nand_chip_select and the send_command functions (flash.c).</p>\r\n\r\n<h3>Address Latch Cycle and Addressing</h3>\r\n\r\n<p>The process for the Address Latch Cycle is similar to that for command latching (with the sense of ALE and CLE reversed) and can be looked at in the data sheet and is implemented in send_address in flash.c. The addressing is done by row and column. There are 5 address cycles on the flash chips we\'re looking at. The first cycle contains bits 0-7 of the column address, the second bits 8-11 with the remaining bits of the byte to be sent low. The row address is over 3 more cycles in a similar fashion.</p>\r\n\r\n<p>You may wish to chose to address the individual bytes of the chip with the OOB data not directly addressable. This has enabled me to lump several chips into the same address space and select the correct chip based on the address. Addresses then need to be converted to row and column. You should also check that they are page/block aligned in the relevant places if that\'s what your functions expect. It needn\'t be done this way any you could use page numbers instead of bytes just as easily.</p>\r\n\r\n<p><br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 2\" height=\"209\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m11b1f893.png\" width=\"654\" /></a></p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>The \'row\' is essentially the page index and the \'column\' is the index into to that page, so if you wanted to read from the start of page 213 you would send 0 for the column and 213 for the row. Conversely if you wanted just the OOB bytes from the same page you would send a column value of 2048 (given a page size of 2048+64 bytes).</p>\r\n\r\n<p><br />\r\n<a href=\"/yaffs-embedded-structure\"><img alt=\"YAFFS porting guide diagram 3\" height=\"271\" src=\"sites/yaffs.net/files/images/yaffs_porting_guide_html_m4650262f.png\" width=\"347\" /></a></p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h3>Finding Chip information</h3>\r\n\r\n<p>You will then need to find out which chips are active (e.g. on the balloon there are 4 possible chips, not all of which will exist) and what type of chips they are. For this there is the \'Read ID\' operation. This operation is implemented in the read_ids function in flash.c. The result of the operation gives the manufacturer and device code of the chip and information about the chip (page size, block size, oob size etc). To find which chips are available, loop through the possible chips and start a Read ID command on each of them, if the expected data is returned then there is a chip at that location.</p>\r\n\r\n<p>The operation is started by sending the command 0x90 and then one address cycle of 0x00. There are then 5 read cycles which give you data about the device. A description of how to unpack this information from the returned bytes is located on page 32 of the data sheet for the chip described here.</p>\r\n\r\n<p>This then gives you how many chips you have and what layout the data in them has.</p>\r\n\r\n<h3>Bad Block Checking</h3>\r\n\r\n<p>Contained within a nand chip are blocks that the manufacturer will not guarantee the reliability of (this is to increase yield in manufacturing) and so bad blocks must be kept track of. The Samsung chips come with the first byte (or word for x16) of the first and second page of each bad block not programmed as 0xFF.</p>\r\n\r\n<p>This bad block marking should be maintained and should be added to in the same way when a bad block is is discovered. Yaffs will expect you to provide a function it can call to mark a particular block as bad when yaffs decides it is necessary.</p>\r\n\r\n<p>Yaffs keeps track of bad blocks itself so that the driver doesn\'t need to worry about masking out bad blocks.</p>\r\n\r\n<h3>Erasing a Block</h3>\r\n\r\n<p>An example of this operation is given in nand_erase_block in flash.c. If you are addressing the nand by bytes then you must first check that the address is aligned to the start of a block and then convert the address into a block number. If there is more than one chip this will involve working out which chip the address refers to and then selecting the correct chip. This can be seen in the select_chip function in flash.c. You must then send the first command cycle for the erase operation before sending 3 cycles of address and then finally the last command cycle.</p>\r\n\r\n<p>For the erase operation the 3 address cycles are different than for the read/write operations. Only address bits A18 to A29 is valid (for x8) while A12 to A17 is ignored. In terms of the ordinary 5 cycles address input you only need to deal with the last 3 cycles and of those only the highest 2 bits of the 3rd cycle are used and the full 4th and 5th cycle are used.</p>\r\n\r\n<p>Once the operation has been started the program can check the progress of the operation by sending a command of 70h. Each subsequent read will contain the read status. The driver should wait until the read is complete (by the read status operation), the read status operation also contains information about whether the erase failed and this information should be returned from the function doing the erase.</p>\r\n\r\n<h3>Reading a Page</h3>\r\n\r\n<p>Reading a page is performed by first selecting the correct chip and then converting the address to a row and column number. You can then sending the first command cycle for the read operation followed by 5 address cycles as described in the previous sections. The second command cycle then starts the read operation. The driver must then wait for the data to be retrieved into the data registers on the NAND before they can be read out over the bus. For the example chip this is 25us, consult the data sheet as this may differ. The data can then be read out sequentially byte by byte until all the data needed is obtained.</p>\r\n\r\n<h3>Writing a Page</h3>\r\n\r\n<p>Page program operations are performed by first selecting the correct chip converting the address to row and column numbers. The page program operation is initiated by the relevant fist command latch cycle (command 0x80) followed by an address latch cycle (as for read), serial data loading and then the second command latch cycle (command 0x10).</p>\r\n\r\n<p>The serial data loading is done by serially writing data to the I/O pins. Up to 2112 bytes (x8) can be loaded into the data registers. Once the second command cycle is sent the program is initiated and there is then a programming period where the loaded data is programmed into the appropriate cell. The driver should wait for this to complete by issuing a read status command (0x70) and monitoring the R/nB (ready / not busy) bit. The R/nB flag is on I/O pin 6 and can be checked by repeatedly reading from the \'NAND Data Bus\' address. Once the operation is complete the Write Status Bit (I/O 0 ) may be checked to confirm that the operation was successful.</p>\r\n\r\n<h2>Yaffs</h2>\r\n\r\n<h3>How To Use Yaffs</h3>\r\n\r\n<h3>Checking Out From Git</h3>\r\n\r\n<p>The first thing to do is to obtain the source code for Yaffs. This can be done from CVS, details of the process can be found at <a href=\"http://www.yaffs.net/download-yaffs-using-git\">http://www.yaffs.net/download-yaffs-using-git</a>.</p>\r\n\r\n<p>The following command will checkout the latest Git version using public read-only access, if you are using bash.</p>\r\n\r\n<p><code>$&nbsp;</code>git clone git://www.aleph1.co.uk/yaffs2&nbsp;</p>\r\n\r\n<h3>Making Some Tweaks to the Source Code</h3>\r\n\r\n<p>As of the latest version from CVS in January 2009, you will need to make a small number of changes before you can compile the source code without errors and warnings. There is a patch file included with this document.</p>\r\n\r\n<p>You will need to provide a definition of loff_t (in yaffs2/direct/ydirectenv.h) this is for holding the file size in bytes, you should make it big enough to hold the largest file size you wish to support. Unsigned long is probably a good place to start. You will need to edit yaffsfs.c to change a #if to a #ifdef. Then if you have the relevant warnings and -Werror switched on you will need to correct a couple of printf format strings to get the type right (changing a few \'%d\' to \'%ld\').</p>\r\n\r\n<p><code>change yaffs/ydirectenv.h </code></p>\r\n\r\n<p><code>+ typedef unsigned long loff_t; </code></p>\r\n\r\n<p><code>change yaffs2/direct/yaffsfs.c ~line 1117 </code></p>\r\n\r\n<p><code>- #if CONFIG_YAFFS_WINCE </code></p>\r\n\r\n<p><code>+ #ifdef CONFIG_YAFFS_WINCE</code></p>\r\n\r\n<h3>Relevant Files to the Direct Interface</h3>\r\n\r\n<p>There are quite a few files that get checked out, not all of which you will need to get going with the yaffs direct interface. The ones you will actually need are listed bellow, you do not need to compile the rest in.</p>\r\n\r\n<p><code><code>direct/yaffsfs.c </code></code></p>\r\n\r\n<p><code><code>yaffs_guts.c </code></code></p>\r\n\r\n<p><code><code>direct/yaffscfg.c </code></code></p>\r\n\r\n<p><code><code>yaffs_nand.c </code></code></p>\r\n\r\n<p><code><code>yaffs_tagsvalidity.c </code></code></p>\r\n\r\n<p><code><code>yaffs_checkptrw.c </code></code></p>\r\n\r\n<p><code><code>yaffs_qsort.c </code></code></p>\r\n\r\n<p><code><code>yaffs_tagscompat.c </code></code></p>\r\n\r\n<p><code><code>yaffs_ecc.c </code></code></p>\r\n\r\n<p><code><code>yaffs_packedtags2.c</code></code></p>\r\n\r\n<h3>Some Relevant Preprocessor Flags</h3>\r\n\r\n<p>There are many different configuration options for yaffs, here are a few that you should be aware of for using the yaffs direct interface.</p>\r\n\r\n<ul>\r\n	<li>CONFIG_YAFFS_DIRECT - Tell yaffs to use the direct interface.</li>\r\n	<li>CONFIG_YAFFS_YAFFS2 - Tell yaffs we want to use yaffs2</li>\r\n	<li>CONFIG_YAFFS_PROVIDE_DEFS - provides some definitions for file types and #includes linux/types.h, linux/fs.h, linux/stat.h (see yaffs2/devextras.h).</li>\r\n	<li>CONFIG_YAFFSFS_PROVIDE_VALUES - This may be used so that you can customise error values and constants like O_RDONLY to match the underlying system values, if itis not defined then it includes errno.h,sys/stat.h and fcntl.h (see yaffs2/direct/yaffsfs.h).</li>\r\n</ul>\r\n\r\n<p>Specify these options when compiling yaffs, i.e. -DCONFIG_YAFFS_DIRECT etc.</p>\r\n\r\n<h3>Configuring</h3>\r\n\r\n<p>You will then need to provide yaffs with configuration information. This includes details about the nand flash you are using and also tells yaffs which functions to call when when it wants to read/write/erase parts of the flash, these functions will form the bridge between yaffs and the underlying hardware driver. This customisation is done in yaffscfg.h. Within yaffscfg.h you will need to provide a number of operating-system-like functions and a function to initialise yaffs. For example providing functions for malloc and free. Here is a breakdown of those functions that need to be implemented.</p>\r\n\r\n<h3>Operating System Functions</h3>\r\n\r\n<p><code><code>void yaffsfs_SetError(int err); </code> </code></p>\r\n\r\n<p>Report system errors, for example using errno if it exists.</p>\r\n\r\n<p><code><code>void *yaffs_malloc(size_t size);</code> <code>void yaffs_free(void *ptr);</code> </code></p>\r\n\r\n<p>As for the standard malloc and free functions, if they already exist on your system then you can just shim them.</p>\r\n\r\n<p><code><code>void yaffsfs_LocalInitialisation(void);</code> <code>void yaffsfs_Lock(void);</code> <code>void yaffsfs_Unlock(void);</code> </code></p>\r\n\r\n<p>Use yaffsfs_LocalInitalisation to initialise \"Real Time Operating System\" state, if the system is multi-threaded then it should initialise a semaphore/mutex for use by lock and unlock. Lock/unlock should use the semaphore set up in LocalInitialisation to lock yaffs from multi-threaded access.</p>\r\n\r\n<p><code><code>__u32 yaffsfs_CurrentTime(void);</code> </code></p>\r\n\r\n<p>This can be any time increment of use to the system. If this is not required, then it is fine to just use a function that returns zero.</p>\r\n\r\n<h3>Yaffs Startup Function</h3>\r\n\r\n<p><code><code>int yaffs_StartUp(void); </code> </code></p>\r\n\r\n<p><code><code>Return value: YAFFS_OK or YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This functions should be used to provide yaffs with many details about the properties of the underlying nand device. Within this function you will need to set up a \'yaffs_Device\' (yaffs_guts.h) and a \'yaffsfs_DeviceConfiguration\' (direct/yaffscfg.h). How to set up a yaffs device will follow in the next section. Once you have set up the required yaffs_Device structures you should call yaffs_initialise (yaffs_guts.h) with a pointer to a null terminated array of yaffs_DeviceConfiguration structures. A yaffs_DeviceConfiguration structure contains a pointer to a yaffs_Device and the \'mount point\' string (prefix) that that device corresponds to.</p>\r\n\r\n<h3>Yaffs Devices</h3>\r\n\r\n<p>A yaffs device is a logical device that represents part of or a whole physical device. You might think of it as a \'partition\' on the nand. For example, it might cover the whole of the nand device or perhaps only claim half, with another yaffs_Device claiming the other half. It may also be used so that you can use a device other than a flash device (e.g. RAM) for testing purposes.</p>\r\n\r\n<p>A yaffs_Device keeps track of the start and end block, so you may have more than one yaffs_Device corresponding to the same physical device by altering the start and end block of the yaffs device.</p>\r\n\r\n<p>The fields on the yaffs_Device struct that you need to set up yourself are listed below, all other fields are setup automatically by yaffs.</p>\r\n\r\n<p><code><code>int nDataBytesPerChunk</code> </code></p>\r\n\r\n<p>As the name suggests this is the number of bytes per chunk, remembering that in yaffs terminology a page is referred to as a chunk, this is then the number of bytes per page. This is the number of data bytes, that is the number of bytes excluding the OOB byte data. E.g. if a page is 2048byte + 64bytes of OOB then set nDataBytesPerChunk to 2048.</p>\r\n\r\n<p><code><code>int nChunksPerBlock </code> </code></p>\r\n\r\n<p>Straightforwardly the number of chunks (pages on the nand) in each block on the physical nand device. Must be at least 2.</p>\r\n\r\n<p><code><code>int spareBytesPerChunk</code></code><br />\r\nThis is the size of the spare area, i.e. the number of OOB bytes per chunk (page)<code>. </code></p>\r\n\r\n<p><code><code>int startBlock</code> </code></p>\r\n\r\n<p>The block number (not the address in bytes) on the chip of the first block of this logical yaffs_Device. Beware, yaffs needs the first block to be free so you should not set this to 0, if it is then yaffs will add on one to it itself and also add on one to the end block which could be an issue if you wanted your device to start at block 0 and finish at the last block which might mean yaffs trying to write to a non-existent block.</p>\r\n\r\n<p><code><code>int endBlock</code> </code></p>\r\n\r\n<p>The block number on the chip of the last block for this logical yaffs_Device. If startBlock == 0 then yaffs will use endBlock+1. Must be at least startBlock + nReservedBlocks + 2.</p>\r\n\r\n<p><code><code>int nReservedBlocks</code> </code></p>\r\n\r\n<p>This is then number of erasable blocks that Yaffs must keep in reserve for garbage collection and to cover for block failures. This must be a minimum of 2, but 5 or so is better. If you are using a medium that is not expected to fail (eg. RAM for a RAM disk, or a host file system emulation then 2 is OK).</p>\r\n\r\n<p><code><code>int nShortOpCaches</code> </code></p>\r\n\r\n<p>This configures the number of entries in the Yaffs cache for this device. A value of zero defeats the cache. A value of 10 to 20 is recommended for most systems. Cannon be any bigger than YAFFS_MAX_SHORT_OP_CACHES.</p>\r\n\r\n<p><code><code>int useNANDECC</code> </code></p>\r\n\r\n<p>This is a flag that tells yaffs whether it should be doing ECC calculations or if it should be left to the driver.</p>\r\n\r\n<p><code><code>void *genericDevice</code> </code></p>\r\n\r\n<p>This is a pointer which should point to any data that the underlying nand driver will need to know to write and read from the physical device.</p>\r\n\r\n<p><code><code>int isYaffs2</code> </code></p>\r\n\r\n<p>Are we using Yaffs2? We only deal with Yaffs2 in this document.</p>\r\n\r\n<p><code><code>int inbandTags</code> </code></p>\r\n\r\n<p>Is there an OOB section? If not then this should be true. Only relevant to Yaffs2.</p>\r\n\r\n<p><code><code>_u32 totalBytesPerChunk</code> </code></p>\r\n\r\n<p>Possibly a misleading name, it should be equal to nDataBytesPerChunk not nDataBytesPerChunk + spareBytesPerChunk as the name might suggest. If inbandTags is true then yaffs sets nDataBytesPerChunk such that there is enough space for the data yaffs would normally store in the spare area.</p>\r\n\r\n<p><code><code>write/readChunkWithTagsFromNAND, markNANDBlockBad, queryNANDBlock</code> </code></p>\r\n\r\n<p>These are all pointers to functions that you shall provide to provide Yaffs with a method of writing/reading etc from the NAND.</p>\r\n\r\n<h3>NAND access functions</h3>\r\n\r\n<p>If you are using Yaffs2 you need to provide pointers to functions that Yaffs can call to write and read from the nand. Example implementations of these function can be seen in yaffs_mtdif.c, these are the functions written to do the same job for the linux mtd layer and provides the write and read functions. The following functions return YAFFS_OK on success and YAFFS_FAIL on failure.</p>\r\n\r\n<p><code><code>int (*writeChunkWithTagsToNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, const __u8 * data,</code> <code>const yaffs_ExtendedTags * tags);</code> <code>dev: yaffs_Device to write to.</code> <code>chunkInNAND: Which page to write the chunk to.</code> <code>Data: Pointer to the data to write</code> <code>tags: Unpacked OOB data.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This function is to write pages (chunks) to the nand. In this function you will probably want to first retrive any useful data that you put in dev-&gt;genericDevice (in the yaffs_StartUp function) and use it to call the function you wrote previously to write data to the nand. For yaffs2 data and tags should never be NULL. chunkInNand is the page number of the page to write to, not an address so it will need converting if that\'s what your underling functions to write to the nand expect.</p>\r\n\r\n<p>You will then need to pack the tags into a yaffs_PackedTags2 structure, this takes out the all relevant details from the yaffs_ExtendedTags tags structure and calculates ECC data on it before placing them in the packedtags2 structure. This structure is the OOB data you will want to write out to the nands spare area.</p>\r\n\r\n<p>How you write these out to the OOB data depends on your architecture, nand chips and therefore how bad block marking is done. If for example the first byte is used for bad block marking then simply writing the tags out after the first byte is acceptable. The ECC data in packed tags only covers error correction and detection for the tags in the OOB data, if you want ECC on the data then you must do that yourself.</p>\r\n\r\n<p>To perform ECC checks to the data bytes you may use the yaffs_ECCCalculate function which calculates ECC data for 256 byte sections of data. This function produces 3 bytes of ECC data per 256 bytes. Therefore for 2048 bytes of data in each page you would need (2048/256) * 3 = 8 * 3 = 24 extra bytes of ECC data. This can be written out after the bad block byte and packed tags data.<br />\r\n&nbsp;</p>\r\n\r\n<p><code><code>int (*readChunkWithTagsFromNAND) (struct yaffs_DeviceStruct * dev,</code> <code>int chunkInNAND, __u8 * data,</code> <code>yaffs_ExtendedTags * tags);</code> <code>dev: The yaffs_Device to read from.</code> <code>chunkInNAND: Which page to read from.</code> <code>Data: Pointer to a buffer to read data to.</code> <code>tags: Pointer to a buffer to unpacked OOB data into.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This function should do the opposite to the previous function. Firstly, read in the data and OOB bytes. Secondly place the data bytes in the area pointed to by data, then unpack the OOB bytes into into the pointer to tags using yaffs_UnpackTags2.</p>\r\n\r\n<p>Once the tags have been unpacked you should then recalculate the ECC data on the data bytes you just read back, just as you did for the write operation. Then use the recalculated ECC and the ECC data read out of the OOB bytes with yaffs_ECCCorrect to correct the data.</p>\r\n\r\n<p>Depending on the return value from yaffs_ECCCorrect you should set tags-&gt;eccResult to reflect whether anything was corrected or the correction failed. yaffs_UnpackTags2 also sets tags-&gt;eccResult so you should only update it if the result of the data correction is worse than is already there. i.e. if after the tags are unpacked and eccResult is YAFFS_ECC_RESULT_FIXED and ECC correction on the data read back resulted in no errors then you should leave unpackedtags2 and YAFFS_ECC_RESULT_FIXED and not set it to YAFFS_ECC_RESULT_NO_ERROR.</p>\r\n\r\n<p><code><code>int (*markNANDBlockBad) (struct yaffs_DeviceStruct * dev, int blockNo);</code> <code>dev: yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code></code></p>\r\n\r\n<p>This should mark the block bad. This probably means reading the OOB data and changing the relevant byte that marks the bad block, and writing the OOB data back.</p>\r\n\r\n<p><code><code>int (*queryNANDBlock) (struct yaffs_DeviceStruct * dev, int blockNo,</code> <code>yaffs_BlockState * state, __u32 *sequenceNumber);</code> <code>dev: The yaffs_Device to write to.</code> <code>blockNo: Which block to mark.</code> <code>state: Upon returning this should be set to the relevant state of this particular block.</code> <code>Sequence number: The Sequence number of this block. 0 if the block is unused.</code> <code>Return: YAFFS_OK / YAFFS_FAIL</code> </code></p>\r\n\r\n<p>This should check whether or not the block is valid.</p>\r\n\r\n<p>If the bad block marker is set in the OOB then *state should be set to YAFFS_BLOCK_STATE_DEAD *sequenceNumber set to 0, and return YAFFS_FAIL.</p>\r\n\r\n<p>If the block is not bad then the tags should be unpacked. After the tags are unpacked, and it is found that chunk is used (see tags.chunkUsed) *sequenceNumber should be set to tags.sequenceNumber and *state to YAFFS_BLOCK_STATE_NEEDS_SCANNING, otherwise if the block is not used then *sequenceNumber should be 0 and *state should be set to YAFFS_BLOCK_STATE_EMPTY.</p>\r\n\r\n<h3>Application Interface</h3>\r\n\r\n<p>The yaffs provides a number of functions for applications to interface with it. These are mostly the same as the standard clib open/close etc prefixed with yaffs_ eg yaffs_open. These functions are defined in direct/yaffsfs.h.</p>\r\n\r\n<p>To initialise yaffs so that reading and writing can be done, you must call yaffs mount for each yaffs device you would like to use, e.g. yaffs_mount(\"/boot\"). This could be done at system boot if there is an operating system present so that the application need to worry about this. You will also need to call yaffs_unmount when you have finished so that yaffs may write any state it needs to to disk.</p>\r\n\r\n<p>If there is already an application interface for reading and writing files you may shim the relevant function calls with the related operating system calls.</p>\r\n\r\n<p>E.g. simply doing #define open(path, oflag, mode) yaffs_open(path, oflag, mode)</p>\r\n\r\n<p>Or having something more complex to provide redirection functions if there is more than one file system present.</p>\r\n\r\n<p><code><code>For example: int open(const char *path,...)<br />\r\n{<br />\r\n//Determine which file system is being used </code> <code>if(it_is_a_yaffs_path(path)) {</code> <code> return yaffs_open(...);<br />\r\n} else {<br />\r\n// Do something else<br />\r\n}<br />\r\n}</code></code></p>\r\n\r\n<h2>Appendices</h2>\r\n\r\n<h3>Appendix A - Accessing the Balloon Source Code</h3>\r\n\r\n<p>The latest source code for the balloon board can be checked out from SVN. There is different code for different balloon versions. Details of getting the source and setting up tool chains is decribed in the following page <a href=\"http://www.balloonboard.org/software.html\">http://www.balloonboard.org/software.html</a>. If you just want to take a look at the latest mainline code then the following will give you what you want.</p>\r\n\r\n<p>svn checkout svn://balloonboard.org/balloon/trunk/</p>\r\n\r\n<p>&nbsp;</p>\r\n','The purpose of this document is to describe how to bring up Yaffs2 on a board previously unsupported using the Yaffs Direct Interface, with an example using eCos on a Balloon board.','basic_html'),('page',0,380,381,'und',0,'<p>We offer support for Yaffs through the <a href=\"http://stoneboat.aleph1.co.uk/mailman/listinfo/yaffs\">Yaffs mailing list</a>. It\'s best to start by searching the <a href=\"http://www.aleph1.co.uk/lurker/list/yaffs.html\">list archive</a> to see if someone has already asked the same question.</p><p>If you feel uncomfortable asking your question on an open mailing list you can try mailing us, but we (or you) may say \'You should be paying for this\', and if that is agreed, then we can accept payments via PayPal or other means.</p><p>Serious long-term work is best done as a negotiated contract; for instance we have built special features for clients with very particular needs. If you think you may want this sort of help then <a href=\"/contact\">contact us</a>, telling us a bit about your problem.</p>','<p>We offer support for Yaffs through the&nbsp;<a href=\"http://stoneboat.aleph1.co.uk/mailman/listinfo/yaffs\">Yaffs mailing list</a>. We also offer paid contracts for longer term needs.</p>','full_html'),('page',0,382,383,'und',0,'<p>Yaffs is available under the GPL licence and under commercial terms.</p><p>For testing and experiment you can grab Yaffs under the GPL free of charge right now&nbsp;<strong><a href=\"/download-yaffs-using-git\">from our GIT repository</a></strong>.</p><p>If you distribute a product using this version of Yaffs, you must release all your linked source code in accordance with the&nbsp;<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GPL</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p><p>Commercial Yaffs licences are non-exclusive, perpetual, world-wide, royalty-free and paid for with a single fee for one product. A commercial licence entitles you to most further development and improvement of the Yaffs code.</p><p>You can find further information about each licence in these documents:</p><ul><li><a href=\"yaffs-gpl\">Yaffs under GPL</a></li><li><a href=\"yaffs-licence-faqs\">Yaffs licensing FAQ&nbsp;</a></li></ul>','<p>For experimental purposes you can grab Yaffs free of charge right now&nbsp;<a href=\"/download-yaffs-using-git\">from our GIT repository</a>.</p><p>If you distribute a product using Yaffs you must release all your linked source code in accordance with the&nbsp;<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GPL</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p>','full_html'),('page',0,382,481,'und',0,'<p>Yaffs is available under the GNU General Public Licence, v.2&nbsp; and under commercial terms.</p><p>For testing and experiment you can grab Yaffs under the GPL free of charge right now&nbsp;<strong><a href=\"/download-yaffs-using-git\">from our GIT repository</a>&nbsp;</strong>and we strongly recommend you also read <strong><a href=\"/documents/how-yaffs-works\">How Yaffs Works</a></strong>.</p><p>The GIT summary page shows <strong>the <a href=\"http://aleph1.co.uk/gitweb?p=yaffs2.git;a=summary\">changes that have been made over time</a> </strong>in the base code.</p><h3 wrap=\"\">LICENSES FOR YAFFS</h3><p wrap=\"\">Yaffs is the property of Aleph One Limited.</p><p wrap=\"\">Yaffs is available free of charge under the terms of the GNU General Public&nbsp;License version 2, GNU GPL2 &nbsp; given at:-&nbsp;<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">http://www.gnu.org/licenses/gpl-2.0.html</a></p><p wrap=\"\">See especially Sections 3.a and 3.b.&nbsp; These and the following sections describe the&nbsp;obligations placed on those who distribute source and/or object code&nbsp;embodying or associated with GPL code, and therefore <strong>apply to all who&nbsp;use Yaffs under GPL</strong>.</p><p wrap=\"\">Linking Yaffs to other software creates a derived work and our&nbsp;interpretation of linking includes dynamic and runtime linking.&nbsp; The&nbsp;derived work has the usual GPL obligation to release source code to&nbsp;anyone who asks. This remains true if you use Yaffs with another, or&nbsp;no, OS.</p><h4 wrap=\"\">Commercial licensing</h4><p wrap=\"\">Aleph One, as owners of Yaffs, sell commercial Licences for the use of Yaffs which&nbsp;do <em>NOT</em> carry the obligations of GPL.</p><p wrap=\"\">Contributing modifications of Yaffs code to the mainline code does not&nbsp;alter its Licence status.</p><p wrap=\"\">Commercial Yaffs licences are non-exclusive, perpetual, world-wide, royalty-free and paid for with a single fee for one product. A commercial Licence entitles you to most further development and improvement of the Yaffs code.</p><p wrap=\"\">The base price for a Licence for a single Product is GB£10,000. Sterling</p><p>You can find further information about Licences in these documents:</p><ul><li><a href=\"yaffs-gpl\">Yaffs under GPL</a></li><li><a href=\"yaffs-licence-faqs\">Yaffs licensing FAQ</a></li><li><a href=\"/licences-more-background-and-detail\">Further licensing background and detail</a></li><li><a href=\"/yaffs-licence-sample\">Sample commercial licence</a></li></ul><p>If you have any questions, or would like to buy a commercial licence, please contact us either at&nbsp;+44 (0)1223 811679 or email&nbsp; sales@aleph1.co.uk&nbsp; or see our Contacts page:-&nbsp; <a href=\"http://www.aleph1.co.uk/contact\">http://www.aleph1.co.uk/contact</a></p>','<p>For experimental purposes you can grab Yaffs free of charge right now&nbsp;<a href=\"/download-yaffs-using-git\">from our GIT repository</a>.</p><p>If you distribute a product using Yaffs you must release all your linked source code in accordance with the <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU General Public Licence</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p>','full_html'),('page',0,382,613,'und',0,'<h2>Licences</h2>\r\n\r\n<p>Yaffs is available under two licences:</p>\r\n\r\n<ul>\r\n	<li>The GPL Version 2 (GNU Public Licence, Version 2). You can try it for free under this licence, and you can use Yaffs&nbsp;in GPL licensed software.&nbsp;</li>\r\n	<li>A proprietary, commercial licence from Aleph One Limited, for use with proprietary, or closed-source software.&nbsp;&nbsp;</li>\r\n</ul>\r\n\r\n<p>Yaffs functionality is the same under both licences, and both licences are royalty-free, but the terms of the GPL place significant obligations on<strong>&nbsp;all who&nbsp;use Yaffs under GPL</strong>. Please be certain to understand these obligations before distributing any software together with Yaffs.<br />\r\n&nbsp;</p>\r\n\r\n<h2>Download options</h2>\r\n\r\n<p>We use Git to manage our software development.</p>\r\n\r\n<ul>\r\n	<li>To browse or download code,&nbsp;<strong><a href=\"http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=summary\" target=\"_self\">access our Git repository over the web</a></strong>. This is also the best option if you are behind a firewall that does not allow direct Git&nbsp;access.</li>\r\n	<li>To get a tarball of the top of the tree, just click \'snapshot\' for the release that you want, or to quickly obtain a snapshot of the top of the tree you can <a href=\"http://aleph1.co.uk/gitweb?p=yaffs2.git;a=snapshot;h=HEAD;\" target=\"_self\">use this URL</a>.</li>\r\n	<li>Clone Yaffs using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone git://www.aleph1.co.uk/yaffs2\r\n</pre>\r\n\r\n<ul>\r\n	<li>If you are a registered developer with a server account you can get read/write access using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2</pre>\r\n\r\n<p>&nbsp;&nbsp;</p>\r\n\r\n<p wrap=\"\">If you have any questions, or would like to buy a commercial licence, please contact us either at&nbsp;+44 (0)1223 811679 or email&nbsp; sales@aleph1.co.uk&nbsp; or see our Contacts page:-&nbsp; <a href=\"http://www.aleph1.co.uk/contact\">http://www.aleph1.co.uk/contact</a></p>\r\n','<p>For experimental purposes you can grab Yaffs free of charge right now&nbsp;<a href=\"/download-yaffs-using-git\">from our GIT repository</a>.</p><p>If you distribute a product using Yaffs you must release all your linked source code in accordance with the <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU General Public Licence</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p>','full_html'),('page',0,382,614,'und',0,'<h2>Licences</h2>\r\n\r\n<p>Yaffs belongs to Aleph One Limited. It&nbsp;is available under two licences:</p>\r\n\r\n<ul>\r\n	<li>The <a href=\"https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html\">GPL Version 2</a> (GNU Public Licence, Version 2). You can try it for free under this licence, and you can use Yaffs&nbsp;in GPL licensed software.&nbsp;</li>\r\n	<li>A proprietary, <a href=\"commercial-licence\">commercial licence</a> from Aleph One Limited, for use with proprietary, or closed-source software.&nbsp;These licences are non-exclusive, perpetual, world-wide, royalty-free and paid for with a single fee for one product.</li>\r\n</ul>\r\n\r\n<p>Yaffs functionality is the same under both licences, and both licences are royalty-free, but the terms of the GPL place significant obligations on<strong>&nbsp;all who&nbsp;use Yaffs under GPL</strong>. Please be certain to <a href=\"/yaffs-gpl\">understand these legal obligations</a> before distributing any software together with Yaffs.</p>\r\n\r\n<h2>Download options</h2>\r\n\r\n<p>We use <a href=\"https://git-scm.com/\">Git</a> to manage our software development.</p>\r\n\r\n<ul>\r\n	<li>To browse or download code,&nbsp;<strong><a href=\"http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=summary\" target=\"_self\">access our Git repository over the web</a></strong>. This is also the best option if you are behind a firewall that does not allow direct Git&nbsp;access.</li>\r\n	<li>To get a tarball of the top of the tree, just click \'snapshot\' for the release that you want, or to quickly obtain a snapshot of the top of the tree you can <a href=\"http://aleph1.co.uk/gitweb?p=yaffs2.git;a=snapshot;h=HEAD;\" target=\"_self\">use this URL</a>.</li>\r\n	<li>Clone Yaffs using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone git://www.aleph1.co.uk/yaffs2\r\n</pre>\r\n\r\n<ul>\r\n	<li>If you are a registered developer with a server account you can get read/write access using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2</pre>\r\n\r\n<p>&nbsp;&nbsp;</p>\r\n\r\n<p wrap=\"\">If you have any questions, or would like to buy a commercial licence, please contact us either at&nbsp;+44 (0)1223 811679 or email&nbsp; sales@aleph1.co.uk&nbsp; or see our Contacts page:-&nbsp; <a href=\"http://www.aleph1.co.uk/contact\">http://www.aleph1.co.uk/contact</a></p>\r\n','<p>For experimental purposes you can grab Yaffs free of charge right now&nbsp;<a href=\"/download-yaffs-using-git\">from our GIT repository</a>.</p><p>If you distribute a product using Yaffs you must release all your linked source code in accordance with the <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU General Public Licence</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p>','full_html'),('page',0,382,639,'und',0,'<h2>Licences</h2>\r\n\r\n<p>Yaffs belongs to Aleph One Limited. It&nbsp;is available under two licences:</p>\r\n\r\n<ul>\r\n	<li>The <a href=\"https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html\">GPL Version 2</a> (GNU Public Licence, Version 2). You can try it for free under this licence, and you can use Yaffs&nbsp;in GPL licensed software.&nbsp;</li>\r\n	<li>A proprietary, <a href=\"commercial-licences\">commercial licence</a> from Aleph One Limited, for use with proprietary, or closed-source software.&nbsp;These licences are non-exclusive, perpetual, world-wide, royalty-free and paid for with a single fee for one product.</li>\r\n</ul>\r\n\r\n<p>Yaffs functionality is the same under both licences, and both licences are royalty-free, but the terms of the GPL place significant obligations on<strong>&nbsp;all who&nbsp;use Yaffs under GPL</strong>. Please be certain to <a href=\"/yaffs-gpl\">understand these legal obligations</a> before distributing any software together with Yaffs.</p>\r\n\r\n<h2>Download options</h2>\r\n\r\n<p>We use <a href=\"https://git-scm.com/\">Git</a> to manage our software development.</p>\r\n\r\n<ul>\r\n	<li>To browse or download code,&nbsp;<strong><a href=\"http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=summary\" target=\"_self\">access our Git repository over the web</a></strong>. This is also the best option if you are behind a firewall that does not allow direct Git&nbsp;access.</li>\r\n	<li>To get a tarball of the top of the tree, just click \'snapshot\' for the release that you want, or to quickly obtain a snapshot of the top of the tree you can <a href=\"http://aleph1.co.uk/gitweb?p=yaffs2.git;a=snapshot;h=HEAD;\" target=\"_self\">use this URL</a>.</li>\r\n	<li>Clone Yaffs using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone git://www.aleph1.co.uk/yaffs2\r\n</pre>\r\n\r\n<ul>\r\n	<li>If you are a registered developer with a server account you can get read/write access using:</li>\r\n</ul>\r\n\r\n<pre>\r\ngit clone ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2</pre>\r\n\r\n<p>&nbsp;&nbsp;</p>\r\n\r\n<p wrap=\"\">If you have any questions, or would like to buy a commercial licence, please contact us either at&nbsp;+44 (0)1223 811679 or email&nbsp; sales@aleph1.co.uk&nbsp; or see our Contacts page:-&nbsp; <a href=\"http://www.aleph1.co.uk/contact\">http://www.aleph1.co.uk/contact</a></p>\r\n','<p>For experimental purposes you can grab Yaffs free of charge right now&nbsp;<a href=\"/download-yaffs-using-git\">from our GIT repository</a>.</p><p>If you distribute a product using Yaffs you must release all your linked source code in accordance with the <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU General Public Licence</a>. Alternatively if you do not wish to disclose your Source Code, commercial licences are available.</p>','full_html'),('what_is_special_about_yaffs',0,384,385,'und',0,'<p><strong>100% ROYALTY FREE</strong></p>\r\n\r\n<p>Of course there\'s no royalty when you use Yaffs under the GPL; it\'s the GPL!</p>\r\n\r\n<p>Our commercial licences are paid for once at the time of buying the Licence, and so they are also royalty free. No accounting and no need to worry about increasing costs as you make or sell more units.</p>\r\n','Whether you use Yaffs under the GNU General Public Licence or under a commercial licence, Yaffs is free of any royalty. No need to worry about rising costs for your hit product!','basic_html'),('what_is_special_about_yaffs',0,385,386,'und',0,'<p>As part of our regular testing, we run power-fail tests. Whether it\'s during a read or a write, Yaffs is designed to preserve your existing data during a device power failure. And because Yaffs is open source, you can download the tests and run them yourself in the most severe conditions you expect the product to encounter. See:- http://www.yaffs.net/documents/yaffs-robustness-and-testing</p>\r\n','After more than 100,000 <strong>random</strong> power-failures during reading or writing, a test file showed NO data corruption at all!','basic_html'),('what_is_special_about_yaffs',0,388,389,'und',0,'<p>Yaffs is downloadable with a GNU General Public Licence v.2, as at&nbsp; http://www.gnu.org/licenses/gpl-2.0.html&nbsp;&nbsp; You get the source code, with all the benefits that brings. And of course, if you buy a commercial licence, you get the source code too, but without the encumberance of your responsibilities under the GNU GPL</p>\r\n\r\n<p>Because it\'s Open Source, you can always see what the code is doing and trace through; and having the code means you\'ll never be in a situation where you are critically dependent on us, either from a technical or a business perspective.</p>\r\n','You can have a look at the code at any time. <a title=\"Get it now!\" href=\"/downloads\">Download it now</a>! And it\'s suitable for GPL and commercially licensed projects.','basic_html'),('what_is_special_about_yaffs',0,389,390,'und',0,'<p>Yaffs is the leading Flash file system, running in millions of devices. It\'s been used on Linux computers, in cameras, mobile phones, hard drives, and on many custom boards. People and companies trust it to keep their data safe. Read more about <a href=\"/documents/yaffs-robustness-and-testing\">how we test Yaffs in our Robustness and Testing white paper</a>.</p>\r\n','Yaffs is widely used in Linux and proprietary commercial RTOSs. It\'s been included in hundreds of devices, and shipped as part of Google\'s Android, with millions of units sold. ','basic_html'),('yaffs_user_logo',0,397,398,'und',0,'<p>Design Electronics use Yaffs</p>\r\n','Design Electronics use Yaffs','basic_html'),('yaffs_user_logo',0,398,399,'und',0,'<p>Eaton use Yaffs</p>\r\n','Eaton use Yaffs','basic_html'),('yaffs_user_logo',0,399,400,'und',0,'<p>Lancom Systems use Yaffs.</p>\r\n','','basic_html'),('yaffs_user_logo',0,400,401,'und',0,'<p>Bernina use Yaffs.</p>\r\n','','basic_html'),('yaffs_user_logo',0,401,402,'und',0,'<p>Used by Gallagher</p>\r\n','Used by Gallagher','basic_html'),('what_is_special_about_yaffs',0,407,408,'und',0,'<p>Being quick to boot was one of the fundamental requirements in Yaffs\' design. Boot-time scanning to build the file structure lists should require just one pass reading NAND memory.</p>\r\n','It is important for a Flash filesystem to boot fast, so boot speed was a fundamental consideration in the design of Yaffs.','basic_html'),('what_is_special_about_yaffs',0,408,409,'und',0,'<p>You can learn from the experience of people and companies who are working with Yaffs. Thousands of developers have used Yaffs successfully, and commercially-licensed Yaffs has many customers that use it repeatedly. Have a look at the mailing list - it\'s a great place to start if you have some questions.<br />\r\n<a href=\"http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs\">http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs</a></p>\r\n\r\n<p>The searchable archive of postings is at <a href=\"http://lists.aleph1.co.uk/lurker/list/yaffs.html\">http://lists.aleph1.co.uk/lurker/list/yaffs.html&nbsp;&nbsp; </a>Or search online to see the variety of work done with Yaffs as its basis - from research papers through to skunkworks projects for testing particular concepts.</p>\r\n','There\'s an active community of people who use Yaffs and who have developed with Yaffs, just a click or two away.','basic_html'),('paper',0,409,410,'und',0,'<p>&nbsp;</p>\r\n\r\n<h2>1 Purpose</h2>\r\n\r\n<p>The purpose of this document is to give a reasonable explanation of most of the core mechanisms that make Yaffs work. As of the time of writing this, the Yaffs2 code base includes approximately 19,000 lines of code making a very detailed discussion impractical.</p>\r\n\r\n<p>This document should serve as a first port of call for understanding Yaffs. Further detailed questions and discussions are welcomed on the Yaffs discussion list.</p>\r\n\r\n<p>This document is updated periodically. Yaffs mechanism design changes from time to time and this document will not always reflect the most up to date code.</p>\r\n\r\n<h2>2 What is Yaffs?</h2>\r\n\r\n<p>Yaffs stands for <em>Yet Another Flash File System</em>, a term coined by Charles Manning in 2001 when suggesting that the already cluttered flash file system space could do with yet another offering – this time a flash file system designed from the ground up to work with NAND flash.</p>\r\n\r\n<p>The first release of Yaffs was developed during the end of 2001 and the beginning of 2002. By mid-2002, Yaffs was being trialled in various products. In May 2002, Yaffs was announced and a few more projects started playing with it. In June, porting to other OSs started. In September 2002, Yaffs was announced on linuxdevices.com which started a far wider uptake of Yaffs.</p>\r\n\r\n<p>Yaffs1, the original version of Yaffs, supported 512-byte page NAND devices with a SmartMedia-like memory layout.</p>\r\n\r\n<p>Yaffs2 is a follow-up to Yaffs1 extending Yaffs1 to support larger and different devices with different constraints.</p>\r\n\r\n<p>Yaffsis highly portable and has been used in many different products and applications as varied as sewing machines, point of sale, phones and aerospace. Yaffs has been used with multiple different operating systems. Native support is available for Linux, WindowsCE and eCOS while Yaffs Direct Interface provides a layer that can be used in other applications such as RTOSs. Yaffs has been used with multiple different CPUs and compilers.</p>\r\n\r\n<p>Yaffs has also been used as a NOR file system and even as a RAM file system.</p>\r\n\r\n<p>3 Design and coding strategies</p>\r\n\r\n<p>Yaffs is designed to work in multiple environments which drives the need for portability. Portability also improves the debugging and testing since it is easier to develop and debug code in an application environment than within an OS kernel. This generally allows Yaffs to progress faster with less programming resources and provides more varied testing. Primary strategies that improve portability include:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>No OS-specific features used in main code body.</p>\r\n	</li>\r\n	<li>\r\n	<p>No compiler-specific features used in the main code body.</p>\r\n	</li>\r\n	<li>\r\n	<p>Abstract types and functions used to allow Unicode or ASCII operation.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Simplicity is another key goal. Complexity is limited to those situations that provide significant improvements to performance or utility. Simplicity improves robustness and the ease of integration and development. Primary strategies that improve simplicity are:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Single threaded model. Yaffs is locked on a per-partition basis at a high level. This is simpler than tracking lower-level locking. Yaffs Direct Interface uses a single lock for all partitions.</p>\r\n	</li>\r\n</ul>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Log structure makes for a simpler garbage collector and allocation methodology.</p>\r\n	</li>\r\n	<li>\r\n	<p>Abstractions that build layered code which is easier to understand, port and debug.</p>\r\n	</li>\r\n</ul>\r\n\r\n<h2>4 Terminology: Yaffs vs Yaffs1 vs Yaffs2</h2>\r\n\r\n<p>Before we embark on our quest to understand what Yaffs is, a terminology explanation is in order.</p>\r\n\r\n<p>There are two versions of Yaffs code: the original Yaffs code-base and the current Yaffs2 code-base. The Yaffs2 code-base supports functionality provided by the Yaffs code-base as well as being extended with new functionality to provide extra modes of operation, most importantly those required to work with larger and more modern NAND parts. The Yaffs2 code-base supports the Yaffs1 mode of operation through a backward compatibility mode.</p>\r\n\r\n<p>Unless explicitly mentioned, this text refers to the Yaffs2 code-base.</p>\r\n\r\n<p>This text uses three terms Yaffs, Yaffs1 and Yaffs2 depending on various modes of operation.</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Yaffs1 is a simpler mode of operation that uses deletion markers to track state.</p>\r\n	</li>\r\n	<li>\r\n	<p>Yaffs2 is a more complex mode of operating that was developed to support larger flash types that cannot used deletion markers.</p>\r\n	</li>\r\n	<li>\r\n	<p>Yaffs means operations common to both.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Yaffs1 originally only worked with 512-byte page devices but has been extended to support larger flash pages such as Intel M18 flash with 1k pages.</p>\r\n\r\n<p>Yaffs2 was originally designed for 1k or larger page sizes but can be used with smaller pages by using in-band tags.</p>\r\n\r\n<p>Since the Yaffs1 mode of operation is simpler to understand than the Yaffs2 mode of operation, Yaffs1 will be described first and readers interested in Yaffs2 operation should first fully acquaint themselves with the Yaffs1 mode of operation. It is suggested that this document be read sequentially rather than browsing it.</p>\r\n\r\n<h2>5 Objects</h2>\r\n\r\n<p>In Yaffs-speak, an Object is anything that is stored in the file system. These are:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Regular data files</p>\r\n	</li>\r\n	<li>\r\n	<p>Directories</p>\r\n	</li>\r\n	<li>\r\n	<p>Hard-links</p>\r\n	</li>\r\n	<li>\r\n	<p>Symbolic links</p>\r\n	</li>\r\n	<li>\r\n	<p>Special objects (pipes, devices etc).</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>All objects are identified by a unique integer <em><strong>object Id</strong></em>.</p>\r\n\r\n<p>In the standard POSIX model, as used by Linux, there are inodes and directory entries (dentries).</p>\r\n\r\n<p>An inode may be a regular file, directory, or special file.</p>\r\n\r\n<p>Directory entries provide the naming mechanism that is used to locate inodes.</p>\r\n\r\n<p>Under POSIX, each inode may have zero, one or many dentries:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>One dentry per inode is commonly understood.</p>\r\n	</li>\r\n	<li>\r\n	<p>Multiple dentries per inode allow the same inode to be accessed via multiple names. This is achieved through hard links.</p>\r\n	</li>\r\n	<li>\r\n	<p>Zero dentries per inode is less often understood. This happens when an inode is unlinked while there is still a handle open to the inode. The unlinking deletes the dentry but the inode still exists. As soon as the handle is closed the inode is deleted too.</p>\r\n	</li>\r\n</ul>\r\n\r\n<h2>6 The Yaffs NAND model</h2>\r\n\r\n<p>The memory in NAND flash is arranged in <em><strong>pages.</strong></em> A page is the unit of allocation and programming. In Yaffs, the unit of allocation is the<em> </em><em><strong>chunk</strong></em>. Typically a chunk will be the same as a NAND page, but there is flexibility to use chunks which map to multiple pages (eg. A system may have two NAND chips in parallel requiring 2x512 = 1024 byte chunks) . This distinction gives a lot of flexibility in how the system can be configured. In this text the term page and chunk are synonymous unless stated otherwise.</p>\r\n\r\n<p>Many, typically 32 to 128 but as many as a few hundred, chunks form a <em><strong>block</strong></em>. A block is the unit of erasure.</p>\r\n\r\n<p>NAND flash may be shipped with bad blocks and further blocks may go bad during the operation of the device. Thus, Yaffs is aware of bad blocks and needs to be able to detect and mark bad blocks.</p>\r\n\r\n<p>NAND flash also typically requires the use of some sort of error detection and correction code (ECC). Yaffs can either use existing ECC logic or provide its own.</p>\r\n\r\n<h2>7 How Yaffs1 stores files</h2>\r\n\r\n<p>Yaffs1 has a modified log structure, while Yaffs2 (see below) has a true log structure. A true log structured file system only ever writes sequentially. Yaffs1 uses deletion markers, which breaks the sequential write rule. Yaffs2 does not use deletion markers and is thus a true log structured file system.</p>\r\n\r\n<p>Instead of writing data in locations specific to the files, the file system data is written in the form of a sequential log, The entries in the log are all one chunk in size and can hold one of two types of chunk:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p><em><strong>Data chunk</strong></em>: A chunk holding regular data file contents.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>Object Header</strong></em>: A descriptor for an object (directory, regular data file, hard link, soft link, special descriptor,...). This holds details such as the identifier for the parent directory, object name, etc.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Each chunk has <em><strong>tags</strong></em> associated with it. The tags comprise the following important fields (others being ignored for now):</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p><em><strong>ObjectId</strong></em>: Identifies which object the chunk belongs to.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>ChunkId</strong></em>: Identifies where in the file this chunk belongs. A chunkId of zero signifies that this chunk contains an objectHeader. ChunkId==1 signifies the first chunk in the file (ie. At file offset 0), chunkId==2 is the next chunk and so on.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>Deletion Marker:</strong></em> (Yaffs1 only) Shows that this chunk is no longer in use.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>Byte Count</strong></em>: Number of bytes of data if this is a data chunk.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>Serial Number</strong></em>: (Yaffs1 only) Serial number used to differentiate chunks with the same objectId and chunkId.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Now let\'s bring that all together in an explanation. This is a simplified explanation and skips over issues such as Soft Deletion (mentioned later in the document). For explanation purposes, we shall consider usage of fictitious NAND type that has 4 chunks per block, starting with an empty (erased) flash.</p>\r\n\r\n<p>First we\'ll create a file.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deletion</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Object Header for this file (length 0)</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nNext we write a few chunks of data to the file.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deletion</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Object Header for this file (length 0)</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>First chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Second chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Third chunk of data</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nNext we close the file. This writers a new object header for the file. Notice how the previous object header is deleted.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deletion</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsoleted object header (length 0)</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>First chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Second chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Third chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>New object header (length n)</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nLet\'s now open the file for read/write, overwrite part of the first chunk in the file and close the file. The replaced data and object header chunks become deleted.<br />\r\n&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deletion</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete first chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Second chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>Third chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>New first chunk of file</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>New object header</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nNow let\'s resize the file to zero by opening the file with O_TRUNC and closing the file. This writes a new object header with length 0 and the contents are pruned making the data chunks deleted.</p>\r\n\r\n<p><br />\r\n&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deletion</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete first chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Second chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Third chunk of data</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted first chunk of file</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Delted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsoleted object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>New object header (length 0).</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nNote how all the pages in block 1 are now marked as deleted. This means that block 1 no longer contains useful information so we can now erase block 1 and reuse the space.</p>\r\n\r\n<p>We will now rename the file. To do this we write a new object header for the file<br />\r\n&nbsp;</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Block</p>\r\n			</td>\r\n			<td>\r\n			<p>Chunk</p>\r\n			</td>\r\n			<td>\r\n			<p>ObjectId</p>\r\n			</td>\r\n			<td>\r\n			<p>ChunkId</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Comment</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>Erased</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>Erased</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>Erased</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>&nbsp;</p>\r\n			</td>\r\n			<td>\r\n			<p>Erased</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted first chunk of file</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsoleted object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Deleted</p>\r\n			</td>\r\n			<td>\r\n			<p>Obsolete object header</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>500</p>\r\n			</td>\r\n			<td>\r\n			<p>0</p>\r\n			</td>\r\n			<td>\r\n			<p>Live</p>\r\n			</td>\r\n			<td>\r\n			<p>New object header showing new name</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\nBlock 2 now contains only deleted chunks and can be erased and reused.</p>\r\n\r\n<p>Note how the tags tell us:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Which chunks belong to which object</p>\r\n	</li>\r\n	<li>\r\n	<p>The position of the chunks within a file,</p>\r\n	</li>\r\n	<li>\r\n	<p>Which chunks are current</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>With that information we can recreate the state of the files regardless of the placement of the chunks in NAND. This means that should the system fail (crash, power fail,...) at any point during the sequences above, we are still able to recover the file system state up to that point.</p>\r\n\r\n<ul>\r\n</ul>\r\n\r\n<p>Note that there are no file allocation tables or similar structures stored in the flash. This reduces the amount of writing and erasing (improving write performance) while also improving robustness. Corruption of file allocation tables and similar structures is a common failure mechanism for embedded file systems. The lack of such structures makes Yaffs more robust. Or, to put it another way, you can\'t corrupt what you don\'t store.</p>\r\n\r\n<h2>8 Garbage collection</h2>\r\n\r\n<p>As we have shown so far, when a block is made up only of deleted chunks, that block can be erased and reused. However, consider what will happen if we have many blocks which each have a few current chunks in them. Clearly we cannot erase any of the current blocks or we will destroy data. What we need to do is copy the useful data chunks off a block, deleting the originals and allowing the block to be erased and reused. This process is referred to as <em><strong>garbage collection</strong></em>.</p>\r\n\r\n<p>The Yaffs garbage collection process works as follows:</p>\r\n\r\n<ol>\r\n	<li>\r\n	<p>Find a block worth collecting (according the the heuristics below). If none found, then exit.</p>\r\n	</li>\r\n	<li>\r\n	<p>Iterate through the chunks in the block. If the chunk is in use then create a new copy and delete the original. Fix up the RAM data structures to reflect the change.</p>\r\n	</li>\r\n</ol>\r\n\r\n<p>Once all chunks in this block have been deleted, the block can be erased ready for reuse.</p>\r\n\r\n<p>Note that although step 2 deletes the original chunk when it gets copied there is not much point in actually programming the deletion marker in flash since we\'re about to erase the block anyway. Thus Yaffs does not program the deletion marker in these cases. If power is lost part way through the operation we can still tell the difference between the original and the copy by looking at the serial number (not that it really matters anyway since the two have the same contents so either can be used).</p>\r\n\r\n<p>The heuristics to determine whether a block is worth collecting are as follows:</p>\r\n\r\n<ol>\r\n	<li>\r\n	<p>If there are many erased blocks available, then Yaffs does not need to work hard, but will instead only attempt to perform garbage collection of blocks with very few chunks in use. This is termed <em><strong>passive</strong></em> garbage collection.</p>\r\n	</li>\r\n	<li>\r\n	<p>If, however, there are very few erased blocks, Yaffs will work much harder to recover more space and will garbage collect blocks with more chunks in use. This is termed <em><strong>aggressive</strong></em> garbage collection.</p>\r\n	</li>\r\n</ol>\r\n\r\n<p>OK, the passive/aggressive names are a bit silly, but they were contrived around midnight... give me a break!</p>\r\n\r\n<p>If garbage collection is aggressive, the whole block is collected in a single garbage collection cycle. If the collection is passive then the number of copies is reduced thus spreading the effort over many garbage collection cycles. This is done to reduce garbage collection load and improve responsiveness.</p>\r\n\r\n<p>The rationale behind the above heuristics is to delay garbage collection when possible to reduce the amount of collection that needs to be performed, thus increasing average system performance. Yet there is a conflicting goal of trying to spread the garbage collection so that it does not all happen at the same causing fluctuations in file system throughput. These conflicting goals make garbage tuning quite challenging.</p>\r\n\r\n<p>All flash file systems need some sort of garbage collector to reclaim space. The garbage collector is often a determining factor in the performance of the flash file system. Many file systems have to do a significant amount of effort in a single collection sweep. Yaffs only deals with one block at a time which constrains the amount of effort in a garbage collection cycle, thus reducing the “stall time”.</p>\r\n\r\n<p>The Yaffs garbage collection algorithm is under review with the goal of reducing “stall time” and increasing throughput.</p>\r\n\r\n<h2>9 Yaffs1 serial numbers</h2>\r\n\r\n<p>In Yaffs1, each chunk is marked with a 2-bit serial number that is incremented every time a chunk with the same tags value is replaced (eg. When a chunk is overwritten or when copied by garbage collection).</p>\r\n\r\n<p>Now let\'s suppose first that we did not have a serial number.</p>\r\n\r\n<p>Let\'s consider a rename where an object header chunk must be replaced with a new one with the new name. Yaffs could do the following:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Delete the old chunk.</p>\r\n	</li>\r\n	<li>\r\n	<p>Write the new chunk.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>If the system fails after the delete, the system could end up with no chunks matching the relevant tags values. This could cause files to be lost (end up in lost+found). Thus, we have to write the new chunk before deleting the old chunk.</p>\r\n\r\n<p>But now consider what might happen if we did this:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Write new chunk.</p>\r\n	</li>\r\n	<li>\r\n	<p>Delete old chunk.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>If the system failed after the write we now have two chunks that match the tags. How can we tell which one is current?</p>\r\n\r\n<p>The current chunk is determined by inspecting the serial number. Since the serial number is only incremented by one before the old chunk is deleted, a 2-bit serial number is sufficient. Valid pairs are:</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>Old</p>\r\n			</td>\r\n			<td>\r\n			<p>New</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>00</p>\r\n			</td>\r\n			<td>\r\n			<p>01</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>01</p>\r\n			</td>\r\n			<td>\r\n			<p>10</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>10</p>\r\n			</td>\r\n			<td>\r\n			<p>11</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>11</p>\r\n			</td>\r\n			<td>\r\n			<p>00</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\n&nbsp;</p>\r\n\r\n<p>Thus, by inspecting the serial number attached to the old and new tags the current chunk can be determined and the old chunk can be deleted.</p>\r\n\r\n<h2>10 Yaffs2 NAND model</h2>\r\n\r\n<p>Yaffs2 is an extension of Yaffs designed to fulfill a new set of objectives to work with newer NAND types including:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Zero overwrites. Yaffs1 only ever overwrites a single byte in the spare area of the chunks to set the deletion marker. More modern NAND devices are less tolerant of overwrites and Yaffs2 performs no overwrites at all.</p>\r\n	</li>\r\n	<li>\r\n	<p>Sequential chunk writing within a block. More modern NAND reliability specifications tend to assume sequential writing. Since Yaffs2 does not write deletion markers, the writing of chunks within a block is strictly sequential.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Since Yaffs2 performs less writes, there is potential for Yaffs2 to have improved write performance.</p>\r\n\r\n<p>Yaffs2 cannot use a deletion marker because that would violate the zero overwrites mandate and alternate mechanisms are provided to determine which chunks are current and which are deleted. These mechanisms are:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p><em><strong>Sequence Number</strong></em>: As each block is allocated, the file system\'s sequence number is incremented and each chunk in the block is marked with that sequence number. The sequence number thus provides a way of organising the log in chronological order.</p>\r\n	</li>\r\n	<li>\r\n	<p><em><strong>Shrink Header Marker</strong></em>: The shrink header marker is used to mark object headers that are written to shrink the size of a data file. This is explained more in the accompanying text.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Note: The Yaffs2 sequence number is not the same as the Yaffs1 serial number!</p>\r\n\r\n<p>Note: We still refer to chunk deletion in Yaffs2. The chunks are marked as deleted in the RAM data structures used by garbage collection etc, but there is no deletion marker written to flash.</p>\r\n\r\n<p>The sequence number allows the chronological order to be determined which allows Yaffs to determine the sequence of events and restore the file system state. This is achieved by scanning <em><strong>backwards</strong></em> chronologically (ie. From the highest sequence number backwards to the lowest sequence number). Thus:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Since we\'re scanning backwards, the most recently written – and thus current – chunk matching an objectId:chunkId pair will be encountered first and all subsequent matching chunks must be obsolete and treated as deleted.</p>\r\n	</li>\r\n	<li>\r\n	<p>The file length in object headers are used to trim back resized files. If an object header is encountered, then subsequent data chunks that lie beyond that file length are clearly obsolete and treated as deleted. Note that both current and obsolete object header sizes must be used to obtain an accurate reconstruction.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Explaining the purpose of the shrink header marker is a bit convoluted. The purpose of a shrink header marker is to show that this object header indicates that a file has shrunken in size, and to prevent those object headers from being deleted by garbage collection. To understand this, it is easiest to consider what would happen if the shrink header markers did not exist.</p>\r\n\r\n<p>For simplification we\'ll assume no garbage collection happens during this part of the exercise. It is safe to make that assumption since it does not alter the reasoning.</p>\r\n\r\n<p>Consider a file that has been through the following:</p>\r\n\r\n<p><code>h = open(“foo”,O_CREAT| O_RDWR, S_IREAD|S_IWRITE); /* create file */<br />\r\nwrite(h,data,51024*1024); /* write 5 MB of data /<br />\r\ntruncate(h,1024*1024); /* truncate to 1MB */<br />\r\nlseek(h,2*1024*1024, SEEK_SET); /* set the file access position to 2MB */<br />\r\nwrite(h,data,1024*1024); /* write 1MB of data */<br />\r\nclose(h);3</code><br />\r\n&nbsp;</p>\r\n\r\n<p>The file will now be 3MB in length, but there will be a “hole” between 1MB and 2MB. According to POSIX (and to aid security etc) that “hole” should always read back as zeros.</p>\r\n\r\n<p>Yaffs2 would represent that in NAND with the following sequence of chunks:</p>\r\n\r\n<ol>\r\n	<li>\r\n	<p>Object header for file creation (file length = 0)</p>\r\n	</li>\r\n	<li>\r\n	<p>5MB worth of data chunks (0 to 5MB)</p>\r\n	</li>\r\n	<li>\r\n	<p>Object header for truncation (file length = 1MB)</p>\r\n	</li>\r\n	<li>\r\n	<p>1MB worth of data chunks (2MB to 3MB)</p>\r\n	</li>\r\n	<li>\r\n	<p>Object header for close (file length = 3MB)</p>\r\n\r\n	<p>At this stage, only the the following data chunks are current:</p>\r\n	</li>\r\n</ol>\r\n\r\n<ul>\r\n	<li>\r\n	<p>The first 1MB of data created in step 2 above.</p>\r\n	</li>\r\n	<li>\r\n	<p>The 1MB of data created in step 4 above.</p>\r\n	</li>\r\n	<li>\r\n	<p>The object header created in step 5 above.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>But Yaffs must remember the truncation that happened in step 3, otherwise Yaffs will “forget” that there is a hole, which would cause the old data to be visible again. Thus, if Yaffs creates a hole it first writes a shrink header to indicate the start of the hole and a regular object header to mark the end of the hole.</p>\r\n\r\n<p>The shrink header modifies the behavior of the garbage collector to ensure that these shrink headers are not erased until it is safe to do so. This unfortunately has a negative impact on garbage collection in systems which make extensive use of files with holes.</p>\r\n\r\n<p>Shrink headers are also used to indicate that a file has been deleted and that the record of the file deletion is not lost.</p>\r\n\r\n<h3>10.1&nbsp;Yaffs2 extended tags</h3>\r\n\r\n<p>Yaffs2 extends the tags in object headers with extra fields to improve mount scanning performance. The operation of extended tags is described later in this document.</p>\r\n\r\n<h2>11 Bad block handling NAND error handling</h2>\r\n\r\n<p>NAND flash is designed to be very low cost and very high density. In order to get high yields, and thus keep costs down, NAND flash is typically shipped with a few bad blocks and some further blocks are expected to go bad during the use of the device. Thus, any flash file system without an effective bad block handling policy is unsuitable for NAND flash.</p>\r\n\r\n<p>Yaffs1 uses the Smart-Media style of bad block marking. This checks the sixth byte (byte 5) of the spare area. In a good block this should be 0xFF. A factory-marked bad block should be 0x00. If Yaffs1 determines that a block has gone bad it is marked bad with 0x59 (\'Y\'). Using a distinctive marker allows Yaffs-marked bad blocks to be differentiated from factory-marked bad blocks.</p>\r\n\r\n<p>Yaffs2 mode is designed to support a wider range of devices and spare-area layouts. Thus, Yaffs2 does not decide which bytes to mark but instead calls driver functions to determine whether the block is bad, or to mark it bad.</p>\r\n\r\n<p>So, when does Yaffs mark a block bad? Yaffs will mark a block bad if a read or write operation fails or if three ECC errors are detected. A block that is marked bad is retired from use, thus improving the robustness of the file system. This policy is suitable for SLC flash. MLC policies are under development.</p>\r\n\r\n<p>Further, NAND flash cells can sometimes be disturbed (corrupted) by NAND activity and charge loss. These errors are corrected by error correction codes (ECC) which may be implemented in hardware, software drivers, or within Yaffs itself. Again, any flash file system lacking effective ECC handling is unsuitable for NAND flash.</p>\r\n\r\n<p>Yaffs1 mode can use either the built in ECC or use ECC provided by the driver or hardware.</p>\r\n\r\n<p>Since Yaffs2 mode is designed for a wider range of devices, it does not provide ECC internally but requires that the driver provide the ECC.</p>\r\n\r\n<p>The ECC code supplied with Yaffs (yaffs_ecc.c) is the fastest C code implementation of a Smart Media compatible ECC algorithm that we are aware of. This code will correct any single bit error within a 256-byte data block and detect 2 errors per 256-byte data block. This is sufficient error correction to provide very high reliability on SLC-type NAND flash.</p>\r\n\r\n<p>For a more complete description of failure handling, please refer to the Yaffs error mitigation document.</p>\r\n\r\n<h2>12 RAM structures</h2>\r\n\r\n<p>While it is theoretically possible to use a log structured file system with very few RAM structures, this would provide reduce performance. Thus, significant RAM data structures are required to store enough information to provide sufficiently high performance.</p>\r\n\r\n<p>Before we jump in, it is a good idea to first figure out what purpose the RAM structures serve. The main structures are defined in yaffs_guts.h and their main purposes, are :</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Device/partition: This is named <em><strong>yaffs_dev</strong></em>. This is required to hold information relating to a Yaffs “partition” or “mount point”. Using these, rather than globals, allows Yaffs to simultaneously support multiple partitions and partitions of different types. In fact, almost other data structures mentioned here are part of, or accessed via, the structure.</p>\r\n	</li>\r\n	<li>\r\n	<p>NAND Block Information: This is named <em><strong>yaffs_block_info </strong></em>and holds the current state of the NAND blocks. Each yaffs_Device has an array of these.</p>\r\n	</li>\r\n	<li>\r\n	<p>NAND Chunk Information: This is a bitfield attached to the yaffs_Device that holds the current in-use state of each chunk in the system. There is one bit per chunk in the partition.</p>\r\n	</li>\r\n	<li>\r\n	<p>Object: This is named <em><strong>yaffs_obj</strong></em> and holds the state of an object (see section 3).There is one of these for each object in the file system, where an object is one of a regular file, directory, hard link, symbolic link or special link. There are different variants of yaffs_Objects to reflect the different data required for these different object types. Each object is uniquely identified by an objectId.</p>\r\n	</li>\r\n	<li>\r\n	<p>File structure: For each file object, Yaffs holds a tree which provides the mechanism to find the data chunks in a file. The tree consists of nodes called <em><strong>yaffs_tnode</strong></em> (tree nodes).</p>\r\n	</li>\r\n	<li>\r\n	<p>Directory structure: The directory structure allows objects to be found by name. The directory structure is built from a doubly-linked list that is rooted in the directory and binds together the sibling objects within a directory.</p>\r\n	</li>\r\n	<li>\r\n	<p>Object number hash table: The object number hash table provides a mechanism to find an object from its objectId. The objectId is hashed to select a hash bucket. Each hash bucket has a doubly-linked list of objects that belong in this hash bucket, as well as a count of the objects in the bucket.</p>\r\n	</li>\r\n	<li>\r\n	<p>Cache: Yaffs provides a read/write cache that significantly improves performance for short operations. The size of the cache can be set at run-time.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>The usage of these structures is described in more detail below.</p>\r\n\r\n<p>Yaffs makes significant use of doubly-linked lists. These data structures are very useful because they provide rapid insertion, removal and traversal. They do however come at the expense of requiring two pointers rather than just one.</p>\r\n\r\n<h3>12.1 Yaffs objects</h3>\r\n\r\n<p>Each object (file, directory,...) in the system is represented by a yaffs_obj. The yaffs_obj\'s main function is to store most of the object metadata and type-specific information. This means that almost all the information about an object can be accessed immediately without reading flash.</p>\r\n\r\n<p>The metadata includes, amongst others:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>objectId: The number used to identify the object.</p>\r\n	</li>\r\n	<li>\r\n	<p>parent: A pointer to the parent directory. Not all objects have a parent. The root director and special directories for unlinked and deleted files do not have parents so this is NULL.</p>\r\n	</li>\r\n	<li>\r\n	<p>Short name: If the name is short enough to fit in a small fixed-sized array (default 16 characters) then it is stored here otherwise it must be fetched from flash each time it is requested.</p>\r\n	</li>\r\n	<li>\r\n	<p>type: Type of object.</p>\r\n	</li>\r\n	<li>\r\n	<p>Permissions, time, ownership and other attributes</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Depending on the object type, yaffs_obj also stores:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>A tnode tree, file extents etc for data files</p>\r\n	</li>\r\n	<li>\r\n	<p>A directory chain for directories</p>\r\n	</li>\r\n	<li>\r\n	<p>An equivalent object for hard links</p>\r\n	</li>\r\n	<li>\r\n	<p>A string for symbolic links</p>\r\n	</li>\r\n</ul>\r\n\r\n<h3>12.2 Look-up by object id</h3>\r\n\r\n<p>The purpose of this mechanism is to rapidly access an object by its device and object Id. This is required during garbage collection, scanning and similar operations.</p>\r\n\r\n<p>Each yaffs_dev uses a hash table for this purpose. The hash table has 256 “buckets” (tunable), each holding a doubly-linked list of the yaffs_objs in that bucket.</p>\r\n\r\n<p>The hash table\'s hash function is just masking the least significant bits of the object Id. This is a very cheap function that provides reasonable “spread”.</p>\r\n\r\n<p>Yaffs makes an attempt to assign objectIds in a way that keeps the number of objects in each hash bucket quite low, thus preventing any one hash entry getting too long.</p>\r\n\r\n<p>This mechanism is also charged with assigning new (unique) object Ids.</p>\r\n\r\n<h3>12.3 Directory structure</h3>\r\n\r\n<p>The purpose of the directory structure is to rapidly access an object by name. This is required to perform file operations such as opening, renaming etc.</p>\r\n\r\n<p>The Yaffs directory structure is formed by a tree of objects of type YAFFS_OBJECT_TYPE_DIRECTORY. These objects have a doubly linked node of children.</p>\r\n\r\n<p>Each yaffs_obj also has a doubly linked list node called sibling which chain together the siblings in a directory.</p>\r\n\r\n<p>Each Yaffs partition has a root directory.</p>\r\n\r\n<p>Each yaffs partition also has some special purpose “fake” directories which are not stored in NAND but are instead created on mounting:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>lost+found: This directory is used as a place to store any lost file parts that cannot be placed in the normal directory tree.</p>\r\n	</li>\r\n	<li>\r\n	<p>Unlinked and deleted: These are pseudo-directories that are not in the directory tree. Placing objects in these directories gives them a status of being unlinked or deleted.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Each object has a name that is used to look up the object within the directory, Thus, each name within a directory must be unique. This rule does not apply to objects in the unlinked and deleted pseudo-directories since we never use names to look up unlinked/deleted files and there may be many files of the same name that have been deleted.</p>\r\n\r\n<p>Name resolution is sped up by two mechanisms:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Short names are stored directly in the yaffs_obj so that they don\'t have to be loaded from flash.</p>\r\n	</li>\r\n	<li>\r\n	<p>Each object has a “name sum”. This is a simple hashing of the name which speeds up the matching process because it is cheaper to compare the hash than compare the whole name string.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<h2>[ibimage==216==original==none==self==null]</h2>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>The above directory structure represents the following directory tree</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>/</p>\r\n			</td>\r\n			<td>\r\n			<p>Root directory</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/a</p>\r\n			</td>\r\n			<td>\r\n			<p>Directory containing c,d,e</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/b</p>\r\n			</td>\r\n			<td>\r\n			<p>Empty directory</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/lost+found</p>\r\n			</td>\r\n			<td>\r\n			<p>Empty directory</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/a/c</p>\r\n			</td>\r\n			<td>\r\n			<p>Directory</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/a/d</p>\r\n			</td>\r\n			<td>\r\n			<p>Data file</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>/a/e</p>\r\n			</td>\r\n			<td>\r\n			<p>Data file</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>If a Yaffs partition has been somehow corrupted then it is possible for an object to be created during scanning but with no object header (which contains the object name) being found. The object would then not have a name. In these cases, Yaffs creates a pseudonym from the object number of the form objnnnn so that the object can be placed in the directory structure.</p>\r\n\r\n<h3>12.4 Hard links</h3>\r\n\r\n<p>In POSIX file systems, the objects (inodes in Linux terminology, vnode in BSD-speak) and the object names (dentry in Linux terminology) are independent in that an object can have zero, one or more names.</p>\r\n\r\n<p>Having files with zero links is caused by constructs such as:</p>\r\n\r\n<p><code>h = open(“foo”,O_CREAT | O_RDWR, S_IREAD | S_IWRITE); /* create file “foo” */</code></p>\r\n\r\n<p><code>unlink(“foo”); /* unlink it so it can\'t be found in the directory */</code></p>\r\n\r\n<p><code>/* we still have a handle to the file so can still access it via the handle */</code></p>\r\n\r\n<p><code>read(h,buffer,100); </code></p>\r\n\r\n<p><code>write(h,buffer,100);</code></p>\r\n\r\n<p><code>close(h); /* as soon as the handle is closed the file is deleted */</code></p>\r\n\r\n<p>Yaffs does not store separate object and name records because that would waste space and incur extra reading/writing. Instead, Yaffs is optimised for the most typical case of one name per object. That is, Yaffs stores one name per yaffs_obj and uses “cheats” to achieve other behavior:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Objects that have zero names (ie unlinked objects) are handled by renaming the object into a fake directory that is used to designate unlinked objects.</p>\r\n	</li>\r\n	<li>\r\n	<p>Multiple names object are handled by designating one of the objects the main object and having multiple hard link pseudo-objects that refer to it.</p>\r\n	</li>\r\n	<li>\r\n	<p>The inode number (vnid in BSD-speak) is a per-file system unique number that identifies the object. The Yaffs object id of the main object is presented to the user. That is, if the inode number is queried from a hardlink object then the object id of the equivalent object is returned.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>The linkage between hard link pseudo-objects and their equivalent object is through two fields:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Each object has a hardLinks doubly linked list node that links the list of hard links to that object.</p>\r\n	</li>\r\n	<li>\r\n	<p>Each hard link has a pointer to the “equivalent object”.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>The usage of this structure is straight forward except for one interesting case when hard links are being deleted. Consider the following sequence of events:</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>1</p>\r\n			</td>\r\n			<td>\r\n			<p># touch a</p>\r\n			</td>\r\n			<td>\r\n			<p>Create file a</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>2</p>\r\n			</td>\r\n			<td>\r\n			<p># ln a b</p>\r\n			</td>\r\n			<td>\r\n			<p>Create a hard link b with equivalent object a.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>3</p>\r\n			</td>\r\n			<td>\r\n			<p># rm a</p>\r\n			</td>\r\n			<td>\r\n			<p>Remove a. The object must still exist under the name b</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p>In step 3, Yaffs cannot just delete the equivalent object since that would leave a “hanging” hard link with no equivalent object.</p>\r\n\r\n<p>We also cannot just change the type of one of the hardlink objects because that would cause the object\'s object id to change. This would be unacceptable since it would break any mechanism that use the object id (of which there are many within and outside of Yaffs).</p>\r\n\r\n<p>Thus, if an object is deleted and it has hard links to it then we do the following:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Select one of the object\'s hard links.</p>\r\n	</li>\r\n	<li>\r\n	<p>Rename the object to the name in the hard link.</p>\r\n	</li>\r\n	<li>\r\n	<p>Delete the hard link pseudo-object.</p>\r\n	</li>\r\n</ul>\r\n\r\n<h3>12.5 Symbolic links and special objects</h3>\r\n\r\n<p>These object types just store values that are needed to provide a full POSIX file system.</p>\r\n\r\n<p>A symbolic link object saves a symbolic link string that is used to provide the POSIX symbolic string mechanism.</p>\r\n\r\n<p>A special object is used to store device numbers, pipes and other similar special objects.</p>\r\n\r\n<h3>12.6 File objects</h3>\r\n\r\n<p>The yaffs_Objects have a type and a variant portion which is a union of different data required to hold the state of different object types.</p>\r\n\r\n<p>The file objects have type YAFFS_OBJECT_TYPE_FILE, and an associated file variant. This stores the following main values:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>fileSize: file size</p>\r\n	</li>\r\n	<li>\r\n	<p>topLevel: depth of the Tnode tree</p>\r\n	</li>\r\n	<li>\r\n	<p>top: pointer to top of Tnode tree</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>The meaning of the file size is quite obvious. This is the current length of the file. Note that a file might have holes in it caused by seeking forward past the extents of the file.</p>\r\n\r\n<p>The top and topLevel work together to control the Tnode trees.</p>\r\n\r\n<h4>12.6.1 Tnode tree</h4>\r\n\r\n<p>Each file has a tnode tree to provide the mapping from file position to actual NAND chunk address. top is a pointer to the top of the tnode tree</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>[ibimage==220==original==none==self==null]<br />\r\n<br />\r\n&nbsp;</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>The tnode tree is made up of tnodes (tree nodes) arranged in levels, each of which holds either:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>At levels greater than 0, a tnode has 8 pointers to other tnodes in the next level down.</p>\r\n	</li>\r\n	<li>\r\n	<p>At level 0, a tnode has 16 NAND chunk Ids which identify the chunk\'s location in RAM.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>These numbers are powers of 2 which makes for simple look-ups by just applying bitmasks. The code that traverses this tree is in yaffs_FindLevel0Tnode().</p>\r\n\r\n<p>As the file size grows, more tnodes are added and as the levels fill, more levels are added. If the file is truncated or resized downwards, then the tree is pruned. If a chunk in a file is replaced (eg. data is overwritten or copied by garbage collection) then the tnode tree must be updated to reflect the change.</p>\r\n\r\n<p>Tnodes typically make up the bulk of the Yaffs\' RAM usage.</p>\r\n\r\n<h2>13 How various mechanisms work</h2>\r\n\r\n<p>Having looked at the Yaffs data structures, we now consider how some of the mechanisms in Yaffs operates. This is most easily done by walking through some operations that Yaffs performs.</p>\r\n\r\n<h3>13.1 Block and chunk management</h3>\r\n\r\n<h4>13.1.1 Block states</h4>\r\n\r\n<p>Yaffs tracks the state of each block and chunk in the partition. This information is first built up during scanning (or recovered from a checkpoint). A block may be in one of the following states (see definition of yaffs_BlockState):</p>\r\n\r\n<table>\r\n	<colgroup>\r\n		<col />\r\n		<col />\r\n	</colgroup>\r\n	<tbody>\r\n		<tr>\r\n			<td>\r\n			<p>UNKNOWN</p>\r\n			</td>\r\n			<td>\r\n			<p>The block state is not yet known.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>NEEDS_SCANNING</p>\r\n			</td>\r\n			<td>\r\n			<p>During pre-scanning it has been determined that this block has something on it and needs scanning.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>SCANNING</p>\r\n			</td>\r\n			<td>\r\n			<p>This block is currently being scanned.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>EMPTY</p>\r\n			</td>\r\n			<td>\r\n			<p>This block has nothing in it (is erased) and may be used for allocation. The block can get to this state by being erased.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>ALLOCATING</p>\r\n			</td>\r\n			<td>\r\n			<p>This is the block currently being used for allocation by the chunk allocator.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>FULL</p>\r\n			</td>\r\n			<td>\r\n			<p>All the chunks in this block have been allocated and at least one chunk contains useful information that has not yet been deleted.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>DIRTY</p>\r\n			</td>\r\n			<td>\r\n			<p>All the chunks in this block have been allocated and all have been deleted. The block might have been in the FULL or COLLECTING state before this. This block can now be erased and returned to EMPTY state.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>CHECKPOINT</p>\r\n			</td>\r\n			<td>\r\n			<p>This block has checkpoint data in it. When the checkpoint is invalidated this block will be erased and returned to the EMPTY state.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>COLLECTING</p>\r\n			</td>\r\n			<td>\r\n			<p>This block is being garbage collected. As soon as all live data has been inspected this block becomes DIRTY.</p>\r\n			</td>\r\n		</tr>\r\n		<tr>\r\n			<td>\r\n			<p>DEAD</p>\r\n			</td>\r\n			<td>\r\n			<p>This block has been retired or was marked bad. This is a terminal state.</p>\r\n			</td>\r\n		</tr>\r\n	</tbody>\r\n</table>\r\n\r\n<p><br />\r\n&nbsp;</p>\r\n\r\n<p>[ibimage==224==original==none==self==null]</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>The regular runtime states are; EMPTY, ALLOCATING, FULL, COLLECTING and DIRTY.</p>\r\n\r\n<p>The checkpoint state is used for checkpoint blocks.</p>\r\n\r\n<p>The DEAD state is the terminal state for blocks that were retired because they were either marked bad or an error was detected.</p>\r\n\r\n<h4>13.1.2 Block and chunk allocation</h4>\r\n\r\n<p>An available chunk must be allocated before it can be written. The chunk allocation mechanism is provided by yaffs_AllocateChunk() and is very simple. Each partition has a current block that it is allocating from. This is termed the <em><strong>allocation block</strong></em>. Chunks are allocated sequentially from the allocation block. As the chunks are allocated, block and chunk management information is updated, including the block\'s pagesInUse count and the chunk use bitmap.</p>\r\n\r\n<p>When the block is fully allocated, another empty block is selected to become the allocation block. The blocks are selected by searching upwards from the previous allocation block.</p>\r\n\r\n<p>Previous to yaffs_guts.c V1.99, Yaffs scanning would identify the allocation block being used when the file system was last shut down and would continue allocation from that point. This had the benefit of continuing to use the same block and slightly reduce garbage creation . However, doing this could potentially cause problems due to attempting to write a block that had been in the middle of a write when power was lost. Thus Yaffs now always starts allocation on a new block after a mount. This slightly increases the amount of garbage (typically by an insignificant amount) but improves robustness.</p>\r\n\r\n<h4>13.1.3 A word about wear leveling</h4>\r\n\r\n<p>Since flash memory blocks can only endure a limited number of writes and erases ( termed the flash endurance), a flash file system needs to ensure that the same few blocks are not overwritten continuously causing those blocks to wear out while the other blocks are hardly used at all.. Instead it is important that the file system spreads out the wear.</p>\r\n\r\n<p>This is extremely important in a file system such as FAT which uses a limited set of logical blocks to store the file allocation table entries which get modified frequently. If FAT is used with a static logical to physical block mapping then the file allocation table blocks will wear out far before other blocks causing premature device failure. Thus, for FAT, it is very important that the logical to physical mapping gets stirred up a bit to cause the file allocation tables to be written to different physical blocks, thus leveling out the wear.</p>\r\n\r\n<p>Wear leveling is far less of a concern in a log structured file system such as Yaffs since we always write to the end of the log and thus don\'t keep on overwriting the same blocks.</p>\r\n\r\n<p>There are basically two ways to achieve wear leveling:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Use a specifically written set of functions that actively perform wear leveling.</p>\r\n	</li>\r\n	<li>\r\n	<p>Allow a degree of wear leveling to happen as a side effect of other activity.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Yaffs takes the second approach.</p>\r\n\r\n<p>Firstly, being log structured, Yaffs inherently spreads out the wear by performing all writes in sequence. That means that we don\'t single out a few blocks for a specific purpose and write them more than others.</p>\r\n\r\n<p>Secondly, blocks are allocated serially from the erased blocks in the partition. Thus the process of erasing (after deletion of garbage collection) and then allocating blocks does tend to spread the block use and provides a level of wear leveling.</p>\r\n\r\n<p>Thus, even though there is no code to specifically perform wear leveling it does happen as a side effect of other activity.</p>\r\n\r\n<p>This strategy performs well and has survived many accelerated lifetime tests in both simulations and on real NAND-based products.</p>\r\n\r\n<h4>13.1.4 Management of yaffs_tnode and yaffs_obj structures</h4>\r\n\r\n<p>yaffs_tnodes and yaffs_objs are dynamically created and released as they are needed.</p>\r\n\r\n<p>The allocation and management could be done by just using the standard memory allocator (malloc, kmalloc etc), but this could cause performance problems, particularly in embedded systems which tend to have rather simplistic memory allocators.</p>\r\n\r\n<p>The allocation and deletion of many small structures can cause memory fragmentation causing out-of-memory and slowdown problems.</p>\r\n\r\n<p>To prevent these problems, Yaffs manages these objects internally. Yaffs creates many structures (100 or so) at a time and then allocates them singly from a free list. When structures are released they are placed on the free list for reuse.</p>\r\n\r\n<h3>13.2 Internal cache</h3>\r\n\r\n<p>This describes the standard Yaffs internal cache implementation. Alternative caches have been devised for other purposes and at some future point Yaffs might be extended to support pluggable cache policies.</p>\r\n\r\n<p>The main purpose of the internal cache is to reduce NAND access for badly behaved applications which perform many small reads and writes. Believe it or not, but there are applications out there that read or write files a few bytes at a time:</p>\r\n\r\n<p><code>while(...)<br />\r\nwrite(h,buf,1);</code></p>\r\n\r\n<p>This sort of behavior would be terrible for performance and flash memory life if each read or write operation resulted in a write to flash. Yaffs provides an internal cache to mitigate against this sort of behaviour.</p>\r\n\r\n<p>The Yaffs internal cache is called a “Short Op Cache” (short operation cache) and only comes in to play for operations which are not chunk aligned. The caching mechanism is very simple and was primarily written for less sophisticated OSs that lack their own file caching layer. The cache is still beneficial in OSs like Linux, which provide a caching layer, because it caches both the read and write path. Thus, while short reads will be serviced by the Linux page cache, the shortOpCache does address non-chunk aligned writes.</p>\r\n\r\n<p>Page aligned reads/writes bypass the cache unless that chunk is already in the cache.</p>\r\n\r\n<p>The cache is stored in an array of cache entries. The number of cache entries is set in the yaffs_Device configuration by dev-&gt;nShortOpCaches and the cache is configured during initialisation. A cache size of zero disables the cache. The cache management algorithms are simplistic and probably don\'t scale well to very large numbers. This means that it is probably best to stick with around 5 to 20 cache entries.</p>\r\n\r\n<p>Each cache entry holds:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>object id, chunk id, nbytes (the tag info of the chunk being cached)</p>\r\n	</li>\r\n	<li>\r\n	<p>The actual data bytes</p>\r\n	</li>\r\n	<li>\r\n	<p>Cache slot status (last used counter, dirty,...)</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Finding an unused cache entry is a simple operation. We just iterate through the cache entries searching for one that is not busy. If all cache entries are busy then a cache push-out is performed and then we retry the find.</p>\r\n\r\n<p>Whenever a cache entry is accessed (read or written) the last-use counter is is set to an incrementing number. This counter value is used to drive the least-recently-used (LRU) algorithm.</p>\r\n\r\n<p>Cache entries which have been modified and not yet written back to flash are marked with a dirty flag. This is tells us whether we need to write out the data during a flush or push-out.</p>\r\n\r\n<p>A push-out happens whenever the cache is full and we need to push an entry out of the cache to make space to load a new entry. Yaffs uses the LRU algorithm to select the LRU cache entry and then write out all dirty entries for that file, in ascending order, and mark these entries as free.</p>\r\n\r\n<p>Whenever a file is flushed (file flush or close), the file\'s dirty entries are written out. At certain times (eg. before an unmount or at sync()) the entire cache is flushed.</p>\r\n\r\n<p>This caching policy is gives a useful performance improvement with very simple algorithms (ie good bang-for-bucks).</p>\r\n\r\n<p>Apart from its normal caching function, the shortOpCache also does much of the heavy lifting for inband tags support since all the inband tags accesses are not chunk aligned and must typically be re-aligned. The cache makes this easy.</p>\r\n\r\n<h3>13.3 Scanning</h3>\r\n\r\n<p>Scanning is the process whereby file system state is rebuilt from scratch. This happens on mounting a Yaffs partition if no checkpoint data is available or if the mounting was told to ignore the checkpoint data.</p>\r\n\r\n<p>Scanning involves reading the tags from all the active chunks in the system so can take quite a while, but probably less time than you\'d expect.</p>\r\n\r\n<p>The scanning process is different for Yaffs1 vs Yaffs2 because of the differences mentioned before.</p>\r\n\r\n<h4>13.3.1 Yaffs1 scanning</h4>\r\n\r\n<p>Yaffs1 scanning is rather straight forward because Yaffs1 uses deletion markers.</p>\r\n\r\n<p>All we really need to do is read the tags off all the chunks in the partition and determine if the chunk is active. Order is not important and blocks could be read in any order. If the deletion marker has not been set then it is active and we need to add the chunk to the file system state as follows:</p>\r\n\r\n<p>If the chunk is a data chunk (chunkId &gt; 0) then the chunk must be added to the relevant file\'s tnode tree. If the object does not exist, then we create it in lost+found, although it has no name and other file details yet.</p>\r\n\r\n<p>If the chunk is an object header (chunkId == 0) then the object must be created (or it might already exist in lost + found and we need to fix up its details and slot it into the correct part of the directory tree.</p>\r\n\r\n<p>If at any time during scanning we find that we are reading a second chunk with the same objectId:chunkId as a previously encountered chunk then the 2-bit serial number is used to resolve the dispute.</p>\r\n\r\n<p>Once the scanning is complete we still need to fix up a few things:</p>\r\n\r\n<p>Hard links must be connected up properly (it is more efficient to defer this until after the scanning has completed).</p>\r\n\r\n<p>Also, objects which were marked as unlinked must be deleted since there are no longer handles open to these objects.</p>\r\n\r\n<h4>13.3.2 Yaffs2 scanning</h4>\r\n\r\n<p>Yaffs2 has no deletion markers which makes the scanning significantly more complex.</p>\r\n\r\n<p>The first thing that needs to be done is to pre-scan the blocks to determine the sequence number for the blocks. The list of blocks and sequence numbers is then sorted to make a chronologically ordered list.</p>\r\n\r\n<p>Yaffs then scans <em><strong>backwards</strong></em> through these blocks (ie in reverse chronological order). Thus, the first encountered objectId:chunkId pair is the current one and subsequent chunks with those tags are out of date.</p>\r\n\r\n<p>We read the tags for each chunk in each block.</p>\r\n\r\n<p>If it is a data chunk ( ie. chunkId &gt; 0) then:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>If a chunk with the same objectId:chunkId has already been found then this is not the current chunk. Delete this one.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else if the object is marked as deleted, or corrupted, then delete it.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else if the object does not yet exist then this chunk was written since the last object header write for this object so this chunk must be the last written chunk in the file and must have happened just before an unclean shutdown with the file still open. We can create the file and use the chunkId and nbytes to set the file extents.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else if the object does exist and the chunk lies beyond the object\'s file scan size (extents) then it is a truncated chunk and can be deleted.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else it is placed into the file\'s tnode tree.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>If it is an object header (ie. chunkId == 0) then:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>If the object is in the deleted directory then mark the object as deleted and set the object\'s shrink size to zero.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else if an object header has not yet been found for this object, then this is the most current object header and holds the most current name etc. If no data chunks have yet been found for this chunk then the size in the object header is also the file extents. The file size is used to set the file scan size since at the time it was written the file did not extend past that point and we can safely ignore further data chunks for that file that extend past that point.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else just use the file size as the scan size if it is smaller than the current file scan size.</p>\r\n	</li>\r\n	<li>\r\n	<p>Else this an obsolete object header. It is deleted.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>A bit more explanation is probably needed to describe the file scan size. The whole purpose of this is to determine data chunks that should be ignored due to the file being truncated.</p>\r\n\r\n<h3>13.4 Checkpoint</h3>\r\n\r\n<p>Mount scanning takes quite a lot of time and slows mounting, though perhaps by less than you\'d think. Checkpointing is a mechanism to speed the mounting by taking a snapshot of the Yaffs runtime state at unmount or sync() and then reconstituting the runtime state on re-mounting. The speed up is dramatic.</p>\r\n\r\n<p>The actual checkpoint mechanism is quite simple. A “stream” of data is written to a set of blocks which are marked as holding checkpoint data and the important runtime state is written to the stream.</p>\r\n\r\n<p>Not all state needs to be saved, only the state needed to reconstitute the structure of the runtime data. For example, file metadata need not be saved since it is very easy to load that through lazy-loading.</p>\r\n\r\n<p>The checkpoint stores data in the following order:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Start marker, including checkpoint format id.</p>\r\n	</li>\r\n	<li>\r\n	<p>yaffs_Device information</p>\r\n	</li>\r\n	<li>\r\n	<p>Block information</p>\r\n	</li>\r\n	<li>\r\n	<p>Chunk flags</p>\r\n	</li>\r\n	<li>\r\n	<p>Objects, including file structure</p>\r\n	</li>\r\n	<li>\r\n	<p>End marker</p>\r\n	</li>\r\n	<li>\r\n	<p>Checksum</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>The checkpoint validity is ensured by the following mechanisms:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>The data is stored using whatever ECC mechanisms are in place.</p>\r\n	</li>\r\n	<li>\r\n	<p>The start marker includes a checkpoint version so that an obsolete checkpoint will not be read if the checkpoint code changes.</p>\r\n	</li>\r\n	<li>\r\n	<p>Data is written to the stream as structured records, each with a type and size.</p>\r\n	</li>\r\n	<li>\r\n	<p>The end marker must be read when expected.</p>\r\n	</li>\r\n	<li>\r\n	<p>Two checksums are maintained across the whole checkpoint data set.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>If any checks fail, the checkpoint is ignored and the state is re-scanned.</p>\r\n\r\n<p>The astute reader might notice that block state changes as we\'re writing checkpoint blocks, so how do we manage to re-constitute the block states correctly? This is achieved by the following:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>As we write the checkpoint, the checkpoint block allocation selects EMPTY blocks. We don\'t change the state as we\'re writing the checkpoint so their state is written to the checkpoint as EMPTY or CHECKPOINT, it does not really matter which.</p>\r\n	</li>\r\n	<li>\r\n	<p>After reading the checkpoint, we know which blocks have been used to store checkpoint data. We update those blocks to reflect the CHECKPOINT state.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>A checkpoint is invalidated by any modifications (writes, erases,...) thus any modification path also checks to see if there is a checkpoint and erases it.</p>\r\n\r\n<p>The regular Yaffs block allocator and garbage collection logic also needs to be aware of the approximate size of the checkpoint so that these can ensure enough spare space is reserved to store a checkpoint. There is a calculation that updates the value whenever the number of objects etc changes.</p>\r\n\r\n<h3>13.5 Extended tags and packed tags</h3>\r\n\r\n<p>Extended tags is an abstraction of a way to store more information in the tags, allowing for faster scan times. Packed Tags is a physical implementation of the storage of extended tags.</p>\r\n\r\n<p>When we\'re scanning we really only need to build up the structure of the file system. In other words, rebuild the directory relationships, tnode trees and such. Much of the detail such as file names, permissions etc can be lazy loaded.</p>\r\n\r\n<p>This required storing extra information, such as the parent directory and object type, in the tags of object headers. But how do we do this without enlarging the tags size?</p>\r\n\r\n<p>Object headers always have a chunkId of zero and nbytes has no meaning because it is not a data chunk. By using a single bit to identify object headers we suddenly open up a whole lot of space that we can stuff full of useful data. By being clever as to what data we use, we can pack in the important data in most circumstances.</p>\r\n\r\n<p>Sometimes, for example very large files, the packing will not work because there are insufficient bits to hold the field so we just write regular tags instead. That\'s OK since there can only be few such files in the system so the performance reduction only impacts very few files and the system level impact is unnoticeable. A simple, cheap, strategy that gives speed up 99% of the time is a very handy one.</p>\r\n\r\n<p>Other details are lazy-loaded on demand. This will happen when the object is looked up (eg. by a file open or searching for the file in the directory).</p>\r\n\r\n<h3>13.6 Block summaries</h3>\r\n\r\n<p>Scanning requires that the tags for each chunk are read so that they can be inspected. Reading the tags from each chunk can be time consuming. Thus, block summaries were added in 2011.</p>\r\n\r\n<p>Block summaries write all the tags data for chunks in the block into the last few (typically only one) chunk in a block. This allows all the tags for chunks in that block to be read in one hit. Depending on the system throughput (CPU, RAM and flash speeds), this can speed up mount time dramatically.</p>\r\n\r\n<p>If a block summary is not available for a block, then the old mechanism is still used to scan the tags on each chunk.</p>\r\n\r\n<h3>13.7 Inband tags</h3>\r\n\r\n<p>Thus far we have considered chunks where there are sufficient unallocated bytes in the spare (or out of band) area to store the tags. This means that the data part of the page is a power of 2 in size. Powers of 2 are very fast to deal with which is why most operating systems use various powers of 2 in their internals.</p>\r\n\r\n<p>But what happens if we don\'t have enough space in the spare area to store the tags? Inband tags to the rescue! With inband tags we store the tags in the flash data area alongside the data. This gives us far more flexibility in the types of storage that Yaffs can support, but breaks the power-of-2 alignment. There are three major penalties with inband tags:</p>\r\n\r\n<ul>\r\n	<li>\r\n	<p>Due to the loss of chunk alignment, all transactions must pass through the shortOpCache. This costs an extra memcpy().</p>\r\n	</li>\r\n	<li>\r\n	<p>Offset to chunk, free space and other calculations are no longer just shift and mask operations but instead require multiplications and divisions which can relatively expensive.</p>\r\n	</li>\r\n	<li>\r\n	<p>Reading tags during scanning etc can involve reading the whole page, making this slower. The impact is minimised by using checkpointing.</p>\r\n	</li>\r\n</ul>\r\n\r\n<p>Thus, it is better, performance wise, to only use inband tags when regular tags will not work.</p>\r\n\r\n<h3>13.8 Soft deletion</h3>\r\n\r\n<p>Soft deletion is a mechanism that was added to speed up file deletion in Yaffs1 mode.</p>\r\n\r\n<p>Looking back to the description of how files are stored in Yaffs1, you can see that deleting a file involves writing the deletion marker of every data chunk in the file. This can take quite some time for large files.</p>\r\n\r\n<p>The soft deletion mechanism was added to avoid writing all those deletion markers. Instead of writing the deletion markers, soft deletion instead tracks the number of chunks in each block that belong to deleted files and leaves the clean up to the garbage collector.</p>\r\n\r\n<p>When the garbage collector looks at a block it can see what current chunks (ie chunks not yet deleted) belong to deleted files and does not copy those, thus effectively deleting the chunk. Once all the chunks associated with a deleted file have cleaned up by the garbage collector the file header object can also be deleted.</p>\r\n\r\n<p>Yaffs2 mode does not write deletion markers and thus does not use soft deletion.</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>&nbsp;</p>\r\n\r\n<p>&nbsp;</p>\r\n','This document gives a reasonable explanation of most of the core mechanisms that make Yaffs work. As of the time of writing this, the Yaffs2 code base includes approximately 19,000 lines of code making a very detailed discussion impractical. This document should serve as a first port of call for understanding Yaffs. Further detailed questions and discussions are welcomed on the Yaffs discussion list.','filtered_html'),