Firefly开源社区

打印 上一主题 下一主题

[Android] 3288J 3288C这两款usb问题

51

积分

0

威望

0

贡献

技术小白

积分
51

3288J 3288C这两款usb问题

发表于 2022-3-11 15:38:37      浏览:2795 | 回复:4        打印      只看该作者   [复制链接] 楼主
这两款板子我们调试usb摄像头。发现用libuvc的库无法预览摄像头。

看了原理图发现usb是用了hub。我们改成不使用hub,直通到底板的usb端口,结果连usb摄像头设备都检测不到了。
提示log

[  733.154747] Using Buffer DMA mode
[  733.154766] Periodic Transfer Interrupt Enhancement - disabled
[  733.154774] Multiprocessor Interrupt Enhancement - disabled
[  733.154782] OTG VER PARAM: 0, OTG VER FLAG: 0
[  733.154789] ^^^^^^^^^^^^^^^^^^Host Mode
[  733.199026] Init: Power Port (0)
[  733.483952] Indeed it is in host mode hprt0 = 00021501
[  733.661048] usb 3-1: new high-speed USB device number 18 using usb20_host
[  734.074185] usb 3-1: device not accepting address 18, error -71
[  734.074511] Indeed it is in host mode hprt0 = 00001101
[  734.251426] usb 3-1: new high-speed USB device number 19 using usb20_host
[  739.378141] NYET/NAK/ACK/other in non-error case, 0x00000002
[  744.504712] usb 3-1: device not accepting address 19, error -110
[  744.505022] Indeed it is in host mode hprt0 = 00001501
[  744.681754] usb 3-1: new high-speed USB device number 20 using usb20_host
[  744.683712] Indeed it is in host mode hprt0 = 00001101
[  744.858881] usb 3-1: device descriptor read/64, error -71
[  744.968965] Indeed it is in host mode hprt0 = 00001101
[  745.144341] usb 3-1: device descriptor read/64, error -71
[  745.252555] Indeed it is in host mode hprt0 = 00001101
[  745.429708] usb 3-1: new high-speed USB device number 21 using usb20_host
[  750.349798] NYET/NAK/ACK/other in non-error case, 0x00000002
[  755.269850] NYET/NAK/ACK/other in non-error case, 0x00000002
[  760.189702] Indeed it is in host mode hprt0 = 00001501
[  760.366800] usb 3-1: device descriptor read/64, error -110
[  760.476061] Indeed it is in host mode hprt0 = 00001101
[  760.652156] usb 3-1: device descriptor read/64, error -71
[  760.760403] hub 3-0:1.0: unable to enumerate USB device on port 1



怀疑是这两款板子的usb设计有问题。有人解决过这问题么。

或者有能用libuvc预览usbcamera的方案也行。
回复

使用道具 举报

3747

积分

17

威望

18

贡献

官方团队

Rank: 9Rank: 9Rank: 9

积分
3747
发表于 2022-3-14 20:51:50        只看该作者  沙发
修改如下再验证一下
  1. --- a/kernel/drivers/usb/dwc_otg_310/usbdev_rk32.c
  2. +++ b/kernel/drivers/usb/dwc_otg_310/usbdev_rk32.c
  3. @@ -480,7 +480,8 @@ static void rk_ehci_hw_init(void)
  4.          * host0 PLL blocks remain powered.
  5.          */
  6.         control_usb->grf_uoc1_base->CON0 = (1 << 16) | 0;
  7. -
  8. +      
  9. +    control_usb->grf_uoc1_base->CON0 = 0x08000000;
  10.         /* DRV_VBUS GPIO init */
  11.         if (gpio_is_valid(control_usb->host_gpios->gpio)) {
  12.                 if (!gpio_get_value(control_usb->host_gpios->gpio))
复制代码
回复

使用道具 举报

51

积分

0

威望

0

贡献

技术小白

积分
51
发表于 2022-3-21 13:53:52        只看该作者  板凳
jpchen 发表于 2022-3-14 20:51
修改如下再验证一下

非常感谢你的回复。我使用你提供的方法做了验证。现象是一样的,没有改善。



另外我再测试中发现如下问题,OTG口的usb无法做usb主设备,即使我通过接口将电源切换到otg,我验证了鼠标 camera都是一样的。

同样的设备,我使用荣品3288的开发板都是工作正常。我也尝试过将荣品的固件烧录到firefly的开发板中,usb接口能工作,但是也无法通过libuvc读取摄像头。而同样的固件能够在荣品开发板上工作。


回复

使用道具 举报

51

积分

0

威望

0

贡献

技术小白

积分
51
发表于 2022-3-25 18:34:31        只看该作者  地板
通过一段时间的分析,有了新的进展。

在usb驱动中devio.c proc_do_submiturb函数。usb_submit_urb之前打印数据,内容是错误的。而在async_completed中数据内容正确。

而用系统自带的camera预览uvc时,并没有使用这部分代码,而是在media中重写了这部分内容,在数据发送完成之后才解码预览。所以工作正常。

这部分功能是一个异步的发送,在发送完成之后再处理数据是合理的。

对比了多个版本的usb驱动,这部分内容和逻辑都是一样的。为什么其他平台都没有问题呢?

最终还是怀疑是firefly的这两款板子的usb部分设计有问题,导致通信时间变长,无法在返回数据前完成异步通信。

我在荣品和firefly上烧录了同样的img文件,一个可以usb预览,一个一直提示数据解析不正常。
回复

使用道具 举报

51

积分

0

威望

0

贡献

技术小白

积分
51
发表于 2022-3-30 11:31:05        只看该作者  5#
问题已解决。
static void compute_isochronous_actual_length(struct urb *urb)
{
        unsigned int i;

        if (urb->number_of_packets > 0) {
                urb->actual_length = 0;
                for (i = 0; i < urb->number_of_packets; i++)
                        urb->actual_length +=
                                        urb->iso_frame_desc[i].actual_length;
        }
}

static int processcompl(struct async *as, void __user * __user *arg)
{
        struct urb *urb = as->urb;
        struct usbdevfs_urb __user *userurb = as->userurb;
        void __user *addr = as->userurb;
        unsigned int i;

        compute_isochronous_actual_length(urb);
        if (as->userbuffer && urb->actual_length) {
                if (copy_urb_data_to_user(as->userbuffer, urb))
                        goto err_out;
        }
        if (put_user(as->status, &userurb->status))
                goto err_out;
        if (put_user(urb->actual_length, &userurb->actual_length))
                goto err_out;
        if (put_user(urb->error_count, &userurb->error_count))
                goto err_out;

        if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
                for (i = 0; i < urb->number_of_packets; i++) {
                        if (put_user(urb->iso_frame_desc[i].actual_length,
                                     &userurb->iso_frame_desc[i].actual_length))
                                goto err_out;
                        if (put_user(urb->iso_frame_desc[i].status,
                                     &userurb->iso_frame_desc[i].status))
                                goto err_out;
                }
        }

        if (put_user(addr, (void __user * __user *)arg))
                return -EFAULT;
        return 0;

err_out:
        return -EFAULT;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表