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

From DAVE Developer's Wiki
Jump to: navigation, search
m (U0007 moved page DESK-MX9-L/Pheripherals/USB1 OTG to DESK-MX9-L/Peripherals/USB1 OTG without leaving a redirect)
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
 
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
|-
 
!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"|Issue Date
 
!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"|2024/01/30
 
|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"|2024/01/30
Line 11: Line 8:
 
|}
 
|}
 
<section end=History/>
 
<section end=History/>
__FORCETOC__
 
 
<section begin=Body/>
 
<section begin=Body/>
  
==Peripheral USB1 OTG ==
+
==Peripheral USB Host ==
 
 
AURA SOM supports OTG/Host/Peripheral modes: on [[AURA SOM/AURA Evaluation Kit | AURA Evaluation Kit]] the USB1 OTG port is configured as peripheral.
 
  
 
=== Device tree configuration ===
 
=== Device tree configuration ===
Here below is an example of device tree configuration used on standard DAVE's kit for the AURA SOM:
+
Here below an example of device tree configuration used on standard DAVE's kit for the AURA SOM:
  
 
From kernel device tree <code>imx93-aura.dtsi</code>:
 
From kernel device tree <code>imx93-aura.dtsi</code>:
Line 27: Line 21:
 
&usbotg1 {
 
&usbotg1 {
 
dr_mode = "peripheral";
 
dr_mode = "peripheral";
 +
hnp-disable;
 +
srp-disable;
 +
adp-disable;
 +
disable-over-current;
 +
samsung,picophy-pre-emp-curr-control = <3>;
 +
samsung,picophy-dc-vol-level-adjust = <7>;
 +
status = "disabled";
 +
};
 +
 +
&usbotg2 {
 +
dr_mode = "otg";
 
hnp-disable;
 
hnp-disable;
 
srp-disable;
 
srp-disable;
Line 42: Line 47:
 
<pre>
 
<pre>
 
/ {
 
/ {
 +
...
 +
regulators {
 +
...
 +
reg_usb_pwr: usb_pwr {
 +
compatible = "regulator-fixed";
 +
regulator-name = "usb_pwr_en";
 +
regulator-min-microvolt = <5000000>;
 +
regulator-max-microvolt = <5000000>;
 +
gpio = <&gpio1 8 GPIO_ACTIVE_HIGH>;
 +
enable-active-high;
 +
};
 +
...
 +
};
 +
...
 +
};
 
...
 
...
 
&usbotg1 {
 
&usbotg1 {
 
dr_mode = "peripheral";
 
dr_mode = "peripheral";
 +
status = "okay";
 +
};
 +
 +
&usbotg2 {
 +
dr_mode = "host";
 +
pinctrl-names = "default";
 +
pinctrl-0 = <&pinctrl_usb_pwr>;
 +
vbus-supply = <&reg_usb_pwr>;
 
status = "okay";
 
status = "okay";
 
};
 
};
 
...
 
...
 +
&iomuxc {
 +
...
 +
pinctrl_usb_pwr: usbpwrgrp {
 +
fsl,pins = <
 +
MX93_PAD_PDM_CLK__GPIO1_IO08 0x31e
 +
>;
 +
};
 +
...
 +
};
 
</pre>
 
</pre>
  
 
===Accessing the peripheral===
 
===Accessing the peripheral===
 
+
====Linux messages at boot time====
==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====
+
When a USB peripheral is inserted, in the following example a memory mass storage device, the kernel recognizes the device (i.e. xlass, vendor id, product id, etc.)
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx93:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
+
[ 1272.354409] usb 1-1: new high-speed USB device number 3 using ci_hdrc
256+0 records in
+
[ 1272.521077] usb-storage 1-1:1.0: USB Mass Storage device detected
256+0 records out
+
[ 1272.527735] scsi host0: usb-storage 1-1:1.0
268435456 bytes (268 MB, 256 MiB) copied, 0.774426 s, 347 MB/s
+
[ 1273.539755] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
root@desk-mx93:~#  mkfs.msdos mass_storage
+
[ 1273.550783] sd 0:0:0:0: [sda] 60125184 512-byte logical blocks: (30.8 GB/28.7 GiB)
mkfs.fat 4.2 (2021-01-31)
+
[ 1273.560595] sd 0:0:0:0: [sda] Write Protect is off
root@desk-mx93:~# mkdir loop
+
[ 1273.567632] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
root@desk-mx93:~# mount -o loop mass_storage loop
+
[ 1273.592520]  sda: sda1
[ 2309.051910] loop0: detected capacity change from 0 to 524288
+
[ 1273.601008] sd 0:0:0:0: [sda] Attached SCSI removable disk
root@desk-mx93:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx93:~# umount loop
 
root@desk-mx93:~#
 
 
</pre>
 
</pre>
  
then insert the <code>g_mass_storage</code> kernel module driver enabling an Windows PC to see it as a ''removable device''
+
=== Additional information ===
 +
 
 +
The root file system configuration does automatically mount the partition:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx93:~# modprobe g_mass_storage removable=y file=mass_storage
+
root@desk-mx93:~# lsblk /dev/sda
[ 2366.224448] Mass Storage Function, version: 2009/09/11
+
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
[ 2366.229698] LUN: removable file: (no medium)
+
sda      8:0    1 28.7G  0 disk
[ 2366.234576] LUN: removable file: /home/root/mass_storage
+
`-sda1  8:1    1 28.7G  0 part /run/media/<name-usb-partition>-sda1
[ 2366.239928] Number of LUNs=1
 
[ 2366.242990] g_mass_storage gadget.0: Mass Storage Gadget, version: 2009/09/11
 
[ 2366.250151] g_mass_storage gadget.0: userspace failed to provide iSerialNumber
 
[ 2366.257373] g_mass_storage gadget.0: g_mass_storage ready
 
root@desk-mx93:~#
 
 
</pre>
 
</pre>
  
Once the USB cable is connected to the PC, the kernel prints the following messages:
+
The directory name mounted depend from usb name partition.
 
 
<pre class="workstation-terminal">
 
[32262.935133] usb 1-1: new high-speed USB device number 2 using ehci-pci
 
[32263.305571] usb 1-1: New USB device found, idVendor=0525, idProduct=a4a5, bcdDevice= 6.01
 
[32263.305574] usb 1-1: New USB device strings: Mfr=3, Product=4, SerialNumber=0
 
[32263.305575] usb 1-1: Product: Mass Storage Gadget
 
[32263.305577] usb 1-1: Manufacturer: Linux 6.1.55-desk-mx9-l-5.0.0+g8942d3259e9b with 4c100000.usb
 
[32263.337697] usb-storage 1-1:1.0: USB Mass Storage device detected
 
[32263.337819] usb-storage 1-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
 
[32263.337867] scsi host4: usb-storage 1-1:1.0
 
[32263.337968] usbcore: registered new interface driver usb-storage
 
[32263.340492] usbcore: registered new interface driver uas
 
[32264.367940] scsi 4:0:0:0: Direct-Access    Linux    File-Stor Gadget 0601 PQ: 0 ANSI: 2
 
[32264.368435] sd 4:0:0:0: Attached scsi generic sg2 type 0
 
[32264.385398] sd 4:0:0:0: Power-on or device reset occurred
 
[32264.404893] sd 4:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 MiB)
 
[32264.519991] sd 4:0:0:0: [sdb] Write Protect is off
 
[32264.519993] sd 4:0:0:0: [sdb] Mode Sense: 0f 00 00 00
 
[32264.637756] sd 4:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 
[32264.942269]  sdb:
 
[32265.225654] sd 4:0:0:0: [sdb] Attached SCSI removable disk
 
</pre>
 
  
<section end=Body/>
+
----
  
[[Category:AURA]]
+
[[Category:AURA]] [[Category:SBCX AURA]]

Revision as of 15:46, 30 January 2024

History
2024/01/30 DESK-MX9-L-5.0.0 release


Peripheral USB Host[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 AURA SOM:

From kernel device tree imx93-aura.dtsi:

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

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

From kernel device tree imx93-aura-cb2001.dts:

/ {
...
	regulators {
...
		reg_usb_pwr: usb_pwr {
			compatible = "regulator-fixed";
			regulator-name = "usb_pwr_en";
			regulator-min-microvolt = <5000000>;
			regulator-max-microvolt = <5000000>;
			gpio = <&gpio1 8 GPIO_ACTIVE_HIGH>;
			enable-active-high;
		};
...
	};
...
};
...
&usbotg1 {
	dr_mode = "peripheral";
	status = "okay";
};

&usbotg2 {
	dr_mode = "host";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb_pwr>;
	vbus-supply = <&reg_usb_pwr>;
	status = "okay";
};
...
&iomuxc {
...
	pinctrl_usb_pwr: usbpwrgrp {
		fsl,pins = <
			MX93_PAD_PDM_CLK__GPIO1_IO08			0x31e
		>;
	};
...
};

Accessing the peripheral[edit | edit source]

Linux messages at boot time[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. xlass, vendor id, product id, etc.)

[ 1272.354409] usb 1-1: new high-speed USB device number 3 using ci_hdrc
[ 1272.521077] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 1272.527735] scsi host0: usb-storage 1-1:1.0
[ 1273.539755] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[ 1273.550783] sd 0:0:0:0: [sda] 60125184 512-byte logical blocks: (30.8 GB/28.7 GiB)
[ 1273.560595] sd 0:0:0:0: [sda] Write Protect is off
[ 1273.567632] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1273.592520]  sda: sda1
[ 1273.601008] sd 0:0:0:0: [sda] Attached SCSI removable disk

Additional information[edit | edit source]

The root file system configuration does automatically mount the partition:

root@desk-mx93:~# lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    1 28.7G  0 disk 
`-sda1   8:1    1 28.7G  0 part /run/media/<name-usb-partition>-sda1

The directory name mounted depend from usb name partition.