Difference between revisions of "Creating JFFS2 Images"

From wiki.emacinc.com
Jump to: navigation, search
(created)
 
(added usage)
Line 1: Line 1:
 +
This page describes the process of creating JFFS2 images on a Linux PC from existing files. This is often used to create new images from existing JFFS2 images in order to resize, modify, or change parameters on the image. If using this process to modify an existing image, please follow the steps in [[Mounting JFFS2 Images on a Linux PC]] to mount the existing image. The mounted directory structure will be used as the root directory for creating the new image.
 +
 +
{{mbox | type = notice | text = This process requires that the mtd utilities packages is installed on the Linux PC. This may be done through the package manager or directly from source through the project website [http://www.linux-mtd.infradead.org/index.html Linux MTD].}}
 +
 +
== Mkfs.jffs2 Usage ==
 +
The <code>mkfs.jffs2</code> application is used to create JFFS2 images. The output of <code>mkfs.jffs2 --help</code> is shown below and lists the available options with brief descriptions:
 +
developer@ldc:~$ sudo mkfs.jffs2
 +
mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
 +
Make a JFFS2 file system image from an existing directory tree
 +
 +
Options:
 +
  -p, --pad[=SIZE]        Pad output to SIZE bytes with 0xFF. If SIZE is
 +
                          not specified, the output is padded to the end of
 +
                          the final erase block
 +
  -r, -d, --root=DIR      Build file system from directory DIR (default: cwd)
 +
  -s, --pagesize=SIZE    Use page size (max data node size) SIZE (default: 4KiB)
 +
  -e, --eraseblock=SIZE  Use erase block size SIZE (default: 64KiB)
 +
  -c, --cleanmarker=SIZE  Size of cleanmarker (default 12)
 +
  -m, --compr-mode=MODE  Select compression mode (default: priortiry)
 +
  -x, --disable-compressor=COMPRESSOR_NAME
 +
                          Disable a compressor
 +
  -X, --enable-compressor=COMPRESSOR_NAME
 +
                          Enable a compressor
 +
  -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
 +
                          Set the priority of a compressor
 +
  -L, --list-compressors  Show the list of the avaiable compressors
 +
  -t, --test-compression  Call decompress and compare with the original (for test)
 +
  -n, --no-cleanmarkers  Don't add a cleanmarker to every eraseblock
 +
  -o, --output=FILE      Output to FILE (default: stdout)
 +
  -l, --little-endian    Create a little-endian filesystem
 +
  -b, --big-endian        Create a big-endian filesystem
 +
  -D, --devtable=FILE    Use the named FILE as a device table file
 +
  -f, --faketime          Change all file times to '0' for regression testing
 +
  -q, --squash            Squash permissions and owners making all files be owned by root
 +
  -U, --squash-uids      Squash owners making all files be owned by root
 +
  -P, --squash-perms      Squash permissions on all files
 +
      --with-xattr        stuff all xattr entries into image
 +
      --with-selinux      stuff only SELinux Labels into jffs2 image
 +
      --with-posix-acl    stuff only POSIX ACL entries into jffs2 image
 +
  -h, --help              Display this help text
 +
  -v, --verbose          Verbose operation
 +
  -V, --version          Display version information
 +
  -i, --incremental=FILE  Parse FILE and generate appendage output for it
 +
 +
Please review the <code>mkfs.jffs2</code> man page as well, which should be available after installing the mtd utilities. The parameters used to create the image will depend on the target system, including the flash type, erase block size, and partition size. Once the parameters have been determined, the JFFS2 image will be created by running <code>mkfs.jffs2</code> and specifying the directory tree to use for making the image using the <code>--root</code> option. The following sections discuss the system variables affecting JFFS2 images.
 +
 +
=== Erase Block Size ===
 +
 +
The erase block size of the flash must be determined before creating the JFFS2 image. This can be found through the contents of <code>/proc/mtd</code> on a running system or through the system documentation. All NOR flashes currently used on EMAC products utilize 128 KiB erase blocks. NAND flashes use a variety of configurations, 128 KiB and 256 KiB are the most common. Contact EMAC if you unsure what value to use.
 +
 +
=== Endianess ===
 +
 +
Currently, all EMAC products that use JFFS2 filesystems are configured as little endian by default. Custom configurations or future products may result in the need for a big endian image. Contact EMAC if you are unsure which endianness to use.
 +
 +
=== Cleanmarkers ===
 +
 +
By default, JFFS2 writes cleanmarker nodes to the beginning of each erase block. While this is desired on NOR flash, it should not be used for NAND flash devices. If the target system uses a NAND flash, cleanmarkers will be disabled with the <code>--no-cleanmarkers</code> option.
 +
 +
=== Padding ===
 +
 +
Padding is used to control the creation of additional JFFS2 nodes in the image beyond the nodes required to store the data in the files used to create the image. This option is not used with NAND flash images. For NOR flash, padding is typically added to the end of the last erase block by specifying the <code>--pad</code> option with no size parameter. However, when using RedBoot as the bootloader the image should be padded to the full size of the JFFS2 partition. For example, when creating a new root filesytem for a board with a 28 MiB root partition running RedBoot, <code>--pad=0x1C00000</code> would be specified to create a padded image.
 +
  
  
 
[[Category:Filesystems]]
 
[[Category:Filesystems]]
 
[[Category:Linux]]
 
[[Category:Linux]]

Revision as of 07:41, 26 April 2013

This page describes the process of creating JFFS2 images on a Linux PC from existing files. This is often used to create new images from existing JFFS2 images in order to resize, modify, or change parameters on the image. If using this process to modify an existing image, please follow the steps in Mounting JFFS2 Images on a Linux PC to mount the existing image. The mounted directory structure will be used as the root directory for creating the new image.

Mkfs.jffs2 Usage

The mkfs.jffs2 application is used to create JFFS2 images. The output of mkfs.jffs2 --help is shown below and lists the available options with brief descriptions:

developer@ldc:~$ sudo mkfs.jffs2
mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree

Options:
  -p, --pad[=SIZE]        Pad output to SIZE bytes with 0xFF. If SIZE is
                          not specified, the output is padded to the end of
                          the final erase block
  -r, -d, --root=DIR      Build file system from directory DIR (default: cwd)
  -s, --pagesize=SIZE     Use page size (max data node size) SIZE (default: 4KiB)
  -e, --eraseblock=SIZE   Use erase block size SIZE (default: 64KiB)
  -c, --cleanmarker=SIZE  Size of cleanmarker (default 12)
  -m, --compr-mode=MODE   Select compression mode (default: priortiry)
  -x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
  -X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
  -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
  -L, --list-compressors  Show the list of the avaiable compressors
  -t, --test-compression  Call decompress and compare with the original (for test)
  -n, --no-cleanmarkers   Don't add a cleanmarker to every eraseblock
  -o, --output=FILE       Output to FILE (default: stdout)
  -l, --little-endian     Create a little-endian filesystem
  -b, --big-endian        Create a big-endian filesystem
  -D, --devtable=FILE     Use the named FILE as a device table file
  -f, --faketime          Change all file times to '0' for regression testing
  -q, --squash            Squash permissions and owners making all files be owned by root
  -U, --squash-uids       Squash owners making all files be owned by root
  -P, --squash-perms      Squash permissions on all files
      --with-xattr        stuff all xattr entries into image
      --with-selinux      stuff only SELinux Labels into jffs2 image
      --with-posix-acl    stuff only POSIX ACL entries into jffs2 image
  -h, --help              Display this help text
  -v, --verbose           Verbose operation
  -V, --version           Display version information
  -i, --incremental=FILE  Parse FILE and generate appendage output for it

Please review the mkfs.jffs2 man page as well, which should be available after installing the mtd utilities. The parameters used to create the image will depend on the target system, including the flash type, erase block size, and partition size. Once the parameters have been determined, the JFFS2 image will be created by running mkfs.jffs2 and specifying the directory tree to use for making the image using the --root option. The following sections discuss the system variables affecting JFFS2 images.

Erase Block Size

The erase block size of the flash must be determined before creating the JFFS2 image. This can be found through the contents of /proc/mtd on a running system or through the system documentation. All NOR flashes currently used on EMAC products utilize 128 KiB erase blocks. NAND flashes use a variety of configurations, 128 KiB and 256 KiB are the most common. Contact EMAC if you unsure what value to use.

Endianess

Currently, all EMAC products that use JFFS2 filesystems are configured as little endian by default. Custom configurations or future products may result in the need for a big endian image. Contact EMAC if you are unsure which endianness to use.

Cleanmarkers

By default, JFFS2 writes cleanmarker nodes to the beginning of each erase block. While this is desired on NOR flash, it should not be used for NAND flash devices. If the target system uses a NAND flash, cleanmarkers will be disabled with the --no-cleanmarkers option.

Padding

Padding is used to control the creation of additional JFFS2 nodes in the image beyond the nodes required to store the data in the files used to create the image. This option is not used with NAND flash images. For NOR flash, padding is typically added to the end of the last erase block by specifying the --pad option with no size parameter. However, when using RedBoot as the bootloader the image should be padded to the full size of the JFFS2 partition. For example, when creating a new root filesytem for a board with a 28 MiB root partition running RedBoot, --pad=0x1C00000 would be specified to create a padded image.