embeded/odroid

odroid c2 usb otg, libcomposite usb hid

구차니 2021. 9. 26. 08:51

방법들은 비슷한데.. 따라하는데 영 안되네?

functions 디렉토리에 hid.usb0 디렉토리를 생성하는데 에러가 발생.

#!/bin/bash
# From the README at https://github.com/girst/hardpass

dtoverlay dwc2
modprobe dwc2
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p g1
cd g1
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "girst" > strings/0x409/manufacturer
echo "Hardpass" > strings/0x409/product

N="usb0"
mkdir -p functions/hid.$N
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length

echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x85\\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\\x05\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0\\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x85\\x02\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x03\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x02\\x81\\x06\\xC0\\xC0 > functions/hid.usb0/report_desc

C=1
mkdir -p configs/c.$C/strings/0x409
echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
echo 250 > configs/c.$C/MaxPower
ln -s functions/hid.usb0 configs/c.$C/

ls /sys/class/udc > UDC

[링크 : https://ndb796.tistory.com/481]

[링크 : https://www.isticktoit.net/?p=1383]

[링크 : https://www.sysnet.pe.kr/2/0/11363]

 

혹시 권한 문제인가 해서 추가해도 안되고..

sysfs 특성이라 드라이버에서 허가되지 않는 파일은 생성이 안되는 것 같은데 왜 일까..

# ls -al
drwxr-xr-x 2 root root    0 Sep 26 09:15 functions

# chmod 777 functions/
# ls -al
drwxrwxrwx 2 root root    0 Sep 26 09:15 functions

# mkdir hid.usb0
mkdir: cannot create directory 'hid.usb0': No such file or directory
# touch hid.usb0
touch: cannot touch 'hid.usb0': Permission denied

 

 

+

3.16 커널인데 3.19 이후 부터 된다고. 드라이버 지원(하드웨어 가속)을 포기하고 신버전을 써봐야 할지도?

# ll /lib/modules/3.16.72-46/kernel/drivers/usb/gadget/
total 804
drwxr-xr-x 2 root root  4096 Aug 13  2019 ./
drwxr-xr-x 7 root root  4096 Aug 13  2019 ../
-rw-r--r-- 1 root root 14424 Aug 13  2019 g_acm_ms.ko
-rw-r--r-- 1 root root 23784 Aug 13  2019 g_audio.ko
-rw-r--r-- 1 root root 12048 Aug 13  2019 g_cdc.ko
-rw-r--r-- 1 root root 14920 Aug 13  2019 g_ether.ko
-rw-r--r-- 1 root root 19632 Aug 13  2019 g_ffs.ko
-rw-r--r-- 1 root root 24208 Aug 13  2019 g_hid.ko

# insmod g_hid
insmod: ERROR: could not load module g_hid: No such file or directory

# modprobe g_hid
modprobe: ERROR: could not insert 'g_hid': No such device

# uname -a
Linux odroid 3.16.72-46 #1 SMP PREEMPT Tue Aug 13 18:09:58 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

[링크 : https://forum.odroid.com/viewtopic.php?t=36602]

[링크 : https://forum.odroid.com/viewtopic.php?t=30267]