项目场景:
项目新增sensor,sensor驱动tx-isp驱动由君正提供
问题描述:
编译生成固件运行主程序时出现 VIDIOC_S_FMT error、IMP_FrameSource_EnableChn、IMP_Encoder_PollingStream timeout。
以下是君正logcat完整日志:
I/OSD ( 172): IMP_OSD_SetPoolSize:524288
D/VIDEO ( 172): imp_system_init start
D/IMP-ISP ( 172): ~~~~~~ IMP_ISP_Open[280] ~~~~~~~
I/IMP-ISP ( 172): IMP_ISP_AddSensor,366: paddr = 0x0, size = 0x477e70
I/Alloc Manager( 172): MEM Alloc Method is kmalloc
D/KMEM Method( 172): CMD Line Rmem Size:25165824, Addr:0x02800000
D/KMEM Method( 172): alloc->mem_alloc.method = kmalloc
D/KMEM Method( 172): alloc->mem_alloc.vaddr = 0x74be6000
D/KMEM Method( 172): alloc->mem_alloc.paddr = 0x02800000
D/KMEM Method( 172): alloc->mem_alloc.length = 25165824
I/Alloc Manager( 172): MEM Manager Method is continuous
D/System ( 172): IMP_System_Init SDK Version:1.1.0-43efbe8-Wed Sep 9 12:25:44 2020 +0800, built: Sep 11 2020 16:51:49
D/System ( 172): system_init()
D/System ( 172): Calling DSystem
D/System ( 172): Calling FrameSource
D/System ( 172): [ignored]read /proc/cpuinfo ret is NULL
D/System ( 172): Calling IVS
D/System ( 172): Calling OSD
D/System ( 172): Calling Encoder
D/System ( 172): Calling FB
D/VIDEO ( 172): ImpSystemInit success
E/Encoder ( 172): IMP_Encoder_GetPool(3143):chnNum: 0 not bind pool
I/Encoder ( 172): encChn=0,srcFrameCnt=3,srcFrameSize=3133440
I/Encoder ( 172): encChn=0,srcStreamCnt=2,enc_chn->stream_frame_size=949248
E/Encoder ( 172): IMP_Encoder_GetPool(3143):chnNum: 1 not bind pool
I/Encoder ( 172): encChn=1,srcFrameCnt=3,srcFrameSize=353280
I/Encoder ( 172): encChn=1,srcStreamCnt=2,enc_chn->stream_frame_size=162304
I/OSD ( 172): IMP_OSD_CreateRgn(1138) create handle=0 success
I/OSD ( 172): IMP_OSD_CreateRgn(1138) create handle=1 success
I/OSD ( 172): IMP_OSD_CreateRgn(1138) create handle=2 success
I/OSD ( 172): IMP_OSD_CreateRgn(1138) create handle=3 success
D/System ( 172): system_bind(): bind DST-OSD-0(4.0.0) to SRC-Framesource-0(0.0.0)
D/System ( 172): system_bind(): bind DST-Encoder-0(1.0.0) to SRC-OSD-0(4.0.0)
E/Framesource( 172): [chn0]: VIDIOC_S_FMT error
E/Framesource( 172): [chn0]: chn_attr.picWidth=1920, chn_attr.picHeight=1080, chn_attr.pixFmt=10
E/Framesource( 172): [chn0]: chn_attr.crop.enable=1, chn_attr.crop.top=0, chn_attr.crop.left=0, chn_attr.crop.width=1920, chn_attr.crop.height=1080
E/Framesource( 172): [chn0]: chn_attr.fcrop.enable=0, chn_attr.fcrop.top=0, chn_attr.fcrop.left=0, chn_attr.fcrop.width=0, chn_attr.fcrop.height=0
E/Framesource( 172): [chn0]: chn_attr.scaler.enable=0, chn_attr.scaler.outwidth=0, chn_attr.scaler.outheight=0
E/Framesource( 172): IMP_FrameSource_EnableChn(): chn 0 reset channel attr error
E/VIDEO ( 172): IMP_FrameSource_EnableChn(-1) error: 0
W/Encoder ( 172): Jpeg channel will not share buff
E/Encoder ( 172): IMP_Encoder_GetPool(3143):chnNum: 2 not bind pool
I/Encoder ( 172): encChn=2,srcFrameCnt=2,srcFrameSize=353280
I/Encoder ( 172): encChn=2,srcStreamCnt=1,enc_chn->stream_frame_size=143552
I/Sample-Ai-Ref( 172): Audio In GetPubAttr samplerate : 8000
I/Sample-Ai-Ref( 172): Audio In GetPubAttr bitwidth : 16
I/Sample-Ai-Ref( 172): Audio In GetPubAttr soundmode : 1
I/Sample-Ai-Ref( 172): Audio In GetPubAttr frmNum : 40
I/Sample-Ai-Ref( 172): Audio In GetPubAttr numPerFrm : 320
I/Sample-Ai-Ref( 172): Audio In GetPubAttr chnCnt : 1
I/ai ( 172): AI Enable: 1
I/Sample-Ai-Ref( 172): Audio In GetChnParam usrFrmDepth : 40
I/ai ( 172): AI Enable Chn: 1-0
I/ai ( 172): EXIT AI Enable Chn: 1-0
I/ai ( 172): AI Set Vol: 100
I/ai ( 172): AI Get Vol: 100
I/Sample-Ai-Ref( 172): Audio In GetVol vol : 100
I/ai ( 172): AI Set Gain: 20
I/ai ( 172): AI Get Gain: 20
I/Sample-Ai-Ref( 172): Audio In GetGain gain : 20
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr samplerate:8000
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr bitwidth:16
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr soundmode:1
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr frmNum:20
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr numPerFrm:320
I/Sample-Ai-Ref( 172): Audio Out GetPubAttr chnCnt:1
I/ao ( 172): AO Enable: 0
I/ao ( 172): AO Ch Enable: 0:0
I/ao ( 172): EXIT AO Ch Enable: 0:0
I/ao ( 172): AO Set Vol: 80
I/ao ( 172): AO Get Vol: 80
I/Sample-Ai-Ref( 172): Audio Out GetVol vol:80
I/ao ( 172): AO Get Gain: 28
I/ao ( 172): AO Get Gain: 28
I/Sample-Ai-Ref( 172): Audio Out GetGain gain : 28
I/ai ( 172): AI NS ENABLE: mode = 3
I/ai ( 172): AI HPF Enable
I/ai ( 172): HPF version is: Ingenic High Pass Filter 1.1.0
D/IVS_MOVE( 172): move->param.sense[0]=3
D/IVS_MOVE( 172): move->param.sense[1]=3
D/IVS_MOVE( 172): move->param.sense[2]=3
D/IVS_MOVE( 172): move->param.sense[3]=3
D/IVS_MOVE( 172): move->param.sense[4]=3
D/IVS_MOVE( 172): move->param.sense[5]=3
D/IVS_MOVE( 172): move->param.sense[6]=3
D/IVS_MOVE( 172): move->param.sense[7]=3
D/IVS_MOVE( 172): move->param.sense[8]=3
D/IVS_MOVE( 172): move->param.sense[9]=3
D/IVS_MOVE( 172): move->param.sense[10]=3
D/IVS_MOVE( 172): move->param.sense[11]=3
D/IVS_MOVE( 172): move->param.sense[12]=3
D/IVS_MOVE( 172): move->param.sense[13]=3
D/IVS_MOVE( 172): move->param.sense[14]=3
D/IVS_MOVE( 172): move->param.sense[15]=3
D/IVS_MOVE( 172): move->param.sense[16]=3
D/IVS_MOVE( 172): move->param.sense[17]=3
D/IVS_MOVE( 172): move->param.sense[18]=3
D/IVS_MOVE( 172): move->param.sense[19]=3
D/IVS_MOVE( 172): move->param.sense[20]=3
D/IVS_MOVE( 172): move->param.sense[21]=3
D/IVS_MOVE( 172): move->param.sense[22]=3
D/IVS_MOVE( 172): move->param.sense[23]=3
D/IVS_MOVE( 172): move->param.sense[24]=3
D/System ( 172): [ignored]read /proc/cpuinfo ret is NULL
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
E/VIDEO ( 172): IMP_Encoder_PollingStream...Polling stream timeout
[ 27.315729] sx=4100,sy=325,cx=8200,cy=1300
[ 36.744565] codec_codec_ctl: set CODEC_TURN_OFF...
[ 36.924076] codec_codec_ctl: set CODEC_TURN_OFF...
原因分析:
1、确认变量
硬件上只是更换sensor。
软件上更换了sensor驱动、tx-isp驱动。
更换之前主程序正常运行没有错误。
2、确认硬件是否正常
使用sensor探测驱动探测,sinfo.ko(需要在SDK sensor_info.c源码里面新增驱动型号编译),修改sensor_info.c需要查看sensor规格书确认sensor参数。PIDH和PIDL是其中两个参数。
在参数正确的情况可以探测到sensor表明sensor硬件没有问题。
3、确认sensor驱动是否正常
加载驱动正常可以编译君正SDK里面的sample去运行,如果运行正常表明sensor驱动没有问题。
或者可以使用SDK里面的Carrier的服务器和客户端,详情看SDK文档开发指南。
4、确认rmem内存是否足够
使用SDK里面的impdbg,带参数使用impdbg --sys,再通过logcat可以查看rmem具体使用内存。
解决方案:
在排除了以上几个问题之后仍然出现VIDIOC_S_FMT error,然后造成编码器超时等。询问君正人员可能是交叉编译链版本不一致,sensor驱动使用uclibc5.4.0编译,但固件也是使用uclibc5.4.0编译。最终确认是固件里面依赖库没有使用对应版本。全部库(libsysutils.a、libimp.a、libaudioProcess.so、libalog.a)替换后问题解决。此处没有分析具体是哪个库,是全部进行了替换。
造成编码器超时问题还有很多原因,在此仅记录此次解决问题的过程。