Difference between revisions of "DESK-MX6UL-L/Peripherals/USB OTG"

From DAVE Developer's Wiki
Jump to: navigation, search
m (U0007 moved page DESK-MX6UL-L/Pheripherals/USB OTG to DESK-MX6UL-L/Peripherals/USB OTG without leaving a redirect)
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<section begin="History" />
+
<section begin=History/>
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History
+
!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" |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"|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" |Notes
+
!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" |{{oldid|14250|2021/07/20}}
+
|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" |First DESK-MX6UL-L release
+
|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
| 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" |{{oldid|16316|2022/03/16}}
 
| 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" |DESK-MX6UL-L 3.0.0 release
 
|-
 
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |2023/05/04
 
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX6UL-L 4.0.0 release
 
 
|}
 
|}
<section end="History" />
+
<section end=History/>
<section begin="Body" />
+
<section begin=Body/>
  
 
==Peripheral USB OTG ==
 
==Peripheral USB OTG ==
Line 22: Line 18:
 
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.
 
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.
  
{{ImportantMessage|text=The USB OTG peripheral is not available - ''as default option'' - on [[AXEL_ULite_SOM/AXEL_ULite_Evaluation_Kit | AXEL ULite EVK]]. Please contact [mailto:sales@dave.eu Sales department] for this option.<br>
+
{{ImportantMessage|text=The USB OTG peripheral is not available - ''as default option'' - on [[AXEL_ULite_SOM/AXEL_ULite_Evaluation_Kit | AXEL ULite EVK]]. Please contact [mailto:sales@dave.eu Sales department] for this option}}
 
This peripheral is available on the i.MX6UL standard product [[SBC_Lynx_SBC | SBCLynx]]}}
 
This peripheral is available on the i.MX6UL standard product [[SBC_Lynx_SBC | SBCLynx]]}}
  
Line 29: Line 25:
 
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:
 
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-cb002f.dts</code>:
+
From <code>imx6ul-axelulite-cb003a.dts</code>:
  
 
<pre>
 
<pre>
pinctrl_usb_otg2: usbotg2grp {
+
&usbotg2 {
fsl,pins = <
+
        vbus-supply = <&reg_usb_otg2_vbus>;
MX6UL_PAD_ENET2_TX_DATA1__GPIO2_IO12    0x17059 /* OTG2_PWR */
+
        pinctrl-names = "default";
MX6UL_PAD_ENET2_TX_EN__USB_OTG2_OC      0x17059 /* OTG2_OC */
+
        pinctrl-0 = <&pinctrl_usb_otg2_id>;
>;
+
        disable-over-current;
};
+
        dr_mode = "host";
};
+
        status = "okay";
 
};
 
};
</pre>
+
...
 
+
...
and from <code>imx6ul-lynx-som0013.dtsi</code>:
+
&iomuxc {
 
+
...
<pre>
+
...
 
+
        usb {
pinctrl_usb_otg2: usbotg2grp {
+
                pinctrl_usb_otg2_id: usbotg2idgrp {
fsl,pins = <
+
                        fsl,pins = <
MX6UL_PAD_ENET2_TX_DATA1__GPIO2_IO12    0x17059 /* OTG2_PWR */
+
                                MX6UL_PAD_ENET2_TX_CLK__ANATOP_OTG2_ID  0x17059         /* OTG ID */
MX6UL_PAD_ENET2_TX_EN__USB_OTG2_OC      0x17059 /* OTG2_OC */
+
                        >;
>;
+
                };
};
+
                pinctrl_usb_otg2: usbotg2grp {
 
+
                        fsl,pins = <
pinctrl_usb_otg2_1: usbotg2grp-1 {
+
                                MX6UL_PAD_GPIO1_IO02__GPIO1_IO02        0x17059         /* OTG PWR */
fsl,pins = <
+
                                MX6UL_PAD_UART2_CTS_B__GPIO1_IO22      0x10b0          /* OTG OC */
MX6UL_PAD_UART3_CTS_B__GPIO1_IO26 0x17059 /* OTG2_PWR */
+
                        >;
MX6UL_PAD_UART3_RTS_B__GPIO1_IO27 0x17059 /* OTG2_OC */
+
                };
>;
+
        };
};
 
 
 
 
</pre>
 
</pre>
  
Line 68: Line 62:
 
...
 
...
 
...
 
...
[    3.458609] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
+
[    1.939073] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    3.467126] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
+
[    1.945990] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    3.474528] usb usb1: Product: EHCI Host Controller
+
[    1.953298] usb usb2: Product: EHCI Host Controller
[    3.479474] usb usb1: Manufacturer: Linux 5.15.71-desk-mx6ul-l-4.0.0-rc1+gb3b0d0fd0042 ehci_hcd
+
[    1.958211] usb usb2: Manufacturer: Linux 4.14.98-desk-mx6ul-l-1.0.1 ehci_hcd
[    3.488899] usb usb1: SerialNumber: ci_hdrc.1
+
[    1.965426] usb usb2: SerialNumber: ci_hdrc.1
 +
[    3.667157] usbcore: registered new interface driver usbhid
 +
[    3.672771] usbhid: USB HID core driver
 
...
 
...
 
...
 
...
Line 82: Line 78:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
94.701909] usb 1-1: new high-speed USB device number 2 using ci_hdrc
+
root@desk-mx6ul-axelulite:~# 40.533219] usb 2-1: new high-speed USB device number 2 using ci_hdrc
94.910476] usb 1-1: New USB device found, idVendor=13fe, idProduct=6700, bcdDevice= 1.10
+
40.775605] usb 2-1: New USB device found, idVendor=0951, idProduct=1665
94.910584] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
+
40.782554] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
94.910651] usb 1-1: Product: USB DISK 3.0
+
40.797569] usb 2-1: Product: DataTraveler 2.0
94.910695] usb 1-1: Manufacturer: Wilk
+
40.802174] usb 2-1: Manufacturer: Kingston
94.910741] usb 1-1: SerialNumber: 07012533C2BE5935
+
40.813793] usb 2-1: SerialNumber: 50E549C202681071F97202CB
94.932930] usb-storage 1-1:1.0: USB Mass Storage device detected
+
40.827294] usb-storage 2-1:1.0: USB Mass Storage device detected
94.941189] scsi host0: usb-storage 1-1:1.0
+
40.850364] scsi host0: usb-storage 2-1:1.0
96.015256] scsi 0:0:0:0: Direct-Access    Wilk    USB DISK 3.0     PMAP PQ: 0 ANSI: 6
+
41.926319] scsi 0:0:0:0: Direct-Access    Kingston DataTraveler 2.0 0000 PQ: 0 ANSI: 4
96.025192] sd 0:0:0:0: [sda] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
+
41.953445] sd 0:0:0:0: [sda] 15151168 512-byte logical blocks: (7.76 GB/7.22 GiB)
96.026459] sd 0:0:0:0: [sda] Write Protect is off
+
41.976216] sd 0:0:0:0: [sda] Write Protect is off
96.026506] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
+
41.981055] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
96.027841] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
+
42.003870] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
96.093511]  sda: sda1 sda2
+
42.040175]  sda: sda1
96.105339] sd 0:0:0:0: [sda] Attached SCSI removable disk
+
42.063618] sd 0:0:0:0: [sda] Attached SCSI removable disk
 +
 
 +
root@desk-mx6ul-axelulite:~#
 
</pre>
 
</pre>
  
Line 102: Line 100:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-lynx:~# dd if=/dev/zero of=mass_storage count=32 bs=1M  
+
root@desk-mx6ul-axelulite:~# dd if=/dev/zero of=mass_storage count=32 bs=1M
 
32+0 records in
 
32+0 records in
 
32+0 records out
 
32+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 0.573118 s, 58.5 MB/s
+
33554432 bytes (34 MB, 32 MiB) copied, 3.62181 s, 9.3 MB/s
root@desk-mx6ul-lynx:~# mkfs.msdos mass_storage
+
root@desk-mx6ul-axelulite:~# mkfs.msdos mass_storage
mkfs.fat 4.2 (2021-01-31)
+
mkfs.fat 4.1 (2017-01-24)
root@desk-mx6ul-lynx:~# mkdir loop
+
root@desk-mx6ul-axelulite:~# mkdir loop
root@desk-mx6ul-lynx:~# mount -o loop mass_storage loop
+
root@desk-mx6ul-axelulite:~# mount -o loop mass_storage loop
root@desk-mx6ul-lynx:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
+
root@desk-mx6ul-axelulite:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx6ul-lynx:~# umount loop/
+
root@desk-mx6ul-axelulite:~# umount loop
 
</pre>
 
</pre>
  
Line 117: Line 115:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-lynx:~# modprobe g_mass_storage removable=y file=mass_storage
+
root@desk-mx6ul-axelulite:~# modprobe g_mass_storage removable=y file=mass_storage
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
+
137.706620] Mass Storage Function, version: 2009/09/11
166.355438] Mass Storage Function, version: 2009/09/11
+
137.711809] LUN: removable file: (no medium)
166.355484] LUN: removable file: (no medium)
+
137.731390] LUN: removable file: /home/root/mass_storage
166.355723] LUN: removable file: /home/root/mass_storage
+
137.737101] Number of LUNs=1
166.355748] Number of LUNs=1
+
137.740256] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
166.365515] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
+
137.751272] g_mass_storage gadget: userspace failed to provide iSerialNumber
166.365556] g_mass_storage gadget: userspace failed to provide iSerialNumber
+
137.760299] g_mass_storage gadget: g_mass_storage ready
166.365572] g_mass_storage gadget: g_mass_storage ready
+
root@desk-mx6ul-axelulite:~#
 
</pre>
 
</pre>
  
Once the USB cable is connected to the PC, the storage is mounted and the ''usb.txt'' file is available:
+
Once the USB cable is connected to the PC, the kernel prints the following messages:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
$ cat /media/tomzy/42D5-CBA5/usb.txt
+
root@desk-mx6ul-axelulite:~# [  214.837430] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
Test USB OTG with mass storage device
 
 
</pre>
 
</pre>
  
The Windows PC also activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
+
and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
  
 
=== Additional information ===
 
=== Additional information ===
  
More information about Mass Storage Gadget driver is given in the kernel tree under ''Documentation/usb/mass-storage.rst''
+
More information about Mass Storage Gadget driver is given in the kernel tree under ''Documentation/usb/mass-storage.txt''
  
<section end="Body" />
+
<section end=Body/>
  
 
----
 
----
  
 
[[Category:AXEL ULite]]
 
[[Category:AXEL ULite]]

Revision as of 10:40, 16 July 2021

History
Version Issue Date Notes
1.0.0 Apr 2021 First DESK release


Peripheral USB OTG[edit | edit source]

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.


200px-Emblem-important.svg.png

The USB OTG peripheral is not available - as default option - on AXEL ULite EVK. Please contact Sales department for this option

This peripheral is available on the i.MX6UL standard product SBCLynx}}

Device tree configuration[edit | edit source]

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 imx6ul-axelulite-cb003a.dts:

&usbotg2 {
        vbus-supply = <&reg_usb_otg2_vbus>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usb_otg2_id>;
        disable-over-current;
        dr_mode = "host";
        status = "okay";
};
...
...
&iomuxc {
...
...
        usb {
                pinctrl_usb_otg2_id: usbotg2idgrp {
                        fsl,pins = <
                                MX6UL_PAD_ENET2_TX_CLK__ANATOP_OTG2_ID  0x17059         /* OTG ID */
                        >;
                };
                pinctrl_usb_otg2: usbotg2grp {
                        fsl,pins = <
                                MX6UL_PAD_GPIO1_IO02__GPIO1_IO02        0x17059         /* OTG PWR */
                                MX6UL_PAD_UART2_CTS_B__GPIO1_IO22       0x10b0          /* OTG OC */
                        >;
                };
        };

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    1.939073] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    1.945990] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.953298] usb usb2: Product: EHCI Host Controller
[    1.958211] usb usb2: Manufacturer: Linux 4.14.98-desk-mx6ul-l-1.0.1 ehci_hcd
[    1.965426] usb usb2: SerialNumber: ci_hdrc.1
[    3.667157] usbcore: registered new interface driver usbhid
[    3.672771] usbhid: USB HID core driver
...
...

Usage in Host mode[edit | edit source]

When a USB peripheral is inserted, in the following example a memory mass storage device, the kernel recognizes the device (i.e. class, vendor id, product id, etc.)

root@desk-mx6ul-axelulite:~# [   40.533219] usb 2-1: new high-speed USB device number 2 using ci_hdrc
[   40.775605] usb 2-1: New USB device found, idVendor=0951, idProduct=1665
[   40.782554] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   40.797569] usb 2-1: Product: DataTraveler 2.0
[   40.802174] usb 2-1: Manufacturer: Kingston
[   40.813793] usb 2-1: SerialNumber: 50E549C202681071F97202CB
[   40.827294] usb-storage 2-1:1.0: USB Mass Storage device detected
[   40.850364] scsi host0: usb-storage 2-1:1.0
[   41.926319] scsi 0:0:0:0: Direct-Access     Kingston DataTraveler 2.0 0000 PQ: 0 ANSI: 4
[   41.953445] sd 0:0:0:0: [sda] 15151168 512-byte logical blocks: (7.76 GB/7.22 GiB)
[   41.976216] sd 0:0:0:0: [sda] Write Protect is off
[   41.981055] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[   42.003870] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   42.040175]  sda: sda1
[   42.063618] sd 0:0:0:0: [sda] Attached SCSI removable disk

root@desk-mx6ul-axelulite:~#

Usage with mass-storage[edit | edit source]

root@desk-mx6ul-axelulite:~# dd if=/dev/zero of=mass_storage count=32 bs=1M
32+0 records in
32+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 3.62181 s, 9.3 MB/s
root@desk-mx6ul-axelulite:~# mkfs.msdos mass_storage
mkfs.fat 4.1 (2017-01-24)
root@desk-mx6ul-axelulite:~# mkdir loop
root@desk-mx6ul-axelulite:~# mount -o loop mass_storage loop
root@desk-mx6ul-axelulite:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx6ul-axelulite:~# umount loop

then insert the g_mass_storage kernel module driver enabling an Windows PC to see it as a removable device

root@desk-mx6ul-axelulite:~# modprobe g_mass_storage removable=y file=mass_storage
[  137.706620] Mass Storage Function, version: 2009/09/11
[  137.711809] LUN: removable file: (no medium)
[  137.731390] LUN: removable file: /home/root/mass_storage
[  137.737101] Number of LUNs=1
[  137.740256] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  137.751272] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  137.760299] g_mass_storage gadget: g_mass_storage ready
root@desk-mx6ul-axelulite:~#

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

root@desk-mx6ul-axelulite:~# [  214.837430] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage

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

Additional information[edit | edit source]

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