DESK-MX9-L/Peripherals/USB1 OTG

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/01/30 DESK-MX9-L-5.0.0 release



Peripheral USB1 OTG[edit | edit source]

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

Device tree configuration[edit | edit source]

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 peripheral[edit | edit source]

Usage with mass-storage[edit | edit source]

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