Open main menu

DAVE Developer's Wiki β

Changes

Memory Tecnology Device (MTD)

529 bytes added, 15:33, 4 May 2015
m
UBIFS
{{InfoBoxBottom}}
{{WorkInProgress}}
= Memory Technology Devices (MTD) =
=== Command line configured MTD partitions ===
== MTD Utils ==
You can interact with the MTD subsystem using the MTD Utilities, a collection of tools that can be used to perform operations on Flash devices. For further information on this package, plese refer to http://processors.wiki.ti.com/index.php/MTD_Utilities
 
Usually the mtd-utils collection is provided as a pre-built binary package. Anyway, it can also be [http://processors.wiki.ti.com/index.php/MTD_Utilities#Target cross-compiled] for the specific target.
== UBI ==
The Journaled Flash File System v.2 provides non-volatile storing and compression of data on flash devices. For more details about is please see http://www.linux-mtd.infradead.org/doc/jffs2.html. It can be a good choice for not too big flash partitions (as a reference, not bigger than 128 MByte).
The default Let's assume the MTD partition associated to the NAND flash is mapped as number ...5. Please note that the same technique can be used with the NOR Flash partitions.
Let’s assume we run the kernel by using the [[Booting_Linux_Kernel#Configuration_net_nfs|net_nfs configuration as described ..]]. From the target shell, run
<pre class="board-terminal">
cat /proc/mtd
<pre class="board-terminal">
eraseall /dev/mtd4mtd5
</pre>
<pre class="board-terminal">
mount -t jffs2 /dev/mtdblock4 mtdblock5 /mnt/nand
</pre>
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/mtdblock4 mtdblock5 on /mnt/nand type jffs2 (rw)
</pre>
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nfs 99077740 44983688 54094052 46% /
/dev/mtdblock4 mtdblock5 32768 912 31856 3% /mnt/nand
</pre>
<pre class="board-terminal">
setenv nandargs 'setenv bootargs root=/dev/mtdblock4 mtdblock5 rw rootflags=noatime rootfstype=jffs2'
</pre>
# mount
rootfs on / type rootfs (rw)
/dev/mtdblock4 mtdblock5 on / type jffs2 (rw,noatime)
/proc on /proc type proc (rw,nodiratime)
</pre>
[[File: Ubifs stack.png]]
The default For more information on UBIFS, please refer to http://www.linux-mtd.infradead.org/doc/ubifs.html Let's assume the MTD partition associated to the NAND flash is mapped as number 4. Let’s assume X and that we run the kernel by using the [[Booting_Linux_Kernel#Configuration_net_nfs|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:
<pre class="board-terminal">
flash_eraseall /dev/mtdX
</pre>
* As an alternative to point 1, launch Launch the following commandto create the UBI volume:
<pre class="board-terminal">
ubiattach /dev/ubi_ctrl -m X
* 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">
ubi.mtd=6 X root=ubi0_0 rootfstype=ubifs rw
</pre>
# the file system is formatted automatically the first time it is mounted
# the mount command don't use the /dev/ prefix before ubi0_0 device
 
== Additional information ==
 
* http://free-electrons.com/blog/managing-flash-storage-with-linux/