官方BUG请管理员修复! 默认demo 报错请教: firefly_rkmedia_vi_uvc_test.c

本帖最后由 ubuntu 于 2021-7-21 15:15 编辑

# 1. 运行环境
刷机包: 官方如下最新包:AIO-RV1126_RV1109-JD4_2021_0709_1611
demo程序来源:
firefly_rkmedia_vi_uvc_test.c
link: https://wiki.t-firefly.com/zh_CN/CORE-1126-JD4/Rkmedia.html#vi-uvc

# 2. 本人严格按照如下readme, step by step 执行的, 还是报错了.
sdk/app/firefly_rkmedia_uvc/README.md

# 3. 错误提示.

[root@RV1126_RV1109:/]# /userdata/firefly_rkmedia_vi_uvc_test -a /oem/etc/iqfile
s/ -c /oem/usr/share/rtsp-nn.cfg -p /oem/usr/share/rknn_model/ssd_inception_v2_r
v1109_rv1126.rknn -l /oem/usr/share/rknn_model/coco_labels_list.txt -b /oem/usr/
share/rknn_model/box_priors.txt
/userdata/firefly_rkmedia_vi_uvc_test: error while loading shared libraries: librkuvc.so: cannot open shared object file: No such file or directory

# 详细步骤log如下:

刷机重启后
[root@RV1126_RV1109:/oem]# RkLunch-stop.sh

adb push firefly_rkmedia_vi_uvc_test /userdata/

# /oem/usb_config.sh
NETINTERFACE=eth2

# 无此文件, 文档是否修正一下?
需要移除文件 /etc/init.d/S58_lunch_init

[root@RV1126_RV1109:/]# /oem/usb_config.sh rndis
mkdir: cannot create directory '/dev/usb-ffs': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6': File exists

adb connect 10.3.1.20:5555
adb shell
/userdata/firefly_rkmedia_vi_uvc_test -a /oem/etc/iqfiles/ -c /oem/usr/share/rtsp-nn.cfg -p /oem/usr/share/rknn_model/ssd_inception_v2_rv1109_rv1126.rknn -l /oem/usr/share/rknn_model/coco_labels_list.txt -b /oem/usr/share/rknn_model/box_priors.txt

$ adb shell
adb[root@RV1126_RV1109:/]# /userdata/firefly_rkmedia_vi_uvc_test -a /oem/etc/iqfile
s/ -c /oem/usr/share/rtsp-nn.cfg -p /oem/usr/share/rknn_model/ssd_inception_v2_r
v1109_rv1126.rknn -l /oem/usr/share/rknn_model/coco_labels_list.txt -b /oem/usr/
share/rknn_model/box_priors.txt
/userdata/firefly_rkmedia_vi_uvc_test: error while loading shared libraries: librkuvc.so: cannot open shared object file: No such file or directory

请问你是用普通的 SDK 还是用 SDK-AI ?
目前这个 demo 只支持 SDK-AI。
由于该 demo 配置项比较多。已经固化到固件了。
编译命令:
./build.sh device/rockchip/rv1126_rv1109/aio-rv1126-rkmedia-uvcc.mk

编译完成并烧录后在 PC 上位机执行:
/oem/usb_config.sh rndis
/userdata/firefly_rkmedia_vi_uvc_test -a /oem/etc/iqfiles/ -c /oem/usr/share/rtsp-nn.cfg -p /oem/usr/share/rknn_model/ssd_inception_v2_rv1109_rv1126.rknn -l /oem/usr/share/rknn_model/coco_labels_list.txt -b /oem/usr/share/rknn_model/box_priors.txt

本帖最后由 799959745 于 2021-7-20 18:00 编辑

上面的代码有点乱。整理了:> - /oem/usb_config.sh rndis

  • /userdata/firefly_rkmedia_vi_uvc_test -a /oem/etc/iqfiles/ -c /oem/usr/share/rtsp-nn.cfg -p /oem/usr/share/rknn_model/ssd_inception_v2_rv1109_rv1126.rknn -l /oem/usr/share/rknn_model/coco_labels_list.txt -b /oem/usr/share/rknn_model/box_priors.txt

799959745 发表于 2021-7-20 17:59
上面的代码有点乱。整理了:

谢谢兄台, 您也是做camera吗?

799959745 发表于 2021-7-20 17:54
请问你是用普通的 SDK 还是用 SDK-AI ?
目前这个 demo 只支持 SDK-AI。
由于该 demo 配置项比较多。已经 …

请教一下,您说的

请问你是用普通的 SDK 还是用 SDK-AI ?
目前这个 demo 只支持 SDK-AI。

从哪里知道是SDK还是SDK-AI? SDK-AI这个名词我第一次看到, 不知这个名词来源哪里, 我是从如下地址下载的code.

repo init  --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m rv1126_rv1109_linux_release.xml

维基不够完善。
参考 https://wiki.t-firefly.com/zh_CN/CAM-C11262U/Source_code.html 中的源码编译获取代码。不过版本比较旧,没有 aio-rv1126-rkmedia-uvcc.mk 文件。我们这几天尽快发布最新的 SDK-AI 版本。

799959745 发表于 2021-7-24 10:02
维基不够完善。
参考 https://wiki.t-firefly.com/zh_CN/CAM-C11262U/Source_code.html 中的源码编译获取 …

谢谢!
请问我该用哪个配置项测试呢?

# RV1109: 编译人脸识别闸机固件
./build.sh cam-crv1109s2u-facial_gate.mk

# RV1126: 编译人脸识别闸机固件
./build.sh cam-crv1126s2u-facial_gate.mk

# RV1109: 编译 AI-UVC-CAMERA 固件
./build.sh cam-crv1109s2u-uvcc.mk

# RV1126: 编译 AI-UVC-CAMERA 固件
./build.sh cam-crv1126s2u-uvcc.mk

这里面的mk文件在维基上都有介绍。功能不包括 firefly_rkmedia_vi_uvc_test 。

尝试以下步骤运行demo。
1、使用 sdk-ai uvcc 固件。官网下载固件。或者手动编译 ./build.sh cam-crv1109s2u-uvcc.mk
2、固件文件系统 /etc/init.d/S50usbdevice 和 sdk-ai-path/buildroot/board/rockchip/rv1126_rv1109/fs-overlay-uvc/etc/init.d/S50usbdevice 要一致
3、将 sdk-ai-path/app/firefly_rkmedia_uvc/1126/librkuvc/librkuvc.so 替换掉固件文件系统的 /usr/lib/librkuvc.so
4、将 sdk-ai-path/app/firefly_rkmedia_uvc/1126/libs/ 目录所有库文件拷贝到固件文件系统 /usr/lib/ 目录下
5、删除文件 /etc/init.d/S58_lunch_init

799959745 发表于 2021-8-3 17:24
尝试以下步骤运行demo。
1、使用 sdk-ai uvcc 固件。官网下载固件。或者手动编译 ./build.sh cam-crv1109s …

谢谢帮忙.
请教一下, step3 step4 里面SDK 中lib库路径是不是贴错了? 以step3 为例, librkuvc.so 有如下路径, 用任何一个push到固件文件系统即可吗?

$ f librkuvc.so
f./buildroot/output/firefly_rv1126_rv1109_uvcc/build/uvc_app/librkuvc.so
./buildroot/output/firefly_rv1126_rv1109_uvcc/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/librkuvc.so
./buildroot/output/firefly_rv1126_rv1109_uvcc/target/usr/lib/librkuvc.so

看来固件很久没更新过了,今天完成SDK代码更新。

799959745 发表于 2021-8-4 09:06
看来固件很久没更新过了,今天完成SDK代码更新。

期待ing{:4_107:}

sdk-ai 代码已更新。请拉取最新的代码。
执行以下步骤:

./build.sh device/rockchip/rv1126_rv1109/aio-rv1126-rkmedia-uvcc.mk
./build.sh

CORE-1126-JD4/CORE-1109-JD4 设备默认没有开启 OTG 功能,请先在内核开启 OTG,编译升级内核。
# sdk-ai/kernel/arch/arm/boot/dts/rv1126-firefly-rk809.dtsi
&usbdrd_dwc3 {
    status = "okay";
    dr_mode = "otg";  #开启OTG
    extcon = <&u2phy0>;
};

799959745 发表于 2021-8-11 09:08
sdk-ai 代码已更新。请拉取最新的代码。
执行以下步骤:

赞. 按照您的步骤可以正常build 为uvc设备了.

有两个小问题:

  1. build error.
2021-08-11T10:57:22 compilation terminated.
2021-08-11T10:57:22 CMakeFiles/ff_uvc.dir/build.make:62: recipe for target 'CMakeFiles/ff_uvc.dir/uvc/uvc-gadget.c.o' failed
2021-08-11T10:57:22 make[4]: *** [CMakeFiles/ff_uvc.dir/uvc/uvc-gadget.c.o] Error 1
2021-08-11T10:57:22 In file included from /root/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/uvc_control.h:42,
2021-08-11T10:57:22 from /root/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/uvc-gadget.h:80,
2021-08-11T10:57:22 from /root/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/uvc_video.h:45,
2021-08-11T10:57:22 from /root/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/uvc_video.cpp:33:
2021-08-11T10:57:22 /root/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/mpi_enc.h:41:10: fatal error: mpp_osd.h: No such file or directory
2021-08-11T10:57:22 #include "mpp_osd.h"
2021-08-11T10:57:22 ^~~~~~~~~~~
2021-08-11T10:57:22 compilation terminated.

workaroud 解决:

=> /home/ws/AI_UVC_CAM-CRV1126S2U/external/uvc_app/uvc [Wed 11-11:05:23] C:1
$ cp * /home/ws/AI_UVC_CAM-CRV1126S2U/buildroot/output/firefly_rv1126_rv1109_rkmedia_uvcc/build/firefly_rkmedia_uvc-1.0/uvc/
cp#
  1. 此贴的主题问题,uvc的demo 如何正确运行呢?

2.1 如下默认方法执行失败,执行完这一步后adb 连接就断开了. 用adb ip:5555 shell 也不行.

/oem/usb_config.sh rndis

2.2 删除/etc/init.d/S58_lunch_init 后重启 adb 无法连接.
这个文件夹里面还有其他S**_lunch_init, 不确定删哪一个.

2.3 cd /oem;./RkLunch-stop.sh 之后再重复上述步骤2.1也无效.

ubuntu 发表于 2021-8-11 15:07
赞. 按照您的步骤可以正常build 为uvc设备了.

有两个小问题:

LOG

     valid_lft forever preferred_lft forever
[root@RV1126_RV1109:/]# /oem/usb_config.sh rndis
killall: udevd: no process killed
mkdir: cannot create directory '/dev/usb-ffs': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/control/header/h': File exists
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/control/class/fs/h/h': Operation not permitted
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/control/class/ss/h/h': Operation not permitted
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/uncompressed/u': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/uncompressed/u/240p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/uncompressed/u/480p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/uncompressed/u/720p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/240p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/360p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/480p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/448p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/720p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/768p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/1080p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/mjpeg/m/1440p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1/480p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1/720p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1/1080p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1/1440p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f1/2160p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2': File exists
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2/480p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2/720p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2/1080p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2/1440p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/framebased/f2/2160p': File exists
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
sh: write error: Device or resource busy
mkdir: cannot create directory '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/header/h': File exists
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/header/h/u/u': Operation not permitted
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/header/h/m/m': Operation not permitted
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/header/h/f1/f1': Operation not permitted
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/header/h/f2/f2': Operation not permitted
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/class/fs/h/h': Device or resource busy
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/class/hs/h/h': Device or resource busy
ln: failed to create symbolic link '/sys/kernel/config/usb_gadget/rockchip/functions/uvc.gs6/streaming/class/ss/h/h': Device or resource busy

=> /home/ws/AI_UVC_CAM-CRV1126S2U [Wed 11-14:51:50]
$ adb shell
adb

使用以下 mk 文件编译出来的固件可以直接使用,不用操作板子。
./build.sh device/rockchip/rv1126_rv1109/aio-rv1126-rkmedia-uvcc.mk

固件烧进板子之后。电脑查看 /dev/video 是哪个节点,根据出现的节点修改 client.cpp 。
修改以下内容:
#define VIDEO_NODE 1

编译执行:

cd sdk-ai-path/app/firefly_rkmedia_uvc/host/
./build.sh
sudo ./client
#正常运行的话就能看到信息了
#程序还没完善,只能运行一次。想要再次打开只能重启板子。

799959745 发表于 2021-8-11 16:41
使用以下 mk 文件编译出来的固件可以直接使用,不用操作板子。
./build.sh device/rockchip/rv1126_rv1109 …

太赞了, 已经导通!

可否再麻烦请教一下,查看video设备的话,其实Core-1126-JD4核心板会显示如下两个video设备.
我目前用的是video8, 请教一下和video9 有什么区别?

$ v4l2-ctl --list-devices
v4l2-ctlUVC: UVC Camera (usb-0000:00:14.0-2):
        /dev/video8
        /dev/video9
        /dev/media1

$ v4l2-ctl -d /dev/video8 --list-formats
v4l2-ctlioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'YUYV' (YUYV 4:2:2)
        [1]: 'MJPG' (Motion-JPEG, compressed)
        [2]: 'H264' (H.264, compressed)
        [3]: '' (35363248-0000-0010-8000-00aa003, compressed)

$ v4l2-ctl -d /dev/video9 --list-formats
v4l2-ctlioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

一个是图像/视频采集,一个是metadata采集。
可以看下这个帖子:https://forum.ubuntu.org.cn/viewtopic.php?t=490552

799959745 发表于 2021-8-12 09:49
一个是图像/视频采集,一个是metadata采集。
可以看下这个帖子:https://forum.ubuntu.org.cn/viewtopic.p

感激不尽.

谢谢您专业负责的帮助.