Difference between revisions of "DESK-MX8M-L/Peripherals/USB2 OTG"

From DAVE Developer's Wiki
Jump to: navigation, search
(Updates for DESK-MX8-L 4.0.0 release)
Line 10: Line 10:
 
|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"|30/12/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"|30/12/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-MX8M-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"|First DESK-MX8M-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:#ededed; padding:5px; color:#000000" |{{oldid|17615|17615}}
 +
| 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" |24/02/2023
 +
| 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-MX8M-L-2.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" |{{oldid|17615|17615}}
 
! 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" |{{oldid|17615|17615}}
! 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" |24/02/2023
+
! 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" |26/07/2023
! 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-MX8M-L-2.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" |DESK-MX8M-L-4.0.0 release
 
|-
 
|-
 
|}
 
|}
Line 95: Line 99:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx8mp:~# [  949.406404] usb 3-1: new high-speed USB device number 3 using xhci-hcd
+
root@desk-mx8mp:~# [  949.406404] [ 6491.481175] usb 3-1: new high-speed USB device number 3 using xhci-hcd
[ 949.559777] usb-storage 3-1:1.0: USB Mass Storage device detected
+
[ 6491.639810] usb-storage 3-1:1.0: USB Mass Storage device detected                    
[ 949.566805] scsi host0: usb-storage 3-1:1.0
+
[ 6491.646905] scsi host0: usb-storage 3-1:1.0                                                                        
[ 950.603883] scsi 0:0:0:0: Direct-Access    SanDisk  Cruzer Force    1.00 PQ: 0 ANSI: 6
+
[ 6493.775259] scsi 0:0:0:0: Direct-Access    Fanxiang F206            1100 PQ: 0 ANSI: 4
[ 950.613554] sd 0:0:0:0: [sda] 60088320 512-byte logical blocks: (30.8 GB/28.7 GiB)
+
[ 6493.786654] sd 0:0:0:0: [sda] 61440000 512-byte logical blocks: (31.5 GB/29.3 GiB)                      
[ 950.621925] sd 0:0:0:0: [sda] Write Protect is off
+
[ 6493.795475] sd 0:0:0:0: [sda] Write Protect is off                                                                
[ 950.627095] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
+
[ 6493.801799] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 950.688387]  sda: sda1
+
[ 6493.818546]  sda: sda1                                                                                            
[ 950.695304] sd 0:0:0:0: [sda] Attached SCSI removable disk
+
[ 6493.824653] sd 0:0:0:0: [sda] Attached SCSI removable disk
 
root@desk-mx8mp:~#
 
root@desk-mx8mp:~#
 
</pre>
 
</pre>
Line 110: Line 114:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx8mp:~# [ 1026.205678] usb 4-1: new SuperSpeed Gen 1 USB device number 2 using xhci-hcd
+
root@desk-mx8mp:~# [ 6798.669673] usb 4-1: new SuperSpeed USB device number 3 using xhci-hcd
[ 1026.231220] usb-storage 4-1:1.0: USB Mass Storage device detected
+
[ 6798.703673] usb-storage 4-1:1.0: USB Mass Storage device detected
[ 1026.237848] scsi host0: usb-storage 4-1:1.0
+
[ 6798.710479] scsi host1: usb-storage 4-1:1.0
[ 1027.275191] scsi 0:0:0:0: Direct-Access    HYPER    FLASHDISK        1507 PQ: 0 ANSI: 0
+
[ 6799.719808] scsi 1:0:0:0: Direct-Access    Wilk    USB DISK 3.0    PMAP PQ: 0 ANSI: 6
[ 1027.284305] sd 0:0:0:0: [sda] 129630208 512-byte logical blocks: (66.4 GB/61.8 GiB)
+
[ 6799.732902] sd 1:0:0:0: [sdb] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
[ 1027.292341] sd 0:0:0:0: [sda] Write Protect is off
+
[ 6799.741747] sd 1:0:0:0: [sdb] Write Protect is off
[ 1027.297451] sd 0:0:0:0: [sda] No Caching mode page found
+
[ 6799.747177] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1027.302780] sd 0:0:0:0: [sda] Assuming drive cache: write through
+
[ 6799.934800sdb:
[ 1027.336127sda: sda1
+
[ 6799.940848] sd 1:0:0:0: [sdb] Attached SCSI removable disk
[ 1027.340540] sd 0:0:0:0: [sda] Attached SCSI removable disk
 
 
</pre>
 
</pre>
  
Line 125: Line 128:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx8mp:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
+
root@desk-mx8mp:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
256+0 records in
+
256+0 records in                                                                                                      
256+0 records out
+
256+0 records out  
268435456 bytes (268 MB, 256 MiB) copied, 16.173 s, 16.6 MB/s
+
268435456 bytes (268 MB, 256 MiB) copied, 0.987911 s, 272 MB/s
root@desk-mx8mp:~# mkfs.msdos mass_storage
+
root@desk-mx8mp:~# mkfs.msdos mass_storage                                                                                                                                                                                                  
mkfs.fat 4.1 (2017-01-24)
+
mkfs.fat 4.2 (2021-01-31)
 
root@desk-mx8mp:~# mkdir loop
 
root@desk-mx8mp:~# mkdir loop
 
root@desk-mx8mp:~# mount -o loop mass_storage loop
 
root@desk-mx8mp:~# mount -o loop mass_storage loop
 +
[ 6664.248804] loop0: detected capacity change from 0 to 524288
 
root@desk-mx8mp:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx8mp:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx8mp:~# umount loop
 
root@desk-mx8mp:~# umount loop
Line 142: Line 146:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@desk-mx8mp:~# modprobe g_mass_storage removable=y file=mass_storage
 
root@desk-mx8mp:~# modprobe g_mass_storage removable=y file=mass_storage
[ 1492.938536] Mass Storage Function, version: 2009/09/11
+
[ 6677.844877] Mass Storage Function, version: 2009/09/11
[ 1492.943718] LUN: removable file: (no medium)
+
[ 6677.850190] LUN: removable file: (no medium)
[ 1492.948194] LUN: removable file: /home/root/mass_storage
+
[ 6677.854585] LUN: removable file: /home/root/mass_storage
[ 1492.953574] Number of LUNs=1
+
[ 6677.859933] Number of LUNs=1
[ 1492.956850] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
+
[ 6677.863239] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 1492.963863] g_mass_storage gadget: userspace failed to provide iSerialNumber
+
[ 6677.870221] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 1492.970944] g_mass_storage gadget: g_mass_storage ready
+
[ 6677.877281] g_mass_storage gadget: g_mass_storage ready
 
root@desk-mx8mp:~#
 
root@desk-mx8mp:~#
 
</pre>
 
</pre>

Revision as of 07:46, 26 July 2023

History
ID# Issue Date Notes

15718

30/12/2021 First DESK-MX8M-L release

17615

24/02/2023 DESK-MX8M-L-2.0.0 release

17615

26/07/2023 DESK-MX8M-L-4.0.0 release


Peripheral USB2 OTG[edit | edit source]

Device tree configuration[edit | edit source]

ORCA SOM[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the ORCA SOM:

From imx8mp-mito8mplus-cb1001.dts:

...
...
&usb3_phy1 {
	fsl,phy-tx-preemp-amp-tune = <2>;
	status = "okay";
};

&usb3_1 {
	status = "okay";
};

&usb_dwc3_1 {
	dr_mode = "otg";
	extcon = <&extcon_usbotg2>;
	hnp-disable;
	srp-disable;
	adp-disable;
	rsp-disable;
	disable-over-current;
	status = "okay";
};
...
...

MITO 8M Mini[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the MITO 8M Mini:

From imx8mm-mito8mmini.dts:

...
...
&usbotg2 {
	dr_mode = "host";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb_pwr>;
	vbus-supply = <&reg_usb_pwr>;
	picophy,pre-emp-curr-control = <3>;
	picophy,dc-vol-level-adjust = <7>;
	status = "okay";
};
...
...
&iomuxc {
...
...
	pinctrl_usb_pwr: usbpwrgrp {
		fsl,pins = <
			MX8MM_IOMUXC_GPIO1_IO12_GPIO1_IO12			  0x19
		>;
	};
...
...
};

Accessing the peripheral SBC ORCA[edit | edit source]

Linux messages in host mode[edit | edit source]

When a USB 2.0 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-mx8mp:~# [  949.406404] [ 6491.481175] usb 3-1: new high-speed USB device number 3 using xhci-hcd
[ 6491.639810] usb-storage 3-1:1.0: USB Mass Storage device detected                     
[ 6491.646905] scsi host0: usb-storage 3-1:1.0                                                                         
[ 6493.775259] scsi 0:0:0:0: Direct-Access     Fanxiang F206             1100 PQ: 0 ANSI: 4
[ 6493.786654] sd 0:0:0:0: [sda] 61440000 512-byte logical blocks: (31.5 GB/29.3 GiB)                       
[ 6493.795475] sd 0:0:0:0: [sda] Write Protect is off                                                                  
[ 6493.801799] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 6493.818546]  sda: sda1                                                                                              
[ 6493.824653] sd 0:0:0:0: [sda] Attached SCSI removable disk
root@desk-mx8mp:~#

When a USB 3.0 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-mx8mp:~# [ 6798.669673] usb 4-1: new SuperSpeed USB device number 3 using xhci-hcd
[ 6798.703673] usb-storage 4-1:1.0: USB Mass Storage device detected
[ 6798.710479] scsi host1: usb-storage 4-1:1.0
[ 6799.719808] scsi 1:0:0:0: Direct-Access     Wilk     USB DISK 3.0     PMAP PQ: 0 ANSI: 6
[ 6799.732902] sd 1:0:0:0: [sdb] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
[ 6799.741747] sd 1:0:0:0: [sdb] Write Protect is off
[ 6799.747177] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 6799.934800]  sdb:
[ 6799.940848] sd 1:0:0:0: [sdb] Attached SCSI removable disk

Usage in device mode with mass-storage[edit | edit source]

root@desk-mx8mp:~#  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, 0.987911 s, 272 MB/s
root@desk-mx8mp:~# mkfs.msdos mass_storage                                                                                                                                                                                                    
mkfs.fat 4.2 (2021-01-31)
root@desk-mx8mp:~# mkdir loop
root@desk-mx8mp:~# mount -o loop mass_storage loop
[ 6664.248804] loop0: detected capacity change from 0 to 524288
root@desk-mx8mp:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx8mp:~# umount loop
root@desk-mx8mp:~# 

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

root@desk-mx8mp:~# modprobe g_mass_storage removable=y file=mass_storage
[ 6677.844877] Mass Storage Function, version: 2009/09/11
[ 6677.850190] LUN: removable file: (no medium)
[ 6677.854585] LUN: removable file: /home/root/mass_storage
[ 6677.859933] Number of LUNs=1
[ 6677.863239] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 6677.870221] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 6677.877281] g_mass_storage gadget: g_mass_storage ready
root@desk-mx8mp:~#

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

root@desk-mx8mp:~# [ 1493.477167] 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).

Accessing the peripheral MITO 8M Mini[edit | edit source]

Linux messages[edit | edit source]

When a USB 2.0 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-mx8mm:~# [   22.858909] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[   23.022240] usb-storage 1-1:1.0: USB Mass Storage device detected
[   23.028819] scsi host0: usb-storage 1-1:1.0
[   24.045317] scsi 0:0:0:0: Direct-Access     SanDisk  Cruzer Force     1.00 PQ: 0 ANSI: 6
[   24.055280] sd 0:0:0:0: [sda] 60088320 512-byte logical blocks: (30.8 GB/28.7 GiB)
[   24.063993] sd 0:0:0:0: [sda] Write Protect is off
[   24.069617] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   24.142194]  sda: sda1
[   24.150358] sd 0:0:0:0: [sda] Attached SCSI removable disk

Additional information in host mode[edit | edit source]

If the root file system configuration does not automatically mount the partition, it is possible to mount the device using the following command:

root@desk-mx8mp:~# mkdir -p /mnt/usb
root@desk-mx8mp:~# mount /dev/sda1 /mnt/usb
[ 1245.415662] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
root@desk-mx8mp:~# ls -la /mnt/usb
total 128
drwxr-xr-x 10 root root  4096 Jan  1  1970 .
drwxr-xr-x  3 root root  4096 Dec 30 11:24 ..
drwxr-xr-x  2 root root  4096 May 13  2021 System Volume Information
drwxr-xr-x  2 root root  4096 Nov 17 15:27 boot
-rwxr-xr-x  1 root root  8016 Nov 17 15:27 boot.scr
-rwxr-xr-x  1 root root  1712 Dec 10 16:16 config.txt
drwxr-xr-x  2 root root  4096 Nov 17 15:27 rfs
-rwxr-xr-x  1 root root 57458 Nov 17 15:27 run-system-update.sh
-rwxr-xr-x  1 root root   531 Nov 17 15:27 settings.txt