VAR-SOM-MX6 USB OTG: Difference between revisions

From Variscite Wiki
Line 5: Line 5:
<br>
<br>
Note: for the VAR-MX6CustomBoard "otg" is not supported - only "host" and "peripheral".<br>
Note: for the VAR-MX6CustomBoard "otg" is not supported - only "host" and "peripheral".<br>
‘USB_OTG_ID’ naming of pin 94 follows the VAR-MX6Customboard schematics design naming, however, this SoC ball does not have the alternate function of USB_OTG_ID
required for OTG implementation.<br>
For implementing full native OTG functionality SoC ‘USB_OTG_ID’ and ‘USB_OTG_PWR’ alternate functions should be utilized.<br>
Please see datasheet section 4.7 for pin mux options and VAR-SOLOCustomBoard schematics for implementation.
<br>
<br>
<br>
For example:<br>
For example:<br>

Revision as of 08:26, 22 July 2018

VAR-SOM-MX6 - USB OTG

Configuring the USB OTG port under Linux

The USB OTG port configuration as either host, peripheral or OTG is set in the device tree of the board. It is determined by the value of the dr_mode property under the usbotg node.
dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"

Note: for the VAR-MX6CustomBoard "otg" is not supported - only "host" and "peripheral".
‘USB_OTG_ID’ naming of pin 94 follows the VAR-MX6Customboard schematics design naming, however, this SoC ball does not have the alternate function of USB_OTG_ID required for OTG implementation.
For implementing full native OTG functionality SoC ‘USB_OTG_ID’ and ‘USB_OTG_PWR’ alternate functions should be utilized.
Please see datasheet section 4.7 for pin mux options and VAR-SOLOCustomBoard schematics for implementation.

For example:
Follow either the "Build the Linux kernel from source code" or "Customizing the Linux kernel" Wiki pages and edit the the appropriate device tree for your board
(imx6dl-var-som-solo-vsc.dts / imx6q-var-dart.dts / imx6qdl-var-som.dtsi / imx6q-var-som-vsc.dts):

&usbotg {
        vbus-supply = <&reg_usb_otg_vbus>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usbotg_2>;
        disable-over-current;
        /* dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" */
-       dr_mode = "host";
+       dr_mode = "otg";
        status = "okay";
};

If you build the kernel manually from source code, you should build only the device trees and copy them to your SD card.

Note: You can read the current dr_mode value on a running target, by executing the following command:

# cat /sys/firmware/devicetree/base/soc/aips-bus@02100000/usb@02184000/dr_mode; echo

Using the USB OTG port under Linux

As host

See USB host section.

As peripheral

In order to use the board as a peripheral, an appropriate module needs to be loaded.
For example, there is an Ethernet gadget module called g_ether, a mass storage gadget called g_mass_storage, a serial gadget called g_serial, etc.

Example using the g_mass_storage module to expose the BOOT partition on our recovery SD card to a PC:
Connect a micro-B plug to Standard-A plug cable between the board and a PC, and run the following on the board:

# umount /dev/mmcblk0p1
# modprobe g_mass_storage file=/dev/mmcblk0p1

Note: On the some board configurations the SD card device will be /dev/mmcblk1 instead of /dev/mmcblk0 in the example above.

The partition should be loaded on the PC as a mass storage device.

As OTG

With OTG, the board can be either a host, or a peripheral.
In order to use it as a host and connect a peripheral (e.g. a USB mouse) to it, an OTG cable is needed (a cable with a micro-A plug on one end and a Standard-A receptacle on the other).
In order to use it as a peripheral and connect it to a PC, for example, a cable with a micro-B plug on one end and a Standard-A plug on the other is needed.