Difference between revisions of "JFFS2 images over UBI layer"

From Compulab Mediawiki
Jump to: navigation, search
(Kernel support)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
On this page we assume, that you have MTD utils installed as described in [[Linux_Development_for_XScale_modules#MTD_utils|Linux Development for XScale modules]] article.
+
#REDIRECT [[Linux: JFFS2 images over UBI layer]]
 
 
== Kernel support ==
 
 
 
In order to get UBI and UBI GLUE driver working you need to enable them in kernel configuration. In kernel configuration choose '''"Device Drivers -> Memory Technology Device (MTD) support -> UBI - Unsorted block images"''' menu and enable '''"Enable UBI"''' and '''"MTD devices emulation driver"''' options.
 
<pre>
 
┌─────────────────────────────────── UBI - Unsorted block images ────────────────────────────────────┐
 
│  Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are hotkeys.  │
 
│  Pressing <Y> includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for │
 
│  Help, </> for Search.  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable        │
 
│                                                                                                    │
 
│ ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │
 
│ │            <*> Enable UBI                                                                    │ │
 
│ │            (4096) UBI wear-leveling threshold                                                │ │
 
│ │            (1)  Percentage of reserved eraseblocks for bad eraseblocks handling              │ │
 
│ │            <*>  MTD devices emulation driver (gluebi)                                        │ │
 
│ │                  *** UBI debugging options ***                                                │ │
 
│ │            [ ]  UBI debugging                                                                │ │
 
│ │                                                                                                │ │
 
│ └────────────────────────────────────────────────────────────────────────────────────────────────┘ │
 
├────────────────────────────────────────────────────────────────────────────────────────────────────┤
 
│                                  <Select>    < Exit >    < Help >                                  │
 
└────────────────────────────────────────────────────────────────────────────────────────────────────┘
 
</pre>
 
Now you can build the kernel with UBI support including the UBI GLUE driver.
 
 
 
== User space tools ==
 
 
 
In this section we will use {{parameter|X}} as the MTD partition number attached to UBI, {{parameter|Y}} as the emulated MTD partition number and we assume that there were no MTD partitions attached to UBI before. <br>
 
To prepare the NAND for use with UBI, you should take the following steps:
 
* Erase the MTD partition that will be used for UBI volume(s):
 
<pre>
 
> flash_eraseall /dev/mtdX
 
</pre>
 
* Attach the MTD partition to UBI:
 
<pre>
 
> ubiattach /dev/ubi_ctrl -m X -O 2048
 
</pre>
 
* Create UBI volume:
 
<pre>
 
> ubimkvol /dev/ubi0 -m -N <ubi volume name>
 
</pre>
 
* Update the new UBI volume with JFFS2 image:
 
<pre>
 
> ubiupdatevol /dev/ubi0_0 <path to JFFS2 image>
 
</pre>
 
If you want to use the new UBI volume as the root filesystem on your device, you should change the {{parameter|root}} parameter of kernel command line to boot from emulated
 
MTD partition '''Y''' (which is UBI volume):
 
'''root=/dev/mtdblockY''' and add '''ubi.mtd=X,2048''' parameter, so the MTD partition containing the new UBI volume will be attached on kernel boot prior to root filesystem mount.
 
 
 
== UBI logical eraseblock size and JFFS2 image eraseblock size ==
 
 
 
UBI layer is using some part of NAND's ''physical'' erase block for it's own needs (e.g. bad blocks handling), therefore it provides a ''logical'' eraseblock for filesystem use. The logical eraseblock size is smaller than the physical, so when you construct the JFFS2/UBIFS image, as described in section [[Linux_Development_for_XScale_modules#JFFS2_images|JFFS2 images]] and [[Linux_Development_for_XScale_modules#UBIFS_images|UBIFS images]], you should set the {{parameter|eraseblock}} (JFFS2) and {{parameter|leb-size}} (UBIFS) parameter to UBI's logical eraseblock size. <br>
 
The UBI logical eraseblock size can be obtained by invoking the command:
 
<pre>
 
> cat /sys/class/ubi/ubiX/eraseblock_size
 
</pre>
 
Where {{parameter|X}} is the UBI device number.
 
 
 
== See also ==
 
* [[Linux_Development_for_XScale_modules|Linux Development for XScale modules]]
 
* [[Linux_MTD_drivers_on_CM-X270|Linux MTD drivers on CM-X270]]
 
* [[Getting_started_with_Linux_on_CM-X300|Getting started with Linux on CM-X300]]
 
* [http://www.linux-mtd.infradead.org/doc/ubi.html UBI documentation]
 
* [http://www.linux-mtd.infradead.org/faq/ubi.html UBI FAQ and HOWTO]
 

Latest revision as of 08:08, 23 December 2009