Welcome! Log In Create A New Profile

Advanced

Using my AM335x board as usb gadget

Posted by Ison Thomas 
Using my AM335x board as usb gadget
September 09, 2017 08:17AM
Hi,

I want to setup my AM335x-usb0 as a slave device. I have configured the dts file as:

&usb0 {
status = "okay";
dr_mode = "peripheral";
};

I am using the the userspace example of usb gadget provided at :
Usb Gadget Userspace example

to make my device work as a slave.

I am connecting this usb to an android tablet and when I run this application I can observe some interaction between the device and android tablet. The application log is giiven

Quote

[ 9008.810292] gadgetfs: bound to musb-hdrc driver

/dev/gadget/musb-hdrc ep0 configured

serial="v0as74ncb6hjtqb2bn3alkyijpx93kmqj77d3i6fgovuxm0byf8hg1k5pnvtnfd"

[ 9009.164766] gadgetfs: connected



** Fri Feb 28 05:04:26 2014

CONNECT high speed

[ 9009.172832] gadgetfs: disconnected

DISCONNECT

[ 9009.374442] gadgetfs: connected

CONNECT high speed

SETUP 80.06 v0300 i0000 255

SETUP 80.06 v0302 i0409 255

Gadget Get String[ 9009.383064] gadgetfs: configuration #3

, str : My Source/Sink Product

Gadget Get Strin[ 9015.873051] BUG: spinlock lockup suspected on CPU#0, usbslave/291

[ 9015.879459] lock: 0xce572a00, .magic: dead4ead, .owner: usbslave/291, .owner_cpu: 0

[ 9015.887580] CPU: 0 PID: 291 Comm: usbslave Not tainted 4.1.18 #13

[ 9015.893965] Hardware name: Generic AM33XX (Flattened Device Tree)

[ 9015.900395] [<c0013a50>] (unwind_backtrace) from [<c0011e3c>] (show_stack+0x10/0x14)

[ 9015.908554] [<c0011e3c>] (show_stack) from [<c0064f6c>] (do_raw_spin_lock+0xd4/0x118)

[ 9015.916802] [<c0064f6c>] (do_raw_spin_lock) from [<c062f49c>] (_raw_spin_lock_irqsave+0x40/0x4c)

[ 9015.926047] [<c062f49c>] (_raw_spin_lock_irqsave) from [<bf0002e4>] (ep0_complete+0x18/0xb8 [gadgetfs])

[ 9015.935944] [<bf0002e4>] (ep0_complete [gadgetfs]) from [<c041b070>] (musb_g_giveback+0x124/0x144)

[ 9015.945367] [<c041b070>] (musb_g_giveback) from [<c0419638>] (musb_g_ep0_queue+0x120/0x16c)

[ 9015.954152] [<c0419638>] (musb_g_ep0_queue) from [<bf0010f4>] (ep0_read+0xc0/0x544 [gadgetfs])

[ 9015.963208] [<bf0010f4>] (ep0_read [gadgetfs]) from [<c01154f8>] (__vfs_read+0x20/0xcc)

[ 9015.971625] [<c01154f8>] (__vfs_read) from [<c0115b88>] (vfs_read+0x84/0xec)

[ 9015.979037] [<c0115b88>] (vfs_read) from [<c01162f8>] (SyS_read+0x40/0x80)

[ 9015.986265] [<c01162f8>] (SyS_read) from [<c000e880>] (ret_fast_syscall+0x0/0x54)

[ 9015.994142] musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage in/status

g, strlen : 22

SETUP 80.06 v0301 i0409 255

Gadget Get String, str : Licensed to Code, LLC

Gadget Get String, strlen : 21

SETUP 80.06 v0303 i0409 255

Gadget Get String, str : v0as74ncb6hjtqb2bn3alkyijpx93kmqj77d3i6fgovuxm0byf8hg1k5pnvtnfd

Gadget Get String, strlen : 63

SETUP 00.09 v0003 i0000 0

CONFIG #3

simple_sink_thread start -1235143584 fd 4

simple_source_thread start -1226754976 fd 5

SETUP 80.06 v0304 i0409 2

Gadget Get String, str : The Configuration

Gadget Get String, strlen : 17

SETUP 80.06 v0304 i0409 36

Gadget Get String, str : The Configuration

Gadget Get String, strlen : 17

SETUP 80.06 v0305 i0409 255

Gadget Get String, str : Source/Sink

Gadget Get String, strlen : 11

SETUP 80.06 v0300 i0000 254

SETUP 80.06 v0301 i0409 254

Gadget Get String, str : Licensed to Code, LLC

Gadget Get String, strlen : 21

SETUP 80.06 v0300 i0000 254

SETUP 80.06 v0302 i0409 254

Gadget Get String, str : My Source/Sink Product

Gadget Get String, strlen : 22

SETUP 80.06 v0300 i0000 254

SETUP 80.06 v0303 i0409 254

Gadget Get String, str : v0as74ncb6hjtqb2bn3alkyijpx93kmqj77d3i6fgovuxm0byf8hg1k5pnvtnfd

Gadget Get String, strlen : 63

SETUP 80.06 v0300 i0000 254

SETUP 80.06 v0304 i0409 254

Gadget Get String, str : The Configuration

Gadget Get String, strlen : 17

SETUP 80.06 v0300 i0000 254

SETUP 80.06 v0305 i0409 254

Gadget Get String, str : Source/Sink

Gadget Get String, strlen : 11

(Kindly ignore the "Gadget Get String, str " and "Gadget Get String, strlen" prints as those were added by me.)

What I can observe is that:
1. while the host device was requesting the string descriptors a spinlock bug has occured.
2. After reading the string descriptors the host is trying to configure my device "SETUP 00.09 v0003 i0000 0"
3. After this command it is again trying to read some string descriptors and stopping there.

My questions are:
1. What could be the reason for spinlock error?
2. Does this cover the entire handshake between usb host and device?

Kindly let me know if something needs to be done to make it work properly. I can see three "Fix me" sections in the usb.c file provided in the link but I am not sure what to add there.

Thanks in advance
Ison Thomas
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 4 plus 8?
Message: