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

From DAVE Developer's Wiki
Jump to: navigation, search
Line 22: Line 22:
  
 
=== Device tree configuration ===
 
=== Device tree configuration ===
 +
 +
==== ORCA ====
 +
 
Here below an example of device tree configuration used on standard DAVE's kit for the ORCA SOM:
 
Here below an example of device tree configuration used on standard DAVE's kit for the ORCA SOM:
  
Line 49: Line 52:
 
</pre>
 
</pre>
  
 +
==== MINI ====
 +
 +
Here below an example of device tree configuration used on standard DAVE's kit for the MINI SOM:
 +
 +
From <code>imx8mm-mito8mmini.dts</code>:
 +
 +
<pre>
 +
&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 = "okay";
 +
};
 +
 +
 +
</pre>
 
===Accessing the peripheral===
 
===Accessing the peripheral===
 +
 +
This procedure is the same for both ORCA and MINI.
  
 
====Linux messages at boot time====
 
====Linux messages at boot time====

Revision as of 14:53, 15 February 2023

History
Version Issue Date Notes
1.0.0 Jan 2022 First DESK-MX8M release
2.0.0 Feb 2023 DESK-MX8M-L-2.0.0


Peripheral USB OTG[edit | edit source]

Device tree configuration[edit | edit source]

ORCA[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";
};

MINI[edit | edit source]

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

From imx8mm-mito8mmini.dts:

&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 = "okay";
};


Accessing the peripheral[edit | edit source]

This procedure is the same for both ORCA and MINI.

Linux messages at boot time[edit | edit source]

...
...
[    4.954820] usb_otg_vbus: disabling
...
...

Usage 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.844688 s, 318 MB/s
root@desk-mx8mp:~# mkfs.msdos mass_storage
mkfs.fat 4.1 (2017-01-24)
root@desk-mx8mp:~# mkdir loop
root@desk-mx8mp:~# mount -o loop mass_storage loop
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
[  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@desk-mx8mp:~#

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

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