DART-6UL USB OTG: Difference between revisions

From Variscite Wiki
No edit summary
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PageHeader|DART-6UL - USB "OTG"}} {{DocImage|category1=DART-6UL|category2=Yocto}} __toc__
{{PageHeader|DART-6UL - USB OTG}} {{DocImage|category1=DART-6UL|category2=Yocto}} __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-6ULCustomBoard.<br>
To use it as peripheral (OTG is not supported in the VAR-6ULCustomBoard) you need to change the value of the dr_mode property, under the usbotg1 node, in the imx6ul-var-dart.dtsi device tree, and assemble a USB Micro-AB receptacle at J23 on the bottom of the VAR-6ULCustomBoard.<br>
To use it as peripheral (OTG is not supported in the VAR-6ULCustomBoard) 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 J23 on the bottom of the VAR-6ULCustomBoard.<br>
<br>
<br>
For example:
For example:<br>
* Get the toolchain and the Linux source code by following the [[DART-6UL_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/imx6ul-var-dart.dtsi:
arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi<br>
<pre>
(in very old kernel releases where this file is not available, you should edit arch/arm/boot/dts/imx6ul-var-dart.dtsi instead)<br>
<syntaxhighlight lang="diff">
  &usbotg1 {
  &usbotg1 {
-      dr_mode = "host";
-      dr_mode = "host";
+      dr_mode = "peripheral";
+      dr_mode = "peripheral";
disable-over-current;
        disable-over-current;
         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 USB1 port under Linux =
Line 23: Line 27:
== 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>

Revision as of 17:20, 12 January 2021

DART-6UL - 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-6ULCustomBoard.
To use it as peripheral (OTG is not supported in the VAR-6ULCustomBoard) 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 J23 on the bottom of the VAR-6ULCustomBoard.

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/imx6ul-imx6ull-var-dart-common.dtsi
(in very old kernel releases where this file is not available, you should edit arch/arm/boot/dts/imx6ul-var-dart.dtsi instead)

 &usbotg1 {
-       dr_mode = "host";
+       dr_mode = "peripheral";
        disable-over-current;
        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 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-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

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