Open main menu

DAVE Developer's Wiki β

DESK-MX6-L/Pheripherals/USB OTG

< DESK-MX6-L
Revision as of 14:22, 16 July 2021 by U0009 (talk | contribs) (U0009 moved page AXEL Lite SOM/DESK-MX6-L/Pheripherals/USB OTG to DESK-MX6-L/Pheripherals/USB OTG: modifica gestione DESK come prodotto a se stante)

History
Version Issue Date Notes
1.0.0 Oct 2020 First DESK release


Contents

Peripheral USB OTGEdit

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 configurationEdit

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 peripheralEdit

Linux messages at boot timeEdit

...
...
[    4.954820] usb_otg_vbus: disabling
...
...

Usage with mass-storageEdit

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 informationEdit

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