vm-larix‎ > ‎Beagleboard‎ > ‎

SD Card

This page documents the steps needed to partition and prepare an SD Card to boot the beagleboard hardware. Most of the information in this page is from the TI processor Wiki

Partitioning the SD Card
We use fdisk to create partitions. Our SD Card happened to be /dev/sdc

bash-4.1$ fdisk /dev/sdc


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

The command 'o' removes all existing partitions.

Command (m for help): o
Building a new DOS disklabel with disk identifier 0xdee8b047.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

The command 'p' displays the partition table information

Command (m for help): p


Disk /dev/sdc: 3965 MB, 3965190144 bytes
49 heads, 48 sectors/track, 3292 cylinders
Units = cylinders of 2352 * 512 = 1204224 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdee8b047


Device Boot Start End Blocks Id System

We now switch to expert mode, and set the heads, cylinders etc.

Command (m for help): x


Expert command (m for help): h
Number of heads (1-256, default 49): 255


Expert command (m for help): s
Number of sectors (1-63, default 48): 63
Warning: setting sector offset for DOS compatiblity


Expert command (m for help): c
Number of cylinders (1-1048576, default 3292): 15


Expert command (m for help): r

Now we create a new partition and set as a FAT32 type.

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-15, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-15, default 15): 15


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


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

And then verify it.

Command (m for help): p


Disk /dev/sdc: 3965 MB, 3965190144 bytes
255 heads, 63 sectors/track, 15 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdee8b047


Device Boot Start End Blocks Id System
/dev/sdc1 * 1 15 120456 c W95 FAT32 (LBA)

Finally, we write to the SD card. Without this step, all the above changes would be discarded.

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


Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 13: Permission denied.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)


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

Now, we format the SD card and create the FAT file system. On other distribution, this utility may exist  as mkfs.fat32

bash-4.1$ mkfs.msdos -F 32 /dev/sdc1
mkfs.msdos 2.11 (12 Mar 2005)

We again go through the same process. This time we create another partition to mount once the kernel comes alive.

bash-4.1$ fdisk /dev/sdc


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').


Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (16-482, default 16):
Using default value 16
Last cylinder, +cylinders or +size{K,M,G} (16-482, default 482):
Using default value 482


Command (m for help): p


Disk /dev/sdc: 3965 MB, 3965190144 bytes
255 heads, 63 sectors/track, 482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdee8b047


Device Boot Start End Blocks Id System
/dev/sdc1 * 1 15 120456 c W95 FAT32 (LBA)
/dev/sdc2 16 482 3751177+ 83 Linux


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


Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 13: Permission denied.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
bash-4.1$ sudo mkfs.ext3 /dev/sdc2
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
234784 inodes, 937794 blocks
46889 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=960495616
29 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736


Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
bash-4.1$

Please remember that while ext3 partition is recognized by the linux kernel. The vmlarix kernel does not have support for ext3 built into it. The file system supported by vmlarix is called sfs (simple file system).

Copying the executables

Once the above steps are done, we may load the x-loader, u-boot and the kernel image onto the card as described here.
  1. The x-loader.bin file is the first file that needs to go on to the SD card as "MLO".
  2. The u-boot.bin is copied next.
  3. Then the init-rd file
  4. and the u-image (kernel image).
To boot the beagle board using the SD card, one had to press and hold the "user button" on the board. This changes the boot order to USB -> UART -> SD -> NAND. When the board is powered up without pressing the user button, the sequence of loading the x-loader is NAND -> USB-> UART -> SD. The x-loader loads the u-boot.bin (the stage 2 boot loader) using a sequence programmed in the source code of the x-loader. It can be modified, recompiled and loaded to look for the u-boot using an alternate sequence.

Comments