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

From DAVE Developer's Wiki
Jump to: navigation, search
m (Minor update for DESK MX6UL 4.0.0 rel)
Line 11: Line 11:
 
| 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" |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" |3.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" |2.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" |Mar 2022
 
| 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" |Mar 2022
 
| 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 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:#edf8fb; padding:5px; color:#000000" |DESK 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:#edf8fb; padding:5px; color:#000000" |3.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 2023
 +
| 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 4.0.0 release
 
|}
 
|}
 
<section end="History" />
 
<section end="History" />
Line 68: Line 72:
 
...
 
...
 
...
 
...
[    3.691938] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
+
[    3.458609] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
[    3.700663] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
+
[    3.467126] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    3.708200] usb usb2: Product: EHCI Host Controller
+
[    3.474528] usb usb1: Product: EHCI Host Controller
[    3.713101] usb usb2: Manufacturer: Linux 5.10.35-desk-mx6ul-l-3.0.0+g48931d32962e ehci_hcd
+
[    3.479474] usb usb1: Manufacturer: Linux 5.15.71-desk-mx6ul-l-4.0.0-rc1+gb3b0d0fd0042 ehci_hcd
[    3.721517] usb usb2: SerialNumber: ci_hdrc.1
+
[    3.488899] usb usb1: SerialNumber: ci_hdrc.1
 
...
 
...
 
...
 
...
Line 82: Line 86:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
86.792011] usb 1-1: new high-speed USB device number 3 using ci_hdrc
+
94.701909] usb 1-1: new high-speed USB device number 2 using ci_hdrc
86.994587] usb 1-1: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00
+
94.910476] usb 1-1: New USB device found, idVendor=13fe, idProduct=6700, bcdDevice= 1.10
87.003001] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
+
94.910584] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
87.010294] usb 1-1: Product: SanDisk 3.2Gen1
+
94.910651] usb 1-1: Product: USB DISK 3.0
87.021695] usb 1-1: Manufacturer: USB
+
94.910695] usb 1-1: Manufacturer: Wilk
87.028329] usb 1-1: SerialNumber: 03017128082020175157
+
94.910741] usb 1-1: SerialNumber: 07012533C2BE5935
87.044709] usb-storage 1-1:1.0: USB Mass Storage device detected
+
94.932930] usb-storage 1-1:1.0: USB Mass Storage device detected
87.065893] scsi host0: usb-storage 1-1:1.0
+
94.941189] scsi host0: usb-storage 1-1:1.0
88.094462] scsi 0:0:0:0: Direct-Access     USB     SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
+
96.015256] scsi 0:0:0:0: Direct-Access     Wilk    USB DISK 3.0    PMAP PQ: 0 ANSI: 6
88.114699] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
+
96.025192] sd 0:0:0:0: [sda] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
88.138282] sd 0:0:0:0: [sda] Write Protect is off
+
96.026459] sd 0:0:0:0: [sda] Write Protect is off
88.153463] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
+
96.026506] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
88.228657]  sda: sda1
+
[  96.027841] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
88.248736] sd 0:0:0:0: [sda] Attached SCSI removable disk
+
96.093511]  sda: sda1 sda2
[  90.031956] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
+
96.105339] sd 0:0:0:0: [sda] Attached SCSI removable disk
 
</pre>
 
</pre>
  
Line 102: Line 106:
  
 
<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-lynx:~# 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.593427 s, 56.5 MB/s
+
33554432 bytes (34 MB, 32 MiB) copied, 0.573118 s, 58.5 MB/s
 
root@desk-mx6ul-lynx:~# mkfs.msdos mass_storage
 
root@desk-mx6ul-lynx:~# mkfs.msdos mass_storage
 
mkfs.fat 4.2 (2021-01-31)
 
mkfs.fat 4.2 (2021-01-31)
 
root@desk-mx6ul-lynx:~# mkdir loop
 
root@desk-mx6ul-lynx:~# mkdir loop
 
root@desk-mx6ul-lynx:~# mount -o loop mass_storage loop
 
root@desk-mx6ul-lynx:~# mount -o loop mass_storage loop
txtt@desk-mx6ul-lynx:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
+
root@desk-mx6ul-lynx:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx6ul-lynx:~# umount loop/
 
root@desk-mx6ul-lynx:~# umount loop/
 
</pre>
 
</pre>
Line 119: Line 123:
 
root@desk-mx6ul-lynx:~# modprobe g_mass_storage removable=y file=mass_storage
 
root@desk-mx6ul-lynx:~# modprobe g_mass_storage removable=y file=mass_storage
 
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
 
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
205.107477] Mass Storage Function, version: 2009/09/11
+
166.355438] Mass Storage Function, version: 2009/09/11
205.107514] LUN: removable file: (no medium)
+
166.355484] LUN: removable file: (no medium)
205.107758] LUN: removable file: /home/root/mass_storage
+
166.355723] LUN: removable file: /home/root/mass_storage
205.107775] Number of LUNs=1
+
166.355748] Number of LUNs=1
205.113207] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
+
166.365515] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
205.113238] g_mass_storage gadget: userspace failed to provide iSerialNumber
+
166.365556] g_mass_storage gadget: userspace failed to provide iSerialNumber
205.113253] g_mass_storage gadget: g_mass_storage ready
+
166.365572] g_mass_storage gadget: g_mass_storage ready
 
</pre>
 
</pre>
  

Revision as of 15:22, 3 April 2023

History
Version Issue Date Notes

1.0.0

Apr 2021 First DESK release
2.0.0 Mar 2022 DESK 3.0.0 release
3.0.0 Apr 2023 DESK 4.0.0 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-lynx-som0013-cb002f.dts:

		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 */
			>;
		};
	};
};

and from imx6ul-lynx-som0013.dtsi:


		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 */
			>;
		};

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    3.458609] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
[    3.467126] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    3.474528] usb usb1: Product: EHCI Host Controller
[    3.479474] usb usb1: Manufacturer: Linux 5.15.71-desk-mx6ul-l-4.0.0-rc1+gb3b0d0fd0042 ehci_hcd
[    3.488899] usb usb1: SerialNumber: ci_hdrc.1
...
...

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.)

[   94.701909] usb 1-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
[   94.910584] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   94.910651] usb 1-1: Product: USB DISK 3.0
[   94.910695] usb 1-1: Manufacturer: Wilk
[   94.910741] usb 1-1: SerialNumber: 07012533C2BE5935
[   94.932930] usb-storage 1-1:1.0: USB Mass Storage device detected
[   94.941189] scsi host0: usb-storage 1-1:1.0
[   96.015256] scsi 0:0:0:0: Direct-Access     Wilk     USB DISK 3.0     PMAP PQ: 0 ANSI: 6
[   96.025192] sd 0:0:0:0: [sda] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
[   96.026459] sd 0:0:0:0: [sda] Write Protect is off
[   96.026506] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
[   96.027841] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   96.093511]  sda: sda1 sda2
[   96.105339] sd 0:0:0:0: [sda] Attached SCSI removable disk

Usage with mass-storage[edit | edit source]

root@desk-mx6ul-lynx:~# 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, 0.573118 s, 58.5 MB/s
root@desk-mx6ul-lynx:~# mkfs.msdos mass_storage
mkfs.fat 4.2 (2021-01-31)
root@desk-mx6ul-lynx:~# mkdir loop
root@desk-mx6ul-lynx:~# mount -o loop mass_storage loop
root@desk-mx6ul-lynx:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx6ul-lynx:~# 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-lynx:~# modprobe g_mass_storage removable=y file=mass_storage
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
[  166.355438] Mass Storage Function, version: 2009/09/11
[  166.355484] LUN: removable file: (no medium)
[  166.355723] LUN: removable file: /home/root/mass_storage
[  166.355748] Number of LUNs=1
[  166.365515] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  166.365556] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  166.365572] g_mass_storage gadget: g_mass_storage ready

Once the USB cable is connected to the PC, the storage is mounted and the usb.txt file is available:

$ cat /media/tomzy/42D5-CBA5/usb.txt 
Test USB OTG with mass storage device

The Windows PC also 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.rst