Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX6UL-L/Peripherals/USB OTG

6,351 bytes added, 10:23, 21 April 2021
Created page with "<section begin=History/> {| style="border-collapse:collapse; " !colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History |- !style="border-le..."
<section begin=History/>
{| style="border-collapse:collapse; "
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
|-
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|1.0.0
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Apr 2021
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|First DESK release
|}
<section end=History/>
<section begin=Body/>

==Peripheral USB OTG ==

The USB OTG ports can be configured as Host or Device mode depending on the device tree configuration.

In OTG mode they can be easily tested using the Mass Storage Gadget, which lets the device export a file as a mass storage device to the connected PC.

=== Device tree configuration ===

Here below an example of device tree configuration used on standard DAVE's kit for the [[AXEL ULite SOM]] where USB OTG1 is configured as ''otg'' while the USB OTG2 port is configured in ''host'' mode:

From <code>imx6ul-lynx-som0013.dtsi</code>:

<pre>
&usbotg1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_otg1_id>;
vbus-supply = <&reg_usb_otg1_vbus>;
dr_mode = "otg";
srp-disable;
hnp-disable;
adp-disable;
status = "disabled";
};

&usbotg2 {
vbus-supply = <&reg_usb_otg2_vbus>;
dr_mode = "host";
status = "disabled";
};
...
...
&iomuxc {
...
...
pinctrl_usb_otg1_id: usbotg1idgrp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO00__ANATOP_OTG1_ID 0x17059
>;
};

pinctrl_usb_otg1: usbotg1grp {
fsl,pins = <
MX6UL_PAD_ENET2_RX_DATA0__GPIO2_IO08 0x10b0 /* OTG1 PWR */
MX6UL_PAD_ENET2_RX_DATA1__GPIO2_IO09 0x17059 /* OTG1_OC */
>;
};

pinctrl_usb_otg1_oc: usbotg1grp1 {
fsl,pins = <
MX6UL_PAD_ENET2_RX_DATA0__GPIO2_IO08 0x10b0 /* OTG1 PWR */
MX6UL_PAD_ENET2_RX_DATA1__USB_OTG1_OC 0x17059 /* OTG1_OC */
>;
};

pinctrl_usb_otg2: usbotg2grp {
fsl,pins = <
MX6UL_PAD_ENET2_TX_DATA1__GPIO2_IO12 0x17059 /* OTG2_PWR */
MX6UL_PAD_ENET2_TX_EN__USB_OTG2_OC 0x17059 /* OTG2_OC */
>;
};

pinctrl_usb_otg2_1: usbotg2grp-1 {
fsl,pins = <
MX6UL_PAD_UART3_CTS_B__GPIO1_IO26 0x17059 /* OTG2_PWR */
MX6UL_PAD_UART3_RTS_B__GPIO1_IO27 0x17059 /* OTG2_OC */
>;
};

</pre>

From <code>imx6ul-lynx-som0013-cb002f.dts</code>:

<pre>
&reg_usb_otg1_vbus {
pinctrl-0 = <&pinctrl_usb_otg1_oc>;
};

&usbotg1 {
over-current-active-low;
status = "okay";
};

&usbotg2 {
over-current-active-low;
status = "okay";
};

...
...
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog_gpios>;

imx6ul-lynx {
...
...
pinctrl_usb_otg1: usbotg1grp {
fsl,pins = <
MX6UL_PAD_ENET2_RX_DATA0__GPIO2_IO08 0x10b0 /* OTG1 PWR */
MX6UL_PAD_ENET2_RX_DATA1__USB_OTG1_OC 0x17059 /* OTG1_OC */
>;
};

pinctrl_usb_otg2: usbotg2grp {
fsl,pins = <
MX6UL_PAD_ENET2_TX_DATA1__GPIO2_IO12 0x17059 /* OTG2_PWR */
MX6UL_PAD_ENET2_TX_EN__USB_OTG2_OC 0x17059 /* OTG2_OC */
>;
};

</pre>


===Accessing the peripheral===
====Linux messages at boot time====

<pre class="workstation-terminal">
...
...
[ 3.387128] usb_otg1_vbus: supplied by SWBST
[ 3.418986] usb_otg2_vbus: supplied by SWBST
[ 5.245408] usb_otg1_vbus: disabling
...
...
</pre>

==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====

<pre class="workstation-terminal">
root@imx6qdlxelk:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 15.924 s, 16.9 MB/s
root@imx6qdlxelk:~# mkfs.msdos mass_storage
mkfs.fat 4.1 (2017-01-24)
root@imx6qdlxelk:~# mkdir loop
root@imx6qdlxelk:~# mount -o loop mass_storage loop
root@imx6qdlxelk:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@imx6qdlxelk:~# umount loop
</pre>

then insert the <code>g_mass_storage</code> kernel module driver enabling an Windows PC to see it as a ''removable device''

<pre class="workstation-terminal">
root@imx6qdlxelk:~# modprobe g_mass_storage removable=y file=mass_storage
[ 891.807023] Mass Storage Function, version: 2009/09/11
[ 891.813145] LUN: removable file: (no medium)
[ 891.818901] LUN: removable file: /home/root/mass_storage
[ 891.824754] Number of LUNs=1
[ 891.827901] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 891.834955] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 891.842109] g_mass_storage gadget: g_mass_storage ready
root@imx6qdlxelk:~#
</pre>

Once the USB cable is connected to the PC, the kernel prints the following messages:

<pre class="workstation-terminal">
root@imx6qdlxelk:~# [ 892.036840] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
</pre>

and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).

=== Additional information ===

More information about Mass Storage Gadget driver is given in the kernel tree under ''Documentation/usb/mass-storage.txt''

<section end=Body/>

----

[[Category:AXEL ULite]]
8,226
edits