Putting Gadgetfs support in Android

557 views
Skip to first unread message

Ashutosh

unread,
Jul 10, 2009, 10:05:35 AM7/10/09
to Android Linux Kernel Development
Hello Everybody,

I wanted to put support for gadgetfs support on ADP1.

I have downloaded android-1.5r2.

My local_manifest.xml is --

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remove-project name="kernel/common"/>
<project path="kernel" name="kernel/msm" revision="refs/heads/
android-msm-2.6.27"/>
<project path="vendor/htc/dream" name="platform/vendor/htc/dream"
revision="cupcake"/>
<project path="hardware/msm7k" name="platform/hardware/msm7k"
revision="refs/heads/master"/>
</manifest>

I have copied arch/arm/configs/msm_defconfig as .config in mydroid/
kernel.

I made changes in .config to support gadgetfs.

As Mike has suggested at http://groups.google.com/group/android-platform/browse_thread/thread/1531ac199565ed3c?pli=1
, I have disabled CONFIG_USB_FUNCTION and enabled CONFIG_USB_GADGET
and CONFIG_USB_GADGET_MSM_72K.

After configuring kernel, GADGET and USB_FUNCTION configuration looks
like below --

CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_SELECTED=y
CONFIG_USB_GADGET_MSM_72K=y
CONFIG_USB_MSM_72K=y
CONFIG_USB_GADGET_DUALSPEED=y
CONFIG_USB_GADGETFS=y



#
# USB Function Support
#
# CONFIG_USB_FUNCTION is not set


Now I try to compile kernel and get below error --

arch/arm/mach-msm/htc_battery.c:187: error: variable
'usb_status_notifier' has initializer but incomplete type
arch/arm/mach-msm/htc_battery.c:188: error: unknown field 'name'
specified in initializer
arch/arm/mach-msm/htc_battery.c:188: warning: excess elements in
struct initializer
arch/arm/mach-msm/htc_battery.c:188: warning: (near initialization for
'usb_status_notifier')
arch/arm/mach-msm/htc_battery.c:189: error: unknown field 'func'
specified in initializer
arch/arm/mach-msm/htc_battery.c:189: warning: excess elements in
struct initializer
arch/arm/mach-msm/htc_battery.c:189: warning: (near initialization for
'usb_status_notifier')
arch/arm/mach-msm/htc_battery.c: In function 'htc_battery_init':
arch/arm/mach-msm/htc_battery.c:793: error: implicit declaration of
function 'usb_register_notifier'

I looked for declaration of t_usb_status_notifier and found it in arch/
arm/mach-msm/include/mach/board_htc.h, but this will be visible only
when CONFIG_USB_FUNCTION_MSM_HSUSB is defined. Since we have disabled
CONFIG_USB_FUNCTION, none of the CONFIG_USB_FUNCTION* are set.

I have tried enabling CONFIG_USB_FUNCTION and
CONFIG_USB_FUNCTION_MSM_HSUSB but that gave many multiple definition
error.

Please suggest how do I go about it?

Thanks

Ashutosh

unread,
Jul 13, 2009, 7:02:15 AM7/13/09
to Android Linux Kernel Development
(especially to Mike Lockwood)

If I want to have gadgetfs support at ADP1 and have adb working, how
do I need to to configure kernel and compile?

I have tried many things including using 'CONFIG_USB_ANDROID=y' and
'CONFIG_USB_FUNCTION is not set' but nothing worked. To compile this
configuration I had to make some modification in some of the files.
List is as below --

1) In arch/arm/mach-msm/include/mach/board_htc.h (Reason: Type of
t_usb_status_notifier was not visible)

58 //#if defined(CONFIG_USB_FUNCTION_MSM_HSUSB)

68 //#endif

2) In arch/arm/mach-msm/htc_battery.c (Reason: Definition of
usb_register_notifier() was not known. Its defintion is in drivers/usb/
function/msm_hsusb.c)

793 // usb_register_notifier(&usb_status_notifier);

I am able to boot this image on ADP1 but when I connect it to my PC
via USB it reboots.



On Jul 10, 7:05 pm, Ashutosh <as...@TechMahindra.com> wrote:
> Hello Everybody,
>
> I wanted to put support for gadgetfs support on ADP1.
>
> I have downloaded android-1.5r2.
>
> My local_manifest.xml is --
>
> <?xml version="1.0" encoding="UTF-8"?>
>  <manifest>
>   <remove-project name="kernel/common"/>
>   <project path="kernel" name="kernel/msm" revision="refs/heads/
> android-msm-2.6.27"/>
>   <project path="vendor/htc/dream" name="platform/vendor/htc/dream"
> revision="cupcake"/>
>   <project path="hardware/msm7k" name="platform/hardware/msm7k"
> revision="refs/heads/master"/>
>  </manifest>
>
> I have copied arch/arm/configs/msm_defconfig as .config in mydroid/
> kernel.
>
> I made changes in .config to support gadgetfs.
>
> As Mike has suggested athttp://groups.google.com/group/android-platform/browse_thread/thread/...

Mike Lockwood

unread,
Jul 13, 2009, 7:35:29 AM7/13/09
to android...@googlegroups.com
Hi Ashutosh,

I think the problem is that the gadget support is broken in our 2.6.27
kernel. However, I do know it is working in 2.6.29. I believe if you
do the following:

- backport the latest drivers/usb/gadget/android.c from 2.6.29 back to 2.6.27

- backport the following commit from 2.6.29 to to 2.6.27:

commit f9335f6d0cfa5b8fc2a10c2a63ebcd42efbf99cb
Author: Mike Lockwood <lock...@android.com>
Date: Fri Feb 20 15:56:06 2009 -0500

[ARM] msm: htc: Clean up USB support in trout and sapphire board files

Signed-off-by: Mike Lockwood <lock...@android.com>

- Finally, configure your kernel with the USB function support
disabled and the following gadget features enabled:

CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_GADGET_SELECTED=y
CONFIG_USB_GADGET_MSM_72K=y
CONFIG_USB_MSM_72K=y
CONFIG_USB_GADGET_DUALSPEED=y
CONFIG_USB_ANDROID=y

I'm not sure how easy this will be to do the backporting, but it
should be possible.

Mike
--
Mike Lockwood
Google android team

Ashutosh

unread,
Jul 24, 2009, 3:50:48 AM7/24/09
to Android Linux Kernel Development
Hi Mike,

I have been able to compile kernel 2.6.29 with configuration (USB
function is disabled)--

CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_GADGET_SELECTED=y
CONFIG_USB_GADGET_MSM_72K=y
CONFIG_USB_MSM_72K=y
CONFIG_USB_GADGET_DUALSPEED=y
CONFIG_USB_ANDROID=y

I am able to get adb shell.

I also compiled gadgetfs as module and got gadgetfs.ko. I inserted it
in kernel but when I try to mount on it (mount -t gadget path /dev/
gadget) I get error "mount: No such device".

I debugged it and found that it fails in usb_gadget_register_driver()
at point --

if (ui->driver)
return -EBUSY;

I am getting this error because msm72k_udc is busy and held by android
gadget (USB_ANDROID).

I tried to compile CONFIG_USB_ANDROID as module (CONFIG_USB_ANDROID=m)
and modified system/core/rootdir/init.rc to insert g_android.ko
(insmod /system/lib/modules/g_android.ko).

This is not working as I am not able to get adb shell.

Would you please let me know, if it is possible to compile g_android
as module and get inserted in kernel at bootup?

Thanks
Ashutosh



On Jul 13, 4:35 pm, Mike Lockwood <lockw...@android.com> wrote:
> Hi Ashutosh,
>
> I think the problem is that the gadgetsupportis broken in our 2.6.27
> kernel.  However, I do know it is working in 2.6.29.  I believe if you
> do the following:
>
> - backport the latest drivers/usb/gadget/android.c from 2.6.29 back to 2.6.27
>
> - backport the following commit from 2.6.29 to to 2.6.27:
>
> commit f9335f6d0cfa5b8fc2a10c2a63ebcd42efbf99cb
> Author: Mike Lockwood <lockw...@android.com>
> Date:   Fri Feb 20 15:56:06 2009 -0500
>
>     [ARM] msm: htc: Clean up USBsupportin trout and sapphire board files
>
>     Signed-off-by: Mike Lockwood <lockw...@android.com>
>
> - Finally, configure your kernel with the USB functionsupport
> disabled and the following gadget features enabled:
>
> CONFIG_USB_GADGET=y
> CONFIG_USB_GADGET_VBUS_DRAW=500
> CONFIG_USB_GADGET_SELECTED=y
> CONFIG_USB_GADGET_MSM_72K=y
> CONFIG_USB_MSM_72K=y
> CONFIG_USB_GADGET_DUALSPEED=y
> CONFIG_USB_ANDROID=y
>
> I'm not sure how easy this will be to do the backporting, but it
> should be possible.
>
> Mike
>
>
>
> On Mon, Jul 13, 2009 at 7:02 AM, Ashutosh<as...@techmahindra.com> wrote:
>
> > (especially to Mike Lockwood)
>
> > If I want to havegadgetfssupportat ADP1 and have adb working, how
> > do I need to to configure kernel and compile?
>
> > I have tried many things including using 'CONFIG_USB_ANDROID=y' and
> > 'CONFIG_USB_FUNCTION is not set' but nothing worked. To compile this
> > configuration I had to make some modification in some of the files.
> > List is as below --
>
> > 1) In arch/arm/mach-msm/include/mach/board_htc.h (Reason: Type of
> > t_usb_status_notifier was not visible)
>
> >  58 //#if defined(CONFIG_USB_FUNCTION_MSM_HSUSB)
>
> >  68 //#endif
>
> > 2) In arch/arm/mach-msm/htc_battery.c (Reason: Definition of
> > usb_register_notifier() was not known. Its defintion is in drivers/usb/
> > function/msm_hsusb.c)
>
> > 793 //  usb_register_notifier(&usb_status_notifier);
>
> > I am able to boot this image on ADP1 but when I connect it to my PC
> > via USB it reboots.
>
> > On Jul 10, 7:05 pm, Ashutosh <as...@TechMahindra.com> wrote:
> >> Hello Everybody,
>
> >> I wanted to putsupportforgadgetfssupporton ADP1.

Mike Lockwood

unread,
Jul 24, 2009, 5:55:33 PM7/24/09
to android...@googlegroups.com
I think the problem is that gadget only supports one driver at a time,
so you cannot run the android gadget driver and gadgetfs
simultaneously. If you built the android driver as a module, then you
could manually load one or the other and switch between android and
gadgetfs. But the android driver is not currently set up to work as a
module (we are just statically linking it in at this point). It
probably wouldn't be too hard to get it working as a module, but I
don't think anyone has done that yet.

Mike

育宇

unread,
Aug 27, 2009, 8:16:59 AM8/27/09
to Android Linux Kernel Development
1.)Is any updates for android gadget driver now? In android 1.5, are
these problems still existen?
2.) I have try to bind acm_bind_config(acm_cdc usb gadget driver) and
gser_bind_config(f_serial.c) in android.c. The first one can be
recongized by acm_cdc driver in PC side, but it can not work. On the
other hand, the second one has to load generic serial driver,such as
Qualcom's usb driver, but it will cause erros:
Do you think theser errors result from the unstable usb device driver
provided by vendor?


[42949437.930000] BUG: scheduling while atomic: NvOsKernelThrea/
176/0x00000100
[42949437.930000] Modules linked in:
[42949437.930000]
[42949437.930000] Pid: 176, comm: NvOsKernelThrea
[42949437.930000] CPU: 0 Not tainted (2.6.29-00117-g3a218ab-dirty
#33)
[42949437.930000] PC is at vprintk+0x214/0x31c
[42949437.930000] LR is at release_console_sem+0x1a4/0x21c
[42949437.930000] pc : [<c008ebe8>] lr : [<c008e620>] psr:
60000013
[42949437.930000] sp : cb923e78 ip : cb923e48 fp : cb923eec
[42949437.930000] r10: c034f8a4 r9 : 00000000 r8 : 0000003b
[42949437.930000] r7 : 00000012 r6 : c03967e6 r5 : cb923ea0 r4 :
cb923ea0
[42949437.930000] r3 : c034f84c r2 : a0000013 r1 : 0001904d r0 :
c034f890
[42949437.930000] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM
Segment kernel
[42949437.930000] Control: 0085787f Table: 0bd60008 DAC: 00000017
[42949437.930000] [<c002549c>] (show_regs+0x0/0x50) from [<c008aad4>]
(__schedule_bug+0x4c/0x60)
[42949437.930000] r4:cb923e30
[42949437.930000] [<c008aa88>] (__schedule_bug+0x0/0x60) from
[<c02928bc>] (schedule+0x3f8/0x47c)
[42949437.930000] r4:ccbda7c8
[42949437.930000] [<c02924c4>] (schedule+0x0/0x47c) from [<c0292fe0>]
(__mutex_lock_slowpath+0x84/0xd8)
[42949437.930000] [<c0292f5c>] (__mutex_lock_slowpath+0x0/0xd8) from
[<c0293058>] (mutex_lock+0x24/0x28)
[42949437.930000] r8:c7214001 r7:c70a7080 r6:ccbda294 r5:00001fff
r4:00000200
[42949437.930000] [<c0293034>] (mutex_lock+0x0/0x28) from [<c0030550>]
(NvUsbShimEpEnqueue+0x40/0x17c)
[42949437.930000] [<c0030510>] (NvUsbShimEpEnqueue+0x0/0x17c) from
[<c01ea9bc>] (gs_start_tx+0x14c/0x1e4)
[42949437.930000] r7:00000001 r6:cb85b000 r5:00001fff r4:00000200
[42949437.930000] [<c01ea870>] (gs_start_tx+0x0/0x1e4) from
[<c01eaafc>] (gs_flush_chars+0x2c/0x34)
[42949437.930000] [<c01eaad0>] (gs_flush_chars+0x0/0x34) from
[<c01b8bb0>] (process_echoes+0x154/0x2c0)
[42949437.930000] r4:00000054
[42949437.930000] [<c01b8a5c>] (process_echoes+0x0/0x2c0) from
[<c01ba6b8>] (n_tty_receive_buf+0x3ec/0x11ac)
[42949437.930000] [<c01ba2cc>] (n_tty_receive_buf+0x0/0x11ac) from
[<c01bd68c>] (flush_to_ldisc+0xf0/0x198)
[42949437.930000] [<c01bd59c>] (flush_to_ldisc+0x0/0x198) from
[<c01bd780>] (tty_flip_buffer_push+0x4c/0x50)
[42949437.930000] [<c01bd734>] (tty_flip_buffer_push+0x0/0x50) from
[<c01eb2ec>] (gs_rx_push+0x19c/0x1f8)
[42949437.930000] [<c01eb150>] (gs_rx_push+0x0/0x1f8) from
[<c0092b84>] (tasklet_action+0x64/0xcc)
[42949437.930000] [<c0092b20>] (tasklet_action+0x0/0xcc) from
[<c00930fc>] (__do_softirq+0x74/0x118)
[42949437.930000] r7:00000100 r6:c0396c20 r5:00000001 r4:00000014
[42949437.930000] [<c0093088>] (__do_softirq+0x0/0x118) from
[<c0093220>] (irq_exit+0x80/0x98)
[42949437.930000] [<c00931a0>] (irq_exit+0x0/0x98) from [<c002304c>]
(asm_do_IRQ+0x4c/0x74)
[42949437.930000] r4:00000014
[42949437.930000] [<c0023000>] (asm_do_IRQ+0x0/0x74) from [<c0023abc>]
(__irq_svc+0x3c/0x100)
[42949437.930000] Exception stack(0xcb923e30 to 0xcb923e78)
[42949437.930000] 3e20: c034f890
0001904d a0000013 c034f84c
[42949437.930000] 3e40: cb923ea0 cb923ea0 c03967e6 00000012 0000003b
00000000 c034f8a4 cb923eec
[42949437.930000] 3e60: cb923e48 cb923e78 c008e620 c008ebe8 60000013
ffffffff
[42949437.930000] r6:00100000 r5:fe604000 r4:ffffffff
[42949437.930000] [<c008e9d4>] (vprintk+0x0/0x31c) from [<c0035a3c>]
(NvOsDebugPrintf+0x1c/0x24)
[42949437.930000] [<c0035a20>] (NvOsDebugPrintf+0x0/0x24) from
[<c0043920>] (NvDdkUsbfEndpointStatus+0x34/0x6c)
[42949437.930000] r3:00000000 r2:0000022c r1:c02953b8 r0:c030d3cc
[42949437.930000] [<c00438ec>] (NvDdkUsbfEndpointStatus+0x0/0x6c) from
[<c00311d8>] (NvUsbShimEventThread+0x238/0xe9c)
[42949437.930000] r6:ccbda000 r5:ccbda104 r4:00000000
[42949437.930000] [<c0030fa0>] (NvUsbShimEventThread+0x0/0xe9c) from
[<c0034898>] (thread_wrapper+0x1c/0x24)
[42949437.930000] [<c003487c>] (thread_wrapper+0x0/0x24) from
[<c00a2a20>] (kthread+0x58/0x8c)
[42949437.930000] [<c00a29c8>] (kthread+0x0/0x8c) from [<c0090fc0>]
(do_exit+0x0/0x71c)
[42949437.930000] r7:00000000 r6:00000000 r5:00000000 r4:00000000
> Google android team- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

育宇

unread,
Aug 27, 2009, 9:43:34 PM8/27/09
to Android Linux Kernel Development
Any updates?

On 7月25日, 上午5時55分, Mike Lockwood <lockw...@android.com> wrote:
> I think the problem is thatgadgetonly supports one driver at a time,
> so you cannot run the androidgadgetdriver and gadgetfs
> simultaneously. If you built the android driver as a module, then you
> could manually load one or the other and switch between android and
> gadgetfs. But the android driver is not currently set up to work as a
> module (we are just statically linking it in at this point). It
> probably wouldn't be too hard to get it working as a module, but I
> don't think anyone has done that yet.
>
> Mike
>
>
>
>
>
> On Fri, Jul 24, 2009 at 3:50 AM, Ashutosh<as...@techmahindra.com> wrote:
>
> > Hi Mike,
>
> > I have been able to compile kernel 2.6.29 with configuration (USB
> > function is disabled)--
>
> > CONFIG_USB_GADGET=y
> > CONFIG_USB_GADGET_VBUS_DRAW=500
> > CONFIG_USB_GADGET_SELECTED=y
> > CONFIG_USB_GADGET_MSM_72K=y
> > CONFIG_USB_MSM_72K=y
> > CONFIG_USB_GADGET_DUALSPEED=y
> > CONFIG_USB_ANDROID=y
>
> > I am able to get adb shell.
>
> > I also compiled gadgetfs as module and got gadgetfs.ko. I inserted it
> > in kernel but when I try to mount on it (mount -tgadgetpath /dev/
> >> disabled and the followinggadgetfeatures enabled:
> >> >> After configuring kernel,GADGETand USB_FUNCTION configuration looks

育宇

unread,
Aug 27, 2009, 8:24:24 AM8/27/09
to Android Linux Kernel Development
1.)Are there any solutions for gadget android module? It seems this
problems still occur on android 1.5.

2.)I have bind the acm_bind_config (acm_cdc usb gadget driver f_acm.c)
and gser_bind_config (generic gadget usb driver f_serial.c) to
android.c. The frist one can be recongized by acm_cdc driver on PC
side, but it can not work. Other other hand, the second one have to
load generic serial usb driver, such as Qualcom's usb driver, but it
will casue errors. Do you think these errors result from the usb
device driver provide by vendor?
On 7月25日, 上午5時55分, Mike Lockwood <lockw...@android.com> wrote:

shashi39

unread,
Sep 21, 2009, 8:42:16 AM9/21/09
to Android Linux Kernel Development
Hi All,
Any body succed MTP Support in android dev,


On Jul 24, 12:50 pm, Ashutosh <as...@TechMahindra.com> wrote:
> Hi Mike,
>
> I have been able to compile kernel 2.6.29 with configuration (USB
> function is disabled)--
>
> CONFIG_USB_GADGET=y
> CONFIG_USB_GADGET_VBUS_DRAW=500
> CONFIG_USB_GADGET_SELECTED=y
> CONFIG_USB_GADGET_MSM_72K=y
> CONFIG_USB_MSM_72K=y
> CONFIG_USB_GADGET_DUALSPEED=y
> CONFIG_USB_ANDROID=y
>
> I am able to get adb shell.
>
> I also compiledgadgetfsas module and gotgadgetfs.ko. I inserted it
Reply all
Reply to author
Forward
0 new messages