WhyCan Forum(哇酷开发者社区)

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn

您尚未登录。

#1 2019-09-19 23:23:47

firstman
会员
注册时间: 2019-04-06
累计积分: 279

V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

# modprobe g_webcam
[   13.884493] g_webcam gadget: uvc: uvc_function_bind()
[   13.889574] g_webcam gadget: uvc: Unable to allocate streaming EP
[   13.895850] g_webcam musb-hdrc.1.auto: failed to start g_webcam: -22
[   13.905209] g_webcam gadget: uvc: uvc_function_bind()
[   13.910284] g_webcam gadget: uvc: Unable to allocate streaming EP
[   13.916566] g_webcam musb-hdrc.1.auto: failed to start g_webcam: -22
modprobe: can't load module g_webcam (kernel/drivers/usb/gadget/legacy/g_webcam.ko): Invalid argument

发现 HI3518 也有一模一样的问题 http://bbs.ebaina.com/thread-39433-1-1.html

离线

#2 2019-09-19 23:28:37

firstman
会员
注册时间: 2019-04-06
累计积分: 279

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

https://devtalk.nvidia.com/default/topic/1036885/tx1-usb-uvc-gadget-troubles/

问题:
TX1的OTG端口是否支持等时模式?
是否有不同的方法来配置系统以解决此错误?
我可以提供其他日志/信息,以便更容易调试吗?

在设备模式下,OTG端口不支持等时模式。

看来有点悲剧了

离线

#3 2019-09-19 23:35:07

firstman
会员
注册时间: 2019-04-06
累计积分: 279

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

不知道这个补丁有没有用哦: https://gitlab-beta.engr.illinois.edu/ejclark2/linux/commit/f82a689faeb328ba7c194782f42cc438519d508e

		musb_writew(hw_ep->regs, MUSB_RXCSR, val);

#ifdef CONFIG_USB_INVENTRA_DMA
		if (usb_pipeisoc(pipe)) {
			struct usb_iso_packet_descriptor *d;

			d = urb->iso_frame_desc + qh->iso_idx;
			d->actual_length = xfer_len;

			/* even if there was an error, we did the dma
			 * for iso_frame_desc->length
			 */
			if (d->status != EILSEQ && d->status != -EOVERFLOW)
				d->status = 0;

			if (++qh->iso_idx >= urb->number_of_packets)
				done = true;
			else
				done = false;

		} else  {
		/* done if urb buffer is full or short packet is recd */
		done = (urb->actual_length + xfer_len >=
				urb->transfer_buffer_length
			|| dma->actual_len < qh->maxpacket);
		}

		/* send IN token for next packet, without AUTOREQ */
		if (!done) {
		if (dma) {
			struct dma_controller	*c;
			u16			rx_count;
			int			ret;
			int			ret, length;
			dma_addr_t		buf;

			rx_count = musb_readw(epio, MUSB_RXCOUNT);


			c = musb->dma_controller;

			if (usb_pipeisoc(pipe)) {
				int status = 0;
				struct usb_iso_packet_descriptor *d;

				d = urb->iso_frame_desc + qh->iso_idx;

				if (iso_err) {
					status = -EILSEQ;
					urb->error_count++;
				}
				if (rx_count > d->length) {
					if (status == 0) {
						status = -EOVERFLOW;
						urb->error_count++;
					}
					DBG(2, "** OVERFLOW %d into %d\n",\
					    rx_count, d->length);

					length = d->length;
				} else
					length = rx_count;
				d->status = status;
				buf = urb->transfer_dma + d->offset;
			} else {
				length = rx_count;
				buf = urb->transfer_dma +
						urb->actual_length;
			}

			dma->desired_mode = 0;
#ifdef USE_MODE1
			/* because of the issue below, mode 1 will
						urb->actual_length)
					> qh->maxpacket)
				dma->desired_mode = 1;
			if (rx_count < hw_ep->max_packet_sz_rx) {
				length = rx_count;
				dma->bDesiredMode = 0;
			} else {
				length = urb->transfer_buffer_length;
			}
#endif

/* Disadvantage of using mode 1:
			 */
			ret = c->channel_program(
				dma, qh->maxpacket,
				dma->desired_mode,
				urb->transfer_dma
					+ urb->actual_length,
				(dma->desired_mode == 0)
					? rx_count
					: urb->transfer_buffer_length);
				dma->desired_mode, buf, length);

			if (!ret) {
				c->channel_release(dma);
		}
	}

	if (dma && usb_pipeisoc(pipe)) {
		struct usb_iso_packet_descriptor	*d;
		int					iso_stat = status;

		d = urb->iso_frame_desc + qh->iso_idx;
		d->actual_length += xfer_len;
		if (iso_err) {
			iso_stat = -EILSEQ;
			urb->error_count++;
		}
		d->status = iso_stat;
	}

finish:
	urb->actual_length += xfer_len;
	qh->offset += xfer_len;

离线

#4 2019-09-19 23:36:15

firstman
会员
注册时间: 2019-04-06
累计积分: 279

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

https://linux-sunxi.org/USB_OTG_Controller_Register_Guide

Supports up to 5 user configurable endpoints for bulk, isochronous, control, and interrupt bi-directional transfers

离线

#5 2019-09-20 08:59:57

firstman
会员
注册时间: 2019-04-06
累计积分: 279

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

http://davinci-linux-open-source.1494791.n2.nabble.com/DM365-uvc-gadget-td5992168.html

对USB协议没有研究, 这个问题太难了,等大神帮我填坑,或者以后再说吧

离线

#6 2020-10-03 19:18:29

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

启动文件: /etc/init.d/S99uvc

mount -t configfs none /sys/kernel/config

mkdir /sys/kernel/config/usb_gadget/g1
cd /sys/kernel/config/usb_gadget/g1
mkdir configs/c.1
mkdir strings/0x409
mkdir configs/c.1/strings/0x409
echo 0x3290 > idProduct
echo 0x18ec > idVendor
echo 0x0310 > bcdUSB
echo serial > strings/0x409/serialnumber
echo manufacturer > strings/0x409/manufacturer
echo UVC Gadget > strings/0x409/product
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
mkdir functions/uvc.usb0
mkdir -p functions/uvc.usb0/streaming/uncompressed/u/480p
cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/480p/dwFrameInterval
333333
1000000
5000000
EOF
echo 480 > functions/uvc.usb0/streaming/uncompressed/u/480p/wHeight
echo 333333 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwDefaultFrameInterval
echo 614400 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMaxVideoFrameBufferSize
echo 73728000 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMaxBitRate
echo 24576000 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMinBitRate
mkdir functions/uvc.usb0/streaming/header/h
cd functions/uvc.usb0/streaming/header/h
ln -s ../../uncompressed/u
cd ../../class/fs
ln -s ../../header/h
cd ../../class/hs
ln -s ../../header/h
cd ../../class/ss
ln -s ../../header/h
cd ../../../control
mkdir header/h
ln -s header/h class/fs
ln -s header/h class/hs
ln -s header/h class/ss
cd /sys/kernel/config/usb_gadget/g1
echo 1024 > functions/uvc.usb0/streaming_maxpacket
echo 15 > functions/uvc.usb0/streaming_maxburst
ln -s functions/uvc.usb0 configs/c.1

ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g1/UDC

/etc/init.d/S99uvc
ln: class/hs: Operation not permitted
[  342.174711] configfs-gadget gadget: uvc: uvc_function_bind()
[  342.180408] configfs-gadget gadget: uvc: Unable to allocate streaming EP
[  342.187336] configfs-gadget musb-hdrc.1.auto: failed to start g1: -22


请问楼主解决了吗?我的也是一样的问题.

离线

#7 2020-10-03 19:24:35

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

https://forum.pine64.org/printthread.php?tid=6227

RE: Problem setting Pine64 as a USB device - martin357 - 07-02-2018

Thank you for your response.

Trying different USB cable, also sudo lsusb but I see no change.

In the meanwhile I tried:
Modprobe g_webcam as the only gadget module that is included in armbain 5.3x 3.10.105/107, it failed to load:
Code:
[  125.143273] g_webcam gadget: uvc_function_bind
[  125.143306] gadget_is_softwinner_otg is not -int # << this is the same error I get when loading
[  125.143314] gadget_is_softwinner_otg is not -int #    the g_serial module without the use_acm=0
[  125.143322] gadget_is_softwinner_otg is not -int #    option. In both cases it doesn't work.
[  125.143330] gadget_is_softwinner_otg is not -int
[  125.143347] g_webcam gadget: Unable to allocate streaming EP
[  125.143382] g_webcam 1c19000.udc-controller: failed to start g_webcam: -22

I get the same errors about endpoints when I try to insert my compiled g_serial without the use_acm=0 option. It realy does seem that gadgets simply do not work with this(BSP/mostly BSP) kernel 3.10.107 and that's why it's not included .  However I can't find any further information about it.
I using configfs to setup the gadget seem to get the same result.(and functionfs is not configured on Armbian with 3.10.105/107 kernel)

I found out that USB gadgets actualy do work with the mainline kernel(4.13.xx), which is great, but does not really solve my problem, because the mainline kernel does not support DSI MIPI displays at this time. Because of that, I am still trying to make it work on the 3.10.xx kernel.

I am looking for a way to get both of those features working.

一样的错误 ...

离线

#8 2020-10-03 19:27:36

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

https://forums.developer.nvidia.com/t/tx2-usb-3-0-device-mode-support-iso-transfer/62626

i want to know did the usb 3.0 host can support ISO transfer

i have apply the patch to set usb 3.0 into device mode

when i set it to bulk mode ,it can work well

but when i try to set it as ISO mode ,it can’t int succeed

[ 176.034876] g_webcam 3550000.xudc: failed to start g_webcam: -22
[ 207.267492] tegra-xotg xotg: update_vbus_state: VBUS detected
[ 207.482267] tegra-usb-cd usb_cd: notification status (0x0, 0x10)
[ 207.488345] tegra-usb-cd usb_cd: connected to CDP
[ 207.493170] tegra-usb-cd usb_cd: set current 0ma
[ 207.497874] tegra-xudc-new 3550000.xudc: exiting ELPG
[ 207.505957] tegra-xudc-new 3550000.xudc: exiting ELPG done
[ 207.511482] tegra-xudc-new 3550000.xudc: device mode on
[ 211.845324] g_webcam gadget: Linux USB Audio Gadget, version: Feb 2, 2012
[ 211.852259] g_webcam gadget: uvc_function_bind
[ 211.856761] g_webcam gadget: Unable to allocate streaming EP
[ 211.862458] ac_intf:0
[ 211.864742] as_in_intf:1
[ 211.867315] f_audio_bind:671
[ 211.870230] g_webcam 3550000.xudc: failed to start g_webcam: -22

any one can help me to confirm that?

是usb 不支持 iso 模式?

离线

#9 2020-10-03 19:41:27

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

http://bbs.ebaina.com/thread-39433-1-1.html

请问有没有在3518EV200上做uvc gadget webcam的?加载驱动报下面的错误,似乎usb ep没申请到,可能是什么问题?
# insmod g_webcam.ko
g_webcam gadget: uvc_function_bind
g_webcam gadget: Unable to allocate streaming EP
insmod: can't insert 'g_webcam.ko': Invalid argument

好像节点不够啊

申请了一个control的EP IN的节点成功了。再申请一个Stream的EP In的节点就失败了。难道3518EV200这个芯片的USB只能支持1个EP In的节点?从哪里可以确认?技术手册?什么文档?

代码里面加了打印,竟然dwc_otg在初始化的时候,只有一个In和一个Out ep。这个是硬件决定的?还是可以修改配置?

硬件决定的,看GHWCFG2这个寄存器。

是的,确实是读这个寄存器,dwc_otg加载的时候,判断的。
就是不清楚是否可以修改。如果改不了,那这个芯片就用不了了。
有没有芯片支持的EP可以多点的?3516、3519、3518?

离线

#10 2020-10-03 19:53:28

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

https://blog.csdn.net/xiaofeng881105/article/details/82530515

如果驱动加载成功且没有报错的话,在电脑端应该能识别到UVC camera。但由于3516av100可用的usb 端点数量有限,g_webcam加载时报错:

g_webcam gadget: uvc_function_bind

g_webcam gadget: Unable to allocate streaming EP

himm 0x10080044  ---> 0x00000024

himm 0x10080048  ---> 0x2288C8D4

读取硬件配置寄存器GHWCFG1和GHWCFG2,可以查看到除了ep0(双向)之外,只有两个可用端点,一个in一个out。Usb协议中ep0为必备端点,上电即可使用,而其他端点需要通过ep0和主机建立连接时进行配置,配置后才可以使用。UVC协议中需要使用两个IN ep,一个用作视频控制VC,一个用作视频流VS,因此在加载该驱动时获取ep失败,在绑定uvc功能模块时报的错。(海思方面答复是3516av100不支持)

注意:驱动本身最大支持到16个端点(含ep0),但是实际可用的受限于硬件,通过读取寄存器获取到可用端点总数和in/out端点数。

理论上可以复用ep0作为uvc的VC端点,因为ep0是双向的;但实际验证行不通,为此做了如下修改尝试:

VC复用ep0
VC为空
VC和VS共用端点
主要修改f_uvd.c中uvc_function_bind函数。

上面的修改均行不通,修改后再host对设备进行配置时,setup报错。

实际查看代码,关于uvc的描述符中定义了uvc控制类和uvc视频流类:uvc_control_cls和uvc_fs_streaming_cls,还有一个uvc_hs_streaming_cls类。

如果要修改还需要对uvc协议和驱动代码深入的了解,时间有限,没有深入去理解。

离线

#11 2020-10-03 20:02:50

听风识雨
会员
注册时间: 2020-08-15
累计积分: 56

Re: V3s Linux4.13执行modprobe g_webcam 出现端点错误, 是端点不够吗? 其他的 g_serial/g_ffs没问题

可能是端点不够, 有空我到 A33 试一试.

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB