DESK-MX8M-L/Peripherals/USB1 OTG

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2021/12/30

First DESK-MX8M-L release

2023/02/24

DESK-MX8M-L-2.0.0 release

2023/08/22

DESK-MX8M-L-4.0.0 release
2024/04/11 DESK-MX8M-L-4.1.0 release


Peripheral USB1 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_phy0 {
	vbus-power-supply = <&ptn5110>;
	fsl,phy-tx-vref-tune = <6>;
	fsl,phy-tx-rise-tune = <0>;
	fsl,phy-tx-preemp-amp-tune = <3>;
	fsl,phy-comp-dis-tune = <7>;
	fsl,pcs-tx-deemph-3p5db = <0x21>;
	fsl,phy-pcs-tx-swing-full = <0x7f>;
	status = "okay";
};

&usb3_0 {
	status = "okay";
};

&usb_dwc3_0 {
	dr_mode = "host";
	status = "okay";

	port {
		usb3_drd_sw: endpoint {
			remote-endpoint = <&typec_dr_sw>;
		};
	};
};
...
...

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.dtsi:

...
...
&usbotg1 {
	dr_mode = "otg";
	picophy,pre-emp-curr-control = <3>;
	picophy,dc-vol-level-adjust = <7>;
	disable-over-current;
	srp-disable;
	hnp-disable;
	adp-disable;
	status = "disabled";
};
...
...

From imx8mm-mito8mmini-sbcx.dts:

...
...
&usbotg1 {
	status = "okay";
};
...
...

Accessing the peripheral SBC ORCA[edit | edit source]

Linux messages in host mode[edit | edit source]

When a USB2.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:~# [ 2778.596667] usb 1-1.2: new high-speed USB device number 4 using xhci-hcd
[ 2778.733583] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ 2778.741662] scsi host0: usb-storage 1-1.2:1.0       
[ 2780.854831] scsi 0:0:0:0: Direct-Access     Fanxiang F206             1100 PQ: 0 ANSI: 4
[ 2780.864795] sd 0:0:0:0: [sda] 61440000 512-byte logical blocks: (31.5 GB/29.3 GiB)                                                                                                                                                         
[ 2780.875879] sd 0:0:0:0: [sda] Write Protect is off
[ 2780.882883] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 2780.883777] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 2780.902324]  sda: sda1
[ 2780.908573] sd 0:0:0:0: [sda] Attached SCSI removable disk

When a USB3.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:~# [ 2786.628638] usb 2-1.2: new SuperSpeed USB device number 4 using xhci-hcd
[ 2786.663569] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[ 2786.670261] scsi host0: usb-storage 2-1.2:1.0
[ 2787.695351] scsi 0:0:0:0: Direct-Access     Wilk     USB DISK 3.0     PMAP PQ: 0 ANSI: 6
[ 2787.719089] sd 0:0:0:0: [sda] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)
[ 2787.727267] sd 0:0:0:0: [sda] Write Protect is off
[ 2787.732132] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
[ 2787.733341] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 2787.818114]  sda:
[ 2787.822985] sd 0:0:0:0: [sda] Attached SCSI removable disk

Additional information[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
root@desk-mx8mp:~# ls -la /mnt/usb
total 104
drwxr-xr-x 5 root root  4096 Jul 26 06:58 .
drwxr-xr-x 3 root root  4096 Jul 26 06:45 ..
drwxr-xr-x 2 root root  4096 Jul 26 06:57 boot
-rw-r--r-- 1 root root 33432 Jul 26 06:57 boot.scr
-rw-r--r-- 1 root root     0 Jul 26 06:57 config.txt
drwx------ 2 root root 16384 Jul 26 06:54 lost+found
drwxr-xr-x 2 root root  4096 Jul 26 06:58 rfs
-rw-r--r-- 1 root root 33432 Jul 26 06:58 settings.txt

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

Usage with mass-storage[edit | edit source]

root@desk-mx8mm:~# 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.844688 s, 318 MB/s
root@desk-mx8mp:~# mkfs.msdos mass_storage
mkfs.fat 4.1 (2017-01-24)
root@desk-mx8mm:~# mkdir loop
root@desk-mx8mm:~# mount -o loop mass_storage loop
root@desk-mx8mm:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx8mm:~# umount loop
root@desk-mx8mm:~#

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

root@desk-mx8mm:~# modprobe g_mass_storage removable=y file=mass_storage
[  128.240835] Mass Storage Function, version: 2009/09/11
[  128.246113] LUN: removable file: (no medium)
[  128.250510] LUN: removable file: /home/root/mass_storage
[  128.255874] Number of LUNs=1
[  128.259140] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  128.266151] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  128.273216] g_mass_storage gadget: g_mass_storage ready
root@desk-mx8mm:~#

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

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