linux - Raspberry Pi Zero USB device emulation -


i know raspberry pi 0 supports otg , usb peripheral protocols, , there's lot of cool built in peripherals shown here: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all#other-modules

the problem need emulate usb peripheral device not appear on list. have vendor id , product id device, , i'm trying figure out how go doing this. need modify otg usb drivers in raspbian kernel? have build own kernel? or there better option don't realize?

thanks in advance!!

do need modify otg usb drivers in raspbian kernel?

the answer first question "it depends", if device doesn't unusual no: need not modify source code kernel modules nor kernel.

you're fortunate raspbian supports modern kernel configfs support. once set dtoverlay=dwc2, can open functionfs bulk endpoint root so:

modprobe libcomposite modprobe usb_f_fs cd /sys/kernel/config/usb_gadget mkdir -p myperipheral; cd myperipheral echo 0x1234 > idvendor  # put actual vendor id here echo 0xabcd > idproduct # put actual product id here mkdir configs/c.1 mkdir configs/c.1/strings/0x409 echo "my peripheral" > configs/c.1/strings/0x409/configuration mkdir functions/ffs.my_func_name ln -s functions/ffs.my_func_name configs/c.1/ mkdir -p /tmp/mount_point mount my_func_name -t functionfs /tmp/mount_point # compile ffs-test source, copy , run /tmp/mount_point ls /sys/class/udc > udc 

if need emulate other device more closely, it's set bcddevice, bcdusb, serial number, manufacturer, product string, max power, os_desc, , possibly other fields.

afaik functionfs not support isochronous endpoints, interrupt transfers, nor out-of-the-ordinary control transfers. if require this, may need start looking extending existing gadget modules, source code here.

update: when got home test this, encountered severe caveat raspbian. it'll fail create ffs.my_func_name because usb_f_fs not enabled default. although need not modify kernel modules, must recompile alternate configuration. make menuconfig -> device drivers -> usb support -> usb gadget support -> usb functions configurable through configfs / function filesystem (functionfs) + other modules test. after uploading new kernel/modules, tested above script on raspbian 8. recommend setting usb gadget drivers / function filesystem (m) in case resort simpler g_ffs legacy module in lieu of configfs.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -