NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Create a CRAMFS Target Image
Contents
Introduction[edit]
The compressed ROM file system (cramfs) is a read-only Linux file system designed to have a small footprint. The main difference between cramfs and a compressed image of a traditional file system is that the cramfs file system can be used without the need to decompress it first. This is accomplished by compressing the file system one page at a time, which allows for random read access. However, this also prevents writing to the file system.
Benefits of CRAMFS[edit]
- CRAMFS file systems have a small footprint.
- CRAMFS file systems can be read without needed to decompress the entire file system first.
Limitations of CRAMFS[edit]
- CRAMFS file systems are read-only.
- CRAMFS file systems have a max size per file of 16MB.
- CRAMFS file systems have a max file system size of a little over 256MB. This is because the last file on the file system must begin before the 256MB mark but may extend past the 256MB mark.
Prerequisites[edit]
- CRAMFS utilities for creating the CRAMFS file system image.
- For more information on obtaining and installing the CRAMFS utilities please see the CRAMFS Utilities page.
- A target (ARM) root file system which you want to create a CRAMFS image of (e.g. the content of a ramdisk or NFS share).
Creating a CRAMFS Target Image[edit]
The following section will walk you through how to create a CRAMFS target image that can be placed in Flash on the DVEVM. To save time, a RAM disk is provided with the DVSDK ARM Linux software. This RAM disk can be used as a base for our cramfs file system image. For newer versions of the DVSDK (DVSDK 1.30 and greater) the sample ramdisk file system can be found at <DVSDK install dri>/<PSP directory>/bin. In older versions of the DVSDK (DVSDK 1.20 and earlier) the sample ramdisk file system can be found in the MontaVista installation directory at <MV install dir>/montavista/pro/devkit/arm/v5t_le/images.
the RAM disk file is called ramdisk.gz (about 2.1 MB gunzipped). In run time, it occupies about 6.3 MB in DDR. This file system contains some unnecessary utilities for this project, but is appropriate for a typical embedded system. We are going to use this file system to generate a cramfs file system. The following steps will demonstrate how to create a cramfs file system image.
- Copy the example initial RAM disk to a temporary location
host $ mkdir –p /mnt/def_cd host $ cp <path to ramdisk>/ramdisk.gz /mnt/def_cd host $ cd /mnt/def_cd
- Mount the example initial RAM disk image
host $ gunzip ramdisk.gz host $ mkdir ram0 host $ mount ramdisk ram0 –o loop
- Modify the example initial RAM disk. You can add new applications or files at this point. For a more detailed example of adding a new application see the [SPRAAH2] document. For this example we will add a simple shell script to print “Hello World!!!” on start-up.
host $ vi ram0/etc/init.d/hello.sh
Add the following 2 lines into the hello.sh file: #!/bin/sh echo “Hello World!!!”
host $ chmod +x ram0/etc/init.d/hello.sh host $ cd ram0/etc/rc.d/rcS.d host $ ln –s ../init.d/hello.sh S50hello host $ cd /mnt/def_cd
- Create a cramfs image of the file system
host $ mkcramfs ram0 cramfs.image
- Un-mount the example initial RAM disk
host $ umount ram0
Conclusion[edit]
You should now have a file /mnt/def_cd/cramfs.image which is a CRAMFS image to the sample ramdisk file system with a script to print "Hello World!!!" on start-up. This image can now be placed in Flash for use as a root file system for the Linux kernel. For information on how to use this image please see the Put CRAMFS Image to Flash page.