The phyCORE-i.MX7 development kit brings out USB Host and OTG capabilities to the USB 2.0 port at connector X9 and micro-USB port at connector X10 respectively. This guide will walk you through the use of these interfaces.

Step-by-Step Guide

USB Host

Storage devices formatted with a FAT32 file system, when connected, are automatically mounted to "/run/media/sda1". 

 Reformat your Flash Drive to FAT32

This process will erase all data on the flash drive. It is highly recommended to back up the contents of your Flash Drive before following these steps.

  • Connect your Flash Drive to your Windows Host Machine
  • Hit the windows key, type "Disk Management" and then hit Enter.
  • Right click your flash drive and select "Format"

  • Select FAT32 under File System and then press OK.

  • Now right click the device in File Explorer and select Eject to safely disconnect the device from your Host Machine.
  • To verify the mount point of your Flash device using the following command: 

    Target (Linux)

    mount
    CODE

    Pro Tip! Try using this command once before and after connecting the Flash Drive to your hardware. This will make it easy to notice which one is the new one and where it is mounted.

  • Insert a USB storage device into the USB Type-A connector. The mount point should be sda1 in the directory /run/media/ and this can be confirmed in the printed messages output to the console when the device is registered.
  • Generate a random 100 MB file to test writing to and from the storage device. 

    Target (Linux)

    dd if=/dev/urandom of=test1.file count=100 bs=1M
    CODE
  • Copy the file to your storage device:

    Target (Linux)

    cp test1.file /run/media/sda1/ && sync
    CODE
  •  Copy the file back to the root file system: 

    Target (Linux)

    cp /run/media/sda1/test1.file test2.file && sync
    CODE
  • To check that the read file is the same as the one that was written, you can use md5sum to compare and verify the data transfer was successful: 

    Target (Linux)

    md5sum test1.file && md5sum test2.file
    CODE

    The above command will generate a long and seemingly random string of characters for both files. This long string is called a "hash" and it uniquely identifies the files. If the hash for both files match then you can be confident that both files (down to each bit) are identical. 

    Expected Output

    root@imx7d-phyboard-zeta-004:~# md5sum test1.file && md5sum test2.file
    81ad66df7f773128aef1ec7966180ebf  test1.file
    81ad66df7f773128aef1ec7966180ebf  test2.file
    CODE

Removing storage devices

  • Ensure that peripheral devices are unmounted properly before disconnecting to avoid data corruption. Enter the following before disconnecting the storage device. 

    Target (Linux)

    umount /dev/sda1
    CODE

USB OTG

See the end of this guide for further information regarding advanced USB-OTG configurations.

  • Connect a micro-USB cable between your host computer and the micro-USB connector X10 on the Carrier Board.
  • Using your Linux console, type the following to load the g_serial module: 

    Target (Linux)

    modprobe g_serial
    CODE
  • Check that the serial device /dev/ttyGS0 exists: 

    Target (Linux)

    ls /dev/tty*
    CODE

    Expected Output

    root@imx7d-phyboard-zeta-004:~# ls /dev/tty*
    /dev/tty    /dev/tty19  /dev/tty3   /dev/tty40  /dev/tty51  /dev/tty62
    /dev/tty0   /dev/tty2   /dev/tty30  /dev/tty41  /dev/tty52  /dev/tty63
    /dev/tty1   /dev/tty20  /dev/tty31  /dev/tty42  /dev/tty53  /dev/tty7
    /dev/tty10  /dev/tty21  /dev/tty32  /dev/tty43  /dev/tty54  /dev/tty8
    /dev/tty11  /dev/tty22  /dev/tty33  /dev/tty44  /dev/tty55  /dev/tty9
    /dev/tty12  /dev/tty23  /dev/tty34  /dev/tty45  /dev/tty56  /dev/ttyGS0
    /dev/tty13  /dev/tty24  /dev/tty35  /dev/tty46  /dev/tty57  /dev/ttymxc0
    /dev/tty14  /dev/tty25  /dev/tty36  /dev/tty47  /dev/tty58  /dev/ttymxc4
    /dev/tty15  /dev/tty26  /dev/tty37  /dev/tty48  /dev/tty59
    /dev/tty16  /dev/tty27  /dev/tty38  /dev/tty49  /dev/tty6
    /dev/tty17  /dev/tty28  /dev/tty39  /dev/tty5   /dev/tty60
    /dev/tty18  /dev/tty29  /dev/tty4   /dev/tty50  /dev/tty61
    CODE
  • A device named "PI USB to Serial" should have been detected by your Host Machine. In Windows, Device Manager will indicate which COM port number corresponds to it.
  • Begin a new serial console using the COM port found in the previous step.

Sending

  • In the Linux console, enter the following to output a message to the newly opened USB1 console: 

    Target (Linux)

    echo "Testing" > /dev/ttyGS0
    CODE
  • Verify that the USB1 console printed "Testing".

Receiving

  • In the Linux console, enter the following to prepare the phyCORE-i.MX7 to receive messages from the Host: 

    Target (Linux)

    cat /dev/ttyGS0
    CODE
  • Now type something into the USB1 console and verify that it outputs to the Linux console once you hit enter. 
  • Enter Ctrl + C in the Linux console to stop waiting for incoming data.


 Advanced USB-OTG Configurations

USB-OTG Jumper Configurations

Due to the small footprint of the solder jumpers, we recommend using caution when making modifications. Please contact our sales team if you require any options beyond the default configuration.

The phyCORE-i.MX7 provides two solder jumper (J) at J5  and J6 for configuring USB-OTG signal termination.

J51+2 (Default)Routes X_USB_OTG2_DN to the Micro-AB USB connector
2+3Routes X_USB_OTG2_DN to the Mini PCIe connector

J61+2 (Default)Routes X_USB_OTG2_DP to the Micro-AB USB connector
2+3Routes X_USB_OTG2_DP to the Mini PCIe connector