Booting Linux with rootfs on SD Card Print

 

Step through the following procedure in order to boot Linux on the VF6 System-On-Module (SOM) with rootfs mounted on an SD card:

  1. Modify the Linux kernel configuration to not include the rootfs into the uImage. For this, run make kmenuconfig in the project directory and uncheck (disable) the Initial RAM filesystem... option:
  2. General setup --->
    [ ] Initial RAM filesystem and RAM disk (initramfs/initrd) support

  3. Modify the kernel configuration to enable SD card support. For this, check (enable) the following options:
  4. Device Drivers --->
    MMC/SD/SDIO card support --->
    <*> MMC block device driver
    (8) Number of minors per block device
    [*] Use bounce buffer for simple hosts
    <*> Secure Digital Host Controller Interface support
    <*> SDHCI support on the platform specific bus
    [*] SDHCI platform support for the Freescale eSDHC i.MX controller

  5. Add the SD card device nodes to the <project>.initramfs file:
  6. nod /dev/mmcblk0 0666 0 0 b 179 0
    nod /dev/mmcblk0p1 0666 0 0 b 179 1
    nod /dev/mmcblk0p2 0666 0 0 b 179 2
    nod /dev/mmcblk0p3 0666 0 0 b 179 3
    nod /dev/mmcblk0p4 0666 0 0 b 179 4

  7. Build the project with the make command.
  8. Insert an SD card to the Linux host and create an ext3 partition on it with the size big enough for the root file system. For example, the following commands create an ext3 partition occupying all free space available on the SD card:
  9. [psl@ocean ~]$ sudo fdisk /dev/sdb
    Welcome to fdisk (util-linux 2.21.2).

    Changes will remain in memory only, until you decide to write them. Be careful before using the write command.

    Command (m for help): n
    Partition type:
    p primary (1 primary, 0 extended, 3 free)
    e extended
    Select (default p): p
    Partition number (1-4, default 2): 2

    First sector (12288-3862527, default 12288): 12288
    Last sector, +sectors or +size{K,M,G} (12288-3862527, default 3862527): 3862527
    Partition 2 of type Linux and of size 1.9 GiB is set

    Command (m for help): p

    Disk /dev/sdb: 1977 MB, 1977614336 bytes
    16 heads, 12 sectors/track, 20117 cylinders, total 3862528 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x3c363366

    Device Boot Start End Blocks Id System
    /dev/sdb1 2048 12287 5120 c W95 FAT32 (LBA)
    /dev/sdb2 12288 3862527 1925120 83 Linux

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

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [psl@ocean ~]$ sudo mkfs.ext3 /dev/sdb2
    mke2fs 1.42.3 (14-May-2012)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    120480 inodes, 481280 blocks
    24064 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=494927872
    15 block groups
    32768 blocks per group, 32768 fragments per group
    8032 inodes per group
    Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912

    Allocating group tables: done
    Writing inode tables: done
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information: done

  10. Mount the ext3 partition, change the current directory to the mounted partition directory and unpack the rootfs.cpio image from the project directory to the partition (you will need to issue the command with the root privileges):
  11. [psl@ocean sdcard]$ sudo cpio -iv --no-absolute-filenames < <project path>/rootfs.cpio

  12. Unmount the SD Card partition, extract the SD card and insert it into the SD card holder on the Vybrid target.
  13. Boot the target to the U-boot prompt.
  14. Update uImage in the Flash. For this, copy <project>.uImage from the project directory to the TFTP directory on the TFTP server; set the image U-boot variable to the name of the uImage; and issue the run update command in U-boot.
  15. Check if the qspiboot variable is present in the U-boot environment:
  16. Vybrid U-Boot> printenv qspiboot
    qspiboot=qspi probe 1;cp.b 20080000 ${loadaddr} ${flashsize};run
    addip;bootm

    If the command exits with the ## Error: "qspiboot" not defined message, the qspiboot variable must be added to the environment.

    For VF6-SOM rev. 2A and later the variable must be defined as follows:

    Vybrid U-Boot> setenv qspiboot qspi probe 1\;cp.b 20080000
    \$\{loadaddr\} \$\{flashsize\}\;run addip\;bootm
    Vybrid U-Boot> saveenv

    For VF6-SOM rev 1A, the variable must be defined as follows:

    Vybrid U-Boot> setenv qspiboot qspi probe 1\;cp.b 20040000
    \$\{loadaddr\} \$\{flashsize\}\;run addip\;bootm
    Vybrid U-Boot> saveenv

  17. Add the following variable in U-boot and save the environment:
  18. Vybrid U-Boot > setenv sdboot set bootargs \$\{bootargs\} \
    root=/dev/mmcblk0p2 rw rootwait\;run qspiboot

    Vybrid U-Boot > saveenv

    Note that /dev/mmcblk0p2 matches the 2nd partition on SD card. This must be modified if another partition is used for the rootfs (/dev/mmcblk0p1 for 1st partition, /dev/mmcblk0p3 for 3rd, and so on).

  19. To boot Linux with the root FS on the SD card, issue the following command in U-boot:
  20. Vybrid U-Boot > run sdboot