Open main menu

DAVE Developer's Wiki β

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

< DESK-MX9-L
(Created page with "<section begin=History/> {| style="border-collapse:collapse; " !colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History |- |style="border-le...")
 
 
(4 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
 
|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"|DESK-MX9-L-5.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:#edf8fb; padding:5px; color:#000000"|DESK-MX9-L-5.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"|2024/05/17
 +
!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-MX9-L-5.1.0 release
 
|-
 
|-
 
|}
 
|}
 
<section end=History/>
 
<section end=History/>
 +
__FORCETOC__
 
<section begin=Body/>
 
<section begin=Body/>
  
==Peripheral USB Host ==
+
==Peripheral USB1 OTG ==
 +
 
 +
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 an example of device tree configuration used on standard DAVE's kit for the AURA SOM:
+
Here below is 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 21: Line 30:
 
&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 47: Line 45:
 
<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====
+
 
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.)
+
==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
[ 1272.354409] usb 1-1: new high-speed USB device number 3 using ci_hdrc
+
root@desk-mx93:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
[ 1272.521077] usb-storage 1-1:1.0: USB Mass Storage device detected
+
256+0 records in
[ 1272.527735] scsi host0: usb-storage 1-1:1.0
+
256+0 records out
[ 1273.539755] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
+
268435456 bytes (268 MB, 256 MiB) copied, 0.774426 s, 347 MB/s
[ 1273.550783] sd 0:0:0:0: [sda] 60125184 512-byte logical blocks: (30.8 GB/28.7 GiB)
+
root@desk-mx93:~#  mkfs.msdos mass_storage
[ 1273.560595] sd 0:0:0:0: [sda] Write Protect is off
+
mkfs.fat 4.2 (2021-01-31)
[ 1273.567632] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
+
root@desk-mx93:~# mkdir loop
[ 1273.592520]  sda: sda1
+
root@desk-mx93:~# mount -o loop mass_storage loop
[ 1273.601008] sd 0:0:0:0: [sda] Attached SCSI removable disk
+
[ 2309.051910] loop0: detected capacity change from 0 to 524288
 +
root@desk-mx93:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 +
root@desk-mx93:~# umount loop
 +
root@desk-mx93:~#
 
</pre>
 
</pre>
  
=== Additional information ===
+
then insert the <code>g_mass_storage</code> kernel module driver enabling an Windows PC to see it as a ''removable device''
 +
 
 +
<pre class="workstation-terminal">
 +
root@desk-mx93:~# modprobe g_mass_storage removable=y file=mass_storage
 +
[ 2366.224448] Mass Storage Function, version: 2009/09/11
 +
[ 2366.229698] LUN: removable file: (no medium)
 +
[ 2366.234576] LUN: removable file: /home/root/mass_storage
 +
[ 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>
  
The root file system configuration does automatically mount the partition:
+
Once the USB cable is connected to the PC, the kernel prints the following messages:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx93:~# lsblk /dev/sda
+
[32262.935133] usb 1-1: new high-speed USB device number 2 using ehci-pci
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
+
[32263.305571] usb 1-1: New USB device found, idVendor=0525, idProduct=a4a5, bcdDevice= 6.01
sda      8:0   1 28.7G  0 disk
+
[32263.305574] usb 1-1: New USB device strings: Mfr=3, Product=4, SerialNumber=0
`-sda1  8:1   1 28.7G  0 part /run/media/<name-usb-partition>-sda1
+
[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>
 
</pre>
  
The directory name mounted depend from usb name partition.
+
<section end=Body/>
 
 
----
 
  
[[Category:AURA]] [[Category:SBCX AURA]]
+
[[Category:AURA]]

Latest revision as of 13:31, 17 May 2024

History
Issue Date Notes
2024/01/30 DESK-MX9-L-5.0.0 release
2024/05/17 DESK-MX9-L-5.1.0 release



Contents

Peripheral USB1 OTGEdit

AURA SOM supports OTG/Host/Peripheral modes: on AURA Evaluation Kit the USB1 OTG port is configured as peripheral.

Device tree configurationEdit

Here below is 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";
};
...

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

/ {
...
&usbotg1 {
	dr_mode = "peripheral";
	status = "okay";
};
...

Accessing the peripheralEdit

Usage with mass-storageEdit

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

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

root@desk-mx93:~# modprobe g_mass_storage removable=y file=mass_storage
[ 2366.224448] Mass Storage Function, version: 2009/09/11
[ 2366.229698] LUN: removable file: (no medium)
[ 2366.234576] LUN: removable file: /home/root/mass_storage
[ 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:~#

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

[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