Difference between revisions of "Memory Tecnology Device (MTD)"

From DAVE Developer's Wiki
Jump to: navigation, search
(UBI)
Line 18: Line 18:
  
 
To access and use UBIFS:
 
To access and use UBIFS:
# Add the ubi.mtd=X parameter to the kernel command line, where X is the number of the mtd partition
+
* Add the ubi.mtd=X parameter to the kernel command line, where X is the number of the mtd partition
# Erase the MTD partition:
+
* Erase the MTD partition:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
flash_eraseall /dev/mtdX  
 
flash_eraseall /dev/mtdX  
 
</pre>
 
</pre>
# As an alternative to point 1, launch the following command:
+
* As an alternative to point 1, launch the following command:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
ubiattach /dev/ubi_ctrl -m X  
 
ubiattach /dev/ubi_ctrl -m X  
 
</pre>
 
</pre>
# The device /dev/ubi0 is now available. To create the UBI volume, launch the following command (-N sets the name and -s sets the size of the volume):
+
* The device /dev/ubi0 is now available. To create the UBI volume, launch the following command (-N sets the name and -s sets the size of the volume):
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
ubimkvol /dev/ubi0 -N rootfs -s 128MiB
 
ubimkvol /dev/ubi0 -N rootfs -s 128MiB
 
</pre>
 
</pre>
# The device /dev/ubi0_0 is now available and can be mounted with one of the following comands:
+
* The device /dev/ubi0_0 is now available and can be mounted with one of the following comands:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
mount -t ubifs ubi0_0 /mnt/ubifs
 
mount -t ubifs ubi0_0 /mnt/ubifs
 
mount -t ubifs ubi0:rootfs /mnt/ubifs
 
mount -t ubifs ubi0:rootfs /mnt/ubifs
 
</pre>
 
</pre>
# To mount the UBI file system as root file system, the binding between MTD and UBI must be specified from the kernel command line, adding the following parameters:
+
* To mount the UBI file system as root file system, the binding between MTD and UBI must be specified from the kernel command line, adding the following parameters:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
ubi.mtd=6 root=ubi0_0 rootfstype=ubifs rw
 
ubi.mtd=6 root=ubi0_0 rootfstype=ubifs rw

Revision as of 16:40, 11 May 2012

Info Box
Tux.png Applies to Linux


WorkInProgress.gif

Introduction[edit | edit source]

MTD Partitions[edit | edit source]

UBI[edit | edit source]

UBIFS can be considered as the next-generation of the JFFS2 file system. It is a new journaled flash file system which works on top of the UBI (Unsorted Block Images) subsystem, a wear-leveling and volume management system for raw flash devices. UBI volumes are higher level entities than MTD devices, which represents the raw flash devices (/dev/mtdX) and provide the interface to access flash chips. The following figure shows the involved subsystems:

Ubifs stack.png

The default MTD partition associated to the NAND flash is mapped as number 4. Let’s assume we run the kernel by using the net_nfs configuration. Since using UBIFS shares some points with using JFFS2, please refer to ... for further details.

To access and use UBIFS:

  • Add the ubi.mtd=X parameter to the kernel command line, where X is the number of the mtd partition
  • Erase the MTD partition:
flash_eraseall /dev/mtdX 
  • As an alternative to point 1, launch the following command:
ubiattach /dev/ubi_ctrl -m X 
  • The device /dev/ubi0 is now available. To create the UBI volume, launch the following command (-N sets the name and -s sets the size of the volume):
ubimkvol /dev/ubi0 -N rootfs -s 128MiB
  • The device /dev/ubi0_0 is now available and can be mounted with one of the following comands:
mount -t ubifs ubi0_0 /mnt/ubifs
mount -t ubifs ubi0:rootfs /mnt/ubifs
  • To mount the UBI file system as root file system, the binding between MTD and UBI must be specified from the kernel command line, adding the following parameters:
ubi.mtd=6 root=ubi0_0 rootfstype=ubifs rw

Please note that

  1. the file system is formatted automatically the first time it is mounted
  2. the mount command don't use the /dev/ prefix before ubi0_0 device

File system on MTD[edit | edit source]

JFFS2[edit | edit source]

UBIFS[edit | edit source]