Difference between revisions of "Mounting JFFS2 Images on a Linux PC"

From wiki.emacinc.com
Jump to: navigation, search
(created)
 
(adding content)
Line 1: Line 1:
 +
It is possible to mount a binary JFFS2 image on a Linux PC without a flash device. This can be useful for examining the contents of the image, making required changes, and creating a new image in any format. When a JFFS2 image is copied directly from a JFFS2 flash partition, the resulting image is the size of the source partition, regardless of how much space is actually used for storage. Mounting the filesystem and using the <code>mkfs.jffs2</code> utility to create a new image will result in a JFFS2 image without blank nodes. This can also be used to create multiple images for flashes with different characteristics, such as erase block sizes. This page describes two different methods of mounting JFFS2 images on a Linux PC.
  
 +
{{mbox | type = notice | text = This procedure requires that the following kernel modules are available or built-in to the kernel on the development machine: mtdram, mtdblock, jffs2, block2mtd, and loop.}}
 +
 +
== Mounting JFFS2 Images using RAM ==
 +
 +
One method of mounting JFFS2 images uses the <code>mtdram</code> module to emulate an MTD device using system RAM. This works well for smaller JFFS2 images less than approximately 32 MB but will not work for larger images since it requires allocating a large amount of system RAM. The basic steps of this process are as follows:
 +
# Load <code>mtdram</code> and <code>mtdblock</code> modules.
 +
# Use <code>dd</code> to copy the JFFS2 image to <code>/dev/mtdblock0</code>.
 +
# Mount <code>/dev/mtdblock0</code> as a JFFS2 filesytem.
 +
 +
In order to simplify this process, EMAC has created a script which takes the JFFS2 image, mount point, and the erase block size of the image as parameters. The default erase block size for this script is 128 KiB, which is the correct value for most NOR flashes used on EMAC products and some NAND flashes. The eraseblock size can be determined from the contents of <code>/proc/mtd</code> from the system that the image was copied from or created for. For example, if the value of the "erasesize" parameter is <code>00040000</code>, the erase block size for the device is 256 KiB (0x40000 = 262144, 262144 / 1024 = 256). The ''jffs2_mount_mtdram.sh'' script is shown below.
  
  
 
[[Category:Filesystems]]
 
[[Category:Filesystems]]
 
[[Category:Linux]]
 
[[Category:Linux]]

Revision as of 08:10, 26 April 2013

It is possible to mount a binary JFFS2 image on a Linux PC without a flash device. This can be useful for examining the contents of the image, making required changes, and creating a new image in any format. When a JFFS2 image is copied directly from a JFFS2 flash partition, the resulting image is the size of the source partition, regardless of how much space is actually used for storage. Mounting the filesystem and using the mkfs.jffs2 utility to create a new image will result in a JFFS2 image without blank nodes. This can also be used to create multiple images for flashes with different characteristics, such as erase block sizes. This page describes two different methods of mounting JFFS2 images on a Linux PC.

Mounting JFFS2 Images using RAM

One method of mounting JFFS2 images uses the mtdram module to emulate an MTD device using system RAM. This works well for smaller JFFS2 images less than approximately 32 MB but will not work for larger images since it requires allocating a large amount of system RAM. The basic steps of this process are as follows:

  1. Load mtdram and mtdblock modules.
  2. Use dd to copy the JFFS2 image to /dev/mtdblock0.
  3. Mount /dev/mtdblock0 as a JFFS2 filesytem.

In order to simplify this process, EMAC has created a script which takes the JFFS2 image, mount point, and the erase block size of the image as parameters. The default erase block size for this script is 128 KiB, which is the correct value for most NOR flashes used on EMAC products and some NAND flashes. The eraseblock size can be determined from the contents of /proc/mtd from the system that the image was copied from or created for. For example, if the value of the "erasesize" parameter is 00040000, the erase block size for the device is 256 KiB (0x40000 = 262144, 262144 / 1024 = 256). The jffs2_mount_mtdram.sh script is shown below.