VAR-SOM-MX6 USB OTG: Difference between revisions

From Variscite Wiki
(Add category Debian)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{PageHeader|VAR-SOM-MX6 - USB OTG}} {{DocImage|category1=VAR-SOM-MX6|category2=Yocto}} __toc__
{{PageHeader|VAR-SOM-MX6 - USB OTG}} {{DocImage|category1=Yocto|category2=Debian}} [[Category:VAR-SOM-MX6]] __toc__
= Configuring the USB OTG port under Linux =
= 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.<br>
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.<br>
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>
For implementing full native OTG functionality please see VAR-SOM-MX6 datasheet section 4.7 and VAR-SOLOCustomBoard schematics implementation.
<br>
<br>
<br>
For example:<br>
For example:<br>

Latest revision as of 19:37, 28 April 2023

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".
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

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.