Template:Box 1

=SD Configuration and Setup=

There are 2 approaches to format the SD card. You could either use the script available or follow the step by step instructions below.

Note: All these instructions are common across all OMAP platforms.

Script to partition/format SDCards
Want to avoid all of the below mentioned instructions and use a simple script instead? See the below link (the script is a bit dangerous!): http://www.xora.org.uk/2009/08/14/omap3-sd-booting/ The script has now been moved into the Ångström contrib area in OE See below link: http://git.openembedded.org/cgit.cgi/openembedded/tree/contrib/angstrom/omap3-mkcard.sh You can also use this script which will refuse to use /dev/sda as the device (that tends to be your primary HDD!). if [ ! "$1" = "/dev/sda" ] ; then DRIVE=$1 if [ -b "$DRIVE" ] ; then dd if=/dev/zero of=$DRIVE bs=1024 count=1024 SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'` echo DISK SIZE - $SIZE bytes CYLINDERS=`echo $SIZE/255/63/512 | bc` echo CYLINDERS - $CYLINDERS {		echo ,9,0x0C,* echo ,,,- } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE mkfs.vfat -F 32 -n "boot" ${DRIVE}1 mke2fs -j -L "rootfs" ${DRIVE}2 fi fi
 * 1) !/bin/sh

After running the script mount the SD card partitions on host: mkdir /tmp/mmc1 mkdir /tmp/mmc2 sudo mount /dev/sdx1 /tmp/mmc1 sudo mount /dev/sdx2 /tmp/mmc2

Verified to work on Ubuntu to boot boards such as beagle, omapzoom2 etc. A big thanks to XorA!

Step by Step Instructions to format SD card
Since putting a Linux file system on a FAT32 partition is problematic, it is recommended to also create a 2nd partition.


 * Insert your SD card into your Linux box
 * Do not mount it

The card shows up as /dev/sd*. To identify the card, you can either do:


 * dmesg | grep sd[a-z]. You will see something like [172407.246308] sdb: sdb1 sdb2 so drive is /dev/sdb
 * ls /dev/sd* before and after plugging SD card and find created devices

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

sudo fdisk /dev/sdc Command (m for help): p Disk /dev/sdc: 1018 MB, 993001472 bytes ... ...

Look for the size in bytes of the device and calculate the number of cylinders, dropping fractions, if we have 255 heads and 63 sectors (and 512 bytes per sector so 1 cylinder is 255 * 63 * 512 = 8225280 bytes).

new_cylinders = Size / 8225280 (for this example we will have 993001472 / 8225280 which equals 120.725 or 120 cylinders)

Delete existing Partitions
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 number of heads to 255, number of sectors to 63, and number of cylinders to new_cylinders.

Command (m for help): d Partition number (1-4): 1 Command (m for help): d Partition number (1-4): 2

Configure SD Card
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): 

Configure SD Partitions
Now we return to the main menu and create 2 partitions as needed - 1 boot partition of 64Meg and the rest a linux partition.


 * Note: +64M is used to set the boot partition to 64MB. If media content is stored on the SD this parition size should be increased to make room for media content (mp3, mp4, aac, etc...). Assuming a 2GB SD card is used a partition size of +1024MB should be enough to handle 1GB of media content.

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 (see note above) 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

Fat32 Partition
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)) Command (m for help): a Partition number (1-4): 1
 * You have to format 1st partitions with vfat32 filesystem.

Check Partition Table
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.

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.

Formatting Partitions
Format the filesystems on the partitions:
 * 1) sudo mkfs.vfat -F 32 -n boot /dev/sdc1
 * 2) sudo mkfs.ext3 -L filesystem /dev/sdc2

Creating a mount point
mkdir /tmp/mmc1 mkdir /tmp/mmc2 sudo mount /dev/sdc1 /tmp/mmc1 sudo mount /dev/sdc2 /tmp/mmc2

Problem seen with FDISK not erasing the first sector
The fdisk utility does not seem to erase the first few bytes of the first sector in the card when the partition table is saved.

Use dd to erase the first sector. dd if=/dev/zero of=/dev/ bs=1024 count=1

Then use the procedure listed in section above to create new partitions and format them accordingly