DESK-MX6-L/Pheripherals/USB OTG
History | |||
---|---|---|---|
ID# | Issue Date | Notes | |
16/07/2021 | First DESK release | ||
03/03/2022 | DESK 3.0.0 release |
Contents
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 = <®_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, 20.9049 s, 12.8 MB/s root@desk-mx6:~# mkfs.msdos mass_storage mkfs.fat 4.2 (2021-01-31) 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 root@desk-mx6:~# dmesg | tail -n 7 [ 767.509357] Mass Storage Function, version: 2009/09/11 [ 767.509373] LUN: removable file: (no medium) [ 767.509486] LUN: removable file: /home/root/mass_storage [ 767.509496] Number of LUNs=1 [ 767.509706] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11 [ 767.509718] g_mass_storage gadget: userspace failed to provide iSerialNumber [ 767.509725] g_mass_storage gadget: g_mass_storage ready
Once the USB cable is connected to the PC, the storage is mounted and the usb.txt file is available:
$ cat /media/user/D193-7AA4/usb.txt Test USB OTG with mass storage device
The Windows PC also 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.rst