We got this to work using Lolo with LTIB rev5. We first applied the litekit patches that you will find in this post:
http://tdg.logicpd.com/viewtopic.php?f=29&t=1310.
We decided to partition our NAND accordingly: 20MB for rootfs, 42MB for userfs, 2MB for the kernel zImage and bootloader. To do this, we modified arch/arm/mach-mx3/mx31lite.c as follows:
static struct mtd_partition mxc_nand_partitions[2] = {
{
.name = "nand.rootfs",
.offset = 0x00000000,
.size = 20 * 1024 * 1024},
{
.name = "nand.userfs",
.offset = MTDPART_OFS_APPEND,
.size = 42 * 1024 * 1024},
};
You will notice that we did not include the final 2MB where we will save the zImage and bootloader because the Lolo Yaffs is incompatible with the kernel.
The next thing we did is to first compile the kernel with settings for an NFS only root file system. LTIB will set up a directory structure for you. We then recompile the kernel for jffs2 as the root file system. When done making the kernel, you will find rootfs.jffs2 in the root of your LTIB directory. This should be the same size as specified in mx31lite.c.
The next thing to do is to boot the kernel with an NFS root file system. You can use the kernel compiled for a jffs2 rootfs, it doesn't matter. What matters is the arguments passed into the kernel from the bootloader. You will find the second stage bootloader we used:
http://tdg.logicpd.com/viewtopic.php?f=29&t=1074&hilit=loader+bootloader.
When booting from NFS, we use this as the command line argument (in the source code):
#define COMMAND_LINE "console=ttymxc0 root=/dev/nfs nfsroot=192.168.3.11:/tftpboot/rootfs rw init=/linuxrc ip=192.168.3.31::192.168.3.1:255.255.255.0 noalign"
When booting from jffs2, we use this as the command line argument:
#define COMMAND_LINE "console=ttymxc0 root=/dev/mtdblock2 rootfstype=jffs2"
You will notice that our rootfs is in mtdblock2. mx31lite.c defines two nor partitions (mtdblocks 0 & 1), and our change defines two nand partitions (mtdblocks 2 & 3).
On this site there are plenty of instructions how to load the boot loader and zImage into RAM using Lolo. Do so and boot the kernel. We then put the rootfs.jffs2 file into the nfs directory our litekit can see and then execute the following:
cat /proc/mtd
will confirm your mtd blocks are correct.
flash_eraseall -j /dev/mtd/2
will erase and setup mtdblock2 to receive a jffs2 formatted file.
nandwrite /dev/mtd/2 $YOUR_LOCATION/rootfs.jffs2
copies the rootfs into nand flash (mtdblock2)
To check to make sure everything is OK, mount the new file system and read its structure. After reboot, you will not need to worry about this again:
mx31# mount -t jffs2 /dev/mtdblock2 /mnt/rootfs.jffs2
mx31# ls /mnt/rootfs.jffs2
To return to Lolo, do the following:
reboot
Now it is time to install zImage and the loader into nand flash. You will recall we reserved the upper 2 MB of nand flash for this. This region begins at block 3968 for a length of 128 blocks. Once you have your networking running in Lolo (ifconfig), do the following (your IP and directory names will differ):
losh> erase B3968 B128 /dev/nand0
losh> add-yaffs boot nand B3968 B128; mount yaffs /boot
losh> cp /tftp/192.168.3.11:/tftpboot/loader_jffs2 /boot/loader_jffs2; cp /tftp/192.168.3.11:/tftpboot/zImage /boot/zImage
To boot the kernel, do the following:
losh> load elf 0x800d03a8 36000 /boot/loader_jffs2; load raw 0x81000000 1684324 /boot/zImage; exec 0x800d03a8
The Lolo reference manual will provide instuctions how to use VOLOecho to make a boot script. Once done, your machine will boot autonomously with a jiffs2 rootfs and no need for NFS.