<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[T113  usb Gadget UVC，pc上没有枚举]]></title><description><![CDATA[<p dir="auto">硬件：T113开发板；<br />
目标：想要在otg-usb口上模拟出uvc 摄像头设备；<br />
测试：</p>
<ul>
<li>
<p dir="auto">1，系统默认otg-usb是ADB devce，在内核和tina linux上关闭了adb相关,otg-usb给Gadget uvc；</p>
</li>
<li>
<p dir="auto">2，参考如下官方资料<br />
<img src="/assets/uploads/files/1752760498159-147823a2-0bbb-4c62-804f-367fdf5b1295-image.png" alt="147823a2-0bbb-4c62-804f-367fdf5b1295-image.png" class=" img-responsive img-markdown" width="494" height="841" /></p>
</li>
<li>
<p dir="auto">3，<a href="http://xn--uvc-y28du2bv1smxa170ahveo5a985btsjtzav2m3m2j.sh" target="_blank" rel="noopener noreferrer nofollow ugc">将官方命令整合成如下脚本uvc.sh</a></p>
</li>
</ul>
<pre><code>#!/bin/sh
mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/g1

echo "0x1f3a" &gt; /sys/kernel/config/usb_gadget/g1/idVendor
echo "0x100d" &gt; /sys/kernel/config/usb_gadget/g1/idProduct

#添加设备字符串
mkdir /sys/kernel/config/usb_gadget/g1/strings/0x409
echo "Tina"         &gt; /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
echo "UVC Cam"      &gt; /sys/kernel/config/usb_gadget/g1/strings/0x409/product
echo "0123456789"   &gt; /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber


#添加 UVC function（最小化配置）
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0

#添加最简单的一组 MJPEG 配置（测试用）
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p
echo 1280 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/wWidth
echo 720 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/wHeight

echo 333333 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/dwFrameInterval
echo 333333 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/dwDefaultFrameInterval
echo 442368000 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/dwMinBitRate
echo 442368000 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/dwMaxBitRate
echo 1843200 &gt; /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize

mkdir /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/class/fs
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/class/hs

mkdir /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/class/fs/
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/class/ss/

mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1
echo 0xc0 &gt; /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
echo 500 &gt; /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
echo 0xc0 &gt; /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
echo 500  &gt; /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower

mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
echo "UVC Config" &gt; /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409/configuration
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/ /sys/kernel/config/usb_gadget/g1/configs/c.1/

ls /sys/class/udc/ | xargs echo &gt; /sys/kernel/config/usb_gadget/g1/UDC
</code></pre>
<ul>
<li>4，在T113开发板上执行如上脚本，没有任何报错，<strong>但是pc上看不到设备枚举动作；</strong></li>
</ul>
<pre><code>root@TinaLinux:/opt# ./uvc.sh
[INFO] Mounting configfs...
[INFO] Creating gadget...
[INFO] Setting device descriptors...
[INFO] Creating UVC function...
[INFO] Setting MJPEG 720p...
[INFO] Creating headers...
[INFO] Linking UVC function to configuration...
[INFO] Enabling gadget...
[   53.291067] configfs-gadget gadget: uvc: uvc_function_bind()
[OK] UVC gadget created and enabled successfully!
</code></pre>
<p dir="auto">敬请指点。</p>
<p dir="auto">另外，参考小机做HID的例子，可以成功的枚举出hid keyboard 设备；用类似的方法做uvc却不行，为什么？<br />
有参考过如下帖子，没有找到答案....，先谢过，折腾了好久没有解决，期待指点迷津....<br />
<a href="https://bbs.aw-ol.com/topic/2888/t113-tina-otg-gadget-uvc%E5%A4%B1%E8%B4%A5/2?_=1752760090570">链接文本</a></p>
]]></description><link>https://bbs.aw-ol.com/topic/6508/t113-usb-gadget-uvc-pc上没有枚举</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 00:57:41 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/6508.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Jul 2025 14:06:35 GMT</pubDate><ttl>60</ttl></channel></rss>