('entity_view:node:418:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1354:\"<span>Data is safe with Yaffs...</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-lock</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>Yaffs provides bad block handling and ECC algorithms to handle deficiencies in NAND flash.</p>\n\n<p>It is a log-structured file system which makes it very robust to corruptions caused by power failures.</p>\n\n<p>We spend about 60% of development time on testing Yaffs, and our test harness is available for download so you can check the testing and perform some yourself.</p>\n\n<p>We\'ve performed hundreds of thousands of tests to make sure that Yaffs is as safe as we can make it, even in the even of a power failure during a firmware update.</p>\n\n<p>You can find full details of the Yaffs testing regime in our paper <a href=\"http://www.yaffs.net/documents/yaffs-robustness-and-testing\">http://www.yaffs.net/documents/yaffs-robustness-and-testing</a>  including all the details on the power-fail stress tests, the Yaffs Direct API tests for commercial RTOSs, Linux testing, and fuzz testing where we deliberately corrupt Yaffs file systems to check that Yaffs can still mount.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:418\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505196111.256,1,'config:filter.format.basic_html node:418 node_view rendered','267'),('entity_view:node:418:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"418\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:418\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505196111.255,1,'config:filter.format.basic_html node:418 node_view rendered','267'),('entity_view:node:418:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:863:\"<article role=\"article\" about=\"/features/data-safe-yaffs\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/data-safe-yaffs\" rel=\"bookmark\"><span>Data is safe with Yaffs...</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/data-safe-yaffs\" rel=\"tag\" title=\"Data is safe with Yaffs...\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Data is safe with Yaffs...</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs is designed for data safety and rigorously tested to ensure it does the best possible to keep users\' data safe. It\'s been crash-tested it hundreds of thousands of times ...</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:418\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.596,1,'config:filter.format.basic_html node:418 node_view rendered user:1','274'),('entity_view:node:418:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"418\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:418\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.595,1,'config:filter.format.basic_html node:418 node_view rendered user:1','274'),('entity_view:node:41:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01QeaPJaHjs2dwkE_1lpycokP2dANJ1l-u8PSLT22joFo','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:11243:\"<article role=\"article\" about=\"/archive/jffs2-and-nand-study\" typeof=\"schema:WebPage\" class=\"page full clearfix\">\n\n  \n      <span property=\"schema:name\" content=\"JFFS2 and NAND study\" class=\"hidden\"></span>\n\n\n  \n  <div class=\"content\">\n    \n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>For the purposes of this discussion, the term NAND will mean both AND and NAND type flash memories, both sharing similar properties from a system perspective.</p>\n<h3>A bit of history -</h3>\n<p>History on my perspective, not the history of JFFS2.</p>\n<p>&nbsp;</p>\n<p>Some years ago I wrote a flash file system for Trimble. Trimble patented this system. This FFS runs on NOR flash and uses a concepts very similar to JFFS to overcome problems associated with Flash Translation Layers, FTLs and flash. This FFS was rigorously tested for block failure, stress tested in various ways and deliberately crashed with an emulator at critical stages to attempt to damage data integrity. The FFS held up to all this.</p>\n<p>Thus, when looking at JFFS2 I can immediately understand why certain things are being done and various benefits of this approach over FTLs.</p>\n<p>At first I thought that using an FTL would be better than JFFS2 for NAND because NAND has a different set of constraints. After a bit of analysis, I came around to thinking that using JFFS2 would still be better than an FTL mainly because JFFS2 dispenses with the need for a logical to physical translation layer.</p>\n<p>&nbsp;</p>\n<h3>NOR and NAND</h3>\n<p>The following table highlights some of the important properties of NOR and NAND flash. This table holds true for most devices, though there are some odd-ball devices out there.</p>\n<p>&nbsp;</p>\n<table border=\"1\" cellpadding=\"1\" style=\"border-spacing: 0px; width: 568px;\">\n<tbody>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p><strong>NOR</strong></p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p><strong>NAND</strong></p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Cost $HIGHER</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Cost LOWER</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Low density (approx 8MB max device size)</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Higher density (approx 256MB max device size)</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Linear random access:</p>\n  <ul>\n   <li>\n   <p>Like RAM</p>\n    </li>\n   <li>\n   <p>Can be used for XIP</p>\n    </li>\n  </ul>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Sector read/write:</p>\n  <ul>\n   <li>\n   <p>Almost like a disk.</p>\n    </li>\n   <li>\n   <p>Can\'t be used for XIP</p>\n    </li>\n  </ul>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Structured as erasable blocks of 8kB to 128kB typical.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Structured as erasable blocks of 32x512-byte pages. Each page has 16-bytes of extra management data.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Endurance 100k to 1M erasures</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Endurance 100k to 1M erasures</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Erase time 1second/erasable block</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Erase time 2ms</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Designed as ROM replacements</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Designed as mass storage replacements</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Byte-by-byte programming allowing single-bit modification. Any single bit can be modified from a 1 to a 0 by programming that byte. However, the only way to modify a 0 to a 1 is to erase the entire erasable block.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Page or partial-page programming. A page may be programmed a maximum number of times. After that number of times, the erasable block must be erased to allow further programming. Write operations can only modify 1s to 0s. Changing 0s to 1s requires an erasure.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Random access programming.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Pages must be written sequentially within a block.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>No bad blocks when delivered, but the devices wear out. Thus file systems should be fault tolerant.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Bad blocks are expected when the devices are delivered. Further degradation is expected with use. Thus fault tolerance is an absolute necessity.</p>\n   </td>\n </tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>It is important to note the various differences between NOR and NAND flash, because these are material in choosing the appropriate file systems for each. In particular:</p>\n<ul>\n<li>\n<p>The erasure times are very different. This impacts on the selection of appropriate garbage collection and erasure strategies. NOR\'s 1 second erasure time is significant and needs to be considered; NAND\'s 2msec erasure time is virtually insignificant.</p>\n </li>\n</ul>\n<ul>\n<li>\n<p>The programming access restrictions that apply to NAND do not apply to NOR.</p>\n </li>\n<li>\n<p>Errors are far more likely in NAND devices, therefore error detection and correction is highly desirable.</p>\n </li>\n<li>\n<p>NAND flash is arranged in pages/sectors of 512b and is inherently block structured.</p>\n </li>\n</ul>\n<p>Both families of flash technology have significant usage restrictions which require special consideration when using the devices for file storage:</p>\n<ul>\n<li>\n<p>All flash memory blocks can only endure a limited number of erasure cycles. Some wear levelling strategy is required to prevent often-used sectors wearing out faster.</p>\n </li>\n<li>\n<p>Sectors, are smaller than an erasable block. Thus, some garbage collection strategy is required to reclaim deleted/dirty sectors. To accomplish this, the \"good data\" must be copied off the selected block so that the whole block can be erased without losing data.</p>\n </li>\n<li>\n<p>If a part of a file needs to be overwritten, it is a limitation of flash memory that the new data cannot just overwrite the data at the same physical location. Instead the data must be written at a new location. Thus, some sort of logical to physical mapping layer (ie. FTL) or alternative data storage approach is required (eg. JFFS2). Such logical to physical decoupling is also required to perform garbage collection.</p>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>Flash file systems in general</h3>\n<p>Flash file systems can essentially be implemented in two possible ways:</p>\n<ul>\n<li>\n<p>Custom-built file system. ie. the whole file system is designed so as to operate with flash memory. An example of this is JFFS2 or Microsoft FFS2.</p>\n </li>\n<li>\n<p>Use a standard file system with a custom block driver (ie Flash Translation Layer - FTL).</p>\n </li>\n</ul>\n<p>Each of these approaches have their pros and cons. FTLs are particularly suited to situations where the file system is pre-ordained; a custom file system is able to be more \"flash friendly\".</p>\n<h3>An appraisal of the JFFS2 file system</h3>\n<p>JFFS, and JFFS2, achieve the logical decoupling between logical file positions and physical memory by using journaling. For this to work, the entire file system must be designed to support journaling - as appropriate to flash memory. This is not excessively restrictive with non-removable media and embedded systems since there is no need to conform to a legacy file system layout.</p>\n<p>JFFS2 is designed to support NOR flash, but is currently not suited to NAND flash since it does not handle bad blocks. If this deficiency was addressed would it be a better choice for NAND than an FTL? Probably not directly, some other tweaks would be needed.</p>\n<p>Journaling is particularly useful: Garbage collection, bad block handling and the restrictions which prevent flash sectors being overwritten mean that data in flash file systems is forever being moved around. For FTLs this means storing logical to physical mappings. Journaling neatly sidesteps this overhead.</p>\n<p>One of the most thorny issues with flash file systems is that there are many patents covering both FTL-like block drivers and various approaches to custom file systems.</p>\n<p>These patents are particularly restrictive in FTL-like block drivers (especially the M-Systems patents). JFFS2 does not violate any patents I am aware of, but it probably comes quite close to some - particularly the Trimble one. Thus it is highly beneficial to have a GPL\'ed system that can be extended.</p>\n<h3>Work needed</h3>\n<p>The following effort is required to make JFFS2 work with NAND:</p>\n<ul>\n<li>\n<p>New MTDs for NAND flash. A new interface is probably required for NAND since many of the functions for NOR make no sense on NAND.</p>\n </li>\n</ul>\n<ul>\n<li>\n<p>Bad block handling. This could be handled in a NOR-specific layer, although it should really be generically supported since NOR can fail too.</p>\n </li>\n<li>\n<p>ECC for data security. Code available from Samsung www. This can be handled as part of the write and read. When a journaling node is written, it should be verified. If the data cannot be retrieved, then a new node is created.</p>\n </li>\n<li>\n<p>Fixed size journaling nodes (since NAND is page oriented with limited writes per page). This might make compression challenging - maybe compression can\'t be used with NAND? Anyway, fixed-size journaling nodes probably reduce fragmentation too (since there\'s an integer number of these per erasable block).</p>\n </li>\n</ul>\n<p>&nbsp;</p>\n<p>The following are possible improvements:</p>\n<ul>\n<li>\n<p>Tuning garbage collection/erasure strategies to suite NAND (eg. NAND erasure time is much faster). Using fixed-size nodes will probably strip out a chunk of code too.</p>\n </li>\n<li>\n<p>Attempting to use the spare 16 bytes per page for journalling tags (if there\'s a useful amount of space left after ECC and bad block management).</p>\n </li>\n</ul>\n<p>Thus, my preliminary suggestion would be to add a NAND sub-system to JFFS2. This subsystem would use the same journaling file system core. Fixing the size of journaling nodes to \"pages\" of 512 bytes quite likely simplifies the interfaces, node management and garbage collection.</p>\n<p>Error handling would fit within the NAND subsystem. Since NOR fails too, bad block handling is really required for NOR too. Whether the same management is appropriate for both is TBD. ECC is only required for NAND.</p>\n<p>&nbsp;</p>\n<p><a name=\"_1065327724\" id=\"_1065327724\"></a> <a name=\"_1065291949\" id=\"_1065291949\"><img border=\"0\" height=\"190\" src=\"/sites/yaffs.net/files/sv9379380.gif\" width=\"227\" alt=\"image\" /></a></p>\n<p><a name=\"_1065291949\"></a></p>\n<h3><a name=\"_1065291949\">References</a></h3>\n<p><a name=\"_1065291949\">Samsung and Toshiba NAND part data sheets and www. Samsung in particular has useful applications notes and code.</a></p>\n<p><a name=\"_1065291949\">JFFS2 presentation materials. http://sources.redhat.com/jffs2/</a></p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:29:\"/archive/jffs2-and-nand-study\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:8:\"/node/41\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:29:\"/archive/jffs2-and-nand-study\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:41\";i:3;s:9:\"node_view\";i:4;s:6:\"user:4\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:57:\"<span property=\"schema:name\">JFFS2 and NAND study</span>\n\";}}',-1,1504790504.594,1,'config:filter.format.full_html config:system.site node:41 node_view rendered user:4','306'),('entity_view:node:41:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"41\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:41\";i:3;s:9:\"node_view\";i:4;s:6:\"user:4\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504790504.591,1,'config:filter.format.full_html config:system.site node:41 node_view rendered user:4','306'),('entity_view:node:41:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:11038:\"<span property=\"schema:name\">JFFS2 and NAND study</span>\n\n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>For the purposes of this discussion, the term NAND will mean both AND and NAND type flash memories, both sharing similar properties from a system perspective.</p>\n<h3>A bit of history -</h3>\n<p>History on my perspective, not the history of JFFS2.</p>\n<p>&nbsp;</p>\n<p>Some years ago I wrote a flash file system for Trimble. Trimble patented this system. This FFS runs on NOR flash and uses a concepts very similar to JFFS to overcome problems associated with Flash Translation Layers, FTLs and flash. This FFS was rigorously tested for block failure, stress tested in various ways and deliberately crashed with an emulator at critical stages to attempt to damage data integrity. The FFS held up to all this.</p>\n<p>Thus, when looking at JFFS2 I can immediately understand why certain things are being done and various benefits of this approach over FTLs.</p>\n<p>At first I thought that using an FTL would be better than JFFS2 for NAND because NAND has a different set of constraints. After a bit of analysis, I came around to thinking that using JFFS2 would still be better than an FTL mainly because JFFS2 dispenses with the need for a logical to physical translation layer.</p>\n<p>&nbsp;</p>\n<h3>NOR and NAND</h3>\n<p>The following table highlights some of the important properties of NOR and NAND flash. This table holds true for most devices, though there are some odd-ball devices out there.</p>\n<p>&nbsp;</p>\n<table border=\"1\" cellpadding=\"1\" style=\"border-spacing: 0px; width: 568px;\">\n<tbody>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p><strong>NOR</strong></p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p><strong>NAND</strong></p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Cost $HIGHER</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Cost LOWER</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Low density (approx 8MB max device size)</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Higher density (approx 256MB max device size)</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Linear random access:</p>\n  <ul>\n   <li>\n   <p>Like RAM</p>\n    </li>\n   <li>\n   <p>Can be used for XIP</p>\n    </li>\n  </ul>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Sector read/write:</p>\n  <ul>\n   <li>\n   <p>Almost like a disk.</p>\n    </li>\n   <li>\n   <p>Can\'t be used for XIP</p>\n    </li>\n  </ul>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Structured as erasable blocks of 8kB to 128kB typical.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Structured as erasable blocks of 32x512-byte pages. Each page has 16-bytes of extra management data.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Endurance 100k to 1M erasures</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Endurance 100k to 1M erasures</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Erase time 1second/erasable block</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Erase time 2ms</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Designed as ROM replacements</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Designed as mass storage replacements</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Byte-by-byte programming allowing single-bit modification. Any single bit can be modified from a 1 to a 0 by programming that byte. However, the only way to modify a 0 to a 1 is to erase the entire erasable block.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Page or partial-page programming. A page may be programmed a maximum number of times. After that number of times, the erasable block must be erased to allow further programming. Write operations can only modify 1s to 0s. Changing 0s to 1s requires an erasure.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>Random access programming.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Pages must be written sequentially within a block.</p>\n   </td>\n </tr>\n <tr valign=\"top\">\n  <td style=\"width: 281px;\">\n  <p>No bad blocks when delivered, but the devices wear out. Thus file systems should be fault tolerant.</p>\n   </td>\n  <td style=\"width: 281px;\">\n  <p>Bad blocks are expected when the devices are delivered. Further degradation is expected with use. Thus fault tolerance is an absolute necessity.</p>\n   </td>\n </tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>It is important to note the various differences between NOR and NAND flash, because these are material in choosing the appropriate file systems for each. In particular:</p>\n<ul>\n<li>\n<p>The erasure times are very different. This impacts on the selection of appropriate garbage collection and erasure strategies. NOR\'s 1 second erasure time is significant and needs to be considered; NAND\'s 2msec erasure time is virtually insignificant.</p>\n </li>\n</ul>\n<ul>\n<li>\n<p>The programming access restrictions that apply to NAND do not apply to NOR.</p>\n </li>\n<li>\n<p>Errors are far more likely in NAND devices, therefore error detection and correction is highly desirable.</p>\n </li>\n<li>\n<p>NAND flash is arranged in pages/sectors of 512b and is inherently block structured.</p>\n </li>\n</ul>\n<p>Both families of flash technology have significant usage restrictions which require special consideration when using the devices for file storage:</p>\n<ul>\n<li>\n<p>All flash memory blocks can only endure a limited number of erasure cycles. Some wear levelling strategy is required to prevent often-used sectors wearing out faster.</p>\n </li>\n<li>\n<p>Sectors, are smaller than an erasable block. Thus, some garbage collection strategy is required to reclaim deleted/dirty sectors. To accomplish this, the \"good data\" must be copied off the selected block so that the whole block can be erased without losing data.</p>\n </li>\n<li>\n<p>If a part of a file needs to be overwritten, it is a limitation of flash memory that the new data cannot just overwrite the data at the same physical location. Instead the data must be written at a new location. Thus, some sort of logical to physical mapping layer (ie. FTL) or alternative data storage approach is required (eg. JFFS2). Such logical to physical decoupling is also required to perform garbage collection.</p>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>Flash file systems in general</h3>\n<p>Flash file systems can essentially be implemented in two possible ways:</p>\n<ul>\n<li>\n<p>Custom-built file system. ie. the whole file system is designed so as to operate with flash memory. An example of this is JFFS2 or Microsoft FFS2.</p>\n </li>\n<li>\n<p>Use a standard file system with a custom block driver (ie Flash Translation Layer - FTL).</p>\n </li>\n</ul>\n<p>Each of these approaches have their pros and cons. FTLs are particularly suited to situations where the file system is pre-ordained; a custom file system is able to be more \"flash friendly\".</p>\n<h3>An appraisal of the JFFS2 file system</h3>\n<p>JFFS, and JFFS2, achieve the logical decoupling between logical file positions and physical memory by using journaling. For this to work, the entire file system must be designed to support journaling - as appropriate to flash memory. This is not excessively restrictive with non-removable media and embedded systems since there is no need to conform to a legacy file system layout.</p>\n<p>JFFS2 is designed to support NOR flash, but is currently not suited to NAND flash since it does not handle bad blocks. If this deficiency was addressed would it be a better choice for NAND than an FTL? Probably not directly, some other tweaks would be needed.</p>\n<p>Journaling is particularly useful: Garbage collection, bad block handling and the restrictions which prevent flash sectors being overwritten mean that data in flash file systems is forever being moved around. For FTLs this means storing logical to physical mappings. Journaling neatly sidesteps this overhead.</p>\n<p>One of the most thorny issues with flash file systems is that there are many patents covering both FTL-like block drivers and various approaches to custom file systems.</p>\n<p>These patents are particularly restrictive in FTL-like block drivers (especially the M-Systems patents). JFFS2 does not violate any patents I am aware of, but it probably comes quite close to some - particularly the Trimble one. Thus it is highly beneficial to have a GPL\'ed system that can be extended.</p>\n<h3>Work needed</h3>\n<p>The following effort is required to make JFFS2 work with NAND:</p>\n<ul>\n<li>\n<p>New MTDs for NAND flash. A new interface is probably required for NAND since many of the functions for NOR make no sense on NAND.</p>\n </li>\n</ul>\n<ul>\n<li>\n<p>Bad block handling. This could be handled in a NOR-specific layer, although it should really be generically supported since NOR can fail too.</p>\n </li>\n<li>\n<p>ECC for data security. Code available from Samsung www. This can be handled as part of the write and read. When a journaling node is written, it should be verified. If the data cannot be retrieved, then a new node is created.</p>\n </li>\n<li>\n<p>Fixed size journaling nodes (since NAND is page oriented with limited writes per page). This might make compression challenging - maybe compression can\'t be used with NAND? Anyway, fixed-size journaling nodes probably reduce fragmentation too (since there\'s an integer number of these per erasable block).</p>\n </li>\n</ul>\n<p>&nbsp;</p>\n<p>The following are possible improvements:</p>\n<ul>\n<li>\n<p>Tuning garbage collection/erasure strategies to suite NAND (eg. NAND erasure time is much faster). Using fixed-size nodes will probably strip out a chunk of code too.</p>\n </li>\n<li>\n<p>Attempting to use the spare 16 bytes per page for journalling tags (if there\'s a useful amount of space left after ECC and bad block management).</p>\n </li>\n</ul>\n<p>Thus, my preliminary suggestion would be to add a NAND sub-system to JFFS2. This subsystem would use the same journaling file system core. Fixing the size of journaling nodes to \"pages\" of 512 bytes quite likely simplifies the interfaces, node management and garbage collection.</p>\n<p>Error handling would fit within the NAND subsystem. Since NOR fails too, bad block handling is really required for NOR too. Whether the same management is appropriate for both is TBD. ECC is only required for NAND.</p>\n<p>&nbsp;</p>\n<p><a name=\"_1065327724\" id=\"_1065327724\"></a> <a name=\"_1065291949\" id=\"_1065291949\"><img border=\"0\" height=\"190\" src=\"/sites/yaffs.net/files/sv9379380.gif\" width=\"227\" alt=\"image\" /></a></p>\n<p><a name=\"_1065291949\"></a></p>\n<h3><a name=\"_1065291949\">References</a></h3>\n<p><a name=\"_1065291949\">Samsung and Toshiba NAND part data sheets and www. Samsung in particular has useful applications notes and code.</a></p>\n<p><a name=\"_1065291949\">JFFS2 presentation materials. http://sources.redhat.com/jffs2/</a></p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:41\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505426007.204,1,'config:filter.format.full_html node:41 node_view rendered','297'),('entity_view:node:41:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"41\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:41\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505426007.201,1,'config:filter.format.full_html node:41 node_view rendered','297'),('entity_view:node:420:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0A3VMJnnZZ6BCfgl4dr6ZiGqHGbY5ssq-cSmlFvIWAyM','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:61467:\"<article role=\"article\" about=\"/documents/yaffs-robustness-and-testing\" class=\"paper is-promoted full clearfix\">\n\n  \n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/charles-manning\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Charles Manning</span></span>\n on <span>8 June, 2012 - 2:35am</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    \n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsRobustnessAndTesting.pdf\" type=\"application/pdf; length=143414\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsRobustnessAndTesting.pdf</a></span><span class=\"file-size\">140.05 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Many embedded systems need to store critical data, making reliable file systems an important part of modern embedded system design. That robustness is not achieved through chance. Robustness is only achieved through design and extensive testing to verify that the file system functions correctly and is resistant to power failure.</p>\n<p>This document describes some of the important design criteria and design features used to achieve a robust design.</p>\n<p style=\"page-break-before: always\"></p>\n<h1 class=\"western\">1 Background</h1>\n<p>Cheaper CPUs and flash have driven up embedded system functionality. These increased functions often require file system storage.</p>\n<p>The original flash file storage mechanisms were the use of a flash translation layer (FTL) – a driver model which makes flash memory appear as a disk drive – in conjunction with a disk-oriented file system such as FAT. This storage methodology has various performance and robustness limitations, leading to the development of file systems designed specifically for flash memory. These are known as flash file systems.</p>\n<p>Flash memory has various limitations when compared with a disk. For example, flash memory pages cannot be individually re-written but instead the whole block must be erased and rewritten with the modified page. Typical FTL achieve this with various logical to physical mapping schemes. Thus emulating disk-like behaviour on flash memory adds an extra layer of software which slows down write performance. Worse still, it adds extra state which is prone to corruption due to power failure.</p>\n<p>A typical FTL-based solution will use a file system such as FAT. FAT always stores tables in the same disk blocks and must thus change the same blocks often. Since flash memory blocks can endure a limited number of write/erasure cycles, the FTL must move the physical location of the block around to prevent the high traffic blocks from wearing out. This requires wear levelling – a further burden.</p>\n<p>Some systems try to mitigate against the performance penalties by caching a lot of data to reduce writes. While this can go some way towards reducing the apparent write time, it does make the solution prone to data loss in the event of a power failure.</p>\n<p>As well as limitations, flash memory also has certain advantages when compared to rotating media. There is no spin up time, making it more responsive. There is no read head so there is no read penalty if data is fragmented. Flash file systems can be designed to exploit these advantages.</p>\n<p>True flash file systems<a class=\"sdfootnoteanc\" name=\"sdfootnote1anc\" href=\"#sdfootnote1sym\" id=\"sdfootnote1anc\"><sup>1</sup></a>, on the other hand, are a single code body designed to take the features and limitations of flash into consideration. Flash file systems can thus be far more “flash friendly”. Well designed flash file systems will avoid using “flash unfriendly” techniques such as allocation tables and in-place rewriting.</p>\n<p>Yaffs is a flash file system, originally designed specifically for NAND flash though also used with great success on NOR flash too. Yaffs development started in 2001 when 32Mbytes of flash was considered large. Since then, Yaffs has been expanded to work properly with different flash types and far larger memory arrays (many GBytes).</p>\n<p>Yaffs was originally deployed in Linux, but was written in an OS neutral way, mainly to facilitate modular development and testing. This turned out to be useful when we had requests to port Yaffs to other operating systems. Since then, Yaffs has been used in many different products in a wide variety of applications from consumer products such as cell phones and sewing machines to aerospace, industrial and medical applications including process control, building management, communications infrastructure and many others.</p>\n<p>Yaffs is not tied to any endian ordering and has been used on a wide variety of architectures including ARM, MIPS, PowerPC, x86, some DSPs. Yaffs has been deployed using a wide variety of compilers from many different vendors.</p>\n<p>Nor is Yaffs tied to any particular operating system. Yaffs has been used with Linux, eCOS, Windows Embedded Compact (previously Windows CE), VxWorks and others.</p>\n<h1 class=\"western\">2 Flash File System considerations</h1>\n<p>There are many criteria that are important when selecting a flash file system. These are some that out customers have found to be most important:</p>\n<ul>\n<li>\n<p>Robustness: It really is not worth having a file system that loses or corrupts data and prevents the system from working properly. Some flash file systems are only robust when synced (flushed) after files have been written. That requires extra code, slows the system and leaves the file system in a non-deterministic state until the sync has been completed. Some file systems need to perform disk repair operations (eg. check disk) in the event of a power failure. This can add considerable time to the start up, preventing the system from being operational.</p>\n </li>\n<li>\n<p>Performance: In many embedded system designs, slow read/write performance can delay tasks and cause system degradation or even failure. It is thus important that read/write performance be acceptable. Note that many flash file systems need to perform extra actions such as garbage collection. In some cases these actions can cause the file system to stall for a long time. It is thus important that these factors be taken into consideration. Performance can sometimes be improved by adding a write caching layer. These caching layers make the file system calls (write etc) proceed quickly, without actually writing the data to flash. This is a two-edged sword as data in the cache will be lost on a power failure and syncing the file system will take a long time. Thus, most flash file systems offer either speed or robustness – not both.</p>\n </li>\n<li>\n<p>Proven: It is very easy for a file system vendor to provide a list of claims saying “100% power safe” or similar, but what evidence do they have to back this up? All file systems, including flash file systems, are complex bodies of software with extremely complex state. They need very significant testing to prove that they work correctly.</p>\n </li>\n<li>\n<p>Portable: Software is a huge investment and it is increasingly important to be able to port the software between OSs and CPU architectures. Most flash file systems are limited to a single operating system which makes it difficult to migrate software between different platforms. In Yaffs\' case portability extends to being able to seamlessly migrate the core Yaffs code into a test framework which enhances testing.</p>\n </li>\n</ul>\n<h1 class=\"western\">3 How Yaffs achieves robustness and performance</h1>\n<p>Yaffs was designed from the ground up specifically to work well with NAND flash. The author had already developed another flash file system, so was already familiar with the design challenges of flash.</p>\n<p>As Yaffs is not just adapting a disk-oriented file system to work with flash it is not surprising that Yaffs is very different in design to most other file systems. The key difference is that Yaffs is a log-structured. file system<a class=\"sdfootnoteanc\" name=\"sdfootnote2anc\" href=\"#sdfootnote2sym\" id=\"sdfootnote2anc\"><sup>2</sup></a>.</p>\n<p>In essence, a log structured file system writes file system changes as a sequential log. The log structure is particularly suitable for various reasons including:</p>\n<ul>\n<li>\n<p>All writes are at the end of the log. When a file is modified, there is no need to erase and rewrite a part of the flash. Changes are just appended to the log. Thus there is no need to erase and copy old data just to change some existing pages in a file. This tends to make writes much faster. There is no need to do a lot of caching to achieve performance. Data can be written to the log immediately meaning that sync time is very low. Data robustness is improved dramatically.</p>\n </li>\n<li>\n<p>There are no allocation tables or similar. This reduces the amount of data being written to the flash, and that there are no tables to corrupt.</p>\n </li>\n<li>\n<p>Since all writes are to the end of the log there are no “high traffic” blocks. This means Yaffs only needs a simpler wear leveling strategy.</p>\n </li>\n<li>\n<p>In the event of a power failure, the file system state is easily re-created from the log. This means there is no need to perform disk repair operations to correct for an unclean shutdown.</p>\n </li>\n</ul>\n<p>So why don\'t we see many log structured file systems for disk file systems? The answer to this is that log file systems tend to spread the writes around on the media. That is typically very problematic for mechanical storage which must physically move the read/write head from one location to another making the access time very slow. Of course that does not apply for flash memory. By designing specifically for flash, Yaffs can ignore this issue and write fast.</p>\n<p>Many flash file systems need make a compromise between robustness against performance. Thanks to the log structure, Yaffs does not need to. Yaffs can provide high performance without giving up on robustness.</p>\n<p>Those familiar with log structured file system design will know that some log structured file systems have problems with garbage collection<a class=\"sdfootnoteanc\" name=\"sdfootnote3anc\" href=\"#sdfootnote3sym\" id=\"sdfootnote3anc\"><sup>3</sup></a>. Garbage collection is used to clean up the log and make more free space available. Some log structured file system designs did not pay enough attention to garbage collection and can stall for a considerable time while garbage collection happens. Yaffs was designed differently. The potential impact of garbage collection was considered throughout the Yaffs design process. As a result, Yaffs has a very simple garbage collection model that allows a lot of flexibility in garbage collection scheduling. This prevents the garbage collection from making the file system unresponsive.</p>\n<p>Most file systems are developed within the context, and framework of, a single operating system. This typically makes the code difficult to explore, debug and port. Yaffs on the other hand was developed from the start inside a portable development/testing framework. Yaffs is then ported to various operating systems through the addition of glue code.</p>\n<p><br />\n<br />\n</p>\n<p><img src=\"data:image/png;base64,[encoded data, 38784 characters]\" width=\"552\" height=\"524\" alt=\"image\" id=\"Object1\" /> <br />\n<br />\n</p>\n<p>There are many benefits to this approach:</p>\n<ul>\n<li>\n<p>A development framework runs in user space which provides a richer development environment than inside an OS kernel. It is much easier to attach debuggers and perform logging and create reproducible testing.</p>\n </li>\n<li>\n<p>The code is structured to be portable. That makes it relatively easy to port to a new OS or RTOS with a high level of confidence.</p>\n </li>\n<li>\n<p>There is a choice of porting interfaces allowing more flexibility to determine which porting method will be simpler. For example, the Linux wrapper accesses the Yaffs core directly while the Windows CE wrapper access the Yaffs Direct Interface<a class=\"sdfootnoteanc\" name=\"sdfootnote4anc\" href=\"#sdfootnote4sym\" id=\"sdfootnote4anc\"><sup>4</sup></a>.</p>\n </li>\n<li>\n<p>Each different environment provides different test tools. For example, Linux provides a raft of file system test tools that do different kinds of testing to the power fail test harness. Since the vast majority of the code is in the portable Yaffs core, that code gets the advantage of all test methods combined. The many millions of Android phone users that use Yaffs-based devices are helping test the core code that is also used on a wide variety of different operating systems and a wide range of different device types.</p>\n </li>\n<li>\n<p>Its Open Source status means any interested person can take a version from git and test it to make sure that it meets their needs.</p>\n </li>\n</ul>\n<h1 class=\"western\">4 Testing</h1>\n<p>It is all very well to design software to be robust, but it needs thorough testing to build confidence in the software and in the code authors and supplier.</p>\n<p>File systems have incredibly complex state so it is not at all surprising that operating system designers find file systems some of the most challenging code to test.</p>\n<p>There is no single test methodology that can test all cases, and exhaustive state testing is impossible. The best we can do is to have a suite of test methodologies that combine to provide thorough testing.</p>\n<p>Approximately 60% of Yaffs development effort is directed towards testing and improving the test environment. We are constantly researching new methodologies.</p>\n<p>The following are descriptions of the most important test strategies used in Yaffs.</p>\n<h2 class=\"western\">4.1 Power Fail Stress Testing</h2>\n<p>By far the most important consideration in Yaffs testing is that it is robust to corruptions caused by power failure. We want Yaffs to provide the basis for reliable products in typical embedded system environments.</p>\n<p>The first power fail testing was done by companies integrating Yaffs into their products. Some of these built test jigs which would automatically interrupt power while running a real hardware device. This approach is better than nothing, but has some limitations:</p>\n<ul>\n<li>\n<p>It is relatively costly to set up. Flash has a limited lifetime meaning that test devices wear out with time and must be replaced.</p>\n </li>\n<li>\n<p>It is relatively slow since each cycle takes many seconds to boot, run the application for a while and then reboot.</p>\n </li>\n<li>\n<p>Many, and perhaps most, of the power interruptions will happen at times when the file system is inactive and thus be wasted cycles.</p>\n </li>\n</ul>\n<p>In 2008 we developed a simulated power-fail-test environment. This simulates power failures using simulated flash memory while running various consistency checks.</p>\n<p>The benefits of a software-based test harness are numerous:</p>\n<ul>\n<li>\n<p>The test harness controls the point at which the simulated power failures happen. That means every test cycle counts.</p>\n </li>\n<li>\n<p>No special hardware is required.</p>\n </li>\n<li>\n<p>Test loops run faster. A quad-core computer can simulate ten to twenty power failures per second. That means about a million power failure simulations per day.</p>\n </li>\n</ul>\n<p>The effectiveness of the new software based testing is dramatic.. A few times we have tested some user-suggested changes that had passed a week or more of real-world power fail testing only to have problems caught by the software simulation in a matter of minutes.</p>\n<p>We regularly run the power fail simulation test over a weekend, testing millions of power fail cycles.</p>\n<h2 class=\"western\">4.2 Testing the Yaffs Direct Interface API</h2>\n<p>Yaffs Direct Interface (YDI) is a POSIX-like wrapper around the Yaffs core. This provides a set of function calls, yaffs_open(), yaffs_write() and the like.</p>\n<p>Each function can return numerous error codes and has to handle numerous different parameters.</p>\n<p>Although there were already significant tests for the YDI, an extensive test harness was developed in 2010 to comprehensively test each of the error paths and generate all of the required errors.</p>\n<p>This provides a high level of confidence that the test interfaces do what they should and that POSIX-like functionality provides relatively clean porting of existing code.</p>\n<h2 class=\"western\">4.3 Linux Testing</h2>\n<p>The main purpose of the Linux testing is to test the Linux wrapper code. It does, however, still exercise the Yaffs core code differently to other testing and thus adds to the test fabric.</p>\n<p>The Linux testing does not do power fail testing but instead tests other aspects such as clean shutdowns, cache integrity and write performance. This gives a useful way to assess the effects of modifications.</p>\n<p>Linux testing is done on both real hardware and on simulated hardware using the Linux mtd nand simulator.</p>\n<p>As with the Power Fail Stress Testing described above, the simulated testing is done using a scrippted environment which is typically run for a few days at a time.</p>\n<h2 class=\"western\">4.4 Fuzz Testing</h2>\n<p>Fuzz testing deliberately corrupts the flash image and ensures that Yaffs still mounts. This is done to ensure that Yaffs does not crash on corrupted data.</p>\n<p>Clearly fuzz testing can corrupt the contents of individual files (that\'s its job), but the file system integrity should not be compromised. </p>\n<h2 class=\"western\">4.5 Software checking</h2>\n<p>Although code checking is not actual testing per se, it does help to verify code changes.</p>\n<p>The Yaffs code has been checked with Coverity<a class=\"sdfootnoteanc\" name=\"sdfootnote5anc\" href=\"#sdfootnote5sym\" id=\"sdfootnote5anc\"><sup>5</sup></a> – a market leader in code checking.</p>\n<p>We are investigating the use of KLEE and other tools.</p>\n<h2 class=\"western\">4.6 Open Source Usage</h2>\n<p>Open Source usage of Yaffs opens it up to testing by the many different projects. Many of these participate in some way with the Yaffs mailing list, helping to uncover issues and generally provide feedback.</p>\n<p>Each different project uses Yaffs in a different way, meaning that a wider range of operation sequences are tested.</p>\n<h2 class=\"western\">4.7 Universities</h2>\n<p>Over its lifetime, Yaffs has been used as a teaching framework for various university course in many different counties around the world.</p>\n<p>For example, Oregon State and Utah State Universities have used Yaffs as a test bench for their post-graduate software testing courses. They essentially test the test tools by injecting errors into the Yaffs code and seeing if these are discovered by the test tools they are testing. Of course this has the side effect of running these tests over the original Yaffs code too. </p>\n<p>Those interested in test methods are encouraged to read some of the university papers in the references of this document.</p>\n<p>We expect to adopt and extend some of the Oregon State ideas and use these to extend our in-house test suite.</p>\n<h1 class=\"western\">5 Conclusions</h1>\n<p>Software development is an iterative process of design and testing. Robust software solutions are only possible with extensive testing.</p>\n<p>Embedded systems increasingly need to store data in file systems as a critical part of their operation. It is thus important to have a file system that is predictable and robust to power failure and similar interruptions.</p>\n<p>Yaffs has been designed from scratch to be robust to power failure and that robustness has been verified with a multi-pronged test strategy that is continuously being improved.</p>\n<h1 class=\"western\" style=\"page-break-before: always\">6References</h1>\n<p>Charles Manning, “How Yaffs Works”.<br />\n<a href=\"http://users.actrix.co.nz/manningc/yaffs-docs/HowYaffsWorks.pdf\">http://users.actrix.co.nz/manningc/yaffs-docs/HowYaffsWorks.pdf</a></p>\n<p><br />\n<br />\n</p>\n<p>A. Groce et al, “Swarm Testing” from Oregon State University, School of EE and Computer Science and Utah State University, School of Computing, 2011.<br />\n<a href=\"http://www.ct.utah.edu/~regehr/papers/swarm12.pdf\">http://</a><a href=\"http://www.ct.utah.edu/~regehr/papers/swarm12.pdf\">www.ct.utah.edu/~regehr/papers/swarm12.pdf</a></p>\n<p><br />\n<br />\n</p>\n<p><em>Wu CH, “Efficient Initialization and Crash Recovery</em> for. <em>Log</em>-<em>based File Systems</em> over Flash Memory” from National Taiwan University, Dept of Computer Science, <span style=\"font-style: normal\">2006.<br />\nhttp://</span><cite>www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf</cite></p>\n<p style=\"font-style: normal\"><br />\n<br />\n</p>\n<div id=\"sdfootnote1\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote1sym\" href=\"#sdfootnote1anc\" id=\"sdfootnote1sym\">1</a>Note that flash translation layers (FTLs) are erroneously refered to as flash file systems. For example, despite the name, M-Systems TrueFFS is not a flash file system but a flash translation layer (FTL).</p>\n</div>\n<div id=\"sdfootnote2\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote2sym\" href=\"#sdfootnote2anc\" id=\"sdfootnote2sym\">2</a>This document only provides a brief overview of the Yaffs architecture and design. The “How Yaffs Works” document provides an in-depth explanation of the Yaffs design and architecture.</p>\n</div>\n<div id=\"sdfootnote3\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote3sym\" href=\"#sdfootnote3anc\" id=\"sdfootnote3sym\">3</a>Refer to the “How Yaffs Works” document to understand the need for garbage collection and how Yaffs does garbage collection.</p>\n</div>\n<div id=\"sdfootnote4\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote4sym\" href=\"#sdfootnote4anc\" id=\"sdfootnote4sym\">4</a>For more information on Yaffs Direct Interface, please read the various documents on the subject.</p>\n</div>\n<div id=\"sdfootnote5\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote5sym\" href=\"#sdfootnote5anc\" id=\"sdfootnote5sym\">5</a>http://www.coverity.com</p>\n</div>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:39:\"/documents/yaffs-robustness-and-testing\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/420\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:39:\"/documents/yaffs-robustness-and-testing\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:78\";i:3;s:8:\"node:420\";i:4;s:9:\"node_view\";i:5;s:6:\"user:6\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:42:\"<span>YAFFS Robustness and Testing</span>\n\";}}',-1,1504703262.926,1,'config:filter.format.raw_html config:system.site file:78 node:420 node_view rendered user:6','272'),('entity_view:node:420:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"420\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:78\";i:3;s:8:\"node:420\";i:4;s:9:\"node_view\";i:5;s:6:\"user:6\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504703262.913,1,'config:filter.format.raw_html config:system.site file:78 node:420 node_view rendered user:6','272'),('entity_view:node:420:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:61050:\"<span>YAFFS Robustness and Testing</span>\n\n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsRobustnessAndTesting.pdf\" type=\"application/pdf; length=143414\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsRobustnessAndTesting.pdf</a></span><span class=\"file-size\">140.05 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Many embedded systems need to store critical data, making reliable file systems an important part of modern embedded system design. That robustness is not achieved through chance. Robustness is only achieved through design and extensive testing to verify that the file system functions correctly and is resistant to power failure.</p>\n<p>This document describes some of the important design criteria and design features used to achieve a robust design.</p>\n<p style=\"page-break-before: always\"></p>\n<h1 class=\"western\">1 Background</h1>\n<p>Cheaper CPUs and flash have driven up embedded system functionality. These increased functions often require file system storage.</p>\n<p>The original flash file storage mechanisms were the use of a flash translation layer (FTL) – a driver model which makes flash memory appear as a disk drive – in conjunction with a disk-oriented file system such as FAT. This storage methodology has various performance and robustness limitations, leading to the development of file systems designed specifically for flash memory. These are known as flash file systems.</p>\n<p>Flash memory has various limitations when compared with a disk. For example, flash memory pages cannot be individually re-written but instead the whole block must be erased and rewritten with the modified page. Typical FTL achieve this with various logical to physical mapping schemes. Thus emulating disk-like behaviour on flash memory adds an extra layer of software which slows down write performance. Worse still, it adds extra state which is prone to corruption due to power failure.</p>\n<p>A typical FTL-based solution will use a file system such as FAT. FAT always stores tables in the same disk blocks and must thus change the same blocks often. Since flash memory blocks can endure a limited number of write/erasure cycles, the FTL must move the physical location of the block around to prevent the high traffic blocks from wearing out. This requires wear levelling – a further burden.</p>\n<p>Some systems try to mitigate against the performance penalties by caching a lot of data to reduce writes. While this can go some way towards reducing the apparent write time, it does make the solution prone to data loss in the event of a power failure.</p>\n<p>As well as limitations, flash memory also has certain advantages when compared to rotating media. There is no spin up time, making it more responsive. There is no read head so there is no read penalty if data is fragmented. Flash file systems can be designed to exploit these advantages.</p>\n<p>True flash file systems<a class=\"sdfootnoteanc\" name=\"sdfootnote1anc\" href=\"#sdfootnote1sym\" id=\"sdfootnote1anc\"><sup>1</sup></a>, on the other hand, are a single code body designed to take the features and limitations of flash into consideration. Flash file systems can thus be far more “flash friendly”. Well designed flash file systems will avoid using “flash unfriendly” techniques such as allocation tables and in-place rewriting.</p>\n<p>Yaffs is a flash file system, originally designed specifically for NAND flash though also used with great success on NOR flash too. Yaffs development started in 2001 when 32Mbytes of flash was considered large. Since then, Yaffs has been expanded to work properly with different flash types and far larger memory arrays (many GBytes).</p>\n<p>Yaffs was originally deployed in Linux, but was written in an OS neutral way, mainly to facilitate modular development and testing. This turned out to be useful when we had requests to port Yaffs to other operating systems. Since then, Yaffs has been used in many different products in a wide variety of applications from consumer products such as cell phones and sewing machines to aerospace, industrial and medical applications including process control, building management, communications infrastructure and many others.</p>\n<p>Yaffs is not tied to any endian ordering and has been used on a wide variety of architectures including ARM, MIPS, PowerPC, x86, some DSPs. Yaffs has been deployed using a wide variety of compilers from many different vendors.</p>\n<p>Nor is Yaffs tied to any particular operating system. Yaffs has been used with Linux, eCOS, Windows Embedded Compact (previously Windows CE), VxWorks and others.</p>\n<h1 class=\"western\">2 Flash File System considerations</h1>\n<p>There are many criteria that are important when selecting a flash file system. These are some that out customers have found to be most important:</p>\n<ul>\n<li>\n<p>Robustness: It really is not worth having a file system that loses or corrupts data and prevents the system from working properly. Some flash file systems are only robust when synced (flushed) after files have been written. That requires extra code, slows the system and leaves the file system in a non-deterministic state until the sync has been completed. Some file systems need to perform disk repair operations (eg. check disk) in the event of a power failure. This can add considerable time to the start up, preventing the system from being operational.</p>\n </li>\n<li>\n<p>Performance: In many embedded system designs, slow read/write performance can delay tasks and cause system degradation or even failure. It is thus important that read/write performance be acceptable. Note that many flash file systems need to perform extra actions such as garbage collection. In some cases these actions can cause the file system to stall for a long time. It is thus important that these factors be taken into consideration. Performance can sometimes be improved by adding a write caching layer. These caching layers make the file system calls (write etc) proceed quickly, without actually writing the data to flash. This is a two-edged sword as data in the cache will be lost on a power failure and syncing the file system will take a long time. Thus, most flash file systems offer either speed or robustness – not both.</p>\n </li>\n<li>\n<p>Proven: It is very easy for a file system vendor to provide a list of claims saying “100% power safe” or similar, but what evidence do they have to back this up? All file systems, including flash file systems, are complex bodies of software with extremely complex state. They need very significant testing to prove that they work correctly.</p>\n </li>\n<li>\n<p>Portable: Software is a huge investment and it is increasingly important to be able to port the software between OSs and CPU architectures. Most flash file systems are limited to a single operating system which makes it difficult to migrate software between different platforms. In Yaffs\' case portability extends to being able to seamlessly migrate the core Yaffs code into a test framework which enhances testing.</p>\n </li>\n</ul>\n<h1 class=\"western\">3 How Yaffs achieves robustness and performance</h1>\n<p>Yaffs was designed from the ground up specifically to work well with NAND flash. The author had already developed another flash file system, so was already familiar with the design challenges of flash.</p>\n<p>As Yaffs is not just adapting a disk-oriented file system to work with flash it is not surprising that Yaffs is very different in design to most other file systems. The key difference is that Yaffs is a log-structured. file system<a class=\"sdfootnoteanc\" name=\"sdfootnote2anc\" href=\"#sdfootnote2sym\" id=\"sdfootnote2anc\"><sup>2</sup></a>.</p>\n<p>In essence, a log structured file system writes file system changes as a sequential log. The log structure is particularly suitable for various reasons including:</p>\n<ul>\n<li>\n<p>All writes are at the end of the log. When a file is modified, there is no need to erase and rewrite a part of the flash. Changes are just appended to the log. Thus there is no need to erase and copy old data just to change some existing pages in a file. This tends to make writes much faster. There is no need to do a lot of caching to achieve performance. Data can be written to the log immediately meaning that sync time is very low. Data robustness is improved dramatically.</p>\n </li>\n<li>\n<p>There are no allocation tables or similar. This reduces the amount of data being written to the flash, and that there are no tables to corrupt.</p>\n </li>\n<li>\n<p>Since all writes are to the end of the log there are no “high traffic” blocks. This means Yaffs only needs a simpler wear leveling strategy.</p>\n </li>\n<li>\n<p>In the event of a power failure, the file system state is easily re-created from the log. This means there is no need to perform disk repair operations to correct for an unclean shutdown.</p>\n </li>\n</ul>\n<p>So why don\'t we see many log structured file systems for disk file systems? The answer to this is that log file systems tend to spread the writes around on the media. That is typically very problematic for mechanical storage which must physically move the read/write head from one location to another making the access time very slow. Of course that does not apply for flash memory. By designing specifically for flash, Yaffs can ignore this issue and write fast.</p>\n<p>Many flash file systems need make a compromise between robustness against performance. Thanks to the log structure, Yaffs does not need to. Yaffs can provide high performance without giving up on robustness.</p>\n<p>Those familiar with log structured file system design will know that some log structured file systems have problems with garbage collection<a class=\"sdfootnoteanc\" name=\"sdfootnote3anc\" href=\"#sdfootnote3sym\" id=\"sdfootnote3anc\"><sup>3</sup></a>. Garbage collection is used to clean up the log and make more free space available. Some log structured file system designs did not pay enough attention to garbage collection and can stall for a considerable time while garbage collection happens. Yaffs was designed differently. The potential impact of garbage collection was considered throughout the Yaffs design process. As a result, Yaffs has a very simple garbage collection model that allows a lot of flexibility in garbage collection scheduling. This prevents the garbage collection from making the file system unresponsive.</p>\n<p>Most file systems are developed within the context, and framework of, a single operating system. This typically makes the code difficult to explore, debug and port. Yaffs on the other hand was developed from the start inside a portable development/testing framework. Yaffs is then ported to various operating systems through the addition of glue code.</p>\n<p><br />\n<br />\n</p>\n<p><img src=\"data:image/png;base64,[encoded data, 38784 characters]\" width=\"552\" height=\"524\" alt=\"image\" id=\"Object1\" /> <br />\n<br />\n</p>\n<p>There are many benefits to this approach:</p>\n<ul>\n<li>\n<p>A development framework runs in user space which provides a richer development environment than inside an OS kernel. It is much easier to attach debuggers and perform logging and create reproducible testing.</p>\n </li>\n<li>\n<p>The code is structured to be portable. That makes it relatively easy to port to a new OS or RTOS with a high level of confidence.</p>\n </li>\n<li>\n<p>There is a choice of porting interfaces allowing more flexibility to determine which porting method will be simpler. For example, the Linux wrapper accesses the Yaffs core directly while the Windows CE wrapper access the Yaffs Direct Interface<a class=\"sdfootnoteanc\" name=\"sdfootnote4anc\" href=\"#sdfootnote4sym\" id=\"sdfootnote4anc\"><sup>4</sup></a>.</p>\n </li>\n<li>\n<p>Each different environment provides different test tools. For example, Linux provides a raft of file system test tools that do different kinds of testing to the power fail test harness. Since the vast majority of the code is in the portable Yaffs core, that code gets the advantage of all test methods combined. The many millions of Android phone users that use Yaffs-based devices are helping test the core code that is also used on a wide variety of different operating systems and a wide range of different device types.</p>\n </li>\n<li>\n<p>Its Open Source status means any interested person can take a version from git and test it to make sure that it meets their needs.</p>\n </li>\n</ul>\n<h1 class=\"western\">4 Testing</h1>\n<p>It is all very well to design software to be robust, but it needs thorough testing to build confidence in the software and in the code authors and supplier.</p>\n<p>File systems have incredibly complex state so it is not at all surprising that operating system designers find file systems some of the most challenging code to test.</p>\n<p>There is no single test methodology that can test all cases, and exhaustive state testing is impossible. The best we can do is to have a suite of test methodologies that combine to provide thorough testing.</p>\n<p>Approximately 60% of Yaffs development effort is directed towards testing and improving the test environment. We are constantly researching new methodologies.</p>\n<p>The following are descriptions of the most important test strategies used in Yaffs.</p>\n<h2 class=\"western\">4.1 Power Fail Stress Testing</h2>\n<p>By far the most important consideration in Yaffs testing is that it is robust to corruptions caused by power failure. We want Yaffs to provide the basis for reliable products in typical embedded system environments.</p>\n<p>The first power fail testing was done by companies integrating Yaffs into their products. Some of these built test jigs which would automatically interrupt power while running a real hardware device. This approach is better than nothing, but has some limitations:</p>\n<ul>\n<li>\n<p>It is relatively costly to set up. Flash has a limited lifetime meaning that test devices wear out with time and must be replaced.</p>\n </li>\n<li>\n<p>It is relatively slow since each cycle takes many seconds to boot, run the application for a while and then reboot.</p>\n </li>\n<li>\n<p>Many, and perhaps most, of the power interruptions will happen at times when the file system is inactive and thus be wasted cycles.</p>\n </li>\n</ul>\n<p>In 2008 we developed a simulated power-fail-test environment. This simulates power failures using simulated flash memory while running various consistency checks.</p>\n<p>The benefits of a software-based test harness are numerous:</p>\n<ul>\n<li>\n<p>The test harness controls the point at which the simulated power failures happen. That means every test cycle counts.</p>\n </li>\n<li>\n<p>No special hardware is required.</p>\n </li>\n<li>\n<p>Test loops run faster. A quad-core computer can simulate ten to twenty power failures per second. That means about a million power failure simulations per day.</p>\n </li>\n</ul>\n<p>The effectiveness of the new software based testing is dramatic.. A few times we have tested some user-suggested changes that had passed a week or more of real-world power fail testing only to have problems caught by the software simulation in a matter of minutes.</p>\n<p>We regularly run the power fail simulation test over a weekend, testing millions of power fail cycles.</p>\n<h2 class=\"western\">4.2 Testing the Yaffs Direct Interface API</h2>\n<p>Yaffs Direct Interface (YDI) is a POSIX-like wrapper around the Yaffs core. This provides a set of function calls, yaffs_open(), yaffs_write() and the like.</p>\n<p>Each function can return numerous error codes and has to handle numerous different parameters.</p>\n<p>Although there were already significant tests for the YDI, an extensive test harness was developed in 2010 to comprehensively test each of the error paths and generate all of the required errors.</p>\n<p>This provides a high level of confidence that the test interfaces do what they should and that POSIX-like functionality provides relatively clean porting of existing code.</p>\n<h2 class=\"western\">4.3 Linux Testing</h2>\n<p>The main purpose of the Linux testing is to test the Linux wrapper code. It does, however, still exercise the Yaffs core code differently to other testing and thus adds to the test fabric.</p>\n<p>The Linux testing does not do power fail testing but instead tests other aspects such as clean shutdowns, cache integrity and write performance. This gives a useful way to assess the effects of modifications.</p>\n<p>Linux testing is done on both real hardware and on simulated hardware using the Linux mtd nand simulator.</p>\n<p>As with the Power Fail Stress Testing described above, the simulated testing is done using a scrippted environment which is typically run for a few days at a time.</p>\n<h2 class=\"western\">4.4 Fuzz Testing</h2>\n<p>Fuzz testing deliberately corrupts the flash image and ensures that Yaffs still mounts. This is done to ensure that Yaffs does not crash on corrupted data.</p>\n<p>Clearly fuzz testing can corrupt the contents of individual files (that\'s its job), but the file system integrity should not be compromised. </p>\n<h2 class=\"western\">4.5 Software checking</h2>\n<p>Although code checking is not actual testing per se, it does help to verify code changes.</p>\n<p>The Yaffs code has been checked with Coverity<a class=\"sdfootnoteanc\" name=\"sdfootnote5anc\" href=\"#sdfootnote5sym\" id=\"sdfootnote5anc\"><sup>5</sup></a> – a market leader in code checking.</p>\n<p>We are investigating the use of KLEE and other tools.</p>\n<h2 class=\"western\">4.6 Open Source Usage</h2>\n<p>Open Source usage of Yaffs opens it up to testing by the many different projects. Many of these participate in some way with the Yaffs mailing list, helping to uncover issues and generally provide feedback.</p>\n<p>Each different project uses Yaffs in a different way, meaning that a wider range of operation sequences are tested.</p>\n<h2 class=\"western\">4.7 Universities</h2>\n<p>Over its lifetime, Yaffs has been used as a teaching framework for various university course in many different counties around the world.</p>\n<p>For example, Oregon State and Utah State Universities have used Yaffs as a test bench for their post-graduate software testing courses. They essentially test the test tools by injecting errors into the Yaffs code and seeing if these are discovered by the test tools they are testing. Of course this has the side effect of running these tests over the original Yaffs code too. </p>\n<p>Those interested in test methods are encouraged to read some of the university papers in the references of this document.</p>\n<p>We expect to adopt and extend some of the Oregon State ideas and use these to extend our in-house test suite.</p>\n<h1 class=\"western\">5 Conclusions</h1>\n<p>Software development is an iterative process of design and testing. Robust software solutions are only possible with extensive testing.</p>\n<p>Embedded systems increasingly need to store data in file systems as a critical part of their operation. It is thus important to have a file system that is predictable and robust to power failure and similar interruptions.</p>\n<p>Yaffs has been designed from scratch to be robust to power failure and that robustness has been verified with a multi-pronged test strategy that is continuously being improved.</p>\n<h1 class=\"western\" style=\"page-break-before: always\">6References</h1>\n<p>Charles Manning, “How Yaffs Works”.<br />\n<a href=\"http://users.actrix.co.nz/manningc/yaffs-docs/HowYaffsWorks.pdf\">http://users.actrix.co.nz/manningc/yaffs-docs/HowYaffsWorks.pdf</a></p>\n<p><br />\n<br />\n</p>\n<p>A. Groce et al, “Swarm Testing” from Oregon State University, School of EE and Computer Science and Utah State University, School of Computing, 2011.<br />\n<a href=\"http://www.ct.utah.edu/~regehr/papers/swarm12.pdf\">http://</a><a href=\"http://www.ct.utah.edu/~regehr/papers/swarm12.pdf\">www.ct.utah.edu/~regehr/papers/swarm12.pdf</a></p>\n<p><br />\n<br />\n</p>\n<p><em>Wu CH, “Efficient Initialization and Crash Recovery</em> for. <em>Log</em>-<em>based File Systems</em> over Flash Memory” from National Taiwan University, Dept of Computer Science, <span style=\"font-style: normal\">2006.<br />\nhttp://</span><cite>www.cis.nctu.edu.tw/~lpchang/papers/SAC_wu_sac06.pdf</cite></p>\n<p style=\"font-style: normal\"><br />\n<br />\n</p>\n<div id=\"sdfootnote1\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote1sym\" href=\"#sdfootnote1anc\" id=\"sdfootnote1sym\">1</a>Note that flash translation layers (FTLs) are erroneously refered to as flash file systems. For example, despite the name, M-Systems TrueFFS is not a flash file system but a flash translation layer (FTL).</p>\n</div>\n<div id=\"sdfootnote2\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote2sym\" href=\"#sdfootnote2anc\" id=\"sdfootnote2sym\">2</a>This document only provides a brief overview of the Yaffs architecture and design. The “How Yaffs Works” document provides an in-depth explanation of the Yaffs design and architecture.</p>\n</div>\n<div id=\"sdfootnote3\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote3sym\" href=\"#sdfootnote3anc\" id=\"sdfootnote3sym\">3</a>Refer to the “How Yaffs Works” document to understand the need for garbage collection and how Yaffs does garbage collection.</p>\n</div>\n<div id=\"sdfootnote4\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote4sym\" href=\"#sdfootnote4anc\" id=\"sdfootnote4sym\">4</a>For more information on Yaffs Direct Interface, please read the various documents on the subject.</p>\n</div>\n<div id=\"sdfootnote5\">\n<p class=\"sdfootnote-western\"><a class=\"sdfootnotesym\" name=\"sdfootnote5sym\" href=\"#sdfootnote5anc\" id=\"sdfootnote5sym\">5</a>http://www.coverity.com</p>\n</div>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:7:\"file:78\";i:2;s:8:\"node:420\";i:3;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505188402.854,1,'config:filter.format.raw_html file:78 node:420 node_view rendered','264'),('entity_view:node:420:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"420\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:7:\"file:78\";i:2;s:8:\"node:420\";i:3;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505188402.852,1,'config:filter.format.raw_html file:78 node:420 node_view rendered','264'),('entity_view:node:420:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1652:\"<article role=\"article\" about=\"/documents/yaffs-robustness-and-testing\" class=\"paper is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/documents/yaffs-robustness-and-testing\" rel=\"bookmark\"><span>YAFFS Robustness and Testing</span>\n</a>\n    </h2>\n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/charles-manning\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Charles Manning</span></span>\n on <span>8 June, 2012 - 2:35am</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/documents/yaffs-robustness-and-testing\" rel=\"tag\" title=\"YAFFS Robustness and Testing\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about YAFFS Robustness and Testing</span></a></li></ul>\n            <div class=\"field field--name-field-teaser-image field--type-image field--label-hidden field--item\">  <a href=\"/documents/yaffs-robustness-and-testing\"><img src=\"/sites/default/files/styles/pdf_image/public/styles/pdf_image/public/downloads/YaffsRobustnessAndTesting.pdf.png?itok=YSeIaJXu\" alt=\"Preview of YaffsRobustnessAndTesting.pdf\" typeof=\"foaf:Image\" class=\"img-responsive\" />\n\n</a>\n</div>\n      \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>This document describes some of the important design criteria and design features used to achieve a robust design suitable for modern embedded systems which need to store critical data.&nbsp; The test methodologies are also described.</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:28:\"config:image.style.pdf_image\";i:2;s:7:\"file:79\";i:3;s:8:\"node:420\";i:4;s:9:\"node_view\";i:5;s:6:\"user:6\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.583,1,'config:filter.format.raw_html config:image.style.pdf_image file:79 node:420 node_view rendered user:6','278'),('entity_view:node:420:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"420\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:28:\"config:image.style.pdf_image\";i:2;s:7:\"file:79\";i:3;s:8:\"node:420\";i:4;s:9:\"node_view\";i:5;s:6:\"user:6\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.581,1,'config:filter.format.raw_html config:image.style.pdf_image file:79 node:420 node_view rendered user:6','278'),('entity_view:node:426:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0MDx5l2YI0i07jsQaVPte90R0HygN4RbSqt4jGMd26OA','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1477:\"<article role=\"article\" about=\"/features/high-and-low-level-interfaces\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-stethoscope</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>We provide a high level interface with the GPL version of Yaffs, so it\'s easy to use with Linux and other OS\'s that support POSIX.  This support includes directories, symbolic and hard links, through standard file system interface calls.</p>\n\n<p>But when you want to integrate Yaffs directly into your OS or your code, you\'ll most likely want to make use of the Yaffs Direct Interface or other low-level interfaces:</p>\n\n<ul><li>Application Interface: This is the interface that the application code uses to access the YAFFS file system.</li>\n	<li>RTOS Integration Interface: These are the functions that much be provided for YAFFS to access the RTOS system resources.</li>\n	<li>NAND Configuration and Access Interface: These are the functions that must be provided for YAFFS to access the NAND flash.</li>\n</ul><p>Have a look at the guides in the Documents section, to find out more about <a href=\"/documents\">integrating Yaffs</a>.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:39:\"/features/high-and-low-level-interfaces\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/426\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:39:\"/features/high-and-low-level-interfaces\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:426\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:46:\"<span>High and low level interfaces...</span>\n\";}}',-1,1504657785.875,1,'config:filter.format.basic_html config:system.site node:426 node_view rendered user:1','278'),('entity_view:node:426:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"426\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:426\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504657785.873,1,'config:filter.format.basic_html config:system.site node:426 node_view rendered user:1','278'),('entity_view:node:426:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1325:\"<span>High and low level interfaces...</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-stethoscope</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>We provide a high level interface with the GPL version of Yaffs, so it\'s easy to use with Linux and other OS\'s that support POSIX.  This support includes directories, symbolic and hard links, through standard file system interface calls.</p>\n\n<p>But when you want to integrate Yaffs directly into your OS or your code, you\'ll most likely want to make use of the Yaffs Direct Interface or other low-level interfaces:</p>\n\n<ul><li>Application Interface: This is the interface that the application code uses to access the YAFFS file system.</li>\n	<li>RTOS Integration Interface: These are the functions that much be provided for YAFFS to access the RTOS system resources.</li>\n	<li>NAND Configuration and Access Interface: These are the functions that must be provided for YAFFS to access the NAND flash.</li>\n</ul><p>Have a look at the guides in the Documents section, to find out more about <a href=\"/documents\">integrating Yaffs</a>.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:426\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505196111.242,1,'config:filter.format.basic_html node:426 node_view rendered','265'),('entity_view:node:426:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"426\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:426\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505196111.240,1,'config:filter.format.basic_html node:426 node_view rendered','265'),('entity_view:node:426:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:883:\"<article role=\"article\" about=\"/features/high-and-low-level-interfaces\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/high-and-low-level-interfaces\" rel=\"bookmark\"><span>High and low level interfaces...</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/high-and-low-level-interfaces\" rel=\"tag\" title=\"High and low level interfaces...\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about High and low level interfaces...</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs has high and low level interfaces, for Posix compliance and more direct use, making it easy to integrate with Linux and other RTOSs.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:426\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.541,1,'config:filter.format.basic_html node:426 node_view rendered user:1','272'),('entity_view:node:426:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"426\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:426\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.539,1,'config:filter.format.basic_html node:426 node_view rendered user:1','272'),('entity_view:node:427:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0qbznl4l9cf4inLwFu8AZdyg9pt848O1266QajGCZnLU','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1563:\"<article role=\"article\" about=\"/features/cross-platform-and-portable\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-truck</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>Yaffs is easy to port. It is written in C, with particular attention paid to making it portable. It\'s CPU independent, high/low bit independent (endian neutral) and doesn\'t rely on any particular operating system.  Look at the schematic in the <a href=\"/yaffs-overview\">Yaffs Overview</a> to see the relationship of the different elements.</p>\n\n<p>It\'s already been used under Linux, eCos, VxWorks, Win CE and more. </p>\n\n<p>Yaffs has been used successfully with many different 32-bit and 64-bit CPUs including MIPS, 68000, many from ARM, ColdFire, PowerPC and x86 variants. Yaffs works with 16-bit CPUs too, but this is less tested and might need some tuning, depending on compiler options. </p>\n\n<p>We\'ve found it easy to move to different processor architectures because it was designed to do this; as long as your processor is greater than 8-bit, Yaffs should run without needing much work.</p>\n\n<p>Read  <a href=\"http://www.yaffs.net/yaffs-porting-guide\">http://www.yaffs.net/yaffs-porting-guide</a> for more detail.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:37:\"/features/cross-platform-and-portable\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/427\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:37:\"/features/cross-platform-and-portable\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:427\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:44:\"<span>Cross-platform and portable...</span>\n\";}}',-1,1504673227.796,1,'config:filter.format.basic_html config:system.site node:427 node_view rendered user:1','278'),('entity_view:node:427:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"427\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:427\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504673227.794,1,'config:filter.format.basic_html config:system.site node:427 node_view rendered user:1','278'),('entity_view:node:427:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1411:\"<span>Cross-platform and portable...</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-truck</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>Yaffs is easy to port. It is written in C, with particular attention paid to making it portable. It\'s CPU independent, high/low bit independent (endian neutral) and doesn\'t rely on any particular operating system.  Look at the schematic in the <a href=\"/yaffs-overview\">Yaffs Overview</a> to see the relationship of the different elements.</p>\n\n<p>It\'s already been used under Linux, eCos, VxWorks, Win CE and more. </p>\n\n<p>Yaffs has been used successfully with many different 32-bit and 64-bit CPUs including MIPS, 68000, many from ARM, ColdFire, PowerPC and x86 variants. Yaffs works with 16-bit CPUs too, but this is less tested and might need some tuning, depending on compiler options. </p>\n\n<p>We\'ve found it easy to move to different processor architectures because it was designed to do this; as long as your processor is greater than 8-bit, Yaffs should run without needing much work.</p>\n\n<p>Read  <a href=\"http://www.yaffs.net/yaffs-porting-guide\">http://www.yaffs.net/yaffs-porting-guide</a> for more detail.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:427\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505489906.059,1,'config:filter.format.basic_html node:427 node_view rendered','265'),('entity_view:node:427:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"427\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:427\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505489906.046,1,'config:filter.format.basic_html node:427 node_view rendered','265'),('entity_view:node:427:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:863:\"<article role=\"article\" about=\"/features/cross-platform-and-portable\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/cross-platform-and-portable\" rel=\"bookmark\"><span>Cross-platform and portable...</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/cross-platform-and-portable\" rel=\"tag\" title=\"Cross-platform and portable...\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Cross-platform and portable...</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs is OS- and CPU- and Endian-independent. It\'s been designed to be easy to port, and has been ported repeatedly by many users.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:427\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.530,1,'config:filter.format.basic_html node:427 node_view rendered user:1','272'),('entity_view:node:427:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"427\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:427\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.528,1,'config:filter.format.basic_html node:427 node_view rendered user:1','272'),('entity_view:node:428:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b08i7rvv9LFEi9AOe-5weexs9_zo4QqMsaeoOX0mKkZMg','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1039:\"<article role=\"article\" about=\"/features/file-system-designed-flash-memory\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-microchip</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>Yaffs was designed from the ground up for Flash memory. It is best with NAND Flash but can be used with NOR too. It has mechanisms for wear-levelling, and special attention has been paid to the safety of the system even under power-failure. It is works well with MLC Nand, as well as SLC; it is compatible with a wide range of Flash, including Toshiba/Sandisk MLC parts.  See also the document   Considerations in Using a Flash File System  for a discussion of the importance of reliability.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:43:\"/features/file-system-designed-flash-memory\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/428\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:43:\"/features/file-system-designed-flash-memory\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:428\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:56:\"<span>A file system designed for Flash memory...</span>\n\";}}',-1,1504697709.023,1,'config:filter.format.basic_html config:system.site node:428 node_view rendered user:1','278'),('entity_view:node:428:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"428\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:428\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504697709.016,1,'config:filter.format.basic_html config:system.site node:428 node_view rendered user:1','278'),('entity_view:node:428:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:893:\"<span>A file system designed for Flash memory...</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-microchip</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>Yaffs was designed from the ground up for Flash memory. It is best with NAND Flash but can be used with NOR too. It has mechanisms for wear-levelling, and special attention has been paid to the safety of the system even under power-failure. It is works well with MLC Nand, as well as SLC; it is compatible with a wide range of Flash, including Toshiba/Sandisk MLC parts.  See also the document   Considerations in Using a Flash File System  for a discussion of the importance of reliability.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:428\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505630853.917,1,'config:filter.format.basic_html node:428 node_view rendered','265'),('entity_view:node:428:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"428\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:428\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505630853.915,1,'config:filter.format.basic_html node:428 node_view rendered','265'),('entity_view:node:428:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1047:\"<article role=\"article\" about=\"/features/file-system-designed-flash-memory\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/file-system-designed-flash-memory\" rel=\"bookmark\"><span>A file system designed for Flash memory...</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/file-system-designed-flash-memory\" rel=\"tag\" title=\"A file system designed for Flash memory...\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about A file system designed for Flash memory...</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs is designed to ensure data safety, whilst offering the advantages of NAND Flash. It works with SLC and MLC NAND Flash and also with NOR Flash. See the document Considerations in Using a Flash File System for a discussion of the importance of reliability.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:428\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.518,1,'config:filter.format.basic_html node:428 node_view rendered user:1','272'),('entity_view:node:428:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"428\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:428\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.516,1,'config:filter.format.basic_html node:428 node_view rendered user:1','272'),('entity_view:node:42:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01P-ZH24uH3b9y9UOmu4FyruSlCz78uAmSLS0a3uxZU9k','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:6117:\"<article role=\"article\" about=\"/archives/state-nand-mtd-driver-start-project\" typeof=\"schema:WebPage\" class=\"page full clearfix\">\n\n  \n      <span property=\"schema:name\" content=\"State of NAND MTD driver at start of project\" class=\"hidden\"></span>\n\n\n  \n  <div class=\"content\">\n    \n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<h3>Current state of NAND MTD</h3>\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>\n<p>There are 3 files:</p>\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>\n<p>spia.c: this initialises the spia hardware to set up the addresses for the hardware access.</p>\n<p>ecc.c: ECC for 256 byte pages.</p>\n<p>What needs to be done at this level:</p>\n<ul>\n<li>\n<p>Hardware abstraction of nand.c. This allows this code to be used with different hardware configurations.</p>\n </li>\n<li>\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>\n </li>\n<li>\n<p>Write a software emulation for a NAND device. The purpose of the software emulator is:</p>\n<ul>\n <li>\n <p>Allow debugging without the need for hardware.</p>\n  </li>\n <li>\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>\n  </li>\n</ul>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>Overall flash system diagram<img alt=\"\" height=\"402\" src=\"/sites/yaffs.net/sv16516600.gif\" width=\"399\" /></h3>\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>\n<p>The NAND flash sub-system uses common layers for:</p>\n<ul>\n<li>\n<p>hardware access</p>\n </li>\n<li>\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>\n </li>\n</ul>\n<h3>Concerns with using JFFS2 on NAND</h3>\n<p>There are some reasons why JFFS and NAND might not work together that well.</p>\n<p>Two particular concerns re booting</p>\n<ul>\n<li>\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>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>Thus booting a 128MB NAND-based JFFS2 is likely to look something like this:</p>\n<ul>\n<li>\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>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>These are probably unacceptable for the product being used. We therefore need to run something better than this.</p>\n<p>Two approaches spring to mind:</p>\n<ul>\n<li>\n<p>Just run FAT16. ie. Just treat all NAND as SmartMedia. Benefits: one code base. Down-side: reliability.</p>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>What I\'m working towards</h3>\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>\n<ul>\n<li>\n<p>The journaling records are stored in fixed-size 512-byte pages.</p>\n </li>\n<li>\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>\n </li>\n<li>\n<p>20 bits of page id within inode</p>\n </li>\n<li>\n<p>20 bits of inode id</p>\n </li>\n<li>\n<p>9 bits length (bytes used in this page).</p>\n </li>\n<li>\n<p>7 bits flags etc.</p>\n </li>\n<li>\n<p>8 bits of hamming code on this area.</p>\n </li>\n</ul>\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>\n<p>The benefits of this approach are:</p>\n<ul>\n<li>\n<p>NAND-friendly since it works within the write limitations of NAND.</p>\n </li>\n<li>\n<p>Less stuff to read to reconstruct file structures (only read management data).</p>\n </li>\n</ul>\n<p>Down sides:</p>\n<ul>\n<li>\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>\n </li>\n</ul>\n<p>Still need to see if a new data structure is going to reduce the overhead of jffs2_raw_node_ref somewhat.</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:45:\"/archives/state-nand-mtd-driver-start-project\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:8:\"/node/42\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:45:\"/archives/state-nand-mtd-driver-start-project\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:42\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:81:\"<span property=\"schema:name\">State of NAND MTD driver at start of project</span>\n\";}}',-1,1504724375.352,1,'config:filter.format.full_html config:system.site node:42 node_view rendered user:1','310'),('entity_view:node:42:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"42\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:42\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504724375.349,1,'config:filter.format.full_html config:system.site node:42 node_view rendered user:1','310'),('entity_view:node:42:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:5896:\"<span property=\"schema:name\">State of NAND MTD driver at start of project</span>\n\n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<h3>Current state of NAND MTD</h3>\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>\n<p>There are 3 files:</p>\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>\n<p>spia.c: this initialises the spia hardware to set up the addresses for the hardware access.</p>\n<p>ecc.c: ECC for 256 byte pages.</p>\n<p>What needs to be done at this level:</p>\n<ul>\n<li>\n<p>Hardware abstraction of nand.c. This allows this code to be used with different hardware configurations.</p>\n </li>\n<li>\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>\n </li>\n<li>\n<p>Write a software emulation for a NAND device. The purpose of the software emulator is:</p>\n<ul>\n <li>\n <p>Allow debugging without the need for hardware.</p>\n  </li>\n <li>\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>\n  </li>\n</ul>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>Overall flash system diagram<img alt=\"\" height=\"402\" src=\"/sites/yaffs.net/sv16516600.gif\" width=\"399\" /></h3>\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>\n<p>The NAND flash sub-system uses common layers for:</p>\n<ul>\n<li>\n<p>hardware access</p>\n </li>\n<li>\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>\n </li>\n</ul>\n<h3>Concerns with using JFFS2 on NAND</h3>\n<p>There are some reasons why JFFS and NAND might not work together that well.</p>\n<p>Two particular concerns re booting</p>\n<ul>\n<li>\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>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>Thus booting a 128MB NAND-based JFFS2 is likely to look something like this:</p>\n<ul>\n<li>\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>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>These are probably unacceptable for the product being used. We therefore need to run something better than this.</p>\n<p>Two approaches spring to mind:</p>\n<ul>\n<li>\n<p>Just run FAT16. ie. Just treat all NAND as SmartMedia. Benefits: one code base. Down-side: reliability.</p>\n </li>\n<li>\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>\n </li>\n</ul>\n<p>&nbsp;</p>\n<h3>What I\'m working towards</h3>\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>\n<ul>\n<li>\n<p>The journaling records are stored in fixed-size 512-byte pages.</p>\n </li>\n<li>\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>\n </li>\n<li>\n<p>20 bits of page id within inode</p>\n </li>\n<li>\n<p>20 bits of inode id</p>\n </li>\n<li>\n<p>9 bits length (bytes used in this page).</p>\n </li>\n<li>\n<p>7 bits flags etc.</p>\n </li>\n<li>\n<p>8 bits of hamming code on this area.</p>\n </li>\n</ul>\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>\n<p>The benefits of this approach are:</p>\n<ul>\n<li>\n<p>NAND-friendly since it works within the write limitations of NAND.</p>\n </li>\n<li>\n<p>Less stuff to read to reconstruct file structures (only read management data).</p>\n </li>\n</ul>\n<p>Down sides:</p>\n<ul>\n<li>\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>\n </li>\n</ul>\n<p>Still need to see if a new data structure is going to reduce the overhead of jffs2_raw_node_ref somewhat.</p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:42\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505425928.802,1,'config:filter.format.full_html node:42 node_view rendered','297'),('entity_view:node:42:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"42\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:42\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505425928.800,1,'config:filter.format.full_html node:42 node_view rendered','297'),('entity_view:node:430:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0cLBSF4PEifpT9OH3qlch48fwd2K1pRziv87xbWvmeYM','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:142:\"<article role=\"article\" about=\"/get-yaffs-nowpng\" class=\"image full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:17:\"/get-yaffs-nowpng\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/430\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:17:\"/get-yaffs-nowpng\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:4:{i:0;s:18:\"config:system.site\";i:1;s:8:\"node:430\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:31:\"<span>get yaffs now.png</span>\n\";}}',-1,1506693644.760,1,'config:system.site node:430 node_view rendered user:1','267'),('entity_view:node:430:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"430\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:4:{i:0;s:18:\"config:system.site\";i:1;s:8:\"node:430\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1506693644.738,1,'config:system.site node:430 node_view rendered user:1','267'),('entity_view:node:433:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0RdH7nk1gEQeFCJVPEmLDOAqpe5WdZ-hANCcGop_Zo0c','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:713:\"<article role=\"article\" about=\"/features/predictable-and-performance-oriented\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-plug</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs has highly optimised and predictable garbage collection strategies. This makes it high performance and very deterministic when compared with similar file systems.</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:46:\"/features/predictable-and-performance-oriented\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/433\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:46:\"/features/predictable-and-performance-oriented\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:433\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:50:\"<span>Predictable and performance oriented</span>\n\";}}',-1,1505003186.561,1,'config:filter.format.full_html config:system.site node:433 node_view rendered user:1','309'),('entity_view:node:433:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"433\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:433\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505003186.558,1,'config:filter.format.full_html config:system.site node:433 node_view rendered user:1','309'),('entity_view:node:433:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:954:\"<article role=\"article\" about=\"/features/predictable-and-performance-oriented\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/predictable-and-performance-oriented\" rel=\"bookmark\"><span>Predictable and performance oriented</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/predictable-and-performance-oriented\" rel=\"tag\" title=\"Predictable and performance oriented\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Predictable and performance oriented</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs has highly optimised and predictable garbage collection strategies. These give it high performance and make it very deterministic when compared with similar file systems.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:433\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.499,1,'config:filter.format.full_html node:433 node_view rendered user:1','303'),('entity_view:node:433:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"433\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:433\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.497,1,'config:filter.format.full_html node:433 node_view rendered user:1','303'),('entity_view:node:434:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0lqa85Wf3CdGZ1Rr5ojLYJsvye1VNZ1Ht_oqJBEeWKDA','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1251:\"<article role=\"article\" about=\"/features/memory-efficiency\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-sort-amount-asc</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs has a lower memory footprint than most other log-structured Flash file systems.&nbsp; Because it is log-structured, RAM is required to build up runtime data structures for acceptable performance. As a rule of thumb, Yaffs uses approximately 2 bytes per chunk of NAND flash, where a chunk is typically one page of NAND. For NAND with 512byte pages, a budget of approximately 4kbytes of RAM per 1Mbyte of NAND is usually sensible. And for 2kbyte page devices a budget of approximately 1kbyte per 1Mbyte of NAND usually suffices.</p>\n<p>You can find out details of Yaffs memory use in the document&nbsp; <a href=\"http://www.yaffs.net/documents/how-yaffs-works\">http://www.yaffs.net/documents/how-yaffs-works</a></p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:27:\"/features/memory-efficiency\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/434\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:27:\"/features/memory-efficiency\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:434\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:31:\"<span>Memory efficiency</span>\n\";}}',-1,1504669091.202,1,'config:filter.format.full_html config:system.site node:434 node_view rendered user:1','309'),('entity_view:node:434:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"434\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:434\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504669091.200,1,'config:filter.format.full_html config:system.site node:434 node_view rendered user:1','309'),('entity_view:node:434:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1096:\"<span>Memory efficiency</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-sort-amount-asc</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs has a lower memory footprint than most other log-structured Flash file systems.&nbsp; Because it is log-structured, RAM is required to build up runtime data structures for acceptable performance. As a rule of thumb, Yaffs uses approximately 2 bytes per chunk of NAND flash, where a chunk is typically one page of NAND. For NAND with 512byte pages, a budget of approximately 4kbytes of RAM per 1Mbyte of NAND is usually sensible. And for 2kbyte page devices a budget of approximately 1kbyte per 1Mbyte of NAND usually suffices.</p>\n<p>You can find out details of Yaffs memory use in the document&nbsp; <a href=\"http://www.yaffs.net/documents/how-yaffs-works\">http://www.yaffs.net/documents/how-yaffs-works</a></p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:434\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1508599882.575,1,'config:filter.format.full_html node:434 node_view rendered','296'),('entity_view:node:434:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"434\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:434\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1508599882.556,1,'config:filter.format.full_html node:434 node_view rendered','296'),('entity_view:node:434:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:751:\"<article role=\"article\" about=\"/features/memory-efficiency\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/memory-efficiency\" rel=\"bookmark\"><span>Memory efficiency</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/memory-efficiency\" rel=\"tag\" title=\"Memory efficiency\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Memory efficiency</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs has a smaller memory footprint than most other log-structured Flash file systems.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:434\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.488,1,'config:filter.format.full_html node:434 node_view rendered user:1','303'),('entity_view:node:434:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"434\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:434\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.487,1,'config:filter.format.full_html node:434 node_view rendered user:1','303'),('entity_view:node:435:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b02Cp9mvo0nCpZoGFiJmtOOKIiklmh4LswxZlY0IK5MV8','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:923:\"<article role=\"article\" about=\"/features/highly-configurable-matches-your-flash-memory\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-check-square</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs is adaptable to suit the Flash geometries, caching options, Error Correction strategies and other features that you need.</p>\n<p>Details of the configuration options can be found in the Linux menuconfig compile options tool, and in&nbsp; <a href=\"http://www.yaffs.net/yaffs-tuning-and-configuration\">http://www.yaffs.net/yaffs-tuning-and-configuration</a></p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:55:\"/features/highly-configurable-matches-your-flash-memory\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/435\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:55:\"/features/highly-configurable-matches-your-flash-memory\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:435\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:61:\"<span>Highly configurable - matches your Flash memory</span>\n\";}}',-1,1504737239.724,1,'config:filter.format.full_html config:system.site node:435 node_view rendered user:1','309'),('entity_view:node:435:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"435\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:435\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504737239.721,1,'config:filter.format.full_html config:system.site node:435 node_view rendered user:1','309'),('entity_view:node:435:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:770:\"<span>Highly configurable - matches your Flash memory</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-check-square</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs is adaptable to suit the Flash geometries, caching options, Error Correction strategies and other features that you need.</p>\n<p>Details of the configuration options can be found in the Linux menuconfig compile options tool, and in&nbsp; <a href=\"http://www.yaffs.net/yaffs-tuning-and-configuration\">http://www.yaffs.net/yaffs-tuning-and-configuration</a></p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:435\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1509271536.902,1,'config:filter.format.full_html node:435 node_view rendered','296'),('entity_view:node:435:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"435\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:435\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1509271536.885,1,'config:filter.format.full_html node:435 node_view rendered','296'),('entity_view:node:435:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:987:\"<article role=\"article\" about=\"/features/highly-configurable-matches-your-flash-memory\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/highly-configurable-matches-your-flash-memory\" rel=\"bookmark\"><span>Highly configurable - matches your Flash memory</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/highly-configurable-matches-your-flash-memory\" rel=\"tag\" title=\"Highly configurable - matches your Flash memory\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Highly configurable - matches your Flash memory</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs is highly configurable, making it possible to work with various Flash geometries, Error Correction and caching options according to your needs.</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:435\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.473,1,'config:filter.format.full_html node:435 node_view rendered user:1','303'),('entity_view:node:435:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"435\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:435\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.471,1,'config:filter.format.full_html node:435 node_view rendered user:1','303'),('entity_view:node:436:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0XPl-lTnX1tXFMisnPolBVemmgAGRbjnD_VPemY1vsec','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:866:\"<article role=\"article\" about=\"/features/simple-integrate\" class=\"what-is-special-about-yaffs is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-puzzle-piece</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs Direct Interface is simple to integrate in a system – only a few interface functions are required. Yaffs also includes a POSIX interface. It has been used with Android, VXWorks, Windows, Linux, bare metal, and more; on ARM (32 and 64), x86 (32 and 64), Atmel, and more. </p>\n<p>You can find details in the Yaffs Direct guide.</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:26:\"/features/simple-integrate\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/436\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:26:\"/features/simple-integrate\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:436\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:33:\"<span>Simple to integrate</span>\n\";}}',-1,1504771257.738,1,'config:filter.format.full_html config:system.site node:436 node_view rendered user:1','313'),('entity_view:node:436:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"436\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:436\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504771257.735,1,'config:filter.format.full_html config:system.site node:436 node_view rendered user:1','313'),('entity_view:node:436:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:714:\"<span>Simple to integrate</span>\n\n  <div class=\"field field--name-field-icon-text field--type-string field--label-above\">\n    <div class=\"field--label\">Icon - text</div>\n              <div class=\"field--item\">fa-puzzle-piece</div>\n          </div>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>Yaffs Direct Interface is simple to integrate in a system – only a few interface functions are required. Yaffs also includes a POSIX interface. It has been used with Android, VXWorks, Windows, Linux, bare metal, and more; on ARM (32 and 64), x86 (32 and 64), Atmel, and more. </p>\n<p>You can find details in the Yaffs Direct guide.</p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:436\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505188402.917,1,'config:filter.format.full_html node:436 node_view rendered','300'),('entity_view:node:436:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"436\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:436\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505188402.915,1,'config:filter.format.full_html node:436 node_view rendered','300'),('entity_view:node:436:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:953:\"<article role=\"article\" about=\"/features/simple-integrate\" class=\"what-is-special-about-yaffs is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/features/simple-integrate\" rel=\"bookmark\"><span>Simple to integrate</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/features/simple-integrate\" rel=\"tag\" title=\"Simple to integrate\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Simple to integrate</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">Yaffs Direct Interface is simple to integrate in a system &ndash; only a few interface functions are required. Yaffs also includes a POSIX interface. It has been used with Android, VXWorks, Windows, Linux, bare metal, and more; on ARM (32 &amp; 64), x86 (32 &amp; 64), Atmel, and more. </div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:436\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1505009157.459,1,'config:filter.format.full_html node:436 node_view rendered user:1','307'),('entity_view:node:436:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"436\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:8:\"node:436\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505009157.457,1,'config:filter.format.full_html node:436 node_view rendered user:1','307'),('entity_view:node:43:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01FwFvTSEIK04fYhnp2JF0bqyE6-dj6lfDZZonHl5q5II','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:4251:\"<article role=\"article\" about=\"/archives/yaffs-history\" typeof=\"schema:WebPage\" class=\"page full clearfix\">\n\n  \n      <span property=\"schema:name\" content=\"Yaffs History\" class=\"hidden\"></span>\n\n\n  \n  <div class=\"content\">\n    \n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<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>\n<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>\n<p>Here is a collection of notable events and milestones in the history of Yaffs.</p>\n<ul>\n<li>2006.10 Yaffs updated to work properly with Linux 2.6.17+ MTD on 512B and 2K page NAND</li>\n<li>2006.05.08 Checkpointing added - so start-up scanning time enormously reduced</li>\n<li>2004.08.02 Linux kernel 2.6 support checked in.</li>\n<li>2004.02 Yaffs presentation given at FOSDEM on embedded track</li>\n<li><i>2003.06.21</i> Yaffs runs with Linux kernel 2.5.70.</li>\n<li><i>2003.05</i> First two Yaffs/direct licencees.</li>\n<li><i>2003.04</i> Yaffs/direct non-GPL license option created for those who can\'t use the GPL.</li>\n<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>\n<li><i>2003.01</i> Yaffs Direct ported to pSOS.</li>\n<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>\n<li><i>2003.01.21</i> Yaffs Bootloader example code checked in, so your bootloader can read directly from Yaffs.</li>\n<li><i>2002.11.04</i> <a href=\"/drupal/yaffs/yaffs2.html\">Yaffs2 spec</a> announced for discussion.</li>\n<li><i>2002.11.08</i> WinCE port code checked-in to CVS.</li>\n<li><i>2002.09.23</i> Announced to the world.</li>\n<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>\n<li><i>2002.09.13</i> Stand-alone system using Yaffs root partition booted.</li>\n<li><i>2002.08</i> WinCE Yaffs port working.</li>\n<li><i>2002.05.20</i> MTD interface tested on hardware emulation and some real hardware.</li>\n<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>\n<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>\n<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>\n<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>\n</ul>\n<p>&nbsp;</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:23:\"/archives/yaffs-history\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:8:\"/node/43\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:23:\"/archives/yaffs-history\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:43\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:50:\"<span property=\"schema:name\">Yaffs History</span>\n\";}}',-1,1504637036.579,1,'config:filter.format.full_html config:system.site node:43 node_view rendered user:1','309'),('entity_view:node:43:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"43\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"node:43\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504637036.577,1,'config:filter.format.full_html config:system.site node:43 node_view rendered user:1','309'),('entity_view:node:43:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:4052:\"<span property=\"schema:name\">Yaffs History</span>\n\n            <div property=\"schema:text\" class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<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>\n<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>\n<p>Here is a collection of notable events and milestones in the history of Yaffs.</p>\n<ul>\n<li>2006.10 Yaffs updated to work properly with Linux 2.6.17+ MTD on 512B and 2K page NAND</li>\n<li>2006.05.08 Checkpointing added - so start-up scanning time enormously reduced</li>\n<li>2004.08.02 Linux kernel 2.6 support checked in.</li>\n<li>2004.02 Yaffs presentation given at FOSDEM on embedded track</li>\n<li><i>2003.06.21</i> Yaffs runs with Linux kernel 2.5.70.</li>\n<li><i>2003.05</i> First two Yaffs/direct licencees.</li>\n<li><i>2003.04</i> Yaffs/direct non-GPL license option created for those who can\'t use the GPL.</li>\n<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>\n<li><i>2003.01</i> Yaffs Direct ported to pSOS.</li>\n<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>\n<li><i>2003.01.21</i> Yaffs Bootloader example code checked in, so your bootloader can read directly from Yaffs.</li>\n<li><i>2002.11.04</i> <a href=\"/drupal/yaffs/yaffs2.html\">Yaffs2 spec</a> announced for discussion.</li>\n<li><i>2002.11.08</i> WinCE port code checked-in to CVS.</li>\n<li><i>2002.09.23</i> Announced to the world.</li>\n<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>\n<li><i>2002.09.13</i> Stand-alone system using Yaffs root partition booted.</li>\n<li><i>2002.08</i> WinCE Yaffs port working.</li>\n<li><i>2002.05.20</i> MTD interface tested on hardware emulation and some real hardware.</li>\n<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>\n<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>\n<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>\n<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>\n</ul>\n<p>&nbsp;</p>\n</div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:43\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505196111.320,1,'config:filter.format.full_html node:43 node_view rendered','296'),('entity_view:node:43:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:2:\"43\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:30:\"config:filter.format.full_html\";i:1;s:7:\"node:43\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505196111.318,1,'config:filter.format.full_html node:43 node_view rendered','296'),('entity_view:node:448:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0Ug4UzAcSwX5g4S2qqySGf2gy6Kxru0HzZ1mu_IFOEdY','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:7108:\"<article role=\"article\" about=\"/documents/faq\" class=\"paper full clearfix\">\n\n  \n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/admin\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Admin</span></span>\n on <span>8 July, 2012 - 11:30pm</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><h3><em>What Operating System (OS) can you use with Yaffs?</em></h3>\n\n<p>Yaffs is agnostic about the OS it is used with; it has been used with many different OSs, including Linux, eCos, Windows CE, ThreadX, pSOS and vXworks. It is POSIX-compliant, so commands in an application calling POSIX functions will usually work.</p>\n\n<p>Windows CE uses the Microsoft file handling model and is not POSIX-like. The difference is handled in the Windows CE wrapper.  Contact us for more information.</p>\n\n<p>Work on closer integration of Yaffs into the Linux kernel started in 2010 and the goal is to have Yaffs merged into the mainline Linux kernel.</p>\n\n<p>The Yaffs Direct Interface, YDI, is the heart of Yaffs and usually stands between the Application, on one side, and the Flash chips, and any OS, on the other side:-</p>\n\n<h3><em>What CPU can you use with Yaffs?</em></h3>\n\n<p>Yaffs has been used with many 32-bit and 64-bit CPUs including MIPS, 68000, ColdFire, PowerPC, x86 variants and many ARM-cored CPUs. It should work with 16-bit CPUs but has not been tested.</p>\n\n<h3><em>Does Yaffs care Which-Endian the CPU is?</em></h3>\n\n<p>No, Yaffs works with Big-Endian and Little-Endian CPUs</p>\n\n<h3><em>How big can the whole file system be, and how big can individual files be?</em></h3>\n\n<p>Yaffs2, which is now standard, can handle a File System (FS) of many Gigabytes total storage; some people are using it with 6GB satisfactorily. <em>Individual</em> files are currently limited to 2GB. The basic Yaffs architecture can handle larger single files and some changes would be required to support individual files greater than 2G bytes. There is an upper limit of around 32GB with the present 2k bytes granularity of \'chunks\' or page size, and the limit of about 16 million chunks per file.</p>\n\n<p>A coarser granularity of larger chunks can probably be obtained, with knock-on effects in other parameters like RAM usage.</p>\n\n<h3><em>How many files can there be?</em></h3>\n\n<p>There is no hard limit. Available flash and RAM will limit this.</p>\n\n<h3><em>What about directories etc?</em></h3>\n\n<p>Yaffs supports many different objects including: directories, regular files, hard links, symbolic links and device nodes.</p>\n\n<p>Yaffs supports long file names, attributes, extended attributes and Unicode.</p>\n\n<h3><em>How much RAM does it need?</em></h3>\n\n<p>This depends particularly on the number of tnodes, which in turn depends on the file size, and is therefore a dynamic variable.</p>\n\n<p>However, Yaffs compares favourably with other similar systems specialised for Flash, and includes robust error handling.</p>\n\n<h4><em>How are errors handled?</em></h4>\n\n<p>Error Correction Code (ECC) is used to correct for single-bit errors.</p>\n\n<p>ECC may use built-in code or that provided from other sources (flash controllers, ECC libraries etc).</p>\n\n<p>Yaffs is frequently tested on a \"fuzzer\" test harness. This randomly corrupts bits of the file system image to check that the file system still mounts and loads correctly.</p>\n\n<h3><em>What about Multi-level cell (MLC) chips?</em></h3>\n\n<p>Because a bit is represented by a smaller amount of charge in the MLC chip compared to a SLC chip, MLC chips are more prone to corruption than SLC.</p>\n\n<p>MLC also has various write restrictions, which are obeyed by Yaffs2.</p>\n\n<p>Yaffs2 has some features such as block refreshing to help alleviate the problems associated with MLC.</p>\n\n<p>MLC generally requires multi-bit ECC. Hardware ECC is preferred since it is faster and requires less computation than software multi-bit correction..</p>\n\n<h3><em>How robust is Yaffs ?</em></h3>\n\n<p>Yaffs is designed specifically to take account of manufacturing faults in, and of accumulated wear in, individual cells, and also to handle power failures during use.</p>\n\n<p>Yaffs allocates flash blocks in a way that gives statistical or implicit wear levelling; when a block is freed up it is released into a <em>free pool</em> and the next allocation comes from this <em>free pool. </em>This randomness tends to spread the blocks in use, giving some wear levelling, rather than one part of the file always being worked intensively.</p>\n\n<p>Accelerated lifetime testing has been carried out to seek evidence for excessive wear. For example on one professional PDA-style device used by surveyors in the field we determined that extreme lifetime usage would be:</p>\n\n<ul><li>20MB per day.</li>\n	<li>200 days per year</li>\n	<li>10 year lifetime</li>\n	<li>Total 40Gbytes lifetime write.</li>\n</ul><p>We then ran well over 200Gbytes of writing through a specially designed File System Exerciser, a multi-threaded application that writes, reads, verifies, then deletes, repeatedly. There was no sign of a single bit of corruption at the end of the test.</p>\n\n<p>Another test applied randomly timed power failures repeatedly while running test code. Millions of cycles have been executed without any errors being observed.</p>\n\n<p>Yaffs is used (under GPL) in the Android mobile phones sold by Google and others. Extensive use in the field like this helps to ensure its robustness.</p>\n\n<h3><em>How big is its code?</em></h3>\n\n<p>That depends on how much of it you need; it is modular in organisation. The innermost or core part is about 11k lines of code, the the Yaffs Direct Interface giving file handle access and a Posix-like interface is around 2k lines.</p>\n\n<h3>Glossary and useful links.</h3>\n\n<table><colgroup><col /><col /></colgroup><tr><td>\n			<p>Big-endian and Little-endian</p>\n			</td>\n			<td>\n			<p>Big-endian is when the most significant data chunk is listed first. Little-endian is when the least significant data chunk is listed first.</p>\n\n			<p><em>http://en.wikipedia.org/wiki/Endianness</em></p>\n			</td>\n		</tr><tr><td>\n			<p>tnodes</p>\n			</td>\n			<td>\n			<p>Tnodes are yaffs data structures used to build trees that map from a file to the file data chunks stored in flash. A large file will have multiple data chunks scattered throughout the flash and will need a larger tnode tree.</p>\n\n			<p>See the HowYaffs Works document for more information.</p>\n			</td>\n		</tr><tr><td>\n			<p>ECC</p>\n			</td>\n			<td>\n			<p>Error correction codes, See the <em>Yaffs Error mitigation</em> document.</p>\n			</td>\n		</tr><tr><td>\n			<p>MLC</p>\n			</td>\n			<td>\n			<p>Multi-level cell, allows more than one bit state to be stored in a memory cell. MLC Flash often allows four state (ie. 2 bits) to be stored in one cell. <em>http://en.wikipedia.org/wiki/Multi-level_cell</em></p>\n\n			<p> </p>\n			</td>\n		</tr></table><p> </p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:14:\"/documents/faq\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/448\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:14:\"/documents/faq\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:448\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:17:\"<span>FAQ</span>\n\";}}',-1,1504699641.198,1,'config:filter.format.basic_html config:system.site node:448 node_view rendered user:1','278'),('entity_view:node:448:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"448\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:448\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504699641.147,1,'config:filter.format.basic_html config:system.site node:448 node_view rendered user:1','278'),('entity_view:node:448:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:6722:\"<span>FAQ</span>\n\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><h3><em>What Operating System (OS) can you use with Yaffs?</em></h3>\n\n<p>Yaffs is agnostic about the OS it is used with; it has been used with many different OSs, including Linux, eCos, Windows CE, ThreadX, pSOS and vXworks. It is POSIX-compliant, so commands in an application calling POSIX functions will usually work.</p>\n\n<p>Windows CE uses the Microsoft file handling model and is not POSIX-like. The difference is handled in the Windows CE wrapper.  Contact us for more information.</p>\n\n<p>Work on closer integration of Yaffs into the Linux kernel started in 2010 and the goal is to have Yaffs merged into the mainline Linux kernel.</p>\n\n<p>The Yaffs Direct Interface, YDI, is the heart of Yaffs and usually stands between the Application, on one side, and the Flash chips, and any OS, on the other side:-</p>\n\n<h3><em>What CPU can you use with Yaffs?</em></h3>\n\n<p>Yaffs has been used with many 32-bit and 64-bit CPUs including MIPS, 68000, ColdFire, PowerPC, x86 variants and many ARM-cored CPUs. It should work with 16-bit CPUs but has not been tested.</p>\n\n<h3><em>Does Yaffs care Which-Endian the CPU is?</em></h3>\n\n<p>No, Yaffs works with Big-Endian and Little-Endian CPUs</p>\n\n<h3><em>How big can the whole file system be, and how big can individual files be?</em></h3>\n\n<p>Yaffs2, which is now standard, can handle a File System (FS) of many Gigabytes total storage; some people are using it with 6GB satisfactorily. <em>Individual</em> files are currently limited to 2GB. The basic Yaffs architecture can handle larger single files and some changes would be required to support individual files greater than 2G bytes. There is an upper limit of around 32GB with the present 2k bytes granularity of \'chunks\' or page size, and the limit of about 16 million chunks per file.</p>\n\n<p>A coarser granularity of larger chunks can probably be obtained, with knock-on effects in other parameters like RAM usage.</p>\n\n<h3><em>How many files can there be?</em></h3>\n\n<p>There is no hard limit. Available flash and RAM will limit this.</p>\n\n<h3><em>What about directories etc?</em></h3>\n\n<p>Yaffs supports many different objects including: directories, regular files, hard links, symbolic links and device nodes.</p>\n\n<p>Yaffs supports long file names, attributes, extended attributes and Unicode.</p>\n\n<h3><em>How much RAM does it need?</em></h3>\n\n<p>This depends particularly on the number of tnodes, which in turn depends on the file size, and is therefore a dynamic variable.</p>\n\n<p>However, Yaffs compares favourably with other similar systems specialised for Flash, and includes robust error handling.</p>\n\n<h4><em>How are errors handled?</em></h4>\n\n<p>Error Correction Code (ECC) is used to correct for single-bit errors.</p>\n\n<p>ECC may use built-in code or that provided from other sources (flash controllers, ECC libraries etc).</p>\n\n<p>Yaffs is frequently tested on a \"fuzzer\" test harness. This randomly corrupts bits of the file system image to check that the file system still mounts and loads correctly.</p>\n\n<h3><em>What about Multi-level cell (MLC) chips?</em></h3>\n\n<p>Because a bit is represented by a smaller amount of charge in the MLC chip compared to a SLC chip, MLC chips are more prone to corruption than SLC.</p>\n\n<p>MLC also has various write restrictions, which are obeyed by Yaffs2.</p>\n\n<p>Yaffs2 has some features such as block refreshing to help alleviate the problems associated with MLC.</p>\n\n<p>MLC generally requires multi-bit ECC. Hardware ECC is preferred since it is faster and requires less computation than software multi-bit correction..</p>\n\n<h3><em>How robust is Yaffs ?</em></h3>\n\n<p>Yaffs is designed specifically to take account of manufacturing faults in, and of accumulated wear in, individual cells, and also to handle power failures during use.</p>\n\n<p>Yaffs allocates flash blocks in a way that gives statistical or implicit wear levelling; when a block is freed up it is released into a <em>free pool</em> and the next allocation comes from this <em>free pool. </em>This randomness tends to spread the blocks in use, giving some wear levelling, rather than one part of the file always being worked intensively.</p>\n\n<p>Accelerated lifetime testing has been carried out to seek evidence for excessive wear. For example on one professional PDA-style device used by surveyors in the field we determined that extreme lifetime usage would be:</p>\n\n<ul><li>20MB per day.</li>\n	<li>200 days per year</li>\n	<li>10 year lifetime</li>\n	<li>Total 40Gbytes lifetime write.</li>\n</ul><p>We then ran well over 200Gbytes of writing through a specially designed File System Exerciser, a multi-threaded application that writes, reads, verifies, then deletes, repeatedly. There was no sign of a single bit of corruption at the end of the test.</p>\n\n<p>Another test applied randomly timed power failures repeatedly while running test code. Millions of cycles have been executed without any errors being observed.</p>\n\n<p>Yaffs is used (under GPL) in the Android mobile phones sold by Google and others. Extensive use in the field like this helps to ensure its robustness.</p>\n\n<h3><em>How big is its code?</em></h3>\n\n<p>That depends on how much of it you need; it is modular in organisation. The innermost or core part is about 11k lines of code, the the Yaffs Direct Interface giving file handle access and a Posix-like interface is around 2k lines.</p>\n\n<h3>Glossary and useful links.</h3>\n\n<table><colgroup><col /><col /></colgroup><tr><td>\n			<p>Big-endian and Little-endian</p>\n			</td>\n			<td>\n			<p>Big-endian is when the most significant data chunk is listed first. Little-endian is when the least significant data chunk is listed first.</p>\n\n			<p><em>http://en.wikipedia.org/wiki/Endianness</em></p>\n			</td>\n		</tr><tr><td>\n			<p>tnodes</p>\n			</td>\n			<td>\n			<p>Tnodes are yaffs data structures used to build trees that map from a file to the file data chunks stored in flash. A large file will have multiple data chunks scattered throughout the flash and will need a larger tnode tree.</p>\n\n			<p>See the HowYaffs Works document for more information.</p>\n			</td>\n		</tr><tr><td>\n			<p>ECC</p>\n			</td>\n			<td>\n			<p>Error correction codes, See the <em>Yaffs Error mitigation</em> document.</p>\n			</td>\n		</tr><tr><td>\n			<p>MLC</p>\n			</td>\n			<td>\n			<p>Multi-level cell, allows more than one bit state to be stored in a memory cell. MLC Flash often allows four state (ie. 2 bits) to be stored in one cell. <em>http://en.wikipedia.org/wiki/Multi-level_cell</em></p>\n\n			<p> </p>\n			</td>\n		</tr></table><p> </p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:448\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505188402.947,1,'config:filter.format.basic_html node:448 node_view rendered','265'),('entity_view:node:448:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"448\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:3:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:448\";i:2;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505188402.945,1,'config:filter.format.basic_html node:448 node_view rendered','265'),('entity_view:node:451:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0HdqrLVTjuyFxNeo88ycz71gr31deOh9vQUoTTjrJaXw','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:13409:\"<article role=\"article\" about=\"/documents/yaffs-tuning\" class=\"paper is-promoted full clearfix\">\n\n  \n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/admin\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Admin</span></span>\n on <span>22 July, 2012 - 8:23pm</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    \n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsTuning.pdf\" type=\"application/pdf; length=93667\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsTuning.pdf</a></span><span class=\"file-size\">91.47 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p> </p>\n\n<h2>1 Yaffs Direct Configuration</h2>\n\n<p>Yaffs behaviour is dictated by compile time and run-time flags.</p>\n\n<h3>1.1 Initialisation Parameters</h3>\n\n<p>Each yaffs device is configured by a yaffs_DeviceParameterStruct structure which is part of the yaffs_DeviceStruct structure. This contains the following fields:</p>\n\n<table><colgroup><col /><col /></colgroup><tr><td>\n			<p>name</p>\n			</td>\n			<td>\n			<p>An optional name for the device</p>\n			</td>\n		</tr><tr><td>\n			<p>totalBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of bytes in the data area of the flash page. If inbandTags is not set then this whole area will be used to store data and the tags will be stored in the spare area. If inbandTags is set then part of this area will be used to store tags and the rest will be used to store data.</p>\n			</td>\n		</tr><tr><td>\n			<p>spareBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of available bytes in the spare area of the flash page. This excludes space used by ECC, bad block markers etc.</p>\n			</td>\n		</tr><tr><td>\n			<p>startBlock</p>\n			</td>\n			<td>\n			<p>The first block in the partition to be used. 0 for first block.</p>\n			</td>\n		</tr><tr><td>\n			<p>endBlock</p>\n			</td>\n			<td>\n			<p>The last block in the partition to be used.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nReservedBlocks</p>\n			</td>\n			<td>\n			<p>Number of good blocks blocks reserved for garbage collection etc. Needs to be at least 2, but 5 would be a more typical number.</p>\n			</td>\n		</tr><tr><td>\n			<p>inbandTags</p>\n			</td>\n			<td>\n			<p>Yaffs2 only:Flag indicating whether tags should be stored in the data area. If inbandTags is set then the short Op cache must be enabled (ie nShortOpCaches must be non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>useNANDECC</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Flag indicating whether the driver performs ECC. If this is zero then Yaffs will perform ECC.</p>\n			</td>\n		</tr><tr><td>\n			<p>noTagsECC</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag indicating whether the tags have ECC attached to them.</p>\n			</td>\n		</tr><tr><td>\n			<p>isYaffs2</p>\n			</td>\n			<td>\n			<p>Flag indicating if this is using the Yaffs2 mechanism. If this is not set then Yaffs1 mode of operation is provided.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nShortOpCaches</p>\n			</td>\n			<td>\n			<p>Number of chunks to store in the short operation cache. Zero disables caching. Typical value is 10 to 20 or so. Caching is required for inband tags.</p>\n			</td>\n		</tr><tr><td>\n			<p>emptyLostAndFound</p>\n			</td>\n			<td>\n			<p>Flag to delete all files in lost and found on mount.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointRead</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip reading checkpoint on mount. If set then a re-scan is forced.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointWrite</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip writing checkpoint on sync or unmount.</p>\n			</td>\n		</tr><tr><td>\n			<p>refreshPeriod</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: How often Yaffs should do a block refresh. Values less than 10 disable block refreshing. Typical values would be1000.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>initialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to initialise flash driver.</p>\n			</td>\n		</tr><tr><td>\n			<p>deinitialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to de-initialise flash driver</p>\n			</td>\n		</tr><tr><td>\n			<p>eraseBlockInNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to erase a flash block</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to write a chunk</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to read a chunk.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkWithTagsToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to write a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkWithTagsFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to read a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>markNANDBlockBad</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to mark a block bad</p>\n			</td>\n		</tr><tr><td>\n			<p>queryNANDBlock</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to query a block state</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>gcControl</p>\n			</td>\n			<td>\n			<p>Callback function that returns the garbage collector control flags. This is optional.</p>\n			</td>\n		</tr><tr><td>\n			<p>removeObjectCallback</p>\n			</td>\n			<td>\n			<p>Callback function called when an object is removed. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p>markSuperBlockDirty</p>\n			</td>\n			<td>\n			<p>Callback function that is called when a clean file system is first modified. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>disableSoftDelete</p>\n			</td>\n			<td>\n			<p>Yaffs1 only. Debug only. Disables soft deletion if non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>useHeaderFileSize</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero</p>\n			</td>\n		</tr><tr><td>\n			<p>disableLazyLoading</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>wideTnodeDisabled</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>deferDirectoryUpdate</p>\n			</td>\n			<td>\n			<p>Used to defer directory updates.</p>\n			</td>\n		</tr></table><p> </p>\n\n<h3>1.2 Compile-time settings</h3>\n\n<p>These setting are used to apply compile-time configurations.</p>\n\n<p>CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED</p>\n\n<p>Normally Yaffs checks that chunks are erased only on the first chunk write to each block. This flag allows you to force all chunks to be checked. This is slower, but is worth using when doing early debugging.</p>\n\n<p>CONFIG_YAFFS_CASE_INSENSITIVE</p>\n\n<p>When selected case insensitive name comparisons are used. Note that this will not magically change Yaffs to be case insensitive in a case sensitive OS. This needs to be set according to the OS policy. Typically this is only used in Windows CE.</p>\n\n<p>CONFIG_YAFFS_DIRECT</p>\n\n<p>Used when compiling Yaffs Direct.</p>\n\n<p>CONFIG_YAFFS_DISABLE_LAZY_LOAD</p>\n\n<p>Lazy loading is used to defer loading up object details until the objects are accessed. This makes mount time faster. This flag can disable lazy loading. Debug only.</p>\n\n<p>CONFIG_YAFFS_ECC_WRONG_ORDER</p>\n\n<p>This flag should only be used with old Linux MTD code which had a bug in the ECC byte ordering.</p>\n\n<p>CONFIG_YAFFS_NO_YAFFS1</p>\n\n<p>Used to say that only Yaffs2 operation should be compiled in. Not currently supported.</p>\n\n<p>CONFIG_YAFFS_SHORT_NAMES_IN_RAM</p>\n\n<p>Set to configure Yaffs to store short object names in RAM. This is faster, but uses up more memory.</p>\n\n<p>CONFIG_YAFFS_UNICODE</p>\n\n<p>Set to configure Yaffs to use Unicode file names (eg. With WinCE).</p>\n\n<p>CONFIG_YAFFS_USE_OWN_SORT</p>\n\n<p>By default, Yaffs uses qsort for sorting blocks at mount scanning time. This is faster. Using this flag forces Yaffs to use a slow internal sort instead. Debug only.</p>\n\n<p>CONFIG_YAFFS_UTIL</p>\n\n<p>Used when compiling Yaffs for utilities.</p>\n\n<p>CONFIG_YAFFS_WINCE</p>\n\n<p>Set when compiling Yaffs for WinCE.</p>\n\n<p>CONFIG_YAFFS_YAFFS2</p>\n\n<p>Set when using Yaffs2 mode. At present this must always be set.</p>\n\n<p>CONFIG_YAFFSFS_PROVIDE_VALUES</p>\n\n<p>Used when compiling Yaffs Direct only.</p>\n\n<h3>2 Tracing mechanism</h3>\n\n<p>Yaffs has a lot of built in tracing to help debug and integrate. The tracing is controlled by yaffs_traceMask bitmask which allows various sets of tracing to be disabled or enabled at runtime.</p>\n\n<p>The trace bits are specified in the yaffs_trace.h file.</p>\n\n<p>The tracing mechanism has also been \'hijacked\' to provide a control mask for extra verification code when the YAFFS_TRACE_VERIFYxxx trace bits are selected.</p>\n\n<p>The tracing mechanism is readily integrated into the system via printf-like statements. Tracing is all done through macros which allow the strings to be converted into unicode or similar if need be.</p>\n\n<h2>3 Linux</h2>\n\n<h3>3.1 Linux compile-time flags</h3>\n\n<p>The Linux compile time flags are documented in the Kconfig file and will not be duplicated here.</p>\n\n<h3>3.2 Linux: /proc/yaffs trace adjustment</h3>\n\n<p>Under Linux, the tracing mechanism is hooked up to both the /proc/yaffs and the sys interface. The /proc/yaffs interface is very user friendly.</p>\n\n<p><code>#cat +os &gt; /proc/yaffs # Enables YAFFS_TRACE_OS<br />\n#cat -all+gc &gt; /proc/yaffs # Disables everything then enable YAFFS_TRACE_GC<br />\n#cat 0xf000 &gt; /proc/yaffs # Set trace mask to specified bitmask.</code></p>\n\n<h3>3.3 Linux: /sys/ interface</h3>\n\n<p>The Linux /sys/ interface is used by many Linux OS components to access the state of control variables. Some Yaffs variables are available via /sys/module/yaffs2/parameters/ *. Values can be read and modified using standard shell commands or from application programs.</p>\n\n<p><code># ls /sys/module/yaffs2/parameters/ yaffs_auto_checkpoint yaffs_traceMask yaffs_wr_attempts<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 1<br />\n# echo \"2\" &gt; /sys/module/yaffs2/parameters/yaffs_auto_checkpoint<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 2 </code></p>\n\n<p>Yaffs currently supports the following variables:</p>\n\n<p>yaffs_auto_checkpoint: Controls when checkpoints should be written.</p>\n\n<p>yaffs_traceMask: An alternative, and less user friendly,interface to modify tracing.</p>\n\n<p>yaffs_wr_attempts: The number of attempts that Yaffs will make to write a chunk.</p>\n\n<p>yaffs_gc_control: Controls the garbage collector.</p>\n\n<h3>3.4 Linux: /proc/yaffs state dumping</h3>\n\n<p>Some of the state of Yaffs mounts can be determined by reading the /proc/yaffs entry.</p>\n\n<p><code># cat /proc/yaffs<br />\ncharles@charles-laptop:/opt/y/cvs/yaffs2$ cat /proc/yaffs<br />\nYAFFS built:Mar 16 2010 11:52:25<br />\n$Id: yaffs_fs.c,v 1.101 2010-03-15 22:27:15 charles Exp $<br />\n$Id: yaffs_guts.c,v 1.119 2010-03-12 02:48:34 charles Exp $<br /><br />\nDevice 0 \"NAND simulator partition 0\" </code><br /><code>startBlock......... 0<br />\nendBlock........... 511<br />\ntotalBytesPerChunk. 2048<br />\nuseNANDECC......... 1<br />\nnoTagsECC.......... 0<br />\nisYaffs2........... 1<br />\ninbandTags......... 0<br />\nemptyLostAndFound.. 1<br />\ndisableLazyLoad.... 0<br />\nrefreshPeriod...... 10000<br />\nnShortOpCaches..... 10<br />\nnReservedBlocks.... 5<br /><br />\nnDataBytesPerChunk. 2048<br />\nchunkGroupBits..... 0<br />\nchunkGroupSize..... 1<br />\nnErasedBlocks...... 152<br />\nblocksInCheckpoint. 0<br /><br />\nnTnodesCreated..... 2300<br />\nnFreeTnodes........ 1852<br />\nnObjectsCreated.... 2300<br />\nnFreeObjects....... 1842<br />\nnFreeChunks........ 27843<br /><br />\nnPageWrites........ 65993<br />\nnPageReads......... 19631<br />\nnBlockErasures..... 1133<br />\nnGCCopies.......... 37<br />\ngarbageCollections. 161<br />\npassiveGCs......... 137<br />\nnRetriedWrites..... 0<br />\nnRetireBlocks...... 0<br />\neccFixed........... 0<br />\neccUnfixed......... 0<br />\ntagsEccFixed....... 0<br />\ntagsEccUnfixed..... 0<br />\ncacheHits.......... 44110<br />\nnDeletedFiles...... 0<br />\nnUnlinkedFiles..... 42917<br />\nrefreshCount....... 1<br />\nnBackgroudDeletions 0</code></p>\n\n<p> </p>\n\n<h2>4 Conclusions</h2>\n\n<p>Yaffs includes many options for changing speed or memory use, with specific flags for the Yaffs Direct Interface as well as Linux. Under Linux many of the control variables can be altered using standard Linux systems.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:23:\"/documents/yaffs-tuning\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/451\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:23:\"/documents/yaffs-tuning\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:85\";i:3;s:8:\"node:451\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:26:\"<span>Yaffs Tuning</span>\n\";}}',-1,1504641960.533,1,'config:filter.format.basic_html config:system.site file:85 node:451 node_view rendered user:1','281'),('entity_view:node:451:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"451\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:85\";i:3;s:8:\"node:451\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504641960.530,1,'config:filter.format.basic_html config:system.site file:85 node:451 node_view rendered user:1','281'),('entity_view:node:451:rss:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:13165:\"<span>Yaffs Tuning</span>\n<span><span lang=\"\" about=\"/user/admin\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Admin</span></span>\n<span>22 July, 2012 - 8:23pm</span>\n\n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsTuning.pdf\" type=\"application/pdf; length=93667\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsTuning.pdf</a></span><span class=\"file-size\">91.47 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p> </p>\n\n<h2>1 Yaffs Direct Configuration</h2>\n\n<p>Yaffs behaviour is dictated by compile time and run-time flags.</p>\n\n<h3>1.1 Initialisation Parameters</h3>\n\n<p>Each yaffs device is configured by a yaffs_DeviceParameterStruct structure which is part of the yaffs_DeviceStruct structure. This contains the following fields:</p>\n\n<table><colgroup><col /><col /></colgroup><tr><td>\n			<p>name</p>\n			</td>\n			<td>\n			<p>An optional name for the device</p>\n			</td>\n		</tr><tr><td>\n			<p>totalBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of bytes in the data area of the flash page. If inbandTags is not set then this whole area will be used to store data and the tags will be stored in the spare area. If inbandTags is set then part of this area will be used to store tags and the rest will be used to store data.</p>\n			</td>\n		</tr><tr><td>\n			<p>spareBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of available bytes in the spare area of the flash page. This excludes space used by ECC, bad block markers etc.</p>\n			</td>\n		</tr><tr><td>\n			<p>startBlock</p>\n			</td>\n			<td>\n			<p>The first block in the partition to be used. 0 for first block.</p>\n			</td>\n		</tr><tr><td>\n			<p>endBlock</p>\n			</td>\n			<td>\n			<p>The last block in the partition to be used.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nReservedBlocks</p>\n			</td>\n			<td>\n			<p>Number of good blocks blocks reserved for garbage collection etc. Needs to be at least 2, but 5 would be a more typical number.</p>\n			</td>\n		</tr><tr><td>\n			<p>inbandTags</p>\n			</td>\n			<td>\n			<p>Yaffs2 only:Flag indicating whether tags should be stored in the data area. If inbandTags is set then the short Op cache must be enabled (ie nShortOpCaches must be non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>useNANDECC</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Flag indicating whether the driver performs ECC. If this is zero then Yaffs will perform ECC.</p>\n			</td>\n		</tr><tr><td>\n			<p>noTagsECC</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag indicating whether the tags have ECC attached to them.</p>\n			</td>\n		</tr><tr><td>\n			<p>isYaffs2</p>\n			</td>\n			<td>\n			<p>Flag indicating if this is using the Yaffs2 mechanism. If this is not set then Yaffs1 mode of operation is provided.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nShortOpCaches</p>\n			</td>\n			<td>\n			<p>Number of chunks to store in the short operation cache. Zero disables caching. Typical value is 10 to 20 or so. Caching is required for inband tags.</p>\n			</td>\n		</tr><tr><td>\n			<p>emptyLostAndFound</p>\n			</td>\n			<td>\n			<p>Flag to delete all files in lost and found on mount.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointRead</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip reading checkpoint on mount. If set then a re-scan is forced.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointWrite</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip writing checkpoint on sync or unmount.</p>\n			</td>\n		</tr><tr><td>\n			<p>refreshPeriod</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: How often Yaffs should do a block refresh. Values less than 10 disable block refreshing. Typical values would be1000.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>initialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to initialise flash driver.</p>\n			</td>\n		</tr><tr><td>\n			<p>deinitialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to de-initialise flash driver</p>\n			</td>\n		</tr><tr><td>\n			<p>eraseBlockInNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to erase a flash block</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to write a chunk</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to read a chunk.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkWithTagsToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to write a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkWithTagsFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to read a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>markNANDBlockBad</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to mark a block bad</p>\n			</td>\n		</tr><tr><td>\n			<p>queryNANDBlock</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to query a block state</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>gcControl</p>\n			</td>\n			<td>\n			<p>Callback function that returns the garbage collector control flags. This is optional.</p>\n			</td>\n		</tr><tr><td>\n			<p>removeObjectCallback</p>\n			</td>\n			<td>\n			<p>Callback function called when an object is removed. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p>markSuperBlockDirty</p>\n			</td>\n			<td>\n			<p>Callback function that is called when a clean file system is first modified. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>disableSoftDelete</p>\n			</td>\n			<td>\n			<p>Yaffs1 only. Debug only. Disables soft deletion if non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>useHeaderFileSize</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero</p>\n			</td>\n		</tr><tr><td>\n			<p>disableLazyLoading</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>wideTnodeDisabled</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>deferDirectoryUpdate</p>\n			</td>\n			<td>\n			<p>Used to defer directory updates.</p>\n			</td>\n		</tr></table><p> </p>\n\n<h3>1.2 Compile-time settings</h3>\n\n<p>These setting are used to apply compile-time configurations.</p>\n\n<p>CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED</p>\n\n<p>Normally Yaffs checks that chunks are erased only on the first chunk write to each block. This flag allows you to force all chunks to be checked. This is slower, but is worth using when doing early debugging.</p>\n\n<p>CONFIG_YAFFS_CASE_INSENSITIVE</p>\n\n<p>When selected case insensitive name comparisons are used. Note that this will not magically change Yaffs to be case insensitive in a case sensitive OS. This needs to be set according to the OS policy. Typically this is only used in Windows CE.</p>\n\n<p>CONFIG_YAFFS_DIRECT</p>\n\n<p>Used when compiling Yaffs Direct.</p>\n\n<p>CONFIG_YAFFS_DISABLE_LAZY_LOAD</p>\n\n<p>Lazy loading is used to defer loading up object details until the objects are accessed. This makes mount time faster. This flag can disable lazy loading. Debug only.</p>\n\n<p>CONFIG_YAFFS_ECC_WRONG_ORDER</p>\n\n<p>This flag should only be used with old Linux MTD code which had a bug in the ECC byte ordering.</p>\n\n<p>CONFIG_YAFFS_NO_YAFFS1</p>\n\n<p>Used to say that only Yaffs2 operation should be compiled in. Not currently supported.</p>\n\n<p>CONFIG_YAFFS_SHORT_NAMES_IN_RAM</p>\n\n<p>Set to configure Yaffs to store short object names in RAM. This is faster, but uses up more memory.</p>\n\n<p>CONFIG_YAFFS_UNICODE</p>\n\n<p>Set to configure Yaffs to use Unicode file names (eg. With WinCE).</p>\n\n<p>CONFIG_YAFFS_USE_OWN_SORT</p>\n\n<p>By default, Yaffs uses qsort for sorting blocks at mount scanning time. This is faster. Using this flag forces Yaffs to use a slow internal sort instead. Debug only.</p>\n\n<p>CONFIG_YAFFS_UTIL</p>\n\n<p>Used when compiling Yaffs for utilities.</p>\n\n<p>CONFIG_YAFFS_WINCE</p>\n\n<p>Set when compiling Yaffs for WinCE.</p>\n\n<p>CONFIG_YAFFS_YAFFS2</p>\n\n<p>Set when using Yaffs2 mode. At present this must always be set.</p>\n\n<p>CONFIG_YAFFSFS_PROVIDE_VALUES</p>\n\n<p>Used when compiling Yaffs Direct only.</p>\n\n<h3>2 Tracing mechanism</h3>\n\n<p>Yaffs has a lot of built in tracing to help debug and integrate. The tracing is controlled by yaffs_traceMask bitmask which allows various sets of tracing to be disabled or enabled at runtime.</p>\n\n<p>The trace bits are specified in the yaffs_trace.h file.</p>\n\n<p>The tracing mechanism has also been \'hijacked\' to provide a control mask for extra verification code when the YAFFS_TRACE_VERIFYxxx trace bits are selected.</p>\n\n<p>The tracing mechanism is readily integrated into the system via printf-like statements. Tracing is all done through macros which allow the strings to be converted into unicode or similar if need be.</p>\n\n<h2>3 Linux</h2>\n\n<h3>3.1 Linux compile-time flags</h3>\n\n<p>The Linux compile time flags are documented in the Kconfig file and will not be duplicated here.</p>\n\n<h3>3.2 Linux: /proc/yaffs trace adjustment</h3>\n\n<p>Under Linux, the tracing mechanism is hooked up to both the /proc/yaffs and the sys interface. The /proc/yaffs interface is very user friendly.</p>\n\n<p><code>#cat +os &gt; /proc/yaffs # Enables YAFFS_TRACE_OS<br />\n#cat -all+gc &gt; /proc/yaffs # Disables everything then enable YAFFS_TRACE_GC<br />\n#cat 0xf000 &gt; /proc/yaffs # Set trace mask to specified bitmask.</code></p>\n\n<h3>3.3 Linux: /sys/ interface</h3>\n\n<p>The Linux /sys/ interface is used by many Linux OS components to access the state of control variables. Some Yaffs variables are available via /sys/module/yaffs2/parameters/ *. Values can be read and modified using standard shell commands or from application programs.</p>\n\n<p><code># ls /sys/module/yaffs2/parameters/ yaffs_auto_checkpoint yaffs_traceMask yaffs_wr_attempts<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 1<br />\n# echo \"2\" &gt; /sys/module/yaffs2/parameters/yaffs_auto_checkpoint<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 2 </code></p>\n\n<p>Yaffs currently supports the following variables:</p>\n\n<p>yaffs_auto_checkpoint: Controls when checkpoints should be written.</p>\n\n<p>yaffs_traceMask: An alternative, and less user friendly,interface to modify tracing.</p>\n\n<p>yaffs_wr_attempts: The number of attempts that Yaffs will make to write a chunk.</p>\n\n<p>yaffs_gc_control: Controls the garbage collector.</p>\n\n<h3>3.4 Linux: /proc/yaffs state dumping</h3>\n\n<p>Some of the state of Yaffs mounts can be determined by reading the /proc/yaffs entry.</p>\n\n<p><code># cat /proc/yaffs<br />\ncharles@charles-laptop:/opt/y/cvs/yaffs2$ cat /proc/yaffs<br />\nYAFFS built:Mar 16 2010 11:52:25<br />\n$Id: yaffs_fs.c,v 1.101 2010-03-15 22:27:15 charles Exp $<br />\n$Id: yaffs_guts.c,v 1.119 2010-03-12 02:48:34 charles Exp $<br /><br />\nDevice 0 \"NAND simulator partition 0\" </code><br /><code>startBlock......... 0<br />\nendBlock........... 511<br />\ntotalBytesPerChunk. 2048<br />\nuseNANDECC......... 1<br />\nnoTagsECC.......... 0<br />\nisYaffs2........... 1<br />\ninbandTags......... 0<br />\nemptyLostAndFound.. 1<br />\ndisableLazyLoad.... 0<br />\nrefreshPeriod...... 10000<br />\nnShortOpCaches..... 10<br />\nnReservedBlocks.... 5<br /><br />\nnDataBytesPerChunk. 2048<br />\nchunkGroupBits..... 0<br />\nchunkGroupSize..... 1<br />\nnErasedBlocks...... 152<br />\nblocksInCheckpoint. 0<br /><br />\nnTnodesCreated..... 2300<br />\nnFreeTnodes........ 1852<br />\nnObjectsCreated.... 2300<br />\nnFreeObjects....... 1842<br />\nnFreeChunks........ 27843<br /><br />\nnPageWrites........ 65993<br />\nnPageReads......... 19631<br />\nnBlockErasures..... 1133<br />\nnGCCopies.......... 37<br />\ngarbageCollections. 161<br />\npassiveGCs......... 137<br />\nnRetriedWrites..... 0<br />\nnRetireBlocks...... 0<br />\neccFixed........... 0<br />\neccUnfixed......... 0<br />\ntagsEccFixed....... 0<br />\ntagsEccUnfixed..... 0<br />\ncacheHits.......... 44110<br />\nnDeletedFiles...... 0<br />\nnUnlinkedFiles..... 42917<br />\nrefreshCount....... 1<br />\nnBackgroudDeletions 0</code></p>\n\n<p> </p>\n\n<h2>4 Conclusions</h2>\n\n<p>Yaffs includes many options for changing speed or memory use, with specific flags for the Yaffs Direct Interface as well as Linux. Under Linux many of the control variables can be altered using standard Linux systems.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:7:\"file:85\";i:2;s:8:\"node:451\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1504783535.989,1,'config:filter.format.basic_html file:85 node:451 node_view rendered user:1','275'),('entity_view:node:451:rss:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"451\";i:3;s:3:\"rss\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:7:\"file:85\";i:2;s:8:\"node:451\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504783535.968,1,'config:filter.format.basic_html file:85 node:451 node_view rendered user:1','275'),('entity_view:node:451:search_result:[languages:language_interface]=en:[theme]=yaffs:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:13011:\"<span>Yaffs Tuning</span>\n\n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsTuning.pdf\" type=\"application/pdf; length=93667\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsTuning.pdf</a></span><span class=\"file-size\">91.47 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p> </p>\n\n<h2>1 Yaffs Direct Configuration</h2>\n\n<p>Yaffs behaviour is dictated by compile time and run-time flags.</p>\n\n<h3>1.1 Initialisation Parameters</h3>\n\n<p>Each yaffs device is configured by a yaffs_DeviceParameterStruct structure which is part of the yaffs_DeviceStruct structure. This contains the following fields:</p>\n\n<table><colgroup><col /><col /></colgroup><tr><td>\n			<p>name</p>\n			</td>\n			<td>\n			<p>An optional name for the device</p>\n			</td>\n		</tr><tr><td>\n			<p>totalBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of bytes in the data area of the flash page. If inbandTags is not set then this whole area will be used to store data and the tags will be stored in the spare area. If inbandTags is set then part of this area will be used to store tags and the rest will be used to store data.</p>\n			</td>\n		</tr><tr><td>\n			<p>spareBytesPerChunk</p>\n			</td>\n			<td>\n			<p>The number of available bytes in the spare area of the flash page. This excludes space used by ECC, bad block markers etc.</p>\n			</td>\n		</tr><tr><td>\n			<p>startBlock</p>\n			</td>\n			<td>\n			<p>The first block in the partition to be used. 0 for first block.</p>\n			</td>\n		</tr><tr><td>\n			<p>endBlock</p>\n			</td>\n			<td>\n			<p>The last block in the partition to be used.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nReservedBlocks</p>\n			</td>\n			<td>\n			<p>Number of good blocks blocks reserved for garbage collection etc. Needs to be at least 2, but 5 would be a more typical number.</p>\n			</td>\n		</tr><tr><td>\n			<p>inbandTags</p>\n			</td>\n			<td>\n			<p>Yaffs2 only:Flag indicating whether tags should be stored in the data area. If inbandTags is set then the short Op cache must be enabled (ie nShortOpCaches must be non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>useNANDECC</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Flag indicating whether the driver performs ECC. If this is zero then Yaffs will perform ECC.</p>\n			</td>\n		</tr><tr><td>\n			<p>noTagsECC</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag indicating whether the tags have ECC attached to them.</p>\n			</td>\n		</tr><tr><td>\n			<p>isYaffs2</p>\n			</td>\n			<td>\n			<p>Flag indicating if this is using the Yaffs2 mechanism. If this is not set then Yaffs1 mode of operation is provided.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>nShortOpCaches</p>\n			</td>\n			<td>\n			<p>Number of chunks to store in the short operation cache. Zero disables caching. Typical value is 10 to 20 or so. Caching is required for inband tags.</p>\n			</td>\n		</tr><tr><td>\n			<p>emptyLostAndFound</p>\n			</td>\n			<td>\n			<p>Flag to delete all files in lost and found on mount.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointRead</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip reading checkpoint on mount. If set then a re-scan is forced.</p>\n			</td>\n		</tr><tr><td>\n			<p>skipCheckpointWrite</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Flag to skip writing checkpoint on sync or unmount.</p>\n			</td>\n		</tr><tr><td>\n			<p>refreshPeriod</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: How often Yaffs should do a block refresh. Values less than 10 disable block refreshing. Typical values would be1000.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>initialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to initialise flash driver.</p>\n			</td>\n		</tr><tr><td>\n			<p>deinitialiseNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to de-initialise flash driver</p>\n			</td>\n		</tr><tr><td>\n			<p>eraseBlockInNAND</p>\n			</td>\n			<td>\n			<p>Pointer to function to erase a flash block</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to write a chunk</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs1 only: Pointer to function to read a chunk.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>writeChunkWithTagsToNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to write a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>readChunkWithTagsFromNAND</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Pointer to function to read a chunk plus tags</p>\n			</td>\n		</tr><tr><td>\n			<p>markNANDBlockBad</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to mark a block bad</p>\n			</td>\n		</tr><tr><td>\n			<p>queryNANDBlock</p>\n			</td>\n			<td>\n			<p>Yaffs2 only: Function to query a block state</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>gcControl</p>\n			</td>\n			<td>\n			<p>Callback function that returns the garbage collector control flags. This is optional.</p>\n			</td>\n		</tr><tr><td>\n			<p>removeObjectCallback</p>\n			</td>\n			<td>\n			<p>Callback function called when an object is removed. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p>markSuperBlockDirty</p>\n			</td>\n			<td>\n			<p>Callback function that is called when a clean file system is first modified. This is set by the wrapper.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>disableSoftDelete</p>\n			</td>\n			<td>\n			<p>Yaffs1 only. Debug only. Disables soft deletion if non-zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>useHeaderFileSize</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero</p>\n			</td>\n		</tr><tr><td>\n			<p>disableLazyLoading</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p>wideTnodeDisabled</p>\n			</td>\n			<td>\n			<p>Debug only. Leave as zero.</p>\n			</td>\n		</tr><tr><td>\n			<p> </p>\n			</td>\n			<td>\n			<p> </p>\n			</td>\n		</tr><tr><td>\n			<p>deferDirectoryUpdate</p>\n			</td>\n			<td>\n			<p>Used to defer directory updates.</p>\n			</td>\n		</tr></table><p> </p>\n\n<h3>1.2 Compile-time settings</h3>\n\n<p>These setting are used to apply compile-time configurations.</p>\n\n<p>CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED</p>\n\n<p>Normally Yaffs checks that chunks are erased only on the first chunk write to each block. This flag allows you to force all chunks to be checked. This is slower, but is worth using when doing early debugging.</p>\n\n<p>CONFIG_YAFFS_CASE_INSENSITIVE</p>\n\n<p>When selected case insensitive name comparisons are used. Note that this will not magically change Yaffs to be case insensitive in a case sensitive OS. This needs to be set according to the OS policy. Typically this is only used in Windows CE.</p>\n\n<p>CONFIG_YAFFS_DIRECT</p>\n\n<p>Used when compiling Yaffs Direct.</p>\n\n<p>CONFIG_YAFFS_DISABLE_LAZY_LOAD</p>\n\n<p>Lazy loading is used to defer loading up object details until the objects are accessed. This makes mount time faster. This flag can disable lazy loading. Debug only.</p>\n\n<p>CONFIG_YAFFS_ECC_WRONG_ORDER</p>\n\n<p>This flag should only be used with old Linux MTD code which had a bug in the ECC byte ordering.</p>\n\n<p>CONFIG_YAFFS_NO_YAFFS1</p>\n\n<p>Used to say that only Yaffs2 operation should be compiled in. Not currently supported.</p>\n\n<p>CONFIG_YAFFS_SHORT_NAMES_IN_RAM</p>\n\n<p>Set to configure Yaffs to store short object names in RAM. This is faster, but uses up more memory.</p>\n\n<p>CONFIG_YAFFS_UNICODE</p>\n\n<p>Set to configure Yaffs to use Unicode file names (eg. With WinCE).</p>\n\n<p>CONFIG_YAFFS_USE_OWN_SORT</p>\n\n<p>By default, Yaffs uses qsort for sorting blocks at mount scanning time. This is faster. Using this flag forces Yaffs to use a slow internal sort instead. Debug only.</p>\n\n<p>CONFIG_YAFFS_UTIL</p>\n\n<p>Used when compiling Yaffs for utilities.</p>\n\n<p>CONFIG_YAFFS_WINCE</p>\n\n<p>Set when compiling Yaffs for WinCE.</p>\n\n<p>CONFIG_YAFFS_YAFFS2</p>\n\n<p>Set when using Yaffs2 mode. At present this must always be set.</p>\n\n<p>CONFIG_YAFFSFS_PROVIDE_VALUES</p>\n\n<p>Used when compiling Yaffs Direct only.</p>\n\n<h3>2 Tracing mechanism</h3>\n\n<p>Yaffs has a lot of built in tracing to help debug and integrate. The tracing is controlled by yaffs_traceMask bitmask which allows various sets of tracing to be disabled or enabled at runtime.</p>\n\n<p>The trace bits are specified in the yaffs_trace.h file.</p>\n\n<p>The tracing mechanism has also been \'hijacked\' to provide a control mask for extra verification code when the YAFFS_TRACE_VERIFYxxx trace bits are selected.</p>\n\n<p>The tracing mechanism is readily integrated into the system via printf-like statements. Tracing is all done through macros which allow the strings to be converted into unicode or similar if need be.</p>\n\n<h2>3 Linux</h2>\n\n<h3>3.1 Linux compile-time flags</h3>\n\n<p>The Linux compile time flags are documented in the Kconfig file and will not be duplicated here.</p>\n\n<h3>3.2 Linux: /proc/yaffs trace adjustment</h3>\n\n<p>Under Linux, the tracing mechanism is hooked up to both the /proc/yaffs and the sys interface. The /proc/yaffs interface is very user friendly.</p>\n\n<p><code>#cat +os &gt; /proc/yaffs # Enables YAFFS_TRACE_OS<br />\n#cat -all+gc &gt; /proc/yaffs # Disables everything then enable YAFFS_TRACE_GC<br />\n#cat 0xf000 &gt; /proc/yaffs # Set trace mask to specified bitmask.</code></p>\n\n<h3>3.3 Linux: /sys/ interface</h3>\n\n<p>The Linux /sys/ interface is used by many Linux OS components to access the state of control variables. Some Yaffs variables are available via /sys/module/yaffs2/parameters/ *. Values can be read and modified using standard shell commands or from application programs.</p>\n\n<p><code># ls /sys/module/yaffs2/parameters/ yaffs_auto_checkpoint yaffs_traceMask yaffs_wr_attempts<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 1<br />\n# echo \"2\" &gt; /sys/module/yaffs2/parameters/yaffs_auto_checkpoint<br />\n# cat /sys/module/yaffs2/parameters/yaffs_auto_checkpoint 2 </code></p>\n\n<p>Yaffs currently supports the following variables:</p>\n\n<p>yaffs_auto_checkpoint: Controls when checkpoints should be written.</p>\n\n<p>yaffs_traceMask: An alternative, and less user friendly,interface to modify tracing.</p>\n\n<p>yaffs_wr_attempts: The number of attempts that Yaffs will make to write a chunk.</p>\n\n<p>yaffs_gc_control: Controls the garbage collector.</p>\n\n<h3>3.4 Linux: /proc/yaffs state dumping</h3>\n\n<p>Some of the state of Yaffs mounts can be determined by reading the /proc/yaffs entry.</p>\n\n<p><code># cat /proc/yaffs<br />\ncharles@charles-laptop:/opt/y/cvs/yaffs2$ cat /proc/yaffs<br />\nYAFFS built:Mar 16 2010 11:52:25<br />\n$Id: yaffs_fs.c,v 1.101 2010-03-15 22:27:15 charles Exp $<br />\n$Id: yaffs_guts.c,v 1.119 2010-03-12 02:48:34 charles Exp $<br /><br />\nDevice 0 \"NAND simulator partition 0\" </code><br /><code>startBlock......... 0<br />\nendBlock........... 511<br />\ntotalBytesPerChunk. 2048<br />\nuseNANDECC......... 1<br />\nnoTagsECC.......... 0<br />\nisYaffs2........... 1<br />\ninbandTags......... 0<br />\nemptyLostAndFound.. 1<br />\ndisableLazyLoad.... 0<br />\nrefreshPeriod...... 10000<br />\nnShortOpCaches..... 10<br />\nnReservedBlocks.... 5<br /><br />\nnDataBytesPerChunk. 2048<br />\nchunkGroupBits..... 0<br />\nchunkGroupSize..... 1<br />\nnErasedBlocks...... 152<br />\nblocksInCheckpoint. 0<br /><br />\nnTnodesCreated..... 2300<br />\nnFreeTnodes........ 1852<br />\nnObjectsCreated.... 2300<br />\nnFreeObjects....... 1842<br />\nnFreeChunks........ 27843<br /><br />\nnPageWrites........ 65993<br />\nnPageReads......... 19631<br />\nnBlockErasures..... 1133<br />\nnGCCopies.......... 37<br />\ngarbageCollections. 161<br />\npassiveGCs......... 137<br />\nnRetriedWrites..... 0<br />\nnRetireBlocks...... 0<br />\neccFixed........... 0<br />\neccUnfixed......... 0<br />\ntagsEccFixed....... 0<br />\ntagsEccUnfixed..... 0<br />\ncacheHits.......... 44110<br />\nnDeletedFiles...... 0<br />\nnUnlinkedFiles..... 42917<br />\nrefreshCount....... 1<br />\nnBackgroudDeletions 0</code></p>\n\n<p> </p>\n\n<h2>4 Conclusions</h2>\n\n<p>Yaffs includes many options for changing speed or memory use, with specific flags for the Yaffs Direct Interface as well as Linux. Under Linux many of the control variables can be altered using standard Linux systems.</p></div>\n      \";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:7:\"file:85\";i:2;s:8:\"node:451\";i:3;s:9:\"node_view\";}s:7:\"max-age\";i:-1;}}',-1,1505139221.206,1,'config:filter.format.basic_html file:85 node:451 node_view rendered','268'),('entity_view:node:451:search_result:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"451\";i:3;s:13:\"search_result\";}s:8:\"contexts\";a:4:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:17:\"url.path.is_front\";i:3;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:7:\"file:85\";i:2;s:8:\"node:451\";i:3;s:9:\"node_view\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1505139221.197,1,'config:filter.format.basic_html file:85 node:451 node_view rendered','268'),('entity_view:node:451:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1408:\"<article role=\"article\" about=\"/documents/yaffs-tuning\" class=\"paper is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/documents/yaffs-tuning\" rel=\"bookmark\"><span>Yaffs Tuning</span>\n</a>\n    </h2>\n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/admin\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Admin</span></span>\n on <span>22 July, 2012 - 8:23pm</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/documents/yaffs-tuning\" rel=\"tag\" title=\"Yaffs Tuning\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Yaffs Tuning</span></a></li></ul>\n            <div class=\"field field--name-field-teaser-image field--type-image field--label-hidden field--item\">  <a href=\"/documents/yaffs-tuning\"><img src=\"/sites/default/files/styles/pdf_image/public/styles/pdf_image/public/downloads/YaffsTuning.pdf.png?itok=idZTTQBs\" alt=\"Preview of YaffsTuning.pdf\" typeof=\"foaf:Image\" class=\"img-responsive\" />\n\n</a>\n</div>\n      \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p>This document describes the parameters which can be modified by the developer in the different phases of applying, debugging, and routine use of Yaffs.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:6:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:28:\"config:image.style.pdf_image\";i:2;s:8:\"file:109\";i:3;s:8:\"node:451\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1504640549.400,1,'config:filter.format.basic_html config:image.style.pdf_image file:109 node:451 node_view rendered user:1','287'),('entity_view:node:451:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"451\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:6:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:28:\"config:image.style.pdf_image\";i:2;s:8:\"file:109\";i:3;s:8:\"node:451\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504640549.397,1,'config:filter.format.basic_html config:image.style.pdf_image file:109 node:451 node_view rendered user:1','287'),('entity_view:node:452:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0ASaLO0Qk1GsZAloy9dP3YUsVlmrTM57615NedbegMd4','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:546:\"<article role=\"article\" about=\"/videos/yaffs-introduction-and-overview-video\" class=\"help-video is-promoted full clearfix\">\n\n  \n    \n\n  \n  <div class=\"content\">\n    \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p><a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">This video</a> from 2007 describes Yaffs1 and Yaffs2. The <a href=\"/yaffs-talk-pdf-slides-celf-2007\">slides</a> from the video are available.</p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:45:\"/videos/yaffs-introduction-and-overview-video\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/452\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:45:\"/videos/yaffs-introduction-and-overview-video\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:452\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:51:\"<span>Yaffs introduction and overview video</span>\n\";}}',-1,1504948845.107,1,'config:filter.format.basic_html config:system.site node:452 node_view rendered user:1','276'),('entity_view:node:452:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"452\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:5:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:18:\"config:system.site\";i:2;s:8:\"node:452\";i:3;s:9:\"node_view\";i:4;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504948845.104,1,'config:filter.format.basic_html config:system.site node:452 node_view rendered user:1','276'),('entity_view:node:452:teaser:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:3:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:1083:\"<article role=\"article\" about=\"/videos/yaffs-introduction-and-overview-video\" class=\"help-video is-promoted teaser clearfix\">\n\n  \n      <h2>\n      <a href=\"/videos/yaffs-introduction-and-overview-video\" rel=\"bookmark\"><span>Yaffs introduction and overview video</span>\n</a>\n    </h2>\n    \n\n  \n  <div class=\"content\">\n    <ul class=\"links inline list-inline\"><li class=\"node-readmore\"><a href=\"/videos/yaffs-introduction-and-overview-video\" rel=\"tag\" title=\"Yaffs introduction and overview video\" hreflang=\"und\">Read more<span class=\"visually-hidden\"> about Yaffs introduction and overview video</span></a></li></ul>\n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\"><p><a href=\"http://free-electrons.com/pub/video/2007/elce/elce-2007-wookey-yaffs.ogg\">This video</a> from 2007 describes Yaffs1 and Yaffs2. The <a href=\"/yaffs-talk-pdf-slides-celf-2007\">slides</a> from the video are available.</p><p><img alt=\"\" src=\"/sites/yaffs.net/files/file_attach/small_yaffs-introduction.png\" /></p></div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:0:{}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:452\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}}',-1,1504986924.787,1,'config:filter.format.basic_html node:452 node_view rendered user:1','270'),('entity_view:node:452:teaser:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"452\";i:3;s:6:\"teaser\";}s:8:\"contexts\";a:5:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";}s:4:\"tags\";a:4:{i:0;s:31:\"config:filter.format.basic_html\";i:1;s:8:\"node:452\";i:2;s:9:\"node_view\";i:3;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504986924.786,1,'config:filter.format.basic_html node:452 node_view rendered user:1','270'),('entity_view:node:453:full:[languages:language_interface]=en:[theme]=yaffs:[timezone]=Europe/London:[url.path.is_front]=is_front.0:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b0EiVGW4eU72t0bxL9yfjZpzkcQ0OyVErrpH2vop1Etm0','a:5:{s:7:\"#markup\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:145971:\"<article role=\"article\" about=\"/documents/yaffs-direct-interface\" class=\"paper is-promoted full clearfix\">\n\n  \n    \n\n      <footer>\n      \n      <div class=\"author\">\n        Submitted by <span><span lang=\"\" about=\"/user/admin\" typeof=\"schema:Person\" property=\"schema:name\" datatype=\"\">Admin</span></span>\n on <span>23 July, 2012 - 12:37am</span>\n        \n      </div>\n    </footer>\n  \n  <div class=\"content\">\n    \n      <div class=\"field field--name-upload field--type-file field--label-hidden field--items\">\n              <div class=\"field--item\"><span class=\"file file--mime-application-pdf file--application-pdf icon-before\"><span class=\"file-icon\"><span class=\"icon glyphicon glyphicon-file text-primary\" aria-hidden=\"true\"></span></span><span class=\"file-link\"><a href=\"https://yaffs.net/sites/default/files/downloads/YaffsDirect.pdf\" type=\"application/pdf; length=256079\" title=\"Open file in new window\" target=\"_blank\" data-toggle=\"tooltip\" data-placement=\"bottom\">YaffsDirect.pdf</a></span><span class=\"file-size\">250.08 KB</span></span></div>\n          </div>\n  \n            <div class=\"field field--name-body field--type-text-with-summary field--label-hidden field--item\">\n<p>This document describes the Yaffs Direct Interface (YDI), which allows Yaffs to be simply integrated with embedded systems, with or without an RTOS.</p>\n<p style=\"page-break-before: always\"><br />\n<br />\n</p>\n<h1 class=\"western\" style=\"page-break-before: always\">1 Background</h1>\n<p>The purpose of this document is to describe the interfacing of the Yaffs Direct Interface (YDI) as well as to provide sufficient information to allow a preliminary evaluation of Yaffs. This document tries to focus on the issues important to the system integrator without getting too detailed about how Yaffs works. Other documents provide an in-depth discussion of how Yaffs works.</p>\n<h1 class=\"western\">2 Licensing</h1>\n<p>Yaffs was originally released for Linux under the GNU Public License (GPL). Various embedded developers soon identified that Yaffs would be ideal for their applications, but were not able to use GPL based code in their systems. Aleph One <span style=\"font-style: normal\"><span style=\"font-weight: normal\">has</span></span> alternative licensing arrangements to support such applications.</p>\n<h1 class=\"western\">3 What are Yaffs and Yaffs Direct Interface?</h1>\n<p>Yaffs stands for <i>Yet Another Flash File System</i>. Yaffs was the first file system designed, from the ground up, for NAND storage.</p>\n<p>In 2002 Aleph One set out to identify file system options for using NAND Flash as a file system. Various file systems available at the time were evaluated and all were found lacking in one way or another. The need for a suitable NAND storage file system was identified and Yaffs was designed to fill that need.</p>\n<p>Although Yaffs was originally designed for NAND flash, it has been used successfully with NOR flash systems and even as a RAM file system. This allows high reliability file systems to be constructed using NOR flash, with a future migration path <span style=\"font-weight: normal\">to NAND</span> flash for higher density and performance.</p>\n<p>Yaffs was originally designed for use with the Linux operating system, but was designed in a very modular way. The operating-system-specific code was kept separate from the main Yaffs file system code. This allows Yaffs to be ported quite cleanly to other operating systems through operating system personality modules. One such personality module is the Yaffs Direct Interface (YDI) which allows Yaffs to be simply integrated with embedded systems, with or without an RTOS. </p>\n<p>Yaffs has been used for many products using various operating systems including Windows CE and various RTOSs, including <span style=\"font-weight: normal\">ThreadX, vXworks, pSOS to name just a few.</span></p>\n<p>Note that there is a native port of Yaffs to eCOS that does not use YDI. This is supported and distributed by eCocCentric.(http://www.ecoscentric.com/).</p>\n<p>Yaffs2, a more recent release of Yaffs, supports a wider range of NAND flash components including 2k page devices and devices with multi-level cells (MLC), and produces equivalent or better performance. It include Yaffs1 compatibility code so Yaffs1 images still work and migration is quite simple. Yaffs1 or Yaffs2 mode of operation are simply selected by a run-time parameter.</p>\n<p>As well as providing a NAND file system, YDI also provides a RAM emulation layer to allow Yaffs to operate as a RAM file system too. While the RAM emulation is perhaps not as efficient as a dedicated RAM file system, this does allow one well proven file system to use both RAM and flash.</p>\n<h1 class=\"western\">4 Why use Yaffs?</h1>\n<p>Yaffs is the first, and perhaps only, file system designed specifically for NAND flash. This means that Yaffs has been designed to work around the various limitations and quirks of NAND flash, as well as exploit the various features of NAND to achieve an effective file system.</p>\n<p>Some features to consider:</p>\n<ul>\n<li>\n<p>Yaffs has been well proven and has been used to ship in <span style=\"font-weight: normal\">large volumes in several products using many different operating systems, compilers and processors.</span></p>\n </li>\n<li>\n<p>Yaffs is written in portable C and is endian neutral.</p>\n </li>\n<li>\n<p>Yaffs provides <span style=\"font-weight: normal\">bad</span> <b></b><span style=\"font-weight: normal\">block</span> handling and ECC algorithms to handle deficiencies in NAND flash.</p>\n </li>\n<li>\n<p>Yaffs is a log-structured file system which makes it very robust to corruptions caused by power failures etc.</p>\n </li>\n<li>\n<p>Yaffs has highly optimised and predictable garbage collection strategies. This makes it high performance and very deterministic when compared with similar file systems.</p>\n </li>\n<li>\n<p>Yaffs has a lower memory footprint than most other log-structured flash file systems.</p>\n </li>\n<li>\n<p>Yaffs provides a wide range of POSIX-style file system support including directories, symbolic and hard links etc. through standard file system interface calls.</p>\n </li>\n<li>\n<p><span style=\"font-weight: normal\">Yaffs is h</span>ighly configurable to work with various flash geometries, various ECC options, caching options etc.</p>\n </li>\n<li>\n<p>Yaffs Direct Interface is simple to integrate in a system – only a few interface functions are required.</p>\n </li>\n<li>\n<p>Yaffs can be used with a wide range of memory technologies.</p>\n </li>\n</ul>\n<h1 class=\"western\">5 Source Code and Yaffs Resources </h1>\n<p><span style=\"font-family: Liberation Serif, serif;\">Please note the licensing terms that apply to using the Yaffs code.</span></p>\n<p><a href=\"http://www.yaffs.net/\"><span style=\"font-family: Liberation Serif, serif;\">http://www.yaffs.net</span></a><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-style: normal\"><span style=\"font-weight: normal\">serves as the hub for all Yaffs information.</span></span></span></p>\n<p><span style=\"font-family: Liberation Serif, serif;\">This document refers to the Yaffs source code extensively.<span style=\"font-style: normal\"><span style=\"font-weight: normal\">and is available via the download link on this site.</span></span></span></p>\n<p><span style=\"font-family: Liberation Serif, serif;\">There are various other documents and a Yaffs mailing list for Yaffs discussions.</span></p>\n<p><span style=\"font-family: Liberation Serif, serif;\">Consulting services are also available.</span></p>\n<h1 class=\"western\">6 System Requirements</h1>\n<p>Determining minimum system requirements is often quite difficult. The following are presented as a guideline only. Contact Aleph One for more detailed analysis if required.</p>\n<ul>\n<li>\n<p>Yaffs is endian-neutral and works fine with little-endian and big-endian processors.</p>\n </li>\n<li>\n<p>Yaffs code has been used successfully with many different 32-bit and 64-bit CPUs including MIPS, 68000, ARM, ColdFire, PowerPC and x86 variants. Yaffs has even been used with various DSP architectures. Yaffs should work with 16-bit CPUs too, but this is generally untested and might need some tuning, depending on compiler options.</p>\n </li>\n<li>\n<p>Because Yaffs is log structured, RAM is required to build up runtime data structures for acceptable performance. As a rule of thumb, budget approximately 2 bytes per <i>chunk</i> of NAND flash, where a <i>chunk</i> is typically one page of NAND. For NAND with 512byte pages, budget approximately 4kbytes of RAM per 1Mbyte of NAND. For 2kbyte page devices budget approximately 1kbyte per 1Mbyte of NAND.</p>\n </li>\n</ul>\n<h1 class=\"western\">7 How to integrate Yaffs with an RTOS/Embedded system</h1>\n<p>Yaffs Direct Interface (YDI) wraps Yaffs in a way that is simple to integrate. You need to provide a few functions for Yaffs to use to talk to your hardware and RTOS. Yaffs provides a set of POSIX-compliant functions for applications to use to talk to it.</p>\n<p>In addition to the Yaffs core file system, the YDI has three parts which are each explained in more detail in further sections:</p>\n<ul>\n<li>\n<p><b>POSIX Application Interface</b>: This is the POSIX-like interface that the application code uses to access the Yaffs file system. (<span style=\"font-family: Times New Roman;\"><i>open, close, read, write, </i></span>etc) </p>\n </li>\n<li>\n<p><b>RTOS Integration Interface</b>: These are the functions that must be provided for Yaffs to access the RTOS system resources. (<span style=\"font-family: Times New Roman;\"><i>initialise, lock, unlock, get time, </i></span><span style=\"font-family: Times New Roman;\"><i>memory allocation,</i></span><span style=\"font-family: Times New Roman;\"><i>set error, </i></span><span style=\"font-family: Times New Roman;\"><i>etc</i></span>). Note that although we use the term RTOS, the same can be done with other OSs or even with no RTOS at all in a bare-metal system.</p>\n </li>\n<li>\n<p><img src=\"data:image/png;base64,[encoded data, 27864 characters]\" width=\"485\" height=\"530\" alt=\"image\" id=\"Object1\" /> <b>Flash Device </b><b>Interface</b>: This interface support is where the flash device and appropriate device drivers are installed to provide an access path from Yaffs to the flash device(s). Multiple different devices and device types can be supported simultaneously.</p>\n </li>\n</ul>\n<h2 class=\"western\">7.1 Source Files</h2>\n<p>The following source files contain the core file system:</p>\n<table cellpadding=\"4\" style=\"width: 100%; border-spacing: 0px;\">\n<col width=\"71*\" /> <col width=\"185*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_allocator.c</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 72%;\">\n <p>Allocates Yaffs object and tnode structures.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p><br />\n  </p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_bitmap.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Block and chunk bitmap handling code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_checkpointrw.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Streamer for writing checkpoint data</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_ecc.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>1-bit Hamming ECC code</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p><br />\n  </p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_guts.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>The major Yaffs algorithms.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_nameval.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Name/value code for handling extended attributes (xattr).</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_nand.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Flash interfacing abstraction.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_packedtags1.c<br />\n  yaffs_packedtags2.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Tags packing code</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_summary.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Code for handling block summaries.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_tagscompat.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Tags compatibility code to support Yaffs1 mode.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_tagsmarshall.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Tags marshalling code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_verify.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Test verification code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_yaffs1.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Yaffs1-mode specific code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_yaffs2.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Yaffs2-mode specific code.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>The Yaffs direct interface is in yaffsfs.c, with the interface functions and structures defined in yaffsfd.h.</p>\n<p><br />\n<br />\n</p>\n<table cellpadding=\"4\" style=\"page-break-inside: avoid; width: 100%; border-spacing: 0px;\">\n<col width=\"72*\" /> <col width=\"184*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_attribs.c</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 72%;\">\n <p>Attribute handling.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_error.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Error reporting code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffsfs.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Yaffs Direct Interface wrapper code.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_hweight.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Counts the number of hot bits in a byte, word etc.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_qsort.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Qsort used during Yaffs2 scanning</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>Example flash drivers, simulators and configurations used for testing are are in direct/test-framework directory. These include:</p>\n<table cellpadding=\"4\" style=\"page-break-inside: avoid; width: 100%; border-spacing: 0px;\">\n<col width=\"72*\" /> <col width=\"184*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>nanddrv.c</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 72%;\">\n <p>A NAND driver layer that performs the commands to access NAND flash in a rudimentary manner. This code should work on many styles of CPU with little modification.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_nanddrv.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A wrapper around the NAND driver which plugs it into Yaffs.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>nandsim.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A NAND simulator layer that works with a nandstore_xxx backing store. This simulates a NAND chip.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>nandstore_file.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A storage backend for a NAND simulator that stores the data to file.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>nandsim_file.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A wrapper around nandsim.c and nandstore_file.c which makes a NAND simulator that saves its data in a file.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_nandsim_file.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A wrapper which creates a nand simulator instance, hooks up the yaffs NAND driver and then adds it to yaffs for use.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_nor_drv.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <ol>\n </ol>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_m18_drv.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A driver for Intel M18-style NOR flash.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_osglue.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>An OS glue layer example used in the test harness.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>Example and testing build files:</p>\n<table cellpadding=\"4\" style=\"width: 100%; border-spacing: 0px;\">\n<col width=\"71*\" /> <col width=\"185*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>dtest.c</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 72%;\">\n <p>A test harness. Also has sample code that can be used for better understanding of how some function calls work.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffscfg2k.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>A test configuration.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 28%;\">\n <p>yaffs_fileem.c<br />\n  yaffs_fileem2k.c</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 72%;\">\n <p>Nand flash simulation using a file as backing store.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>Further testing files are in direct/tests and direct/python.</p>\n<h2 class=\"western\" style=\"page-break-before: always\">7.2 Integrating the POSIX Application Interface</h2>\n<p>The application interface is defined in yaffsfs.h. These provide a POSIX file system interface. For the most part, this interface consists of the standard clib function names prefixed with <code class=\"western\">yaffs_</code>. For example, <code class=\"western\">yaffs_open(), yaffs_close()</code> etc.</p>\n<p><br />\n<br />\n</p>\n<p>There is a lot of flexibility in how these functions are used and the system integrator needs to determine the best strategy for the system.</p>\n<p>These functions can be used directly, with the code written using these names. For example</p>\n<p class=\"code-western\"><code class=\"western\">int main(...)<br />\n{<br />\n// initialisation<br />\nf = yaffs_open(...);<br />\nyaffs_read(f,...);<br />\nyaffs_close(f);<br />\n}</code></p>\n<p>The <span style=\"font-family: Times New Roman;\">yaffs</span> functions can also be wrapped in some way to allow existing code to use yaffs without modification. For example:</p>\n<p style=\"margin-bottom: 0cm; orphans: 0; widows: 0; page-break-before: auto; page-break-after: avoid\"><br />\n</p>\n<p class=\"code-western\"><code class=\"western\">#define open(path, oflag, mode) yaffs_open(path, oflag, mode)<br />\n..<br />\n<br />\nint main(...)<br />\n{<br />\n// initialisation<br />\nf = open(...);<br />\nread(f,...);<br />\nclose(f);<br />\n}</code><br />\n<br />\n<br />\n</p>\n<p style=\"margin-bottom: 0cm; orphans: 0; widows: 0; page-break-before: auto\"><br />\n</p>\n<p>A more complex approach that can be used if more than one file-system is used is to provide redirection functions. For example:</p>\n<p style=\"margin-bottom: 0cm; orphans: 0; widows: 0; page-break-before: auto; page-break-after: avoid\"><br />\n</p>\n<p class=\"code-western\"><code class=\"western\">int open(const char *path,...)<br />\n{<br />\n// Determine which file system is being used<br />\n</code><code class=\"western\">i</code><code class=\"western\">f(it_is_a_yaffs_path(path))<br />\nreturn yaffs_open(...);<br />\nelse {<br />\n// Do something else<br />\n}<br />\n}</code></p>\n<p style=\"margin-left: 1.25cm; margin-bottom: 0cm; page-break-inside: avoid; orphans: 0; widows: 0; page-break-before: auto; page-break-after: auto\"><br />\n</p>\n<p><br />\n<br />\n</p>\n<p>Some RTOS\'s provide a flexible way to integrate file systems in which case YDI can typically use these interfaces to access yaffs file systems.</p>\n<h1 class=\"western\" style=\"page-break-before: always\">8 RTOS Integration Interface</h1>\n<p>Before Yaffs can be used, it needs to be integrated with the system and configured so that the correct actions are performed.</p>\n<p>To do this, you need to modify the configuration file. An example configuration file is presented in <span style=\"font-family: Bitstream Vera Sans;\"><span style=\"font-family: Times New Roman;\">yaffscfg.c and yaffscfg2k.c.</span></span></p>\n<p>This is a relatively straight forward process and defines the RTOS access functions.</p>\n<p>The RTOS access functions are:</p>\n<ul>\n<li>\n<p><code class=\"western\">void yaffsfs_SetError(int err)</code>: Called by Yaffs to set the system error.</p>\n </li>\n<li>\n<p><code class=\"western\">void yaffsfs_Lock(void)</code>: Called by Yaffs to lock Yaffs from multi-threaded access.</p>\n </li>\n<li>\n<p><code class=\"western\">void yaffsfs_Unlock(void)</code>: Called by Yaffs to unlock Yaffs.</p>\n </li>\n<li>\n<p><code class=\"western\">u32 yaffsfs_CurrentTime(void)</code>: Get current time from RTOS.</p>\n </li>\n<li>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>void *yaffsfs_malloc(size_t size)</b></span></span>: Called to allocate memory.</p>\n </li>\n<li>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>void yaffsfs_free(void *ptr)</b></span></span>: Called to free memory.</p>\n </li>\n<li>\n<p><code class=\"western\">void yaffsfs_</code><code class=\"western\">OS</code><code class=\"western\">Initialisation(void)</code>: Called to initialise RTOS context.</p>\n </li>\n<li>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>void yaffs_bug_fn(const char *file_name, int line_no)</b></span></span>: Function to report a bug.</p>\n </li>\n<li>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>int yaffsfs_CheckMemRegion(const void *addr, size_t size, int writ</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>e_request</b></span></span>) : Function to check if accesses to a memory region is valid. This function must return zero if the test passes and negative if it fails.</p>\n </li>\n</ul>\n<p><br />\n<br />\n</p>\n<p>If Yaffs is being used in a multi-threaded environment, then typically <code class=\"western\">yaffs_LocalInitialisation()</code> will initialise a suitable RTOS semaphore and <code class=\"western\">yaffs_Lock()</code> and <code class=\"western\">yaffs_Unlock()</code> will call the appropriate functions to lock and release the semaphore.</p>\n<p><code class=\"western\">yaffs_CurrentTime()</code> 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 is hard-wired to return zero.</p>\n<p>Before the application code uses Yaffs, the <code class=\"western\">yaffs</code><code class=\"western\">fs</code><code class=\"western\">_</code><code class=\"western\">OSInitialisation</code><code class=\"western\">()</code> function must be called.</p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>yaffsfs_CheckMemRegion()</b></span></span><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 12pt; font-size: medium; font-size: medium;\"><span style=\"font-weight: normal\">is used to check addresses passed to the various yaffs_xxx functions (yaffs_open(), yaffs_read() etc)). If the function returns -1, then the yaffs_xxx function will return -EFAULT rather than attempt to dereference the address and crash.</span></span></span></p>\n<p style=\"font-weight: normal\"><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 12pt; font-size: medium; font-size: medium;\">An implementation might do something like:</span></span></p>\n<p style=\"font-weight: normal\"><br />\n<br />\n</p>\n<p class=\"code-western\"><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>int yaffsfs_CheckMemRegion(const void addr, size_t size, <br />\nint write_</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>request</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>) <br />\n{<br />\nu32 uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>= (u32) addr;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>u32 uaddrt = uaddrb + size -1;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b><br />\nif( uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&gt;= stack_bottom &amp;&amp; uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&lt;= stack_top &amp;&amp;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>uaddrt &gt;= stack_bottom &amp;&amp; uaddrt &lt;= stack_top)<br />\nreturn 0; /* </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>r/w </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>access is OK */<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b><br />\nif( uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&gt;= </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>heap</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>_bottom &amp;&amp; uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&lt;= </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>heap</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>_top &amp;&amp;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>uaddrt &gt;= heap_bottom &amp;&amp; uaddrt &lt;= heap_top)<br />\nreturn 0; /* </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>r/w</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>access is OK /<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b><br />\nif( !</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>write_request &amp;&amp;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&gt;= </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>rom</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>_bottom &amp;&amp; uaddr</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>b</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>&lt;= </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>rom</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>_top &amp;&amp;<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>uaddrt &gt;= rom_bottom &amp;&amp; uaddrt &lt;= rom_top)<br />\nreturn 0; / </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>read </b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>access is OK /</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b><br />\n<br />\n</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>return -1; /* Bad access */</b></span></span><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b><br />\n<br />\n}</b></span></span></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<h1 class=\"western\" style=\"page-break-before: always\">9 Yaffs NAND Model</h1>\n<p>Before defining the flash integration interface, it is important to understand the model and corresponding nomenclature used throughout Yaffs and its documentation.</p>\n<p>Yaffs uses a fairly abstract model for NAND flash. This allows a lot of flexibility in the way it can be used.</p>\n<p>Yaffs is designed for NAND flash and makes the following assumptions and definitions:</p>\n<ul>\n<li>\n<p>The flash is arranged in <i><b>blocks</b></i>. Each block is the same size and comprises an integer number of <span style=\"font-style: normal\"><span style=\"font-weight: normal\">chunks</span></span>. Each block is treated as a single erasable item. A block contains a number of chunks.</p>\n </li>\n<li>\n<p>A <i><b>chunk</b></i> equates to the allocation units of flash. For Yaffs1, each chunk equates to a 512-byte or larger NAND page (that is, a 512-byte or larger data portion and a 16-byte spare area). For Yaffs2, a chunk will typically be larger (eg. on 2k page devices, a chunk will typically be a single 2k page: 2kbytes of data and 64 bytes of spare). Yaffs2 is capable of working with smaller chunk sizes by using inband tags.</p>\n </li>\n<li>\n<p>All accesses (reads and writes) are page chunk aligned. Some reads might only read the spare area where the tags are kept.</p>\n </li>\n<li>\n<p>When programming a NAND flash, only the zero bits in the pattern being programmed are relevant, and one bits are &quot;don\'t care&quot;. For example, if a byte already contains the binary pattern b1010, then programming b1001 will result in the pattern which is the logical AND of these two patterns ie. b1000. This is different to NOR flash which would typically abort the attempt to convert a 0 into a 1.</p>\n </li>\n</ul>\n<p><br />\n<br />\n</p>\n<p>Yaffs ide<span style=\"font-weight: normal\">ntifies</span> blocks by their block number and chunks by the chunk Id. A chunk Id is calculated as:</p>\n<p><code class=\"western\">chunkId = block_id * chunks_per_block + chunk_offset_in_block</code></p>\n<p>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>\n<p>Yaffs2 has a generalised tags interface to provide better flexibility to cater for a wider range of devices with larger pages and stricter programming limitations. Yaffs2 thus handles more abstract constructs than Yaffs1 and, in older versions of Yaffs, more effort was required to interface to the NAND.</p>\n<p>In newer versions of Yaffs, the tags management has been abstracted out of the driver. This makes the driver interface far simpler.</p>\n<h2 class=\"western\">9.1 Formatting</h2>\n<p>Yaffs treats erased blocks as empty. That makes it really easy to “format” a device: just erase it.. Note that this should be done while the partition is not mounted.</p>\n<p>Unmounting will not normally work when the file system is busy (eg. files are open), Some extra non-standard unmount options are provided to enable an unmount to be forced. Note that using these will break any current handles and you will no longer be able to use open files.</p>\n<p><code class=\"western\"><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 12pt; font-size: medium; font-size: medium;\"><span style=\"font-weight: normal\">There is a </span></span></span></code><code class=\"western\"><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>yaffs_format() </b></span></span></code><code class=\"western\"><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 12pt; font-size: medium; font-size: medium;\"><span style=\"font-weight: normal\">function that will take care of the details.</span></span></span></code></p>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">9.2 NAND Model considerations for Yaffs1</h2>\n<p>The historical Yaffs1 tags structure was laid out in accordance with the SmartMedia specification for use with 512-byte pages. There is now much more flexibility in the way things can be configured.</p>\n<p><br />\n<br />\n</p>\n<p>Yaffs1 is capable of being used with a variety of memory layouts so long as the flash supports the ability to overwrite the tags area to set the deletion marker to zero.</p>\n<p>If the yaffs_dev\'s use_nand_ecc field is not set, then yaffs will perform the ECC calculations. If this is set then yaffs will expect the NAND driver to do any required ECC checks. On devices that are not using ECC, for example NOR, set use_nand_ecc=1 and then don\'t do any ECC anyway.</p>\n<p>The Yaffs1 flash model expects an area of 16 spare bytes, some of which are used for tags. The mapping between the spare bytes and the usage of the bytes is specified in yaffs_packedtags1.c</p>\n<p>The Yaffs1 model has been used in many NOR-based systems. One particularly instructive example is in yaffs_nor_drv.c which implements a driver for Yaffs1 mode on CFI-style NOR flash. This does not use ECC but uses checksumming instead.</p>\n<p>The yaffs_dev structure has a yaffs_driver structure which holds the function pointers to the driver. For Yaffs1 mode of operations the following are required:</p>\n<table cellpadding=\"4\" style=\"page-break-inside: avoid; width: 100%; border-spacing: 0px;\">\n<col width=\"77*\" /> <col width=\"179*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_write_chunk_fn</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 70%;\">\n <p>Write a data chunk</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_read_chunk_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Read a data chunk.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_erase_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Erase a block</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_initialise_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Initialisation.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_deinitialise_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>De-initialise</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>These functions are described later.</p>\n<h2 class=\"western\">9.3 NAND Model for Yaffs2</h2>\n<p>The Yaffs2 interface is far more flexible than Yaffs1, but that means a bit more effort must be done in the driver. In particular:</p>\n<ul>\n<li>\n<p>There is is no standard spare area/ECC layout. The driver must handle all the layout of the spare area and ECC handling.</p>\n </li>\n<li>\n<p>There is not a standard implementation for bad block markers. Thus, the driver must provide functions for checking and marking bad blocks.</p>\n </li>\n</ul>\n<p>The yaffs_driver structure for Yaffs2 mode requires the following functions:</p>\n<p style=\"margin-bottom: 0cm; orphans: 0; widows: 0; page-break-before: auto\"><br />\n</p>\n<table cellpadding=\"4\" style=\"page-break-inside: avoid; width: 100%; border-spacing: 0px;\">\n<col width=\"77*\" /> <col width=\"179*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_write_chunk_fn</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 70%;\">\n <p>Write a data chunk</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_read_chunk_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Read a data chunk.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_erase_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Erase a block</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_mark_bad_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Mark a block bad</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_check_bad_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Check bad block status of a block.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_initialise_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>Initialisation.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 30%;\">\n <p>drv_deinitialise_fn</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 70%;\">\n <p>De-initialise</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">9.4 Overview of flash driver function</h2>\n<p>The best way to understand how to write these functions is to look at the example drivers.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int (*drv_write_chunk_fn) (struct yaffs_dev *dev, int nand_chunk, </p>\n<p class=\"code-western\">const u8 *data, int data_len, </p>\n<p class=\"code-western\">const u8 *oob, int oob_len)</p>\n<p>This function writes the specified chunk data and oob/spare data to flash.</p>\n<p>This function should return YAFFS_OK on success or YAFFS_FAIL on failure.</p>\n<p>If this is a Yaffs2 device, or Yaffs1 with use_nand_ecc set, then this function must take care of any ECC that is required.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int (*drv_read_chunk_fn) (struct yaffs_dev *dev, int nand_chunk, </p>\n<p class=\"code-western\">u8 *data, int data_len, </p>\n<p class=\"code-western\">u8 *oob, int oob_len,</p>\n<p class=\"code-western\">enum yaffs_ecc_result *ecc_result)</p>\n<p>This function reads the specified chunk data and oob/spare data from flash.</p>\n<p>This function should return YAFFS_OK on success or YAFFS_FAIL on failure.</p>\n<p>If this is a Yaffs2 device, or Yaffs1 with use_nand_ecc set, then this function must take care of any ECC that is required and set the ecc_result.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int (*drv_erase_fn) (struct yaffs_dev *dev, int block_no) </p>\n<p>This function erases the specified block.</p>\n<p>This function should return YAFFS_OK on success or YAFFS_FAIL on failure.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int (*drv_mark_bad_fn) (struct yaffs_dev *dev, int block_no); </p>\n<p class=\"code-western\">int (*drv_check_bad_fn) (struct yaffs_dev *dev, int block_no); </p>\n<p>These functions are only required for Yaffs2 mode. They mark a block bad or check if it is bad.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int (*drv_initialise_fn) (struct yaffs_dev *dev); </p>\n<p class=\"code-western\">int (*drv_deinitialise_fn) (struct yaffs_dev *dev); </p>\n<p>These functions provide hooks for initialising or deinitialising the flash driver.</p>\n<p><br />\n<br />\n</p>\n<h1 class=\"western\" style=\"page-break-before: always\">10 Configuration and flash driver installation</h1>\n<p>For an example of how to do the configuration, refer to yaffs_cfg2k.c and one of the drivers such as yaffs_nand_drv.c</p>\n<p>The old mechanism was static and required a table of devices that was installed at start up. This mechanism had shortcomings – in particular it broke modularity and did not allow devices to be added dynamically.</p>\n<p>Things are different now. As any time, a yaffs_dev structure can be configured and then registered with Yaffs by using the yaffs_add_device() function.</p>\n<p>A yaffs_dev structure has two parts which must be configured before yaffs_add_device() is called: the paramers (dev-&gt;param) and the driver (dev-&gt;drv). The driver configuration (plugging in the driver functions) has already been described above, so we will now look at the yaffs parameters.</p>\n<p><br />\n<br />\n</p>\n<p>The yaffs_param structure must be set before the yaffs_dev is added with yaffs_add_device() and should not be modified after that.</p>\n<p>The params are defined in the Yaffs Tuning Document.</p>\n<h1 class=\"western\" style=\"page-break-before: always\">11 Using the POSIX file system interface</h1>\n<p>This section is directed to readers that might not be very familiar with accessing a file system via POSIX and POSIX-like interfaces.</p>\n<h2 class=\"western\">11.1 Difference to Windows POSIX-like interfaces</h2>\n<p>MSDOS and Windows provide a POSIX-lke interface. If you are familiar with this then that will help you. There are are however some slight differences, most importantly:</p>\n<ul>\n<li>\n<p>Windows has no concept of links and has a 1:1 mapping between file names and files.POSIX supports files with zero, one or many names. Refer to the sections on linking and unlinking files. For instance POSIX allows you to unlink a file (ie delete the name for a file) while it is still in use. You can continue to read/write the file but it will be deleted as soon as the last file handle to the file is closed. Windows, on the other hand, does not allow you to unlink a file while it is in use.</p>\n </li>\n<li>\n<p>Windows names drives with a letter. POSIX has no drive letters. The whole POSIX file system is in a single directory tree.</p>\n </li>\n<li>\n<p>Directories and “folders” are the same thing.</p>\n </li>\n</ul>\n<h2 class=\"western\">11.2 Fundamental concepts</h2>\n<table cellpadding=\"4\" style=\"width: 642px; border-spacing: 0px;\">\n<col width=\"126\" /> <col width=\"499\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>File</p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 499px;\">\n <p>A file is an object that is stored in the file system. yaffs supports the following file types:</p>\n <p>A regular file is a sequence of bytes stored in the file system.</p>\n <p>A directory holds links to other files.</p>\n <p>A symbolic link holds a name to another file.</p>\n <p>A special file holds device ids or similar information.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>Directory</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>This is a structure that holds links and allows a file to be found by name. Note that a single file may have many links(ie names) and many be found in many places in the directory structure.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>Link</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>This is a name that allows the file to be found. There are two types of link: real links (sometimes called hard links) and symbolic (or soft) links. </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>Handle</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>A file handle provides a context from which a file can be accessed and manipulated. A handle has a current file position pointer which points to where the file is being read or written. Multiple handles can simultaneously access a single file.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>File mode</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>The mode is the set of flags that define the type of file as well as the current permissions associated with the file.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>Path</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>This is a string that defines the directories and file name. For example:</p>\n <p>“/data/direct-1/file1”</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>File metadata</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>This is the information about the file, excluding the file contents. The metadata includes the name, mode, size and other details.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>Mount,<br />\n  partition,<br />\n  file system</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>These terms all refer to a single mounted flash area. Each mount is hooked into a common directory structure.<br />\n  The term file system can sometimes be confusing because it is used both for a single mounted partition as well as the the file system code. In other words, we might say that both “/boot” is a file system and might also say that yaffs is a file system.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 126px;\">\n <p>inode number</p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 499px;\">\n <p>The inode number is a unique number that identifies the object within the mount. Note that inodes are not unique between two or more mounts. There is no way to reach a file by inode, only via its links.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.3 Error code</h2>\n<p>Most functions result in error codes if the function does not execute successfully. In these cases yaffs calls a function called <code class=\"western\">yaffs_SetError()</code> with the error value. This function can be configured to deliver the error into the system\'s error mechanism.</p>\n<p>In the case of functions that return integers, a returned value smaller than 0 indicates an error occurred. Functions returning pointers will return NULL if an error occurred.</p>\n<h2 class=\"western\">11.4 Links – the hard kind (not symbolic links)</h2>\n<p>At first we\'re just considering real links and not symbolic links. Sometimes real links are also called hard links to differentiate them from symbolic links (which are sometimes called soft links).</p>\n<p>The difference between links and files is subtle and can be confusing. Briefly:</p>\n<ul>\n<li>\n<p>a file is the stored object in the file system</p>\n </li>\n<li>\n<p>the link is how it is hooked into the directory structure.</p>\n </li>\n</ul>\n<p><br />\n<br />\n</p>\n<p>The first link to a file is created by using the file creation calls: <code class=\"western\">yaffs_open()</code>, <code class=\"western\">yaffs_mknod()</code>, <code class=\"western\">yaffs_symlink()</code> and <code class=\"western\">yaffs_mkdir()</code>.</p>\n<p>A link can be destroyed by using the <code class=\"western\">yaffs_unlink()</code> function. Directories are destroyed using the <code class=\"western\">yaffs_rmdir()</code> function (oh, and the directory must be empty).</p>\n<p>Once a file is both unused (there are no handles open to it) and there are no links to it it is then deleted.</p>\n<p>A link can be renamed by using the <code class=\"western\">yaffs_rename()</code> function.</p>\n<p>A file may have many links. These may be created using the <code class=\"western\">yaffs_link()</code> function. All the links access the same file and there is no one link that is considered “the real link” and others being “the duplicate link”. All links to a file have the same priority. If you look at the inode number for “a” and for “b” then they will be the same because they are refering to exactly the same file.</p>\n<p>Thus:</p>\n<ol>\n<li>\n<p>If we start with a file called “a” and then call <code class=\"western\">yaffs_link(“a”, “b”)</code> we now have two links to the same file. We can\'t tell them apart.</p>\n </li>\n<li>\n<p>If we now unlink “a”, the file still exists under the link “b”.</p>\n </li>\n<li>\n<p>If we now unlink “b” the file will no longer be linked. If there is a handle open to the file then we can still access the file through the handle and continue to read or modify the file. If there is no link to the file it is deleted.</p>\n </li>\n<li>\n<p>If an unlinked file was kept alive because of a handle being open, the file will not show up in the directory structure (because it has no link) and will be deleted as soon as the handle is closed (or if the file system is unmounted).</p>\n </li>\n</ol>\n<p>There are some limitations in how links are used:</p>\n<ul>\n<li>\n<p>The existing file you are linking to must exist.</p>\n </li>\n<li>\n<p>The file you are linking to must be in the same mount (partition) as the link you are creating.</p>\n </li>\n<li>\n<p>You cannot create a link to a directory because this would allow the creation of recursive loops.</p>\n </li>\n<li>\n<p>The new link name must not exist.</p>\n </li>\n</ul>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.5 Symbolic links</h2>\n<p>Now that you understand how hard links work, we\'ll introduce symbolic (or soft) links.</p>\n<p>A symbolic link holds an alias for a different object. When you use that symbolic link in a path the alias is used instead. To that extent symbolic link and hard links are the same.</p>\n<p>You can remove symbolic links with the <code class=\"western\">yaffs_unlink()</code> function, just like hard links.</p>\n<p>There are, however, some important differences. A symbolic link only does its linking function when the path is being evaluated and thus:</p>\n<ul>\n<li>\n<p>The file you are creating an alias to does not have to exist.</p>\n </li>\n<li>\n<p>The file you are creating an alias to does not have to be in the same mount.</p>\n </li>\n<li>\n<p>You can create symbolic links to directories.</p>\n </li>\n<li>\n<p>A symbolic link will not keep a file alive by itself. Only a hard link can do that.</p>\n </li>\n</ul>\n<p>Thus:</p>\n<ol>\n<li>\n<p>If we start with a file called “a” and then call <code class=\"western\">yaffs_symlink(“a”, “b”)</code> we now have one link to the file called “a” and a symbolic link aliasising from “b” to “a”.</p>\n </li>\n<li>\n<p>If we use <code class=\"western\">yaffs_open(“a”)</code> or <code class=\"western\">yaffs_open(“b”)</code> they will open the same file. The path resolution mechanism substitutes in the alias and so will look up “a”. The same applies to almost all functions that takes a path, such as <code class=\"western\">yaffs_truncate()</code>, <code class=\"western\">yaffs_stat()</code> etc. The only exceptions are <code class=\"western\">yaffs_lstat()</code> and <code class=\"western\">yaffs_readlink()</code> which will treat the path as pointing to the symbolic link and not the file.</p>\n </li>\n<li>\n<p>You can tell “a” and “b” apart by using <code class=\"western\">yaffs_lstat()</code>. <code class=\"western\">yaffs_lstat(“a”)</code> will show the information for file “a”. <code class=\"western\">yaffs_lstat(“b”)</code> will show the information for the symbolic link itself. Note the difference with hard links. With hard links <code class=\"western\">yaffs_lstat(“a”)</code> and <code class=\"western\">yaffs_lstat(“b”)</code> would show the same results since they are EXACTLY the same thing being referenced.</p>\n </li>\n<li>\n<p>If we now unlink “a”. then the file is no longer linked and will no longer be accessible from “b”. Note the difference with hard links.</p>\n </li>\n</ol>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.6 Handle-based file handling</h2>\n<p>A handle is file accessor that allows us to access the contents of a regular file. The handle identifies the file being accessed as well as a position pointer tracking where the next read or write operation will take place.</p>\n<p>A handle is identified by an integer of value 0 or greater.</p>\n<p>A handle is created by using the <code class=\"western\">yaffs_open()</code> call and returns the handle value. If the handle could not be created then a negative value is returned and the yaffs error code is set.</p>\n<p>A handle remains valid until the handle is closed by <code class=\"western\">yaffs_close()</code>.</p>\n<p>The <code class=\"western\">yaffs_open()</code> call takes three parameters:</p>\n<ul>\n<li>\n<p>name: Full path name of the file being opened.</p>\n </li>\n<li>\n<p>access flags: Flags being used to open this handle</p>\n </li>\n<li>\n<p>creation mode: Mode flags used when creating a file.</p>\n </li>\n</ul>\n<p>The access flags are one or more of:</p>\n<table cellpadding=\"4\" style=\"width: 100%; border-spacing: 0px;\">\n<col width=\"59*\" /> <col width=\"197*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_CREAT</code></span></span></p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 77%;\">\n <p>Create file if it does not already exist.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_EXCL</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>Only use with O_CREAT. Create file if it does not exist. If the file already exists then fail.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_TRUNC</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>If the file exists, and opening with write access, then truncate the file to zero bytes long.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><br />\n  </p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_APPEND</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>Regardless of the handle position, always write to the end of the file.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><br />\n  </p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_RDWR</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>Open for read/write access.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">O_WRONLY</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>Open for write access and no read access.</p>\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>0 (zero)</b></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>If neither O_RDWR or O_WRONLY is set then the file will be opened for read-only access.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>Where they are not mutually exclusive, these flags are typically combined. For example:</p>\n<p><code class=\"western\">O_CREAT | O_TRUNC | O_RDWR</code> : Create a new file if it does not exist otherwise if the file already exists then truncate to zero length. Typically used to overwrite a file or create if it does not already exist.</p>\n<p><code class=\"western\">O_CREAT | OEXCL | O_WRONLY</code> : Create a new file, opening it for write only. Fails if file already exists.</p>\n<p>There are three mode flags that can be controlled or set. These flags may be set by the open that creates the file or later by the <code class=\"western\">yaffs_chmod()</code>.</p>\n<table cellpadding=\"4\" style=\"width: 100%; border-spacing: 0px;\">\n<col width=\"59*\" /> <col width=\"197*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">S_IREAD</code></span></span></p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 77%;\">\n <p>The file may be opened for read access.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">S_IWRITE</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>The file may be opened for write access.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 23%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">S_IEXEC</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 77%;\">\n <p>The file may be opened for execution. This is not enforced by yaffs.</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<p>Once you have opened a handle you can then do various operations on the file.</p>\n<table cellpadding=\"4\" style=\"width: 605px; border-spacing: 0px;\">\n<col width=\"248\" /> <col width=\"339\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_close(handle)</code></span></span></p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 339px;\">\n <p>Close the handle. It is no longer usable.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_fsync(handle)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Flush out any cached writes to the file, as well as the file meta-data.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_datasync(handle)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Same as yaffs_fsync() but no file metadata.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_flush(handle)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Same as yaffs_fsync()</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_dup(handle)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Duplicates a handle.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_lseek(handle, offset, whence)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Set the handle read/write position. Note that this does not modify the file. You can seek past the end of the file. This does not modify the file size.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_ftruncate(handle, size)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Change the file size. It can be made bigger or smaller. This does not change the handle read/write position.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_fstat(handle, buf)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Get file status.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_fchmod(handle, mode)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Change the file mode.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><br />\n  </p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p><br />\n  </p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_read(handle, buffer, nbytes)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Read data from file at file pointer and update pointer.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_pread(handle, buffer, nbytes, position)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Read data from file at specified position. Does not modify file pointer</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_write(handle, buffer, nbytes)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Write data to file at file pointer and update pointer.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 248px;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">yaffs_pread(handle, buffer, nbytes, position)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 339px;\">\n <p>Write data to file at specified position. Does not modify file pointer</p>\n  </td>\n</tr>\n</table>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.7 Changing file size</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_truncate(path, newSize)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_ftruncate(handle, newSize)</code></p>\n<p><br />\n<br />\n</p>\n<p>These change a file\'s size. Note that truncating does not just mean make the file smaller. The file can also be made larger.</p>\n<p>Yaffs does not store bytes that it does not need to. If you use truncate to make a file larger then this will not necessarily occupt more flash space.</p>\n<p>See also <code class=\"western\">yaffs_lseek()</code> too. Note that <code class=\"western\">yaffs_lseek() </code>only changes the position of the write pointer and does not impact on the file size unless the file is written.</p>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.8 Getting/setting information about files</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_chmod(path, mode)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_fchmod(handle, mode)</code></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_access(path,amode)</code></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_stat(path, struct yaffs_stat *buf) </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_fstat(handle, struct yaffs_stat *buf)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_lstat(path, struct yaffs_stat *buf)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_readlink(path, buf, bufsize)</code></p>\n<p><br />\n<br />\n</p>\n<p>The chmod calls allow you to set different mode flags for the file. These can only be used to manipulate the permissions flags and not change the mode flags relating to the type of file.</p>\n<p><code class=\"western\">yaffs_access() </code>tests that the file can be accessed in the specified mode. This call returns zero on success and -1 is returned</p>\n<p>amode is a bitmask of the following values:</p>\n<table cellpadding=\"4\" style=\"width: 100%; border-spacing: 0px;\">\n<col width=\"43*\" /> <col width=\"213*\" />\n<tr valign=\"top\">\n <td style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 17%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">R_OK</code></span></span></p>\n  </td>\n <td style=\"border: 1px solid #000000; padding: 0.1cm; width: 83%;\">\n <p>Check read is OK</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 17%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">W_OK</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 83%;\">\n <p>Check write is OK</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 17%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">X_OK</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 83%;\">\n <p>Check execute is OK.</p>\n  </td>\n</tr>\n<tr valign=\"top\">\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; width: 17%;\">\n <p><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><code class=\"western\">0 (zero)</code></span></span></p>\n  </td>\n <td style=\"border-top: none; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; width: 83%;\">\n <p>Just checks the file exists</p>\n  </td>\n</tr>\n</table>\n<p>These can be combined.</p>\n<p>For example:</p>\n<p class=\"code-western\"><code class=\"western\">if(yaffs_access(path, R_OK | W_OK) == 0)</code></p>\n<p class=\"code-western\"><code class=\"western\">the file exists and can be read and written</code></p>\n<p class=\"code-western\"><code class=\"western\">if(yaffs_access(path, 0) == 0)</code></p>\n<p class=\"code-western\"><code class=\"western\">the file exists</code></p>\n<p><br />\n<br />\n</p>\n<p>The stat calls retrieve a yaffs_stat structure of data which is defined in yaffsfs.h. There are three versions:</p>\n<p><code class=\"western\">yaffs_fstat</code>: Takes a handle.</p>\n<p><code class=\"western\">yaffs_stat</code>: Takes a path name and follows symbolic links.</p>\n<p><code class=\"western\">yaffs_lstat</code>: Takes a path but does not follow symbolic links.</p>\n<p><br />\n<br />\n</p>\n<p>Thus, if path is a symbolic link, <code class=\"western\">yaffs_fstat() </code>will give information on the file that the link points to while <code class=\"western\">yaffs_lstat()</code> will give information about the link itself.</p>\n<p><code class=\"western\">yaffs_readlink()</code> will read the read the link value into the buffer provided. For example:</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_symlink(“target”,”/link”); /* create a link called link to target */</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_readlink(“/link”,buffer,10); /* now buffer contains “target” */</code></p>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.9 Changing the directory structure and names</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_open(path, flags, mode)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_mkdir(path, mode)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_symlink(targetPath, linkPath)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_mknod(pathname, mode, dev)</code></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_link(existingPath, newath)</code></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_unlink(path)</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_rmdir(path)</code></p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\">yaffs_rename(oldPath, newPath)</code></p>\n<p><br />\n<br />\n</p>\n<p>Files of various types, and their first link, are created via the <code class=\"western\">yaffs_open()</code><code class=\"western\"><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-weight: normal\">,</span></span></code><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></span><code class=\"western\">yaffs_mkdir()</code><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">, </span></span><code class=\"western\">yaffs_symlink()</code> and <code class=\"western\">yaffs_mknod()</code><span style=\"font-family: Liberation Serif, serif;\"><span style=\"font-size: 12pt; font-size: medium; font-size: medium;\"></span></span>functions.</p>\n<p><code class=\"western\">yaffs_link()</code> can be used to create subsequent links to files. Note that you cannot create a link to a directory.</p>\n<p><code class=\"western\">yaffs_rename()</code> allows you to rename a link. Note that renaming one link over another link is an atomic operation. That means that even if the operation is interrupted by a power failure, the result will either complete or not happen at all. If the target link is for a directory, then the rename will only work if the target directory is empty.</p>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.10 Searching directories</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_DIR *yaffs_opendir(const YCHAR *dirname) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">void yaffs_rewinddir(yaffs_DIR *dirp) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">int yaffs_closedir(yaffs_DIR *dirp) ; </code> </p>\n<p><br />\n<br />\n</p>\n<p>Searching is performed by the following sequence of operations:</p>\n<ul>\n<li>\n<p>Open the directory for reading with <code class=\"western\">yaffs_opendir()</code>.</p>\n </li>\n<li>\n<p>Iterate through the entries in the directory using <code class=\"western\">yaffs_readdir()</code>. Each read will advance the directory read position.</p>\n </li>\n<li>\n<p>You can reset to the start of the directory with <code class=\"western\">yaffs_rewinddir()</code>.</p>\n </li>\n<li>\n<p>Close the directory when finished with <code class=\"western\">yaffs_closedir()</code>.</p>\n </li>\n</ul>\n<h2 class=\"western\">11.11 Searching directories (fd interface)</h2>\n<p class=\"code-western\"><code class=\"western\">int </code><code class=\"western\">yaffs_open(const YCHAR *dirname, </code><code class=\"western\">O_RDONLY, 0</code><code class=\"western\">) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">struct yaffs_dirent *yaffs_readdir_</code><code class=\"western\">fd</code><code class=\"western\">(</code><code class=\"western\">int fd</code><code class=\"western\">) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">void yaffs_rewinddir_</code><code class=\"western\">fd</code><code class=\"western\">(</code><code class=\"western\">int fd</code><code class=\"western\">) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">int yaffs_close(</code><code class=\"western\">int fd</code><code class=\"western\">) ; </code> </p>\n<p><br />\n<br />\n</p>\n<p>This is not a POSIX interface, but provides an alternate interface for reading directories.</p>\n<p><br />\n<br />\n</p>\n<p>Searching is performed by the following sequence of operations:</p>\n<ul>\n<li>\n<p>Open the directory for reading with <code class=\"western\">yaffs_open( </code><code class=\"western\">name, O_RDONLY, 0</code><code class=\"western\">)</code>.</p>\n </li>\n<li>\n<p>Iterate through the entries in the directory using <code class=\"western\">yaffs_readdir_</code><code class=\"western\">fd</code><code class=\"western\">()</code>. Each read will advance the directory read position.</p>\n </li>\n<li>\n<p>You can reset to the start of the directory with <code class=\"western\">yaffs_rewinddir_</code><code class=\"western\">fd</code><code class=\"western\">()</code>.</p>\n </li>\n<li>\n<p>Close the directory when finished with <code class=\"western\">yaffs_close()</code>.</p>\n </li>\n</ul>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.12 Mount control and similar</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_mount(path) ; </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_mount2(path, readOnly); </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_unmount(path);</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_unmount2(path, int force); </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_remount(path, force, readOnly);</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_sync(path) ;</code></p>\n<p class=\"code-western\"><code class=\"western\">yaffs_format(const YCHAR *path, </code> </p>\n<p><code class=\"western\"></code> <code class=\"western\">int unmount_flag, </code> </p>\n<p><code class=\"western\"></code> <code class=\"western\">int force_unmount_flag, </code> </p>\n<p><code class=\"western\"></code> <code class=\"western\">int remount_flag) </code> </p>\n<p><br />\n<br />\n</p>\n<p>A partition must be mounted to be accessed. <code class=\"western\">yaffs_mount()</code> will mount the partition for read/write access. <code class=\"western\">yaffs_mount2()</code> can be used to control whether the access is read/write or read only.</p>\n<p>A partition can be unmounted to remove it from use. <code class=\"western\">yaffs_unmount()</code> will fail if any files are in use whereas <code class=\"western\">yaffs_unmount2()</code> allows you to force the unmount even if files are open. Note that any file handles will then be broken and will no longer access the files.</p>\n<p><code class=\"western\">yaffs_remount()</code> can be used to change the access to a currently mounted partition and is equivalent to making an <code class=\"western\">unmount2()</code> call followed by a <code class=\"western\">mount2()</code> call.</p>\n<p><code class=\"western\">yaffs_sync()</code> does not change the mount status but flushes out any pending data on a partition that is mounted with write access.</p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>yaffs_format()</b></span></span> provides a mechanism to format a device. It has various parameters.<br />\n<span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>unmount_flag</b></span></span>: If set, yaffs_format() will unmount the device before formatting. If this flag is not set and the device is mounted, then the format will fail with EBUSY.</p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>force_unmount</b></span></span>: If set, then an unmount is allowed even if the device is busy (eg. files open). If not set, then yaffs_format() will fail (EBUSY) if files are open.</p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"><b>remount_flag</b></span></span>: If set, then the device will be remounted after the format if it was mounted.</p>\n<p>The force_unmount and remount_flag options only have meaning if unmount_flag is set.</p>\n<h2 class=\"western\">11.13 Extended attributes (xattrt)</h2>\n<p>Extended attributes provide a mechanism to attach a limited amount of extra data to a file without actually modifying the file. Each xattribute is a named pair of name and some data. Each file can have as many xattribs as there is space for. In Yaffs, this is around chunk-size – 512 bytes. So on devices with 2kbyte chunks you can store up to 1.5kbytes of xattribute information.</p>\n<p>Although there are 12 xattr functions, there are really only four basic functions, each with 3 different flavours.</p>\n<p>The basic functions are: set an xattr, get an xattr, remove an xattribute and list the xattribute names.</p>\n<p class=\"code-western\">int yaffs_setxattr(const char *path, const char *name, </p>\n<p class=\"code-western\">const void *data, int size, int flags); </p>\n<p class=\"code-western\">int yaffs_lsetxattr(const char *path, const char *name, </p>\n<p class=\"code-western\">const void *data, int size, int flags); </p>\n<p class=\"code-western\">int yaffs_fsetxattr(int fd, const char *name, </p>\n<p class=\"code-western\">const void *data, int size, int flags); </p>\n<p>These functions are called with name being the name of the xattr, a pointer to the data and the size of the data, and flags.</p>\n<p>The flags are:</p>\n<p>XATTR_CREATE: Create a new xattr, fail with -EEXIST if the xattrib already exists.</p>\n<p>XATTR_REPLACE: Replace an existing xattr, fail with -ENOATTR if it does not exist.</p>\n<p>zero: Just create with no checks, replace if it already exists.</p>\n<p><br />\n<br />\n</p>\n<p>Setting can fail with -ENOSPC if there is not enough space to store the xattrib.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int yaffs_getxattr(const char *path, const char *name, </p>\n<p class=\"code-western\">void *data, int size); </p>\n<p class=\"code-western\">int yaffs_lgetxattr(const char *path, const char *name, </p>\n<p class=\"code-western\">void *data, int size); </p>\n<p class=\"code-western\">int yaffs_fgetxattr(int fd, const char *name, </p>\n<p class=\"code-western\">void *data, int size); </p>\n<p>These get (fetch) an xattrib.</p>\n<p>If the call succeeds, the length of the retrieved xattrib is returned. This call can fail with -ENOATTR if the requested xattr does not exist or -ERANGE if the buffer was too small.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int yaffs_removexattr(const char *path, const char *name); </p>\n<p class=\"code-western\">int yaffs_lremovexattr(const char *path, const char *name); </p>\n<p class=\"code-western\">int yaffs_fremovexattr(int fd, const char *name); </p>\n<p>These functions delete an existing xattr. If the xattr does not exist then -ENOATTR is returned.</p>\n<p><br />\n<br />\n</p>\n<p class=\"code-western\">int yaffs_listxattr(const char *path, char *list, int size); </p>\n<p class=\"code-western\">int yaffs_llistxattr(const char *path, char *list, int size); </p>\n<p class=\"code-western\">int yaffs_flistxattr(int fd, char *list, int size); </p>\n<p>These functions fetch a list of the xattrib names into the list buffer. The names are NUL terminated. eg. “attrib0\\0attrib1\\0...”.</p>\n<p>The function returns the length of the list, otherwise if the list buffer is too short it returns -ERANGE.</p>\n<p>Note: If you call these functions with a list buffer size of zero, this acts as a query of the required buffer size. No data is actually transferred into the list.</p>\n<p><br />\n<br />\n</p>\n<p>For example we might choose to add some xattribs to a media file:</p>\n<p class=\"code-western\">//Set description</p>\n<p class=\"code-western\">yaffs_fsetxattr(fd, “user-comment”, “I hate this song!”,18);</p>\n<p class=\"code-western\">yaffs_fsetxattr(fd, “price-in-cents”, &amp;cost, sizeof(cost));</p>\n<p class=\"code-western\">// Get the comment</p>\n<p class=\"code-western\">yaffs_fgetxattr(fd, “user_comment”, buffer, sizeof(buffer);</p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\">//List the attributes in a NUL delimited list</p>\n<p class=\"code-western\">yaffs_flistxattr(fd, list_buf, sizeof(list_buf));</p>\n<p class=\"code-western\">// Now list_buf has user-comment\\0price-in-cents\\0</p>\n<p class=\"code-western\">yaffs_fremovexattr(fd, ”user-comment”);</p>\n<p><br />\n<br />\n</p>\n<h2 class=\"western\">11.14 Other</h2>\n<p class=\"code-western\"><code class=\"western\">yaffs_freespace(path); </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_totalspace(path); </code> </p>\n<p class=\"code-western\"><code class=\"western\">yaffs_inodecount(path); </code> </p>\n<p><br />\n<br />\n</p>\n<p>These functions provide information on the free and total space (in bytes) for the mount that the path addresses.</p>\n<p><code class=\"western\">yaffs_inodecount()</code> returns the number of files on the mount that the path addresses.</p>\n<h1 class=\"western\" style=\"page-break-before: always\">12 Example: yaffs_readdir() and yaffs_stat()</h1>\n<p>This code snippet illustrates using <code class=\"western\">yaffs_readdir()</code> and associated functions to iterate through a directory. It also shows how to use <code class=\"western\">yaffs_lstat() </code>to get information on a file and interpret it.</p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">void dump_directory(const char *dname) </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">{ </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">yaffs_DIR *d; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">yaffs_dirent *de; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">struct yaffs_stat s; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">char str[100]; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">d = yaffs_opendir(dname); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">if(!d) { </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">printf(&quot;opendir failed\\n&quot;); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">} else { </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">while((de = yaffs_readdir(d)) != NULL) { </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">sprintf(str,&quot;%s/%s&quot;,dname,de-&gt;d_name); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">yaffs_lstat(str,&amp;s); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">printf(&quot;%s inode %d length %d mode %X &quot;,</span></code></p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">str,s.st_ino,(int)s.st_size,s.st_mode); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">switch(s.st_mode &amp; S_IFMT) { </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">case S_IFREG: printf(&quot;data file&quot;); break; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">case S_IFDIR: printf(&quot;directory&quot;); break; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">case S_IFLNK: printf(&quot;symlink --&gt;&quot;); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">if(yaffs_readlink(str,str,100) &lt; 0) </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">printf(&quot;no alias&quot;); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">else </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">printf(&quot;\\&quot;%s\\&quot;&quot;,str);</span></code></p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">break; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">default: printf(&quot;unknown&quot;); break; </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">}</span></code></p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">printf(&quot;\\n&quot;); </span></code> </p>\n<p class=\"code-western\"><br />\n<br />\n</p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">if((s.st_mode &amp; S_IFMT) == S_IFDIR)</span></code></p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">dump_directory_tree_worker(str); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">} </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\"></span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">yaffs_closedir(d); </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">} </span></code> </p>\n<p class=\"code-western\"><code class=\"western\"><span style=\"font-size: 10pt; font-size: small; font-size: small;\">} </span></code> </p>\n<p><br />\n<br />\n</p>\n</div>\n      \n  </div>\n\n</article>\n\";}s:9:\"#attached\";a:1:{s:14:\"html_head_link\";a:3:{i:0;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"canonical\";s:4:\"href\";s:33:\"/documents/yaffs-direct-interface\";}i:1;b:1;}i:1;a:2:{i:0;a:2:{s:3:\"rel\";s:9:\"shortlink\";s:4:\"href\";s:9:\"/node/453\";}i:1;b:1;}i:2;a:2:{i:0;a:2:{s:3:\"rel\";s:8:\"revision\";s:4:\"href\";s:33:\"/documents/yaffs-direct-interface\";}i:1;b:1;}}}s:6:\"#cache\";a:3:{s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:80\";i:3;s:8:\"node:453\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;}s:17:\"#cache_properties\";a:1:{i:0;s:6:\"#title\";}s:6:\"#title\";O:25:\"Drupal\\Core\\Render\\Markup\":1:{s:9:\"\0*\0string\";s:36:\"<span>Yaffs Direct Interface</span>\n\";}}',-1,1504659337.826,1,'config:filter.format.raw_html config:system.site file:80 node:453 node_view rendered user:1','275'),('entity_view:node:453:full:[languages:language_interface]=en:[theme]=yaffs:[user.permissions]=aa7fc4c8fb40c7a8665ccd12fea07926dff0f59b9ee3346bc513c6399bee5b01:[user.roles:anonymous]=0','a:2:{s:15:\"#cache_redirect\";b:1;s:6:\"#cache\";a:5:{s:4:\"keys\";a:4:{i:0;s:11:\"entity_view\";i:1;s:4:\"node\";i:2;s:3:\"453\";i:3;s:4:\"full\";}s:8:\"contexts\";a:7:{i:0;s:28:\"languages:language_interface\";i:1;s:5:\"theme\";i:2;s:8:\"timezone\";i:3;s:17:\"url.path.is_front\";i:4;s:16:\"user.permissions\";i:5;s:20:\"user.roles:anonymous\";i:6;s:24:\"user.roles:authenticated\";}s:4:\"tags\";a:6:{i:0;s:29:\"config:filter.format.raw_html\";i:1;s:18:\"config:system.site\";i:2;s:7:\"file:80\";i:3;s:8:\"node:453\";i:4;s:9:\"node_view\";i:5;s:6:\"user:1\";}s:7:\"max-age\";i:-1;s:3:\"bin\";s:6:\"render\";}}',-1,1504659337.823,1,'config:filter.format.raw_html config:system.site file:80 node:453 node_view rendered user:1','275');
