How to Boot from SD

Requirements

You need the following components:

  • 1 GB or larger Secure Digital Card
  • Secure Digital Card reader for your development system (USB readers are available for about $15)

Board-Specific Methods

If your board is listed below, you should use that guide instead of this.

  • Digi ConnectCore Wi.iMX51 JS
  • NXP/Embedded Artists LPC313x
  • TI AM3517 EVM
  • Freescale QorIQ Platforms

Generic Method

Formatting the Card

The following steps will create two partitions on a single SD card. The first partition is a FAT16 partition which will contain the kernel and device tree blob (if applicable). The second contains the root filesystem.

  1. Connect the SD card to your host system. Many modern systems have SD card slots on the case, or you can purchase a USB SD Card Reader for around $15 US.
  2. Determine the device name of the SD Card. This can be done using dmesg. In the following example, the device is /dev/sdb, which contains one partition sdb1.
    $ dmesg | tail
    [88050.184080]    sd 4:0:0:0:    [sdb]  1990656 512-byte hardware sectors: (1.01 GB/972 Mi
    [88050.184821]    sd 4:0:0:0:    [sdb]  Write Protect is off
    [88050.184824]    sd 4:0:0:0:    [sdb]  Mode Sense: 03 00 00 00
    [88050.184827]    sd 4:0:0:0:    [sdb]  Assuming drive cache: write through
    [88050.185575]    sd 4:0:0:0:    [sdb]  1990656 512-byte hardware sectors: (1.01 GB/972 Mi
    [88050.186323]    sd 4:0:0:0:    [sdb]  Write Protect is off
    [88050.186325]    sd 4:0:0:0:    [sdb]  Mode Sense: 03 00 00 00
    [88050.186327]    sd 4:0:0:0:    [sdb]  Assuming drive cache: write through
    [88050.186330]      sdb: sdb1
    
  3. Unmount the partition if it was automounted by using the umount command.
    $ umount /dev/sdb1
  4. As root, run the fdisk utility on the drive.
    $ sudo fdisk /dev/sdb
  5. In fdisk, delete the existing partition table and create a new one using the o command.
    Command (m for help): o
    Building a new DOS disklabel with disk identifier 0x8b025602.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won’t be recoverable.
    
  6. Create a new primary partition using the n command. Set it as partition 1, accept the default for the first cylinder, and set the last cylinder to +16M.
    Command (m for help): n
    Command action
       e    extended
       p    primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-240, default 1):
    Using default value 1
    Last cylinder, +cylinders or +sizeK,M,G (1-1015, default 1015): +16M
    
  7. Set the type of the first partition to FAT16 using the t command. The code for FAT16 is 6.
    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 6
    Changed system type of partition 1 to 6 (FAT16)
    
  8. Create another new primary partition using the n command. Set it as partition 2, accept the defaults for both the first and last cylinders.
    Command (m for help): n
    Command action
       e    extended
       p    primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (3-1015, default 3):
    Using default value 3
    Last cylinder, +cylinders or +sizeK,M,G (3-1015, default 1015):
    Using default value 1015
    
  9. Verify that the partition table is correct by using the p command. It should look similar to the following:
    Command (m for help): p
    
    Disk /dev/sdb: 2030 MB, 2030043136 bytes
    63 heads, 62 sectors/track, 1015 cylinders
    Units = cylinders of 3906 * 512 = 1999872 bytes
    Disk identifier: 0x9fee7cf8
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1           2        3875    6  FAT16
    /dev/sdb2               3        1015     1978389   83  Linux
    
  10. This step will destroy all data on the SD Card: Write the partition table to the card using the w command.
    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.
    
  11. Format the first partition with a vfat filesystem using the mkfs.vfat tool.
    $ mkfs.vfat -n"BOOT" /dev/sdb1
  12. Format the second partition with an EXT filesystem using the mkfs.ext2 tool. Most of the Timesys kernels support EXT2 by default, but many will also support EXT3 and EXT4 as well.
    $ mkfs.ext2 -L RFS /dev/sdb2
  13. Sync the partitions using the sync command:
    $ sync
  14. Remove the SD Card from your system.

Writing the Kernel and DTB to the SD Card

  1. Insert the SD Card into your system. It should automatically mount the partitions in most modern Linux systems.
  2. Copy your uImage file and DTB file to the first partition. On most systems, it should show up as /media/BOOT
    cp uImage-3.0-ts-armv7l /media/boot

Writing the RFS to the SD Card

  1. Insert the SD Card into your system. It should automatically mount the partitions in most modern Linux systems.
  2. The Factory builds a tarball of the root filesystem by default. Extract this tarball at the base of the SD card:
    # sudo tar -xvf /path/to/factory/build_*/images/rfs/rootfs.tar.gz -C /media/disk
  3. Unmount the drive again and remove it from the system. Insert it into the SD Card slot on the board.

Booting the board

These steps depend heavily upon the configuration of your board, including bootloader type and version, number of SD slots, and other features. Not every bootloader supports loading a kernel/device tree from an SD card. If you have questions, please contact

U-Boot

The following commands should be run on the U-Boot command line:

  1. Enable the SD/MMC interface:
    mmc rescan
  2. Load the kernel from the first partition:
    fatload mmc 0:1 $loadaddr uImage-3.0-ts-armv7l
  3. If needed, load the device tree from the first partition:
    fatload mmc 0:1 $fdtaddr devicetree.dtb
  4. Modify your kernel bootargs to use the second MMC partition as your root filesystem:
    setenv bootargs console=$console root=/dev/mmcblk0p1 rootwait
  5. Boot the board. If using a device tree, use the following:
    bootm $loadaddr - $fdtaddr

    Otherwise, use:
    bootm $loadaddr

Generic

If you simply want to mount the SD card as the RFS, add the following parameters to the kernel command line when booting the board:

root=/dev/mmcblk0p2 rw rootwait

root is the name of your MMC/SD Partition, and rootwait tells the board to wait for the SD card to enumerate before mounting the RFS since it takes some time for the SD card to mount.

You must also remove any other root= information from your kernel command line string.