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?

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/b8e73b33-b68f-4e09-ac97-066e02f6d1e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/bin/bash
# This script will create a HID device on the BBB

# if the g_multi device is loaded remove it
if lsmod | grep g_multi >/dev/null ; then
  modprobe -r g_multi
fi
# check for the existance of configfs
if mount | grep '/sys/kernel/config' >/dev/null ; then
  umount /sys/kernel/config
fi
mount none -t configfs /sys/kernel/config
# create a keyboard device
kbdir="/sys/kernel/config/usb_gadget/kb"
if [ ! -d "$kbdir" ] ; then
  mkdir $kbdir
fi
echo 0x1337 >"$kbdir/idVendor"
echo 0x1337 >"$kbdir/idProduct"
echo 0x0100 >"$kbdir/bcdDevice"
echo 0x0100 >"$kbdir/bcdUSB"        # Changed to suggest compatibility with USB 1.0. 0x0110 is 1.1, 0x0200 is USB 2.0.
if [ ! -d "$kbdir/configs/c.1" ] ; then
  mkdir "$kbdir/configs/c.1"
fi
echo 500 >"$kbdir/configs/c.1/MaxPower"
if [ ! -d "$kbdir/functions/hid.usb0" ] ; then
  mkdir "$kbdir/functions/hid.usb0"
fi
echo 1 >"$kbdir/functions/hid.usb0/subclass"
echo 1 >"$kbdir/functions/hid.usb0/protocol"
echo 8 >"$kbdir/functions/hid.usb0/report_length"
cp report_descriptor_kb.bin "$kbdir/functions/hid.usb0/report_desc"
ln -s "$kbdir/functions/hid.usb0" "$kbdir/configs/c.1"

#echo musb-hdrc.0.auto >"$kbdir/UDC"
#echo musb-hdrc.0.auto >"$kbdir/UDC"

#v4.4.x-ti
if [ -d /sys/class/udc/musb-hdrc.0.auto ] ; then
  echo musb-hdrc.0.auto >"$kbdir/UDC"
else
  #v4.9.x-ti
  if [ -d /sys/class/udc/musb-hdrc.0 ] ; then
    echo musb-hdrc.0 >"$kbdir/UDC"
  fi
fi

Reply via email to