Difference between revisions of "DESK-MX6-L/Peripherals/USB OTG"

From DAVE Developer's Wiki
Jump to: navigation, search
m (U0007 moved page DESK-MX6-L/Pheripherals/USB OTG to DESK-MX6-L/Peripherals/USB OTG without leaving a redirect)
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<section begin="History" />
+
<section begin=History/>
 
{| 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"|Version
! 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"|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" |{{oldid|14089|2021/07/16}}
 
| 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-MX6-L 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" |{{oldid|17003|2022/03/03}}
 
| 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-MX6-L 3.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" |2023/04/11
 
! 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-MX6-L 4.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"|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"|Oct 2020
 +
|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 release
 
|}
 
|}
<section end="History" />
+
<section end=History/>
<section begin="Body" />
+
<section begin=Body/>
  
 
==Peripheral USB OTG ==
 
==Peripheral USB OTG ==
Line 64: Line 59:
  
 
===Accessing the peripheral===
 
===Accessing the peripheral===
 +
====Linux messages at boot time====
 +
 +
<pre class="workstation-terminal">
 +
...
 +
...
 +
[    4.954820] usb_otg_vbus: disabling
 +
...
 +
...
 +
</pre>
 +
 
==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====
 
==== Usage with [https://www.kernel.org/doc/Documentation/usb/mass-storage.txt mass-storage] ====
  
Line 70: Line 75:
 
256+0 records in
 
256+0 records in
 
256+0 records out
 
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 8.63267 s, 31.1 MB/s
+
268435456 bytes (268 MB, 256 MiB) copied, 15.924 s, 16.9 MB/s
root@desk-mx6:~# mkfs.msdos mass_storage
+
root@imx6qdlxelk:~# mkfs.msdos mass_storage
mkfs.fat 4.2 (2021-01-31)
+
mkfs.fat 4.1 (2017-01-24)
 
root@desk-mx6:~# mkdir loop
 
root@desk-mx6:~# mkdir loop
 
root@desk-mx6:~# mount -o loop mass_storage loop
 
root@desk-mx6:~# mount -o loop mass_storage loop
[  176.970284] loop0: detected capacity change from 0 to 524288
 
 
root@desk-mx6:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx6:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
 
root@desk-mx6:~# umount loop
 
root@desk-mx6:~# umount loop
Line 84: Line 88:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@desk-mx6:~# modprobe g_mass_storage removable=y file=mass_storage
 
root@desk-mx6:~# modprobe g_mass_storage removable=y file=mass_storage
root@desk-mx6:~# dmesg | tail -n 7
+
891.807023] Mass Storage Function, version: 2009/09/11
157.011126] Mass Storage Function, version: 2009/09/11
+
891.813145] LUN: removable file: (no medium)
157.011146] LUN: removable file: (no medium)
+
891.818901] LUN: removable file: /home/root/mass_storage
157.011252] LUN: removable file: /home/root/mass_storage
+
891.824754] Number of LUNs=1
157.011263] Number of LUNs=1
+
891.827901] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
157.012243] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
+
891.834955] g_mass_storage gadget: userspace failed to provide iSerialNumber
157.012263] g_mass_storage gadget: userspace failed to provide iSerialNumber
+
891.842109] g_mass_storage gadget: g_mass_storage ready
157.012272] g_mass_storage gadget: g_mass_storage ready
+
root@desk-mx6:~#
 
</pre>
 
</pre>
  
Once the USB cable is connected to the PC, the storage is mounted and the ''usb.txt'' file is available:
+
Once the USB cable is connected to the PC, the kernel prints the following messages:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
$ cat /media/user/0001-66DD/usb.txt
+
root@desk-mx6:~# [  892.036840] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
Test USB OTG with mass storage device
 
 
</pre>
 
</pre>
  
The Windows PC also activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
+
and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
  
 
=== Additional information ===
 
=== Additional information ===
  
More information about Mass Storage Gadget driver is given in the kernel tree under ''Documentation/usb/mass-storage.rst''
+
More information about Mass Storage Gadget driver is given in the kernel tree under ''Documentation/usb/mass-storage.txt''
  
<section end="Body" />
+
<section end=Body/>
  
 
----
 
----
  
 
[[Category:AXEL Lite]]
 
[[Category:AXEL Lite]]

Revision as of 14:46, 14 July 2021

History
Version Issue Date Notes
1.0.0 Oct 2020 First DESK release


Peripheral USB OTG[edit | edit source]

The USB OTG feature can be easily tested using the Mass Storage Gadget, which lets the device export a file as a mass storage device to the connected PC.

Device tree configuration[edit | edit source]

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

From imx6qdl-axelcommon.dtsi:


        reg_usb_otg_vbus: usb_otg_vbus {
                compatible = "regulator-fixed";
                regulator-name = "usb_otg_vbus";
                regulator-min-microvolt = <5000000>;
                regulator-max-microvolt = <5000000>;
                gpio = <&gpio4 14 0>;
                enable-active-high;
        };
...
...
&usbotg {
    vbus-supply = <&reg_usb_otg_vbus>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_usbotg_2>;
    disable-over-current;
    status = "okay";
};
...
...
&iomuxc {
...
...
    usbotg {
        pinctrl_usbotg_2: usbotggrp-2 {
            fsl,pins = <
                MX6QDL_PAD_ENET_RX_ER__USB_OTG_ID 0x17059
            >;
        };
    };
};

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-mx6:~# 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-mx6:~# mkdir loop
root@desk-mx6:~# mount -o loop mass_storage loop
root@desk-mx6:~# echo "Test USB OTG with mass storage device" > loop/usb.txt
root@desk-mx6:~# umount loop

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

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

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

Additional information[edit | edit source]

More information about Mass Storage Gadget driver is given in the kernel tree under Documentation/usb/mass-storage.txt