1 如何使用
1.1 需要加载的驱动
zcat /proc/config.gz | grep CONFIG_USB_F
libcomposite.ko
usb_f_fs.ko
usb_f_mass_storage.ko
modinfo usb_f_fs.ko
1.2 GENIVI arm64 adbd
https://github.com/BigfootACA/adbd
https://github.com/tonyho/adbd-linux
1.3 如何使用
function init()
{
mount -t configfs none /sys/kernel/config
cd /sys/kernel/config/usb_gadget
mkdir g1
cd g1
echo "0xabcd" > idVendor
echo "0x1234" > idProduct
echo "0x100" > bcdDevice
echo "0x200" > bcdUSB
mkdir strings/0x409
echo "0123456789abcdef" > \
strings/0x409/serialnumber
echo "master" > \
strings/0x409/manufacturer
echo "george" > \
strings/0x409/product
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "config1" > \
configs/c.1/strings/0x409/configuration
# name is from the first argument of
# DECLARE_USB_FUNCTION_INIT(name, ...)
mkdir functions/ffs.adb
mkdir functions/mass_storage.ms
echo /dev/sde5 > \
functions/mass_storage.ms/lun.0/file
mkdir /dev/usb-ffs
mkdir /dev/usb-ffs/adb
}
function start()
{
cd /sys/kernel/config/usb_gadget/g1
ln -s functions/mass_storage.ms \
configs/c.1/f1
ln -s functions/ffs.adb \
configs/c.1/f2
mount -t functionfs adb /dev/usb-ffs/adb
adbd &
ls /sys/class/udc/
cat /sys/devices/platform/soc/a600000.ssusb/mode
echo peripheral > \
/sys/devices/platform/soc/a600000.ssusb/mode
echo a600000.dwc3 > UDC
cat /sys/class/udc/a600000.dwc3/state
}
function stop()
{
cd /sys/kernel/config/usb_gadget/g1
echo "" > UDC
killall adbd
rm configs/c.1/f1
rm configs/c.1/f2
umount /dev/usb-ffs/adb
}
function print_usage()
{
echo "Usage: usb.sh {init|start|stop}"
}
case "$1" in
"init")
init
;;
"start")
start
;;
"stop")
stop
;;
*)
print_usage
;;
esac
2 驱动调用流程
2.1 创建一个USB配置
# mkdir configs/c.1
format: <char>.<number>
<char>: any character
<number>: usb configuration value, which should be started from 1
call-stack:
gadgets_make
--->
config_desc_make
2.2 创建一个USB功能
# mkdir functions/acm.gs0
format: <func_name>.<instance_name>
func_name is from the first argument of
DECLARE_USB_FUNCTION_INIT(name, ...)
call-stack:
gadgets_make
--->
function_make
2.3 配置USB描述中的字符串
# echo "oem-demo" > xxx/strings/0x409/xxx
call-stack:
gadget_strings_langid_attrs
This string length should be less than 40.
3 Abbreviations
ARC:Argonant RISC Core
AT91SAM9260:SAM means Smart ARM-based Microcontroller
ATMEL SAMBA:ATMEL Smart ARM-based Microcontroller Boot Assistant
CC2530:TI ChipCon2530
DWC2:Design Ware Controller 2,Apple的嵌入式设备,包括iPad和iPhone都是使用的DWC2
ISP1161:Philips' Integrated host Solution Pairs 1161,“Firms introduce USB host controllers”,https://www.eetimes.com/document.asp?doc_id=1290054
Quirks:the attributes of a device that are considered to be noncompliant with expected operation
SL811HS:Cypress/ScanLogic 811 Host/Slave,性能上与ISP1161(Integrated host Solution Pairs 1161)相当
TDI:TransDimension Inc.,该公司首先发明了将TT集成到EHCI RootHub中的方法,这样对于嵌入式系统来说,就省去了OHCI/UHCI的硬件,同时降低了成本,作为对该公司的纪念,Linux内核定义了宏ehci_is_TDI(ehci);产品UHC124表示USB Host Controller;收购了ARC USB技术;现已被chipidea收购,chipidea又被mips收购
TLV:TI Low Value,高性价比
TPS:TI Performance Solution
TT:Transaction Translator(事务转换器,将USB2.0的包转换成USB1.1的包)
USB BH reset:Bigger Hammer or Brad Hosler,表示warm reset;you may be confused why the USB 3.0 spec calls the same type of reset "warm reset" in some places and "BH reset" in other places. "BH" reset is supposed to stand for "Big Hammer" reset, but it also stands for "Brad Hosler". Brad died shortly after the USB 3.0 bus specification was started, and they decided to name the reset after him. The suggestion was made shortly before the spec was finalized, so the wording is a bit inconsistent.
Linux USB configfs使用总结
最新推荐文章于 2024-07-03 16:14:43 发布