Trouble building a configfs for HID device on BBBW

351 views
Skip to first unread message

ssci...@gmail.com

unread,
Nov 22, 2017, 1:23:15 PM11/22/17
to BeagleBoard
I am trying to get a BBBW to register itself as a pure HID device.

I'm starting with a modified version of Phil Polstra's bash script presented at DEF CON (attached). His script was built originally for Ubuntu, but I'm running the latest 9.1 Debian image.

I have updated the original last line from echoing 'musb-hdrc.0.auto' to 'musb-hdrc.0' (for versions 4.9.x, which mine is).

Here's what happens:

debian@beaglebone:~$ sudo bash create-hid-BB.sh

create-hid-BB.sh: line 44: echo: write error: Device or resource busy

debian@beaglebone:~$ sudo bash create-hid-BB.sh

create-hid-BB.sh: line 29: echo: write error: Device or resource busy

create-hid-BB.sh: line 30: echo: write error: Device or resource busy

create-hid-BB.sh: line 31: echo: write error: Device or resource busy

cp: error writing '/sys/kernel/config/usb_gadget/kb/functions/hid.usb0/report_desc': Device or resource busy

ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/kb/configs/c.1/hid.usb0': File exists

create-hid-BB.sh: line 44: echo: write error: Device or resource busy

debian@beaglebone:~$ sudo bash create-hid-BB.sh

create-hid-BB.sh: line 29: echo: write error: Device or resource busy

create-hid-BB.sh: line 30: echo: write error: Device or resource busy

create-hid-BB.sh: line 31: echo: write error: Device or resource busy

cp: error writing '/sys/kernel/config/usb_gadget/kb/functions/hid.usb0/report_desc': Device or resource busy

ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/kb/configs/c.1/hid.usb0': File exists

create-hid-BB.sh: line 44: echo: write error: Device or resource busy


I also tried:
  1. Restarting the system.
  2. Leaving g_multi in place.
  3. Building a kb folder in another folder with the customizations specified in the attached script.
  4. Copying the kb folder to /sys/kernel/config/usb_gadget/
  5. This also fails with the same messages. It's almost like the moment there's a /sys/kernel/config/usb_gadget/kb folder, the system connects to it and starts using it. (Note that during this time, my computer is NOT registering the BBBW as a HID device yet).
It seems like it shouldn't be this difficult. How can I make a BBBW pure HID?

create-hid-BB.sh

Robert Nelson

unread,
Nov 22, 2017, 1:34:00 PM11/22/17
to Beagle Board, SS Cirrus
On Wed, Nov 22, 2017 at 12:23 PM, <ssci...@gmail.com> wrote:
> I am trying to get a BBBW to register itself as a pure HID device.
>
> I'm starting with a modified version of Phil Polstra's bash script presented
> at DEF CON (attached). His script was built originally for Ubuntu, but I'm
> running the latest 9.1 Debian image.
>
> I have updated the original last line from echoing 'musb-hdrc.0.auto' to
> 'musb-hdrc.0' (for versions 4.9.x, which mine is).
>
> Here's what happens:
>
> debian@beaglebone:~$ sudo bash create-hid-BB.sh
>
> create-hid-BB.sh: line 44: echo: write error: Device or resource busy

add the -ex options to bash, so you can actually watch and therefore
trace what happens..

Regards,


--
Robert Nelson
https://rcn-ee.com/
Message has been deleted

ssci...@gmail.com

unread,
Nov 22, 2017, 2:09:28 PM11/22/17
to BeagleBoard
The first time:

debian@beaglebone:~$ sudo bash -ex create-hid-BB.sh
[sudo] password for debian:
+ grep g_multi
+ lsmod
+ mount
+ grep /sys/kernel/config
+ umount /sys/kernel/config
+ mount none -t configfs /sys/kernel/config
+ kbdir=/sys/kernel/config/usb_gadget/kb
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb ']'
+ mkdir /sys/kernel/config/usb_gadget/kb
+ echo 0x1337
+ echo 0x1337
+ echo 0x0100
+ echo 0x0110
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb/configs/c.1 ']'
+ mkdir /sys/kernel/config/usb_gadget/kb/configs/c.1
+ echo 500
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb/functions/hid.usb0 ']'
+ mkdir /sys/kernel/config/usb_gadget/kb/functions/hid.usb0
+ echo 1
+ echo 1
+ echo 8
+ cp report_descriptor_kb.bin /sys/kernel/config/usb_gadget/kb/functions/hid.usb0/report_desc
+ ln -s /sys/kernel/config/usb_gadget/kb/functions/hid.usb0 /sys/kernel/config/usb_gadget/kb/configs/c.1
+ '[' -d /sys/class/udc/musb-hdrc.0.auto ']'
+ '[' -d /sys/class/udc/musb-hdrc.0 ']'
+ echo musb-hdrc.0

create
-hid-BB.sh: line 44: echo: write error: Device or resource busy


Same command again:

debian@beaglebone:~$ sudo bash -ex create-hid-BB.sh
+ lsmod
+ grep g_multi
+ grep /sys/kernel/config
+ mount
+ umount /sys/kernel/config
+ mount none -t configfs /sys/kernel/config
+ kbdir=/sys/kernel/config/usb_gadget/kb
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb ']'
+ echo 0x1337
+ echo 0x1337
+ echo 0x0100
+ echo 0x0110
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb/configs/c.1 ']'
+ echo 500
+ '[' '!' -d /sys/kernel/config/usb_gadget/kb/functions/hid.usb0 ']'
+ echo 1
create
-hid-BB.sh: line 29: echo: write error: Device or resource busy




Andrew P. Lentvorski

unread,
Jan 16, 2018, 4:41:40 AM1/16/18
to BeagleBoard
Did you ever get an answer for this.  I followed the directions at: https://wiki.tizen.org/USB/Linux_USB_Layers/Configfs_Composite_Gadget/Usage_eq._to_g_hid.ko

And am now bumping into the same problem:
root@beaglebone:/home/debian/cfg/usb_gadget/g1# pwd

 

/home/debian/cfg/usb_gadget/g1

root@beaglebone
:/home/debian/cfg/usb_gadget/g1# ls

bcdDevice bcdUSB bDeviceClass bDeviceProtocol bDeviceSubClass bMaxPacketSize0 configs functions idProduct idVendor os_desc strings UDC

root@beaglebone
:/home/debian/cfg/usb_gadget/g1# ls -al /sys/class/udc

total
0

drwxr
-xr-x 2 root root 0 Jan 16 09:30 .

drwxr
-xr-x 58 root root 0 Jan 16 09:30 ..

lrwxrwxrwx
1 root root 0 Jan 16 09:29 musb-hdrc.0.auto -> ../../devices/platform/ocp/47400000.usb/47401400.usb/musb-hdrc.0.auto/udc/musb-hdrc.0.auto

root@beaglebone
:/home/debian/cfg/usb_gadget/g1# echo musb-hdrc.0.auto > UDC

-su: echo: write error: Device or resource busy

root@beaglebone
:/home/debian/cfg/usb_gadget/g1# echo musb-hdrc.0 > UDC

-su: echo: write error: No such device

root@beaglebone
:/home/debian/cfg/usb_gadget/g1# uname -r

4.4.91-ti-r133



andrei...@gmail.com

unread,
Aug 16, 2018, 3:40:49 PM8/16/18
to BeagleBoard
Hello,

Were you able to solve this issue? I am getting the same "Device or resource busy" message.

Thank you.

andrei...@gmail.com

unread,
Aug 27, 2018, 11:53:30 AM8/27/18
to BeagleBoard
Hello,

Were you able to solve this problem? I am facing the same issue here.

Thank you.

Andrei
Reply all
Reply to author
Forward
0 new messages