VAR-SOM-MX6 USB OTG: Difference between revisions

From Variscite Wiki
(Created page with "{{PageHeader|VAR-SOM-MX6 - USB OTG}} {{DocImage|category1=VAR-SOM-MX6|category2=Yocto}} __toc__ = Configuring the USB OTG port under Linux = The USB OTG port configuration as ...")
 
(Add category Debian)
 
(22 intermediate revisions by 3 users 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>
dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"<br>
dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"<br>
Note: in the VAR-MX6CustomBoard "otg" is not supported - only "host" and "peripheral".<br>
<br>
<br>
For example:
Note: for the VAR-MX6CustomBoard "otg" is not supported - only "host" and "peripheral".<br>
* Get the toolchain and the Linux source code by following the [[VAR-SOM-MX6_Yocto_Jethro_R4_Build_Linux_out_of_tree|Build Linux from source code]] guide.
For implementing full native OTG functionality please see VAR-SOM-MX6 datasheet section 4.7 and VAR-SOLOCustomBoard schematics implementation.
* Edit the appropriate device tree for your board (imx6dl-var-som-solo-vsc.dts / imx6qdl-var-dart.dtsi / imx6qdl-var-som.dtsi / imx6q-var-som-vsc.dts):
<br>
<pre>
<br>
For example:<br>
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<br>
(imx6dl-var-som-solo-vsc.dts / imx6q-var-dart.dts / imx6qdl-var-som.dtsi / imx6q-var-som-vsc.dts):<br>
<syntaxhighlight lang="diff">
&usbotg {
&usbotg {
         vbus-supply = <&reg_usb_otg_vbus>;
         vbus-supply = <&reg_usb_otg_vbus>;
Line 19: Line 22:
         status = "okay";
         status = "okay";
};
};
</pre>
</syntaxhighlight>
* Continue following the Build Linux from source code guide to build the device trees only and to copy them to your SD card.
If you build the kernel manually from source code, you should build ''only'' the device trees and copy them to your SD card.<br>
<br>
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 USB1 port under Linux =
= Using the USB OTG port under Linux =
== As host (default) ==
== As host ==
[[IMX_USB_Host|USB host]]
See [[IMX_USB_Host|USB host]] section.


== As peripheral ==
== As peripheral ==
In order to use the board as a peripheral, an appropriate module needs to be loaded.<br>
In order to use the board as a peripheral, an appropriate module needs to be loaded.<br>
For example, there is an Ethernet gadget module called g_ether, and a mass storage gadget called g_mass_storage.<br>
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.<br>
<br>
<br>
Example using the g_mass_storage module to expose the BOOT partition on our recovery SD card to a PC:<br>
Example using the g_mass_storage module to expose the BOOT partition on our recovery SD card to a PC:<br>
Connect a micro-A plug to Standard-A plug cable between the board and a PC, and run the following on the board:
Connect a micro-B plug to Standard-A plug cable between the board and a PC, and run the following on the board:
<pre>
<pre>
# umount /dev/mmcblk0p1
# umount /dev/mmcblk0p1
# modprobe g_mass_storage file=/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.
</pre>  
</pre>  
The partition should be loaded on the PC as a mass storage device.
The partition should be loaded on the PC as a mass storage device.
Line 41: Line 49:
With OTG, the board can be either a host, or a peripheral.<br>
With OTG, the board can be either a host, or a peripheral.<br>
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).<br>
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).<br>
In order to use it as a peripheral and connect it to a PC, for example, a cable with a micro-A plug on one end and a Standard-A plug on the other is needed.<br>
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.<br>
<br>
<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.