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

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "{{subst:Peripheral | nome-som=ORCA | nome-peripheral = USB OTG}}")
 
Line 7: Line 7:
 
!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"|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"|X.Y.Z
+
|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"|Month Year
+
|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"|Jan 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"|TBD
+
|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 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"|[TBD_link X.Y.Z]
 
|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"|Month Year
 
|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"|TBD
 
|-
 
|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"|...
 
|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"|...
 
|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"|...
 
 
|-
 
|-
 
|}
 
|}
Line 25: Line 16:
  
 
==Peripheral USB OTG ==
 
==Peripheral USB OTG ==
 
''TBD: sostituire tutti i dump con le informazioni sull'uso della periferica''
 
  
 
=== Device tree configuration ===
 
=== Device tree configuration ===
 
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:
  
From <code>''carrier.dts''</code>:
+
From <code>imx8mp-mito8mplus-cb1001.dts</code>:
  
 
<pre>
 
<pre>
&can1 {
+
&usb3_phy0 {
    pinctrl-names = "default";
+
vbus-power-supply = <&ptn5110>;
    pinctrl-0 = <&pinctrl_flexcan1_axel>;
+
fsl,phy-tx-vref-tune = <6>;
    status = "okay";
+
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 = "otg";
 +
hnp-disable;
 +
srp-disable;
 +
adp-disable;
 +
usb-role-switch;
 +
status = "okay";
 +
 +
port {
 +
usb3_drd_sw: endpoint {
 +
remote-endpoint = <&typec_dr_sw>;
 +
};
 +
};
 +
};
 +
 
</pre>
 
</pre>
  
 
From <code>''carrier-common.dtsi''</code>:
 
From <code>''carrier-common.dtsi''</code>:
  
<pre>
+
===Accessing the peripheral===
    can1 {
 
        pinctrl_flexcan1_axel: flexcan1axelgrp-1 {
 
            fsl,pins = <
 
                MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x80000000
 
                MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x80000000
 
            >;
 
        };
 
    };
 
</pre>
 
  
===Accessing the peripheral===
 
 
====Linux messages at boot time====
 
====Linux messages at boot time====
  
Line 60: Line 64:
 
...
 
...
 
...
 
...
[    1.807495] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
+
[    4.954820] usb_otg_vbus: disabling
[    1.817366] flexcan 2090000.flexcan: device registered (reg_base=c0a30000, irq=31)
 
 
...
 
...
 
...
 
...
[    3.952659] can: controller area network core (rev 20170425 abi 9)
 
[    3.963413] can: raw protocol (rev 20170425)
 
[    3.967717] can: broadcast manager protocol (rev 20170425 t)
 
[    3.973397] can: netlink gateway (rev 20170425) max_hops=1
 
 
</pre>
 
</pre>
  
====Enable the interface and check status====
+
==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====
 +
 
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qxelk:~# ip link set can0 type can bitrate 500000
+
root@desk-mx8mp:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
root@imx6qxelk:~# ifconfig can0 up
+
256+0 records in
root@imx6qxelk:~# ifconfig can0
+
256+0 records out
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
+
268435456 bytes (268 MB, 256 MiB) copied, 15.924 s, 16.9 MB/s
          UP RUNNING NOARP  MTU:16  Metric:1
+
root@imx6qdlxelk:~# mkfs.msdos mass_storage
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
+
mkfs.fat 4.1 (2017-01-24)
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
+
root@desk-mx8mp:~# mkdir loop
          collisions:0 txqueuelen:10
+
root@desk-mx8mp:~# mount -o loop mass_storage loop
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
+
root@desk-mx8mp:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
          Interrupt:31
+
root@desk-mx8mp:~# umount loop
 +
</pre>
 +
 
 +
then insert the <code>g_mass_storage</code> kernel module driver enabling an Windows PC to see it as a ''removable device''
  
root@imx6qxelk:~#
+
<pre class="workstation-terminal">
 +
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:~#
 
</pre>
 
</pre>
  
==== Usage with [https://github.com/linux-can/can-utils can-utils] ====
+
Once the USB cable is connected to the PC, the kernel prints the following messages:
 
 
''TBD: reference verso eventuali informazioni sul web''
 
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qxelk:~# ip link set can0 type can bitrate 500000 triple-sampling on
+
root@desk-mx6:~# [ 892.036840] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
root@imx6qxelk:~# ifconfig can0 up
 
root@imx6qxelk:~# cansend can0 128#1122334455667788
 
root@imx6qxelk:~# candump can0
 
  can0 128  [8] 11 22 33 44 55 66 77 88
 
root@imx6qxelk:~#  
 
 
</pre>
 
</pre>
  
=== Additional information ===
+
and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
Each CAN port appears like a networking interface in the form <code>canX</code> where <b><i>X</i></b> is the port number.  
 
  
Information about programming the CAN socket interface is given in the kernel tree under ''Documentation/networking/can.txt''
 
<section end=Body/>
 
  
 
----
 
----
  
 
[[Category:ORCA]]
 
[[Category:ORCA]]

Revision as of 14:31, 30 December 2021

History
Version Issue Date Notes
1.0.0 Jan 2022 First DESK-MX8M release


Peripheral USB OTG[edit | edit source]

Device tree configuration[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 = "otg";
	hnp-disable;
	srp-disable;
	adp-disable;
	usb-role-switch;
	status = "okay";

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

From carrier-common.dtsi:

Accessing the peripheral[edit | edit source]

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, 15.924 s, 16.9 MB/s
root@imx6qdlxelk:~# 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

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