Personal tools

Difference between revisions of "1-1-1-1-3-1-21"

From ICOP tech wiki

Jump to: navigation, search
(Created page with " <div id="column-content"> <div id="content"> <a id="top"></a> <h1 id="firstHeading" class="firstHeading">DART-MX8M USB OTG</h1> <div id="bodyContent">...")
 
 
Line 1: Line 1:
<div id="column-content">
+
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default
<div id="content">
+
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
<a id="top"></a>
+
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_SUMO_V1.0_DART-MX8M}}}} <!--
<h1 id="firstHeading" class="firstHeading">DART-MX8M USB OTG</h1>
+
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_N7.1.1_1.0.0_VAR-SOM-MX6}}}} <!--
<div id="bodyContent">
+
--> {{PageHeader|{{#var:HARDWARE_NAME}} USB OTG}} {{DocImage|category1=Yocto|category2=Android}}[[Category:DART-MX8M]][[Category:DART-MX8M-MINI]] __toc__
<h3 id="siteSub">From Variscite Wiki</h3>
 
<div id="contentSub"></div>
 
<div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content -->
 
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><p><br />                                                                                         
 
<span style="font-size:16pt;">DART-MX8M-MINI USB OTG</span>
 
</p>
 
<hr /> <div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 
<ul>
 
<li class="toclevel-1 tocsection-1"><a href="#Configuring_the_USB_OTG_port_under_Linux"><span class="tocnumber">1</span> <span class="toctext">Configuring the USB OTG port under Linux</span></a></li>
 
<li class="toclevel-1 tocsection-2"><a href="#Using_the_USB_OTG_port_under_Linux"><span class="tocnumber">2</span> <span class="toctext">Using the USB OTG port under Linux</span></a>
 
<ul>
 
<li class="toclevel-2 tocsection-3"><a href="#As_host_.28default.29"><span class="tocnumber">2.1</span> <span class="toctext">As host (default)</span></a></li>
 
<li class="toclevel-2 tocsection-4"><a href="#As_peripheral"><span class="tocnumber">2.2</span> <span class="toctext">As peripheral</span></a></li>
 
<li class="toclevel-2 tocsection-5"><a href="#As_OTG"><span class="tocnumber">2.3</span> <span class="toctext">As OTG</span></a></li>
 
</ul>
 
</li>
 
</ul>
 
</div>
 
  
<h1><span class="mw-headline" id="Configuring_the_USB_OTG_port_under_Linux"><span class="mw-headline-number">1</span> Configuring the USB OTG port under Linux</span></h1>
+
= Configuring the USB OTG port under Linux =
<p>By default, the USB OTG port is configured as OTG in the device tree, and a USB type-C receptacle is assembled on the DART-MX8M custom board.<br>
+
By default, the USB OTG port is configured as OTG in the device tree, and a USB type-C receptacle is assembled on the DART-MX8M custom board.<br>
 
To use it as host only or peripheral only you need to change the value of the dr_mode property under the USB node in the device tree.<br>
 
To use it as host only or peripheral only you need to change the value of the dr_mode property under the USB node in the device tree.<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>
Line 30: Line 12:
 
For example:<br>
 
For example:<br>
 
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>
 
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>
arch/arm64/boot/dts/freescale/fsl-imx8mm-var-dart.dts <br>
+
arch/arm64/boot/dts/{{#ifeq: {{#var:HARDWARE_NAME}}|DART-MX8M|{{#ifeq: {{#var:YOCTO_NAME}}|Morty|variscite/imx8m-var-dart-common.dtsi|freescale/fsl-imx8mq-var-dart-common.dtsi}}|freescale/fsl-imx8mm-var-dart.dts}} <br>
</p>
+
 
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr"><div class="diff source-diff"><pre class="de1">&amp;usbotg1 <span class="br0">&#123;</span>
+
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |
<span class="re7">-&#9;dr_mode = &quot;otg&quot;;</span>
+
<syntaxhighlight lang="diff">
<span class="re8">+      dr_mode = &quot;host&quot;;</span>
+
&usb_dwc3_0 {
&#9;picophy,pre-emp-curr-control = &lt;<span class="nu0">3</span>&gt;;
+
        status = "okay";
&#9;picophy,dc-vol-level-adjust = &lt;<span class="nu0">7</span>&gt;;
+
        extcon = <&typec_ptn5150>;
&#9;status = &quot;okay&quot;;
+
-       dr_mode = "otg";
<span class="br0">&#125;</span>;</pre></div></div>
+
+      dr_mode = "host";
<p>If you build the kernel manually from source code, you should build <i>only</i> the device trees and copy them to your SD card or eMMC.<br>
+
};
 +
</syntaxhighlight>
 +
|
 +
<syntaxhighlight lang="diff">
 +
&usbotg1 {
 +
- dr_mode = "otg";
 +
+      dr_mode = "host";
 +
picophy,pre-emp-curr-control = <3>;
 +
picophy,dc-vol-level-adjust = <7>;
 +
status = "okay";
 +
};
 +
</syntaxhighlight>
 +
}}
 +
 
 +
If you build the kernel manually from source code, you should build ''only'' the device trees and copy them to your SD card or eMMC.<br>
 
<br>
 
<br>
 
Note: You can read the current dr_mode value on a running target, by executing the following command:
 
Note: You can read the current dr_mode value on a running target, by executing the following command:
</p>
+
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |
 +
<pre>
 +
# cat /sys/firmware/devicetree/base/usb@38100000/dwc3/dr_mode; echo
 +
</pre>
 +
|
 
<pre>
 
<pre>
 
# cat /sys/firmware/devicetree/base/usb@32e40000/dr_mode; echo
 
# cat /sys/firmware/devicetree/base/usb@32e40000/dr_mode; echo
 
</pre>
 
</pre>
<h1><span class="mw-headline" id="Using_the_USB_OTG_port_under_Linux"><span class="mw-headline-number">2</span> Using the USB OTG port under Linux</span></h1>
+
}}
<h2><span class="mw-headline" id="As_host_.28default.29"><span class="mw-headline-number">2.1</span> As host (default)</span></h2>
+
 
<p><a href="/index.php?title=IMX_USB_Host" title="IMX USB Host">USB host</a>
+
= Using the USB OTG port under Linux =
</p>
+
== As host (default) ==
<h2><span class="mw-headline" id="As_peripheral"><span class="mw-headline-number">2.2</span> As peripheral</span></h2>
+
[[IMX_USB_Host|USB host]]
<p>In order to use the board as a peripheral, an appropriate module needs to be loaded.<br>
+
 
 +
== As peripheral ==
 +
{{#ifeq: {{#var:ANDROID_NAME}} | Pie |
 +
By default Android configures USB peripheral as ADB, if connected Type - C plug to Standard-A plug cable between board and PC it configures
 +
{{#var:HARDWARE_NAME}} as gadget. <br>
 +
Connect a type-C plug to Standard-A plug cable between the board and a PC <br>
 +
$ adb devices
 +
You should see below output
 +
 
 +
$ adb devices
 +
List of devices attached
 +
0a2299d4e6fe1111        device
 +
|
 +
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, a mass storage gadget called g_mass_storage, a serial gadget called g_serial, etc.<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 root partition on eMMC to a PC while booting from recovery SD card:<br>
 
Example using the g_mass_storage module to expose the root partition on eMMC to a PC while booting from recovery SD card:<br>
 
Connect a type-C plug to Standard-A plug cable between the board and a PC, and run the following on the board:
 
Connect a type-C plug to Standard-A plug cable between the board and a PC, and run the following on the board:
</p>
+
# umount /dev/{{#var:EMMC_ROOTFS_DEV}}p1
<pre># umount /dev/mmcblk2p1
+
# modprobe g_mass_storage file=/dev/{{#var:EMMC_ROOTFS_DEV}}p1
# modprobe g_mass_storage file=/dev/mmcblk2p1
 
 
</pre>
 
</pre>
</pre>
+
The partition should be loaded on the PC as a mass storage device.
<p>The partition should be loaded on the PC as a mass storage device.
+
}}
</p>
+
 
<h2><span class="mw-headline" id="As_OTG"><span class="mw-headline-number">2.3</span> As OTG</span></h2>
+
== As OTG ==
<p>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 flash drive) to it, either use a peripheral with type-C connector or use type-C to type-A adapter.<br>
 
In order to use it as a host and connect a peripheral (e.g. a USB flash drive) to it, either use a peripheral with type-C connector or use type-C to type-A adapter.<br>
 
In order to use it as a peripheral and connect it to a PC, for example, a cable with a type-C 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 type-C plug on one end and a Standard-A plug on the other is needed.<br>
 
<br>
 
<br>
</p>
 

Latest revision as of 16:24, 10 March 2020

                                                                                         Android Platform Customization  

DART-MX8M USB OTG


Configuring the USB OTG port under Linux

By default, the USB OTG port is configured as OTG in the device tree, and a USB type-C receptacle is assembled on the DART-MX8M custom board.
To use it as host only or peripheral only you need to change the value of the dr_mode property under the USB node in the device tree.
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/arm64/boot/dts/freescale/fsl-imx8mq-var-dart-common.dtsi

<syntaxhighlight lang="diff">

&usb_dwc3_0 {
       status = "okay";
       extcon = <&typec_ptn5150>;

- dr_mode = "otg"; + dr_mode = "host"; }; </syntaxhighlight>

If you build the kernel manually from source code, you should build only the device trees and copy them to your SD card or eMMC.

Note: You can read the current dr_mode value on a running target, by executing the following command:

# cat /sys/firmware/devicetree/base/usb@38100000/dwc3/dr_mode; echo

Using the USB OTG 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 root partition on eMMC to a PC while booting from recovery SD card:
Connect a type-C 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 flash drive) to it, either use a peripheral with type-C connector or use type-C to type-A adapter.
In order to use it as a peripheral and connect it to a PC, for example, a cable with a type-C plug on one end and a Standard-A plug on the other is needed.