SD Card Partitioning Print

 

The Emcraft Linux software distribution for the NXP i.MX RT1050 EVK assumes the following utilization of the SD card storage:

Start sector End sector Size _. Description
0 0 1KB MBR. Master Boot Record, which holds the SD partition table
2 2047 ~1MB U-Boot
2048 32767 15MB Partition 1: FAT with U-Boot env, uImage, and other system files
... ... ... Optional: any other partitions (2..N)


To format your SD card, use the standard fdisk utility. As all operations are made with root permissions, please be carefull, and verify the destination /dev/sdX to avoid corruption of your system drives.

Here is how the SD card should be formatted for use with the NXP i.MX RT1050 EVK. The procedure below assumes that you have already installed the U-Boot image into the SD Card (Installing U-Boot to the NXP i.MX RT1050 EVK board). However this is not a requirement: U-Boot is located in separate sectors of the SD Card, so you may install U-Boot either before, or after the procedure described below.

  1. Remove the SD Card from the NXP EVK board. Plug it into the Linux PC, either directly or using an USB-to-SD card converter.
  2. Find out a /dev/sdX device the system has assigned to your SD Card:
  3. $ dmesg | tail
    sd 1:0:0:0: [sdb] 31116288 512-byte logical blocks: (15.9GB/14.8 GiB)
    sd 1:0:0:0: [sdb] Cache data unavailable
    sd 1:0:0:0: [sdb] Assuming drive cache: write through
    sd 1:0:0:0: [sdb] Cache data unavailable
    sd 1:0:0:0: [sdb] Assuming drive cache: write through
    sdb: sdb1 sdb2 < > sdb3

  4. Use the /dev/sdX as the parameter for fdisk command. Verify that you specify the correct /dev/sdX before proceeding:

    $ sudo fdisk /dev/sdb

    Command (m for help):

    • Determine which partitions exist on the SD Card using the p command in the fdisk shell:
    • Command (m for help): p
      Disk /dev/sdb: 15.9 GB, 15931539456 bytes
      64 heads, 32 sectors/track, 15193 cylinders, total 31116288 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: 0x37ebc1ca
      Device Boot Start End Blocks Id System
      /dev/sdb1 2048 2099199 1048576 b W95 FAT32
      /dev/sdb2 2099200 6293503 2097152 85 Linux extended
      /dev/sdb3 6293504 31116287 12411392 83 Linux
      Command (m for help):

    • Remove all partitions using the d command:

      Command (m for help): d
      Partition number (1-5): 3
      Command (m for help): d
      Partition number (1-5): 2
      Command (m for help): d
      Selected partition 1
      Command (m for help): p
      Disk /dev/sdb: 15.9 GB, 15931539456 bytes
      64 heads, 32 sectors/track, 15193 cylinders, total 31116288 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: 0x37ebc1ca
      Device Boot Start End Blocks Id System
      Command (m for help):

    • Use the n command to create a new primary (p) first (1) partition in 2048 .. 32767 sectors:
    • Command (m for help): n
      Partition type:
      p primary (0 primary, 0 extended, 4 free)
      e extended
      Select (default p): p
      Partition number (1-4, default 1): 1
      First sector (2048-31116287, default 2048): 2048
      Last sector, +sectors or +size{K,M,G} (2048-31116287, default 31116287): 32767
      Command (m for help):

    • Use the t command to specify the correct b (Win95 FAT32) system type for the partition:
    • Command (m for help): t
      Selected partition 1
      Hex code (type L to list codes): b
      Changed system type of partition 1 to b (W95 FAT32)
      Command (m for help):

    • Validate that everything is correct using the p command:
    • Command (m for help): p
      Disk /dev/sdb: 15.9 GB, 15931539456 bytes
      64 heads, 32 sectors/track, 15193 cylinders, total 31116288 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: 0x37ebc1ca
      Device Boot Start End Blocks Id System
      /dev/sdb1 2048 32767 15360 b W95 FAT32
      Command (m for help):

    • Write the partition table to the SD card with 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.
      $

  5. Build a FAT file-system on the just created partition on the SD Card:
  6. $ sudo mkfs.vfat /dev/sdb1
    mkfs.fat 3.0.26 (2014-03-07)

  7. Validate that you can mount the FAT file-system on the SD Card. Then flush system caches, and safely remove the SD Card from Linux PC:
  8. $ sudo mount /dev/sdb1 /mnt/
    $ ls -l /mnt/
    total 0
    $ sudo umount /mnt
    $ sync

  9. Insert the SD Card back to the SD Card holder on the NXP EVK board. Power on the EVK board. On the first boot observe the expected message Unable to read uboot.env from mmc0:1:
  10. U-Boot 2017.09-rc1-gdf312544d6 (Oct 13 2017 - 23:16:48 +0300)

    CPU: i.MX RT105x at 600MHz
    Model: NXP i.RT1050 EVK
    DRAM: 32 MiB
    MMC: FSL_SDHC: 0
    reading uboot.env

    ** Unable to read "uboot.env" from mmc0:1 **
    Using default environment

    Video: 480x272x24
    In: serial@40184000
    Out: serial@40184000
    Err: serial@40184000
    Net: eth0: ethernet@402D8000
    reading splash-rt1050-series_24.bmp
    ** Unable to read file splash-rt1050-series_24.bmp **
    reading mxrt105x-evk.ini
    ** Unable to read file mxrt105x-evk.ini **
    Hit any key to stop autoboot: 0
    reading rootfs.uImage
    ** Unable to read file rootfs.uImage **
    =>

    This warning will go away as soon as you save the environment for the first time:

    => save
    Saving Environment to FAT...
    writing uboot.env
    done
    => reset
    resetting ...

    U-Boot 2017.09-rc1-gdf312544d6 (Oct 13 2017 - 23:16:48 +0300)

    CPU: i.MX RT105x at 600MHz
    Model: NXP i.RT1050 EVK
    DRAM: 32 MiB
    MMC: FSL_SDHC: 0
    reading uboot.env
    Video: 480x272x24
    In: serial@40184000
    Out: serial@40184000
    Err: serial@40184000
    Net: eth0: ethernet@402D8000
    reading splash-rt1050-series_24.bmp
    ** Unable to read file splash-rt1050-series_24.bmp **
    reading mxrt105x-evk.ini
    ** Unable to read file mxrt105x-evk.ini **
    Hit any key to stop autoboot: 0
    reading rootfs.uImage
    ** Unable to read file rootfs.uImage **
    =>

    The other warning messages in the dump above are expected if the special U-Boot files and Linux images are not installed by this moment. Refer to Installing Linux image to SD Card for further details.