How to use usb in gadget mode using g_mass_storage.ko

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use usb in gadget mode using g_mass_storage.ko

Jump to solution
7,312 Views
bandarulavanya
Contributor V

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>;

                        output-high;

                        enable-active-high;

                };

                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>;

                        enable-active-high;

                };

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>;

        dr-mode="host";

        output-high;

        disable-over-current;

        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

root@imx6_fs_wcam:/home#

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,

Lavanya

Labels (3)
0 Kudos
Reply
1 Solution
3,947 Views
bandarulavanya
Contributor V

Hi Qinghua Zhu,

for my board i need to do only file=/dev/mmcblk2p1.

I found the problem.

In dts file i commented following things after that it is working fine. and usb is mounting in PC.

/*&usbh1 {

        vbus-supply = <&reg_usb_h1_vbus>;

        status = "okay";

};

*/

Thanks & regards,

Lavanya

View solution in original post

0 Kudos
Reply
5 Replies
3,947 Views
qinghuazhu
Contributor III

I didn't test your method, below is my script,FYI:

insmod configfs.ko

insmod libcomposite.ko

insmod usb_f_mass_storage.ko

insmod gadgetfs.ko

insmod g_mass_storage.ko file=/dev/mmcblk1p1

0 Kudos
Reply
3,947 Views
ramyaravichandr
Contributor I

Hi Qinghua Zhu San,

Has the issue got resolved?

Thanks,

Ramya

0 Kudos
Reply
3,948 Views
bandarulavanya
Contributor V

Hi Qinghua Zhu,

for my board i need to do only file=/dev/mmcblk2p1.

I found the problem.

In dts file i commented following things after that it is working fine. and usb is mounting in PC.

/*&usbh1 {

        vbus-supply = <&reg_usb_h1_vbus>;

        status = "okay";

};

*/

Thanks & regards,

Lavanya

0 Kudos
Reply
3,947 Views
jimmychan
NXP TechSupport
NXP TechSupport

which bsp are you using?

0 Kudos
Reply
3,947 Views
bandarulavanya
Contributor V

HI jimmychan ,

kernel 3.14.28 from yocto i am using.

Thanks & regards,

Lavanya

0 Kudos
Reply