Userspace root image

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Using pre-created root fs image)
m (typo)
Line 1: Line 1:
 
== Creating a root filesystem from scratch ==
 
== Creating a root filesystem from scratch ==
  
To create a root file system image for storage in NAND flash, we use the mkfs.jffs2 program contained int the Debian package ''mtd-tools''.
+
To create a root file system image for storage in NAND flash, we use the mkfs.jffs2 program contained in the Debian package ''mtd-tools''.
  
 
  mkfs.jffs2 --pad=0x700000 -o rootfs.jffs2 -e 0x4000 -n -d/tmp/jffsroot/
 
  mkfs.jffs2 --pad=0x700000 -o rootfs.jffs2 -e 0x4000 -n -d/tmp/jffsroot/

Revision as of 01:59, 24 August 2007

Contents

Creating a root filesystem from scratch

To create a root file system image for storage in NAND flash, we use the mkfs.jffs2 program contained in the Debian package mtd-tools.

mkfs.jffs2 --pad=0x700000 -o rootfs.jffs2 -e 0x4000 -n -d/tmp/jffsroot/

is a typical command. It creates a FS image for our erase block size of 16k, padded to 0x700000 bytes in length from the files contained in the /tmp/jffsroot directory and stores the FS image in rootfs.jffs2.

Using pre-created root fs image

Prebuilt

See Repositories and update the list if you have more information.

OpenEmbedded

OpenEmbedded will itself create a jffs2 image at the end of the build process.

Once the build server is running, it will create root filesystem images for us.

demo JFFS2 root image

Check the Flashing openmoko page for pre-built root images. Please note that this image may take long to boot the first time, since this boot finishes the installation process.

Mounting the JFFS2 image on a loop back (MTD RAM) device

As mounting the JFFS2 image from /dev/loop0 device is not supported, use the mtdram device as described in http://www.handhelds.org/hypermail/familiar/62/6232.html

modprobe mtdcore
modprobe jffs2
modprobe mtdram total_size=59024  # default is 4 MByte - set to max. available size
modprobe mtdchar
modprobe mtdblock

Using total_size=59024 will set the filesystem size to the available space on /dev/mtd4 of the GTA1 device. So when you copy the image back it will be about 58 MB. You can set this to smaller values though.


Be careful to really use the mtd-ram-disk (maybe there is a real Flash-device somewhere in your development system)

So check for that looking into /proc/mtd:

cat /proc/mtd 
# dev:    size   erasesize  name
# mtd0: 039a4000 00020000 "mtdram test device"

Then write the image to that device and mount it:

dd if=<rootfs.jffs2> of=/dev/mtd0
mount /dev/mtdblock0 <mountpoint>

create the new image

To get the changed image back there are two ways. The obvious one is to unmount it and copy the data back from the MTD block device (the image will be 58 MB):

umount /dev/mtdblock0
dd if=/dev/mtdblock0 of=<rootfs.jffs2>

You can also create a new image using the mounted file system and the method described above (the image will have the size of its data):

mkfs.jffs2 --pad=0x700000 -o new_rootfs.jffs2 -e 0x4000 -n -d <mountpoint>

Flashing a root filesystem into NAND

See U-boot#Writing_rootfs_to_NAND

Personal tools

Creating a root filesystem from scratch

To create a root file system image for storage in NAND flash, we use the mkfs.jffs2 program contained in the Debian package mtd-tools.

mkfs.jffs2 --pad=0x700000 -o rootfs.jffs2 -e 0x4000 -n -d/tmp/jffsroot/

is a typical command. It creates a FS image for our erase block size of 16k, padded to 0x700000 bytes in length from the files contained in the /tmp/jffsroot directory and stores the FS image in rootfs.jffs2.

Using pre-created root fs image

Prebuilt

See Repositories and update the list if you have more information.

OpenEmbedded

OpenEmbedded will itself create a jffs2 image at the end of the build process.

Once the build server is running, it will create root filesystem images for us.

demo JFFS2 root image

Check the Flashing openmoko page for pre-built root images. Please note that this image may take long to boot the first time, since this boot finishes the installation process.

Mounting the JFFS2 image on a loop back (MTD RAM) device

As mounting the JFFS2 image from /dev/loop0 device is not supported, use the mtdram device as described in http://www.handhelds.org/hypermail/familiar/62/6232.html

modprobe mtdcore
modprobe jffs2
modprobe mtdram total_size=59024  # default is 4 MByte - set to max. available size
modprobe mtdchar
modprobe mtdblock

Using total_size=59024 will set the filesystem size to the available space on /dev/mtd4 of the GTA1 device. So when you copy the image back it will be about 58 MB. You can set this to smaller values though.


Be careful to really use the mtd-ram-disk (maybe there is a real Flash-device somewhere in your development system)

So check for that looking into /proc/mtd:

cat /proc/mtd 
# dev:    size   erasesize  name
# mtd0: 039a4000 00020000 "mtdram test device"

Then write the image to that device and mount it:

dd if=<rootfs.jffs2> of=/dev/mtd0
mount /dev/mtdblock0 <mountpoint>

create the new image

To get the changed image back there are two ways. The obvious one is to unmount it and copy the data back from the MTD block device (the image will be 58 MB):

umount /dev/mtdblock0
dd if=/dev/mtdblock0 of=<rootfs.jffs2>

You can also create a new image using the mounted file system and the method described above (the image will have the size of its data):

mkfs.jffs2 --pad=0x700000 -o new_rootfs.jffs2 -e 0x4000 -n -d <mountpoint>

Flashing a root filesystem into NAND

See U-boot#Writing_rootfs_to_NAND