VAR-SOM-MX6 Android USB OTG

From Variscite Wiki
VAR-SOM-MX6 - USB OTG

Configuring the USB OTG port under Android

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".
For implementing full native OTG functionality please see VAR-SOM-MX6 datasheet section 4.7 and VAR-SOLOCustomBoard schematics 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

Default Gadget

By default VAR-SOM-MX6 , DART-MX6 and VAR-SOM-SOLO/DUAL have USB OTG configured as gadget for ADB function. Refer to Android_Setup_for_ADB_and_Fastboot

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.