Monday, February 4, 2008

Formatting of MMC and files to be copied on MMC for booting the OMAP board.

Formatting the SD Card
Since putting a Linux file system on a FAT32 partition is problematic, it is recommended to

create 2 partitions. The first partition is a boot partition between 64-128 Megabytes and the

second partition is a Linux partition consuming the rest of the card.
Plug your SD card into your Linux box - do not mount it. For this example, we will assume

the card shows up as /dev/sdc - substitute this for the real device on your specific machine.
Fdisk the drive and print the partition information
Code:
fdisk /dev/sdc
Command (m for help): p
Disk /dev/sdc: 1018 MB, 1018691584 bytes
......


Look for the size in bytes of the device and calculate the number of cylinders, dropping

factions, if we have 255 heads and 63 sectors.

new_cylinders = Size / 8225280 (for this example we will have 993001472 / 8225280

which equals 120.725 or 120 cylinders)

Since we are changing the underlying geometry of the disk, we must clear the partition

table before doing it. So delete all partitions using the fdisk 'd' command - yes, you will lose

all data on the card. Once that is done, we can set the new geometry in expert mode. We

will set the # of heads to 255, # of sectors to 63, and # of cylinders to new_cylinders.
Code:
Command (m for help): x
Expert command (m for help): h
Number of heads (1-256, default 30): 255
Expert command (m for help): s
Number of sectors (1-63, default 29): 63
Warning: setting sector offset for DOS compatiblity
Expert command (m for help): c
Number of cylinders (1-1048576, default 2286): 120


Now we return to the main menu and create our 2 partitions as needed - 1 boot partition of

64Meg and the rest a linux partition.
Code:
Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-123, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-123, default 123): +64M

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-123, default 10):
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-123, default 123):
Using default value 123


Set the partition type of the first partition to FAT32 and make it active.
Code:
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))


* You have to format 1st partitions with vfat32 filesystem.

Code:
Command (m for help): a
Partition number (1-4): 1


The partition table should look something like the following. Notice the heads, sectors, and

cylinders. Make sure partition 1 is active and FAT32. If it looks good - write the new

partition information out.
Code:
Command (m for help): p
Disk /dev/sdc: 993 MB, 993001472 bytes
255 heads, 63 sectors/track, 120 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 9 72261 c W95 FAT32 (LBA)
/dev/sdc2 10 120 891607+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


Formating the partitions
Format the filesystems on the partitions
Code:
mkfs.vfat -F 32 -n boot /dev/sdc1
mkfs.ext3 /dev/sdc2


Installing the Boot Files
If you haven't already built them, you will need a u-boot image and the signed nand xloader

image.
Build x-loader (nand version)
Build UBoot

Create some mount point to use
Code:
mkdir /tmp/mmc1
mkdir /tmp/mmc2
mount /dev/sdc1 /tmp/mmc1



mount /dev/sdc2 /tmp/mmc2


Copy x-loader, u-boot, and kernel images to the boot partition. You can have multiple

kernel images and name isn't important. Note: The signed x-loader must be called MLO on

the card.
Code:
cp x-load-nand-signed.bin /tmp/mmc1/MLO
cp u-boot.bin /tmp/mmc1/u-boot.bin
cp kernel.uImg /tmp/mmc1/kernel-x.x.uImg
umount /tmp/mmc1
umount /tmp/mmc2


Insert the card into the OmapZoom and reboot or hit the HARDWARE-reset-Button. x-loader

should start and you should see the following message from the x-loader on boot.
Code:
Texas Instruments X-Loader? 1.41
Starting OS Bootloader from MMC/SD1 ...


If you see the the following output, then congratulations, you have booted from MMC. Smile

Maybe you'll need to add some bootargs to boot from MMC:

Code:
setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1

mem=128M
nand unlock
saveenv