Open main menu

DAVE Developer's Wiki β

Changes

Memory Tecnology Device (MTD)

3,307 bytes added, 16:48, 11 May 2012
JFFS2
==== JFFS2 ====
 
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 ....
 
The default MTD partition associated to the NAND flash is mapped as number .... Please note that the same technique can be used with the NOR Flash partitions.
 
Let’s assume we run the kernel by using the net_nfs configuration as described ... From the target shell, run
<pre class="board-terminal">
cat /proc/mtd
</pre>
 
This command lists all the MTD partitions. For example, the mtd4 partition can be used.
 
<pre class="board-terminal">
eraseall /dev/mtd4
</pre>
 
<pre class="board-terminal">
bash-2.05b# eraseall /dev/mtd5
Erasing 16 Kibyte @ nand_erase: attempt to erase a bad block at page 0x0000a740
Erasing 16 Kibyte @ 14e8000 -- 65 % complete.
eraseall: /dev/mtd5: MTD Erase failure: Input/output error
Erased 32768 Kibyte @ 0 -- 100% complete.
</pre>
 
This operation is a sort of formatting. The error shown above refers to a bad block found in the device. These bad block are common for NAND flashes. They resemble somehow bad block of hard disk.
<pre class="board-terminal">
mkdir /mnt/nand
</pre>
 
<pre class="board-terminal">
mount -t jffs2 /dev/mtdblock4 /mnt/nand
</pre>
 
<pre class="board-terminal">
mount
</pre>
 
Linux should print something like this:
 
<pre class="board-terminal">
/dev/nfs on / type nfs (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/mtdblock4 on /mnt/nand type jffs2 (rw)
</pre>
 
This means than the device is correctly mounted on /mnt/nand.
 
To see how much space is left on the device please run the df command:
 
<pre class="board-terminal">
bash-2.05b# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nfs 99077740 44983688 54094052 46% /
/dev/mtdblock4 32768 912 31856 3% /mnt/nand
</pre>
 
Now it is possibile to create create files and directories in /mnt/nand. This stuff will be permanently stored in the NAND flash chip.
 
 
==== Mount root filesystem from MTD JFFS2 partition ====
 
First of all it is necessary to have the root file system available on a directory, for example /mnt/rfs (user can mount it throug NFS or loop-mount an ext2 image). Then:
 
<pre class="board-terminal">
cd /mnt/rfs/
cp -aRv . /mnt/nand/
</pre>
 
You should see something like this:
<pre class="board-terminal">
bash-2.05b# cp -aRv . /mnt/nand/
`./bin' -> `/mnt/nand/./bin'
`./bin/login' -> `/mnt/nand/./bin/login'
`./bin/application' -> `/mnt/nand/./bin/application'
`./bin/busybox' -> `/mnt/nand/./bin/busybox'
...
`./var/run' -> `/mnt/nand/./var/run'
bash-2.05b#
</pre>
 
Now reboot the system in order to access the U-Boot shell and modify the root and rootfstype kernel command line parameters on the nandargs environment variable:
 
<pre class="board-terminal">
setenv nandargs 'setenv bootargs root=/dev/mtdblock4 rw rootflags=noatime rootfstype=jffs2'
</pre>
 
Now run the kernel with this command:
 
<pre class="board-terminal">
run flash_nand
</pre>
 
When kernel completed boot process, you can verify that the root file system is the one stored in the NAND flash:
<pre class="board-terminal">
# mount
rootfs on / type rootfs (rw)
/dev/mtdblock4 on / type jffs2 (rw,noatime)
/proc on /proc type proc (rw,nodiratime)
</pre>
==== UBIFS ====
customer
235
edits