Hi All
I'm currently working on a touchscreen keyboard project where the BBB displays images on a screen, receives the touch events form the touch panel and has to send them to the main PC as key events. So the BBB has to present it self as a HID (keyboard) device to the PC.
What I have to do is, write a program that runs on the BeagleBone that has to do the following things:
- Takes the images from its FLASH memory and arranges them on the screen;
- Captures the output of the touch panel and translates them into proper key events.
- And lastly, it has to connect to the USB Device controller and send those key events to the PC.
The hardware is present. The BBB has USB On-The-Go, which can be used as USB device controller. It's configured as USB Ethernet device and mass storage device by default and those functions do work.
So far I've written a script that configures the USB OTG device as HID, but now what?!
I really don't know how to continue. I'm not even sure that my script configures everything as it should. The examples (of such scripts) I looked from, were somewhat outdated.
The script fills in data like VID and PID into the files created by the configfs and creates some new files and directories as per the examples I've seen. Only the last command fails:
ls: write error: Device or resource busy
This is where the desired kernel module has to be mentioned so that configfs loads it. But the module (usb_f_hid) does get loaded! So I thought that error is not a big deal?!
I was expecting that a device file would appear in /dev after the script is ran, so I can open it and start communicating with the USB device controller. But I was not able to find such a device file. it has to be named "usb0" but no device filed with "usb" prefix are present before or after the script is ran.
The BeagleBone runs Debian
Linux beaglebone 4.4.14-bone11 #1 Thu Jul 14 08:51:47 EEST 2016 armv7l GNU/Linux
Can you point me to some resources that explain the process of using BBB as HID or something of the sort.
Also how can I remove the USB network functionality properly?
Thanks a lot in advance.
What I have tried:
This is the entire script. It's executed as
root
.
The configfs is already mounted and the libcomposite module is loaded at startup so I don't have to do that in the script.
mkdir /sys/kernel/config/usb_gadget/usb_keyboard
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0
echo "1" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/protocol # set the HID protocol
echo "1" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/subclass # set the device subclass
echo "8" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/report_length # REPORT_LENGTH = 8 set the byte length of HID reports
cat /home/debian/report_desc.bin > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/report_desc
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/strings/0x409
echo "0x37f2" > /sys/kernel/config/usb_gadget/usb_keyboard/idVendor
echo "0x0001" > /sys/kernel/config/usb_gadget/usb_keyboard/idProduct
echo "0x03" > /sys/kernel/config/usb_gadget/usb_keyboard/bDeviceClass
echo "71cb32dc0e49d782e9d1" > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/serialnumber
echo "**** ***** Technology Ltd." > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/manufacturer
echo "*** Keyboard" > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/product
echo "Custom USB Keyboard" > /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/strings/0x409/configuration
echo "120" > /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/MaxPower
ln -s /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0 /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/usb_keyboard/UDC #This fails with "ls: write error: Device or resource busy"
The contetnts of
/sys/class/udc/
are not what they're supposed to be as per the instructions for configfs HID setup. There sould be a list of modules to be loaded. Instead, there is this "
musb-hdrc.0.auto
" simlink.
Also I googled my a** off trying to find some more info on the matter but nothing comes out.