rock3a can support a usb3.0 otg or usb 2.0 otg, but when i use usb otg to simulate a hid, it sames doesn’t work, however when i run my otg hid shell on another board (cpu is rk3566), use the same kernel image as rock3a, and use the same usb config for dtc code. it works well on rk3566. Why is it? is there some hardware err on rock3a ?
kernel driver need:
modprobe configfs
modprobe libcomposite
modprobe usb_f_hid
create usb otg hid shell is:
create_usbhid.zip (983 Bytes)
#!/bin/sh
new_directory="/sys/kernel/config/usb_gadget/otg"
if [ $# -ne 1 ]
then
echo “usage: $0 <start|stop>” >&2
exit 0
fiaction=$1
if [ $action = “start” ];then
original_directory="$(pwd)"
mkdir “${new_directory}”
cd “${new_directory}”echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x1d6b > idVendor # Linux Foundationmkdir strings/0x409
echo “hid” > strings/0x409/manufacturer
echo “virtual_input” > strings/0x409/product
echo “OTG0001” > strings/0x409/serialnumbermkdir functions/hid.0
echo 1 > functions/hid.0/protocol # 1: keyboard
echo 8 > functions/hid.0/report_length
echo 1 > functions/hid.0/subclassecho -ne ‘\x05\x01\x09\x06\xa1\x01\x05\x07\x19\xe0\x29\xe7\x15\x00\x25\x01\x75\x01\x95\x08\x81\x02\x95\x01\x75\x08\x81\x03\x95\x05\x75\x01\x05\x08\x19\x01\x29\x05\x91\x02\x95\x01\x75\x03\x91\x03\x95\x06\x75\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xc0’ > functions/hid.0/report_desc
mkdir functions/hid.1
echo 0 > functions/hid.1/protocol # 2: mouse
echo 6 > functions/hid.1/report_length
echo 1 > functions/hid.1/subclassecho -ne ‘\x05\x01\x09\x02\xa1\x01\x09\x01\xa1\x00\x05\x09\x19\x01\x29\x03\x15\x00\x25\x01\x95\x05\x75\x01\x81\x02\x95\x01\x75\x03\x81\x01\x05\x01\x09\x30\x09\x31\x15\x00\x26\xff\x7f\x75\x10\x95\x02\x81\x02\x09\x38\x15\x81\x25\x7f\x75\x08\x95\x01\x81\x06\xc0\xc0’ > functions/hid.1/report_desc
mkdir configs/c.1
mkdir configs/c.1/strings/0x409echo 0x80 > configs/c.1/bmAttributes
echo 300 > configs/c.1/MaxPower
echo “” > configs/c.1/strings/0x409/configurationln -s functions/hid.0 configs/c.1
ln -s functions/hid.1 configs/c.1echo “fcc00000.dwc3” > UDC
cd “${original_directory}”
elif [ $action = “stop” ];then
original_directory="$(pwd)"
cd $new_directory
rm configs/c.1/hid.0
rm configs/c.1/hid.1
rmdir functions/hid.0
rmdir functions/hid.1
rmdir configs/c.1/strings/0x409
rmdir configs/c.1
rmdir strings/0x409
cd “${original_directory}”
rmdir $new_directory
else
echo “invalid action $action” >&2
exit 1
fiexit 0
use “create_usbhid.sh start” to create a mouse and keyboard, and use “create_usbhid.sh stop” to remove mouse and keyboard, i’m sure my shell script is correct, but i still not konw where is wrong with rock3a.
If you success creat a mouse and keyboard, you will see like this:
and rock3a is like this: