AnsweredAssumed Answered

How to use usb in gadget mode using g_mass_storage.ko

Question asked by Bandaru Lavanya on Aug 9, 2016
Latest reply on Sep 14, 2017 by Ramya Ravichandran

Hi all,


i want to use usb in device mode for that i did like below in dts file.


   reg_usb_otg_vbus: regulator@0 {

                        compatible = "regulator-fixed";

                        reg = <0>;

                        regulator-name = "usb_otg_vbus";

                        regulator-min-microvolt = <5000000>;

                        regulator-max-microvolt = <5000000>;

                        gpio = <&gpio3 22 0>;





                reg_usb_h1_vbus: regulator@1 {

                        compatible = "regulator-fixed";

                        reg = <1>;

                        regulator-name = "usb_h1_vbus";

                        regulator-min-microvolt = <5000000>;

                        regulator-max-microvolt = <5000000>;

                        gpio = <&gpio1 29 0>;



pinctrl_usbotg: usbotggrp {

                        fsl,pins = <

                                        MX6QDL_PAD_GPIO_1__USB_OTG_ID           0x17059




&usbh1 {

        vbus-supply = <&reg_usb_h1_vbus>;

        status = "okay";



&usbotg {

        vbus-supply = <&reg_usb_otg_vbus>;

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_usbotg>;




        status = "okay";



My log when i am installing modules.


root@imx6_fs_wcam:/home# insmod configfs.ko

root@imx6_fs_wcam:/home# insmod libcomposite.ko

root@imx6_fs_wcam:/home# insmod usb_f_mass_storage.ko

movable=1_fs_wcam:/home# insmod g_mass_storage.ko file=/dev/mmcblk2p1 stall=0 re

Number of LUNs=8

Mass Storage Function, version: 2009/09/11

LUN: removable file: (no medium)

Number of LUNs=1

LUN: removable file: /dev/mmcblk2p1

Number of LUNs=1

g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11

g_mass_storage gadget: userspace failed to provide iSerialNumber

g_mass_storage gadget: g_mass_storage ready


and in dmesg i observed like this

fec 2188000.ethernet eth0: registered PHC device 0

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver

ehci-mxc: Freescale On-Chip EHCI Host driver

usbcore: registered new interface driver usb-storage

2184800.usbmisc supply vbus-wakeup not found, using dummy regulator

ci_hdrc ci_hdrc.0: EHCI Host Controller

ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1

ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 1 port detected

ci_hdrc ci_hdrc.1: doesn't support gadget

ci_hdrc ci_hdrc.1: EHCI Host Controller

ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2

ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00

hub 2-0:1.0: USB hub found

hub 2-0:1.0: 1 port detected


When i connected usb cable from board to PC. i got like this:

root@imx6_fs_wcam:/home# ci_hdrc ci_hdrc.0: remove, state 4

usb usb1: USB disconnect, device number 1

ci_hdrc ci_hdrc.0: USB bus 1 deregistered

ci_hdrc ci_hdrc.0: timeout waiting for 00000800 in 12


i need to get like this :

g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage


and it should mount in PC .

can any one please help me to sort it out.


Thanks & regards,