编译源码external目录下模块

测试环境:

  • LKD3588: Ubuntu 20.04

  • 内核版本: 5.10.110

编译rockit/mpi

1、rockit源码位置:

SDK/external/rockit

2、将rockit文件夹拷贝到开发板/home/neardi目录。

3、默认的CMakeLists在开发板上编译会报错,rockit/mpi/CMakeLists.txt替换成以下内容:

cmake_minimum_required( VERSION 2.8.8 )
project (rockit)
include_directories(sdk/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
set(ROCKIT_DEP_COMMON_LIBS
    ${CMAKE_CURRENT_LIST_DIR}/../lib/lib64/librockit.so
)
set(ROCKIT_FILE_LIBS
    ${ROCKIT_DEP_COMMON_LIBS}
    ${CMAKE_CURRENT_LIST_DIR}/sdk/lib64/libgraphic_lsf.so
    ${CMAKE_CURRENT_LIST_DIR}/sdk/lib64/librkgfx_avs.so
)
set(ROCKIT_DUMPSYS_FILE ${CMAKE_CURRENT_LIST_DIR}/example/bin/bin64/dumpsys)

add_subdirectory(sdk)
add_subdirectory(example)

注意加入set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread"), 否则会报以下错误:

/usr/bin/ld: ../common/librt_test_comm.a(test_mod_vpss.cpp.o): undefined reference to symbol 'pthread_create@@GLIBC_2.17'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libpthread.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

4、开发板安装编译环境

sudo update
sudo apt install gcc g++ clang make-guile build-essential cmake

5、开始编译

neardi@LPA3588:~/rockit/mpi$ cmake .
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build WITH linker libs for Linux
-- Configuring done

-- Generating done
-- Build files have been written to: /home/neardi/rockit/mpi
neardi@LPA3588:~/sdk/rockit/mpi$ make -j8
Scanning dependencies of target rt_test_comm
[  3%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_imgproc.cpp.o
[  5%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_sys.cpp.o
[  7%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_argparse.cpp.o
......
[ 94%] Built target rk_mpi_adec_test
[ 96%] Building CXX object example/mod/CMakeFiles/rk_mpi_rgn_test.dir/test_mpi_rgn.cpp.o
[ 98%] Linking CXX executable rk_mpi_tde_test
[100%] Linking CXX executable rk_mpi_rgn_test
[100%] Built target rk_mpi_tde_test
[100%] Built target rk_mpi_rgn_test

6、编译生成的文件在rockit/mpi/example目录。

7、测试

root@LPA3588:/home/neardi/rockit/mpi/example/mod# ./rk_mpi_vi_test -t 1  -w 1920 -h 1080 -m 1 -n /dev/video22
vi               09:54:03-390 {main              :1381} test running enter!
vi               09:54:03-390 {main              :1487} test running enter ctx->aEntityName=/dev/video22!
cmd parse result:
output file open      : 0
yuv output file name  : /
enc0 output file path : //
enc1 output file path : //
loop count            : 100
enMode                : 1
dev                   : 0
pipe                  : 0
channel               : 1
width                 : 1920
height                : 1080
enCompressMode        : 0
enMemoryType          : 1
aEntityName           : /dev/video22
.....
vi               09:54:53-143 {test_vi_bind_venc_:999} chn:0, loopCount:97 enc->seq:97 wd:69 pts=1758285506 delay=63061us

vi               09:54:53-200 {test_vi_bind_venc_:999} chn:0, loopCount:98 enc->seq:98 wd:69 pts=1758345853 delay=58999us

RTScheduler      09:54:53-264 {pause             :332} calling pause
vi               09:54:53-264 {test_vi_bind_venc_:999} chn:0, loopCount:99 enc->seq:99 wd:69 pts=1758406155 delay=63416us

RTScheduler      09:54:53-275 {stop              :371} calling stop
RTDeviceV4L2     09:54:53-275 {invoke            :975} unsupport command interrupt
RTScheduler      09:54:53-319 {checkScheduleDone :221} quit scheduler, error/limit is found!
RTScheduler      09:54:53-320 {quit              :393} Signaling scheduler termination
RTDeviceV4L2     09:54:53-320 {invoke            :975} unsupport command interrupt
vi               09:54:53-370 {test_vi_bind_venc_:1024} RK_MPI_VI_DisableChn 0
RTScheduler      09:54:53-370 {pause             :332} calling pause
vi               09:54:53-370 {test_vi_bind_venc_:1031} destroy enc chn:0
RTScheduler      09:54:53-370 {stop              :371} calling stop
RTScheduler      09:54:53-370 {checkScheduleDone :221} quit scheduler, error/limit is found!
RTScheduler      09:54:53-370 {quit              :393} Signaling scheduler termination
vi               09:54:53-392 {test_vi_bind_venc_:1040} RK_MPI_VI_DisableDev 0
vi               09:54:53-392 {main              :1526} test running exit:0
RKSockServer     09:54:53-466 {start             :163} accept failed
rk-debug call distortionByGpuDeinit mInitSucee=1,threadId=547729088944
rk-debug GpuManage.refcnt=2
rk-debug call distortionByGpuDeinit mInitSucee=1,threadId=547608326576
rk-debug GpuManage.refcnt=1
rk-debug call destroyEGL 
RTAllocatorStore 09:54:53-509 {commFinalize      :200} release common allocator[0x55afa66e30]

若测试提示缺少库,需要手动将编译出的so,拷贝到/usr/lib64目录下。

8、rockit使用手册

随SDK一起申请的文档查看:Linux->Multimedia->Rockchip_User_Guide_Linux_Rockit_CN.pdf,也可在百度网盘下载。