⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enabling_jffs2.html

📁 ADI 公司blackfin系列的用户使用文挡。
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>  <title></title>  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="level1"><div class="li"><span class="li"><a href="#jffs2_details" class="toc">JFFS2 Details</a></span></div><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#setting_jffs2_flash_partitions" class="toc">Setting JFFS2 Flash partitions</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#parallel_nor_flash" class="toc">Parallel NOR Flash</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#serial_nor_flash" class="toc">Serial NOR Flash</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#kernel_settings_for_jffs2" class="toc">Kernel Settings for JFFS2</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#using_u-boot_to_write_the_jffs2_and_kernel_image" class="toc">Using U-Boot to write the JFFS2 and Kernel image</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#remarks" class="toc">Remarks</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#using_jffs2_flash_partitions_in_the_kernel" class="toc">Using JFFS2 Flash partitions in the kernel</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#booting_kernel_filesystem_image_and_mounting_a_jffs2_partition" class="toc">Booting Kernel/filesystem image and mounting a JFFS2 partition</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#booting_kernel-only_image_with_jffs2_root_file_system" class="toc">Booting Kernel-only image with JFFS2 root file system</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#mounting_jffs2_via_loop" class="toc">Mounting JFFS2 via Loop</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#troubleshooting" class="toc">Troubleshooting</a></span></div></li></ul></li></ul></div></div><h1><a name="jffs2_details" id="jffs2_details">JFFS2 Details</a></h1><div class="level1"><p> There are a few terms to understand when dealing with file systems:</p><ul><li class="level1"><div class="li"> ramfs - The common way of storing files where read-write access is needed is to put them into a Ramdisk, a fixed-size(at boot time) solution for creating a virtual block device for storing a filesystem. The downside of ramfs, is information is lost between power cycles, or on reset.</div></li><li class="level1"><div class="li"> <a href="http://en.wikipedia.org/wiki/Ext2" class="urlextern" title="http://en.wikipedia.org/wiki/Ext2"  rel="nofollow">ext2fs</a> - second extended file system is a file system for the Linux kernel. <a href="http://genext2fs.sourceforge.net/more info" class="urlextern" title="http://genext2fs.sourceforge.net/more info"  rel="nofollow">http://genext2fs.sourceforge.net/more info</a> and <a href="http://e2fsprogs.sourceforge.net/ext2.html" class="urlextern" title="http://e2fsprogs.sourceforge.net/ext2.html"  rel="nofollow">more info</a>. When using a ramfs, uClinux normally creates a ext2 filesystem, and puts it into a ram disk.</div></li><li class="level1"><div class="li"> <a href="http://en.wikipedia.org/wiki/JFFS2" class="urlextern" title="http://en.wikipedia.org/wiki/JFFS2"  rel="nofollow">JFFS2</a> - is a file system designed for use on flash devices in embedded systems. This turns your Flash device into what looks like a hard drive to the kernel<a href="http://sources.redhat.com/jffs2/" class="urlextern" title="http://sources.redhat.com/jffs2/"  rel="nofollow">more info</a> and  <a href="http://www.linux-mtd.infradead.org/" class="urlextern" title="http://www.linux-mtd.infradead.org/"  rel="nofollow">more info</a>.</div></li></ul><p> JFFS2 can be enabled in the uClinux kernel and U-Boot.  Enabling JFFS2 in U-Boot allows U-Boot to access kernel images stored in the JFFS2 image.  </p><p>There are a variety of different Flash devices that JFFS2 images can be stored in:</p><ul><li class="level1"><div class="li"> Parallel NOR Flash - has a full address/data (memory) interface that allows random access to any location. It is block-erasable (many words will be erased at once), but is typically programmable as words or bytes at a time. Since this is connected to the address bus, on the BF533, the max Flash is 4Megbytes (max external addressable memory).</div></li><li class="level1"><div class="li"> Serial NOR Flash - a four-wire SPI-compatible interface as used for serial EEPROM which provides a sequential read access.  They offer densities up to 8Mbytes.<a href="http://www.st.com/stonline/products/families/memories/fl_ser/sf_code.htm" class="urlextern" title="http://www.st.com/stonline/products/families/memories/fl_ser/sf_code.htm"  rel="nofollow">ST Flash</a> has been validated with uClinux/Blackfin, and drivers are available.</div></li><li class="level1"><div class="li"> Parallel NAND Flash - NAND Flash is the ideal solution for applications requiring a large amount of data storage memory. It allows densities from 128Mbit (16Mbytes) up to 8Gbit (1Gbyte) in a common footprint, with a common driver, only occupying one external bank on the uClinux/Blackfin Solution.</div></li></ul><p> When using JFFS2 on large (128MB or larger) flash devices - the developer must be aware of the downsides. Since there is no indexing information stored on the flash media, each JFFS2 node contains full information about itself, but there is no central index. The index is the crucial part of any file system as it is used to quickly locate any piece of information (i.e., find all the files kept in a directory, find the physical flash address where the files data is stored, etc.). In JFFS2, the index is maintained in RAM and takes significant amount of it - a 128MB NAND would use about 4MB RAM in node tables. Roughly speaking, there is a in-RAM data structure for each on-flash node.</p><p>The in RAM index must be built on each mount. For this reason, JFFS2 must scan the flash media. And it is logically then the more data you have on flash, the longer is JFFS2 mount time and memory consumption. Namely, the above 2 characteristics linearly depend on the flash size (O(N), N - flash size). This can mean scan time at boot time gets longer every day of usage. Eg.  when flash is empty it takes ~10 s to mount 20Mb of flash, later when there are some files present it takes &gt; 30s and increasing. This is normal for JFFS2. The more data is in the flash, the longer is JFFS2 being mounted. This issue is being resolved in the development of <a href="http://www.linux-mtd.infradead.org/tech/JFFS3design.pdf" class="urlextern" title="http://www.linux-mtd.infradead.org/tech/JFFS3design.pdf"  rel="nofollow">JFFS3</a>, and is available today by using the <a href="http://www.aleph1.co.uk/yaffs/" class="urlextern" title="http://www.aleph1.co.uk/yaffs/"  rel="nofollow">YAFFS</a> filesystem.</p><p>There are a few steps before you can start playing with a JFFS2 image:</p><ol><li class="level1"><div class="li"> setting the source to describe the JFFS2 image location to the kernel</div></li><li class="level1"><div class="li"> create a kernel which will understand and mount a jffs2 image</div></li><li class="level1"><div class="li"> create the jffs2 file system (this is done automatically during a kernel <code>make</code> and is found in: <code>./uclinux-dist/images/jffs2.image</code>)</div></li><li class="level1"><div class="li"> write the jffs2 file system (<code>jffs2.img</code>) into flash with U-Boot</div></li><li class="level1"><div class="li"> tell the kernel where the JFFS2 file system is stored</div></li><li class="level1"><div class="li"> boot the kernel built in step 1</div></li></ol><p> These steps will be reviewed in detail below.</p></div><!-- SECTION [1-4273] --><h2><a name="setting_jffs2_flash_partitions" id="setting_jffs2_flash_partitions">Setting JFFS2 Flash partitions</a></h2><div class="level2"><p> Before using JFFS2, you must describe to the kernel where in the flash the JFFS2 image will reside. There are optional flags which can be set for each partition. The variable <code>mask_flags</code> can be set to (from <code>./linux-2.6.x/include/mtd/mtd-abi.h</code>): </p><ul><li class="level1"><div class="li"> MTD_CAP_ROM - No write</div></li><li class="level1"><div class="li"> MTD_CAP_RAM - Bits can be cleared, Bits can be set, Direct IO is possible</div></li><li class="level1"><div class="li"> MTD_CAP_NORFLASH - Bits can be cleared, Has an erase function</div></li><li class="level1"><div class="li"> MTD_CAP_NANDFLASH - Bits can be cleared, Has an erase function, Out-of-band data</div></li></ul></div><!-- SECTION [4274-4828] --><h3><a name="parallel_nor_flash" id="parallel_nor_flash">Parallel NOR Flash</a></h3><div class="level3"><p>The base address of the flash is at 0&times;20000000 for the BF533 and BF537. The base address was set in the kernel options. The table below describes a partition table set up like:</p><ol><li class="level1"><div class="li"> boot loader:</div><ul><li class="level2"><div class="li"> starting at the beginning of flash (0&times;20000000) = offset 0&times;0</div></li><li class="level2"><div class="li"> size of 256kBytes = 0x40000h</div></li></ul></li><li class="level1"><div class="li"> a kernel image </div><ul><li class="level2"><div class="li"> starting at memory location 0&times;20040000 = offset 0&times;40000</div></li><li class="level2"><div class="li"> a size of 768kBytes = 0xC0000h </div></li></ul></li><li class="level1"><div class="li"> JFFS2 Image</div><ul><li class="level2"><div class="li"> starting at 0&times;20100000 = offset 0&times;100000 </div></li><li class="level2"><div class="li"> size of 3.0Meg = 0x300000h</div></li></ul></li></ol><p> JFFS2 partitions are described in: </p><p></p></div><!-- SECTION [4829-5662] --><h3><a name="serial_nor_flash" id="serial_nor_flash">Serial NOR Flash</a></h3><div class="level3"><p>For Serial Flash, there is no base address which needs to be set. The table below describes a partition table set up like:</p><ol><li class="level1"><div class="li"> boot loader:</div><ul><li class="level2"><div class="li"> starting at the beginning of flash = offset 0&times;0</div></li><li class="level2"><div class="li"> size of 256kBytes = 0x40000h</div></li></ul></li><li class="level1"><div class="li"> a kernel image </div><ul><li class="level2"><div class="li"> starting at 256k into the seial flash = offset 0&times;40000</div></li><li class="level2"><div class="li"> a size of 768kBytes = 0xC0000h </div></li></ul></li><li class="level1"><div class="li"> JFFS2 Image</div><ul><li class="level2"><div class="li"> starting 1Meg into the serial flash = offset 0&times;100000 </div></li><li class="level2"><div class="li"> size of 3.0Meg = 0x300000h</div></li></ul></li></ol><p> JFFS2 partitions are described in: </p></div><!-- SECTION [5663-6301] --><h2><a name="kernel_settings_for_jffs2" id="kernel_settings_for_jffs2">Kernel Settings for JFFS2</a></h2><div class="level2"><p> The following settings must be set in the kernel configuration with either <code>make menuconfig</code> or <code>make xconfig</code>.</p><p>If you will be using a JFFS2 root filesystem (booting from JFFS2), you should have the following settings: </p><pre class="code">Kernel hacking  ---&gt;  [ ] Compiled-in Kernel Boot Parameter (disable this option)</pre><p>If you will be using or booting from JFFS2 </p><pre class="code">Device Drivers  ---&gt;  Memory Technology Devices (MTD)  ---&gt;    &lt;*&gt; Memory Technology Device (MTD) support    [*]   MTD partitioning support    [*]   Direct char device access to MTD devices    [*]   Caching block device access to MTD devices</pre><p>If you are using Parallel NOR Flash, in the MTD menu, select: </p><pre class="code">RAM/ROM/Flash chip drivers  ---&gt;  &lt;*&gt; Detect non-CFI AMD/JEDEC-compatible flash chips  [*] Flash chip driver advanced configuration options  &lt;*&gt; ST MW320D compatible flash chip support  &lt;*&gt; Support for RAM chips in bus mapping  &lt;*&gt; Support for ROM chips in bus mappingMapping drivers for chip access  ---&gt;  [*] Support non-linear mappings of flash chips  &lt;*&gt; Blackfin BF5xx Flash Chip Support  (0x400000) Size in bytes HEX  (0x20000000) Base Address in HEX      FLASH_EBIU_AMBCTL Control  ---&gt;        (0x7BB0) Bank 0        (0x7BB0) Bank 1        (0x7BB0) Bank 2        (0x7BB0) Bank 3  &lt; &gt; Generic uClinux RAM/ROM filesystem support (disable this option)</pre><p>If you are using Serial NOR Flash, select: </p><pre class="code">    Select - RAM/ROM/Flash chip drivers          Enable - Detect non-CFI AMD/JEDEC-compatible flash chips          Enable - Flash chip driver advanced configuration options          Select - Specific CFI Flash geometry selection               Enable - Support 16-bit bus width               Enable - Support 4-chip flash interleave          Enable - Support for ST flash chips          Enable - ST M25P64 compatible flash chip support (NEW)             Enable - Support for RAM chips in bus mapping          Enable - Support for ROM chips in bus mapping     Select - Mapping drivers for chip access          Enable - Support non-linear mappings of flash chips                                                            Disable 鈥

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -