Timesys Getting Started Guide for PHYTEC phyFLEX i.MX6


Contents

Introduction

This document will describe in detail the procedures for booting a Linux kernel image and mounting a root file system from an SD Card on the PHYTEC phyFLEX i.MX6.

Prerequisites

Host Requirements

To properly boot the PHYTEC phyFLEX i.MX6 using software from Timesys, your host machine must meet the following requirements:

  • Modern GNU/Linux Distribution. Timesys recommends one of the following distributions:
    • Ubuntu (Most recent release or LTS)
    • Fedora (Most recent release)
  • Root or sudo permission on the Development Host.
  • A copy of the Linux Kernel (uImage-3.0-ts-armv7l) and Root File System (rootfs.tar.gz) for the Target Board downloaded from Factory. These are found in the output directory of your online build, or in the directory build_armv7l-timesys-linux-<libc>/images/ on the command line.
  • A barebox image (barebox-phytec-pbab01-1gib.img) and environment (barebox_default_env), built for your model of the phyFLEX module. For the purposes of this document, we assume the usage of the 1GiB RAM part. These are found in the output directory of your online build, or in the directory build_armv7l-timesys-linux-<libc>/images//bootloader on the command line.
  • An available RS232 Port on your Development Host.
  • A SD card slot or adapter on your Development Host.

Target Requirements

To boot the PHYTEC phyFLEX i.MX6, you will need the following items:

  • PHYTEC phyFLEX i.MX6
  • SD Card
  • Straight-through RS232 Cable
  • Ethernet Crossover Cable or Ethernet hub/switch and Ethernet Patch Cables

Once you have all of the necessary components, you should perform the following steps:

  1. Connect the RS232 Cable to the UART0 port of the phyFLEX i.MX6
  2. If you are using a cross-over cable, connect the Ethernet port of the board to the second Ethernet port of your workstation.
  3. Connect the power supply to your board.
  4. Set aside the SD card, you will need to intialize it from the Development Host before booting the board.
  5. Set the boot switches (S3) located near the reset button. For SD boot, set switches 1-4 to On On Off Off, respectively.

Preparing the Target

Configuring Serial Communication

The phyFLEX i.MX6 uses a serial debug port to communicate with the host machine. The commands discussed in this section are meant to be performed by a privileged user account. This requires the root login or prepending each command with sudo.

Using Minicom

  1. Start minicom on your host machine in configuration mode. As root:

    # minicom -o -s -w

  2. A menu of configuration should appear. Use the Down-arrow key to scroll down and select the Serial port setup option, and press Enter.
  3. Verify that the listed serial port is the same one that is connected to the target board. If it is not, press A, and enter the correct device. This is /dev/ttyS0 on most Linux distributions.
  4. Set the Bps/Par/Bits option by pressing the letter E and using the next menu to set the appropriate values. You press the key that corresponds to the value 115200, then press Enter.
  5. Set Hardware flow control to No using the F key.
  6. Set Software flow control to No using the G key.
  7. Press Enter to return to the main configuration menu, and then press Esc to exit this menu.
  8. Reset the board, and wait for a moment. If you do not see output from the board, press Enter several times until you see the prompt. If you do not see any output from the board, and have verified that the serial terminal connection is setup correctly, contact your board vendor.

TIP: If you experience an error similar to Device /dev/ttyS0 is locked when starting minicom, it usually means that another process is using the serial port (which is usually another instance of minicom). You can find the process that is currently using the serial port by executing the following:

# fuser /dev/ttyS0
/dev/ttyS0:         28358

# ps 28358
  PID TTY      STAT  TIME COMMAND
  28923 pts/0    S+    0:00 minicom

This process can also be killed directly with fuser as root. Please use this command with caution:

# fuser -k /dev/ttyS0

Using GNU Screen

To quickly connect to a board using Gnu Screen, execute the following:

# screen /dev/ttyS0 115200

For more information about using screen, please consult the man page, or view the manual online at http://www.gnu.org/software/screen/manual/screen.html

Preparing the Secure Digital Card

The phyFLEX i.MX6 boots from an SD card. Some kits may be shipped with one that contains a sample kernel and RFS preloaded. We will be replacing these with the kernel and RFS from Factory. If you are using a blank SD card or have trouble replacing the software on the preloaded one, see Partitioning the SD Card. Otherwise, skip directly to Writing Boot Files to the SD Card. Before you begin, you should determine the name of your SD card on your host system. To do so:
  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/sdX, which contains one partition sdX1.
    $ dmesg | tail
    [88050.184080] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
    [88050.184821] sd 4:0:0:0: [sdX] Write Protect is off
    [88050.184824] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
    [88050.184827] sd 4:0:0:0: [sdX] Assuming drive cache: write through
    [88050.185575] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
    [88050.186323] sd 4:0:0:0: [sdX] Write Protect is off
    [88050.186325] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
    [88050.186327] sd 4:0:0:0: [sdX] Assuming drive cache: write through
    [88050.186330]  sdX: sdX1

Partitioning the SD Card

You will use the fdisk tool to partition your SD card. Please note that all data on the card will be lost upon completion of these steps.
  1. Unmount the partition if it was automounted by using the umount command.
    $ sudo umount /dev/sdX*
  2. Next, find the size of your kernel uImage in MB.
    $ du -h uImage-3.0-ts-armv7l
    4.1M    uImage-3.0-ts-armv7l
  3. As root, run the fdisk utility on the drive.
    $ sudo fdisk /dev/sdX
  4. 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 0xf10ac982.
    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)

  5. Create a new 32MB primary partition using the n command. You will need to leave space (8MB) for Barebox and it's environment, so set the first sector to +8MB.

    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-7862271, default 2048): +8M
    Last sector, +sectors or +sizeK,M,G (16384-7862271, default 7862271): +32M

  6. Using the t command, set the partition type to c:

    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))

  7. Create a second primary partition partition using the n command, starting at +40M. It may encompass the remaining space on the SD card.

    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 (2048-7862271, default 2048): +40M
    Last sector, +sectors or +sizeK,M,G (81920-7862271, default 7862271):
    Using default value 7862271

  8. 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/sde: 4025 MB, 4025483264 bytes
    255 heads, 63 sectors/track, 489 cylinders, total 7862272 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: 0x04ba9b9b

       Device Boot      Start         End      Blocks   Id  System
    /dev/sde1           16384       81919       32768    c  W95 FAT32 (LBA)
    /dev/sde2           81920     7862271     3890176   83  Linux

  9. 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.
    Syncing disks.

  10. Format the first partition on the SD card with a vfat filesystem using the mkfs.vfat tool.

    $ sudo /sbin/mkfs.vfat /dev/sdX1 -n boot

  11. Format the second partition on the SD card with an EXT3 filesystem using the mkfs.ext3 tool.

    $ sudo /sbin/mkfs.ext3 /dev/sdX2 -L rfs

Writing the Boot Files to the SD Card

  1. Mount the partitions. You can remove and reinsert the card to trigger the automount, or you can use the mount command to mount the partitions to an arbitrary locations.

    $ sudo mount /dev/sdX1 /media/boot
    $ sudo mount /dev/sdX2 /media/rfs

  2. Copy barebox image and environment to the SD card using the dd command:

    $ sudo dd if=barebox-phytec-pbab01-1gib.img of=/dev/sdX seek=2 bs=512
    706+1 records in
    706+1 records out
    361504 bytes (362 kB) copied, 0.141874 s, 2.5 MB/s
    $ dd if=barebox_default_env of=/dev/sdX bs=512 seek=4096
    31+1 records in
    31+1 records out
    15992 bytes (16 kB) copied, 0.214199 s, 74.7 kB/s

  3. Copy the kernel image to the first partition of the card:

    $ cp uImage-3.0-ts-armv7l /media/boot/linuximage

  4. As root, extract the rootfs.tar.gz archive to the card.

    $ sudo tar xzf rootfs.tar.gz -C /media/rfs

  5. Unmount the card before removing it from the Development Host. Then place the card in the SD0 slot (the left slot when the slots are facing you) on the phyFLEX i.MX6.

    $ sudo umount /dev/sdX*

Preparing the Host

No additional host setup is required to boot from SD.

Booting the Board

By default, Barebox is configured to boot the image from NAND flash. You must interrupt the boot process and manually boot from the SD card.
  • Ensure that the boot switch S3 is set to SD card boot (On On Off Off).
  • Power up or reset the board.
  • Interrupt the boot process by pressing a key before the timer expires.

    Board: Phytec phyFLEX-i.MX6 Quad Carrier-Board
    detected i.MX6 Dual/Quad revision 1.2
    mdio_bus: miibus0: probed
    eth0: got preset MAC address: 50:2D:F4:06:6A:96
    nand: NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit), 1024MiB, page size: 2048, OOB size: 64
    Bad block table found at page 524224, version 0x01
    Bad block table found at page 524160, version 0x01
    m25p80 m25p80@00: n25q128 (16384 Kbytes)
    imx-esdhc 2194000.usdhc: registered as 2194000.usdhc
    imx-esdhc 2198000.usdhc: registered as 2198000.usdhc
    netconsole: registered as cs2
    Module Revision: 2
    Using environment in MMC Flash
    imx6_ocotp imx6_ocotp: probe failed: Device or resource busy
    malloc space: 0x4be00000 -> 0x4fdfffff (size 64 MiB)
    mmc2: registered mmc2
    barebox-environment environment-mmc.9: setting default environment path to /dev/mmc2.barebox-environment
    envfs: wrong magic on /dev/mmc2.barebox-environment
    no valid environment found on /dev/mmc2.barebox-environment. Using default environment
    running /env/bin/init...

    Hit m for menu or any other key to stop autoboot:  3

  • Run the boot sd-ext3 command to boot from the SD card.

    barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ boot sd-ext3

Additional Information

Board Documentation

Factory Documentation