VAR-SOM-MX7 USB OTG: Difference between revisions

From Variscite Wiki
(Add category Debian)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{PageHeader|VAR-SOM-MX7 - USB OTG}} {{DocImage|category1=VAR-SOM-MX7|category2=Yocto}} __toc__
{{PageHeader|VAR-SOM-MX7 - USB OTG}} {{DocImage|category1=Yocto|category2=Debian}} [[Category:VAR-SOM-MX7]] __toc__
= Configuring the USB1 port under Linux =
= Configuring the USB1 port under Linux =
By default, the USB1 port is configured as host in the device tree, and a USB type-A receptacle is assembled on the VAR-MX7CustomBoard.<br>
By default, the USB1 port is configured as host in the device tree, and a USB type-A receptacle is assembled on the VAR-MX7CustomBoard.<br>
To use it as OTG or peripheral you need to change the value of the dr_mode property, under the usbotg1 node, in the imx7d-var-som.dtsi device tree, and assemble a USB Micro-AB receptacle at J27 on the bottom of the VAR-MX7CustomBoard.<br>
To use it as OTG or peripheral you need to change the value of the dr_mode property under the usbotg1 node, in the device tree, and assemble a USB Micro-AB receptacle at J27 on the bottom of the VAR-MX7CustomBoard.<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>
<br>
<br>
For example:
For example:<br>
* Get the toolchain and the Linux source code by following the [[VAR-SOM-MX7_Yocto_Jethro_Build_Linux_out_of_tree|Build Linux from source code]] guide.
Follow either the "Build the Linux kernel from source code" or "Customizing the Linux kernel" Wiki pages and edit the following device tree file:<br>
* Edit arch/arm/boot/dts/imx7d-var-som.dtsi:
arch/arm/boot/dts/imx7d-var-som.dtsi<br>
<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
  &usbotg1 {
  &usbotg1 {
Line 16: Line 16:
  };
  };
</syntaxhighlight>
</syntaxhighlight>
* Continue following the [[VAR-SOM-MX7_Yocto_Jethro_Build_Linux_out_of_tree|Build Linux from source code]] guide to build ''only'' the device trees 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@30800000/usb@30b10000/dr_mode; echo


= Using the USB1 port under Linux =
= Using the USB1 port under Linux =

Latest revision as of 20:38, 28 April 2023

VAR-SOM-MX7 - USB OTG

Configuring the USB1 port under Linux

By default, the USB1 port is configured as host in the device tree, and a USB type-A receptacle is assembled on the VAR-MX7CustomBoard.
To use it as OTG or peripheral you need to change the value of the dr_mode property under the usbotg1 node, in the device tree, and assemble a USB Micro-AB receptacle at J27 on the bottom of the VAR-MX7CustomBoard.
dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"

For example:
Follow either the "Build the Linux kernel from source code" or "Customizing the Linux kernel" Wiki pages and edit the following device tree file:
arch/arm/boot/dts/imx7d-var-som.dtsi

 &usbotg1 {
        vbus-supply = <&reg_usb_otg1_vbus>;
-       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@30800000/usb@30b10000/dr_mode; echo

Using the USB1 port under Linux

As host (default)

USB host

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-A 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

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-A plug on one end and a Standard-A plug on the other is needed.