Sunday, April 19, 2009

Root filesystem on SD MMC card


Introduction :
Hacking Linux kernel for LN2410 Single board computer

Here I would like to share my experience in porting root File system on the SD MMC card,and configuring the kernel to use it

I have done it in following steps
1. Setting up the environment
2. Kernel compilation and loading it to NOR flash
3. preparing the SD MMC card and File system.
4. Copying the rootfs to SD MMC Card


Requirements :
Toolchain :
gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2
Kernel:
linux-2.6.13.2-lc6.tar.gz
File system:
LN2410disk.gz (provided by vendor)

Setting up the environment:
-Extract the tool chain and update the environment.
Please follow these steps
create an arm folder in "/usr/local" and extract the binaries in this folder
#mkdir /usr/local/arm
#cd /usr/local/arm
#tar –jxvf gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2
update the shell environment by adding the following in .bashrc file
export PATH=$PATH:/usr/local/arm/bin


Kernel compilation and loading it to NOR flash

a. Extract the kernel source and compile it using the menuconfig option.
# tar xvzf linux-2.6.13.2-lc6.tar.gz
#make menuconfig -------- for configuring kernel
CONFIG_CMDLINE="root=/dev/mmcblk0p1 rootfstype=ext2 console=ttySAC0 rw"(kernel command line we used)
In the Kernel command line we convey in command line the type of filesystem, the partition on which the root file system is available
Under character device driver section do select the
<*> MMC support
[ ] MMC debugging
<*> MMC block device driver
< > Winbond W83L51xD SD/MMC Card Interface support
<*> Samsung S3C2410 Multimedia Card Interface support
#make ---------- u will get zimage in (./arch/arm/boot/zimage)
Once the Image is ready copy this image using the following commands.
LN2410SBC # loadb 0x31000000 (Using Kermit send the zimage.bin )
Once the image is copied the size of byte is indicated in the terminal
LN2410SBC # erase 1:7-33
LN2410SBC # cp.b 0x31000000 0x40000 size

preparing the SD MMC card and File system.

# fdisk /dev/sda
To create a new partition that will use up the whole free space, use the command sequence
like this:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1011, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1011, default 1011):
Using default value 1011

prepare /dev/sda1 for ext2 filesystem
mkfs.ext2 /dev/sda1



Changes in the kernel command line argument
#make menuconfig -------- for configuring kernel
and in CONFIG_CMDLINE="root=/dev/sda1 rootfstype=ext2 rootdelay=10 init=/linuxrc rw"

Coping the rootfs to SD MMC Card

#gzip -dc LN2410disk.gz
#mkdir olddisk
#mount -o loop LN2410disk olddisk
Now mount the newly created partition on SD MMc card on /mnt
#mount /dev/sda1 /mnt
#cp -rf olddisk/* /mnt
Now connect SD MMC card on LN2410 board.

Restart the board and type loadm 0x40000 on shell prompt.

Now the Kernel will mount the file system from SD MMC card!!