DESK-MX6-L/Pheripherals/USB OTG

From DAVE Developer's Wiki
< DESK-MX6-L
Revision as of 14:39, 13 October 2020 by U0007 (talk | contribs) (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...")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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:

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

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

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

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

root@imx6qdlxelk:~# [  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