Ubuntu 18.04.5 LTS
Hi3519AV100_SDK_V2.0.1.0
Hi3519AV100开发板
MPP 即Media Process Platform媒体处理平台,是集成视频输入(VI)、视频处理(VPSS)、视频编码(VENC)、视频解码(VDEC)、视频输出(VO)、视频侦测分析(VDA)、音频输入(AI)、音频输出(AO)、音频编码(AENC)、音频解码(ADEC)、区域管理(REGION)等模块,可以说是海思芯片的核心业务。相关内容可以参考海思《HiMPP V4.0 媒体处理软件开发参考》、《HiMPP 媒体处理软件 FAQ》。
下面以Hi3519AV100为例介绍怎么把这模块功能部署到单板上。
我这里已经把海思SDK放到服务器解压安装好了,交叉编译工具也安装好了。海思芯片SDK、交叉编译工具安装都差不多的。
MPP位于:Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/
在部署到单板之前先把mpp编译一下
在这路径编译/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/
make会出现找不到kernel路径的情况
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user$ make
make[1]: Entering directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/firmware'
--Compiling 'firmware'... Configs as follow:
---- CROSS=arm-himix200-linux-
---- HIARCH=hi3519av100, HICHIP=0x3519A100, CVER=.C02, HIDBG=
---- SDK_PATH=/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../.. , PARAM_FILE=../../../Makefile.param
---- KERNEL_ROOT=/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../../../../osdrv/opensource/kernel/linux-4.9.y-smp
make[2]: Entering directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/firmware/src'
compiling /home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../component/isp/user/firmware/arch/hi3519av100/algorithms/isp_awb.c ...
Assembler messages:
Fatal error: can't create /home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../component/isp/user/firmware/src/obj/isp_awb.o: ????
Makefile:90: recipe for target '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../component/isp/user/firmware/src/obj/isp_awb.o' failed
make[2]: *** [/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/../../../component/isp/user/firmware/src/obj/isp_awb.o] Error 1
make[2]: Leaving directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/firmware/src'
Makefile:4: recipe for target 'all' failed
make[1]: *** [all] Error 1
make[1]: Leaving directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/firmware'
Makefile:15: recipe for target 'firmware' failed
make: *** [firmware] Error 2
原因是编译默认的路径是linux-4.9.y-smp,而实际是linux-4.9.y,这里可以通过添加软连接解决
ln -s linux-4.9.y linux-4.9.y-smp
在kernel路径输入命令如下
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/osdrv/opensource/kernel$ ln -s linux-4.9.y linux-4.9.y-smp
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/osdrv/opensource/kernel$ ls -l
total 153744
-rw-rw-r-- 1 zfeng zfeng 9369053 Nov 15 2018 linux-4.9.37.patch
drwxrwxr-x 25 zfeng zfeng 4096 Oct 6 18:44 linux-4.9.y
lrwxrwxrwx 1 zfeng zfeng 11 Oct 6 18:44 linux-4.9.y-smp -> linux-4.9.y
-rw-rw-r-- 1 zfeng zfeng 148043870 Aug 18 22:02 linux-4.9.y.tgz
-rw-rw-r-- 1 zfeng zfeng 1370 Nov 15 2018 readme_cn.txt
-rw-rw-r-- 1 zfeng zfeng 1448 Nov 15 2018 readme_en.txt
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/osdrv/opensource/kernel$
接着在make编译会出现找不到gcc
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100$ make
--Compiling 'sensor'... Configs as follow:
---- CROSS=arm-himix200-linux-
---- HIARCH=hi3519av100, HICHIP=0x3519A100, CVER=.C02, HIDBG=
---- SDK_PATH=/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100/../../../../../.. , PARAM_FILE=../../../../../Makefile.param
---- KERNEL_ROOT=/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100/../../../../../../../../osdrv/opensource/kernel/linux-4.9.y-smp
make[1]: Entering directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100/sony_imx290'
make[1]: arm-himix200-linux-gcc: Command not found
Makefile:50: recipe for target 'obj/imx290_cmos.o' failed
make[1]: *** [obj/imx290_cmos.o] Error 127
make[1]: Leaving directory '/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100/sony_imx290'
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 1
这里出现gcc找不到情况,但通过arm-himix200-linux-gcc -v却能正常找到找到gcc
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100$ arm-himix200-linux-gcc -v
???? specs?
COLLECT_GCC=arm-himix200-linux-gcc
COLLECT_LTO_WRAPPER=/opt/hisi-linux/x86-arm/arm-himix200-linux/host_bin/../libexec/gcc/arm-linux-gnueabi/6.3.0/lto-wrapper
??:arm-linux-gnueabi
???:/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/src/gcc-6.3.0/configure --host=i586-suse-linux --build=i586-suse-linux --target=arm-linux-gnueabi --prefix=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/install --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --enable-nls --enable-clocale=gnu --enable-extra-hisi-multilibs --with-sysroot=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/install/target --with-build-sysroot=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/install/target --with-gmp=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/obj/host-libs/usr --with-mpfr=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/obj/host-libs/usr --with-mpc=/usr1/code/CODE_CCTD_V1R2C00/code/current/SDK_CPU_UNIFIED/build/script/arm-himix200-linux/arm_himix200_build_dir/obj/host-libs/usr --enable-libgomp --disable-libitm --enable-poison-system-directories --with-pkgversion='HC&C V100R002C00B021_20180917'
????:posix
gcc ?? 6.3.0 (HC&C V100R002C00B021_20180917)
zfeng@ubuntu:~/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/component/isp/user/sensor/hi3519av100$
这是可以通过sudo -s命令解决
至此sensor的相关ko文件可以编译完成。
sample路径Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux/mpp/sample
要是上面的问题处理完之后,这里可以直接编译通过。
单板的文件系统使用的SDK默认的。
路径hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp_image_glibc/rootfs_hi3519av100_32M.ext4
系统起来后默认网络不配的,可以通过下面方法自动添加网络。
在 /etc/init.d/rcS后续添加
ifconfig lo 127.0.0.1
ifconfig eth0 192.168.1.119 netmask 255.255.255.0;route add default gw 192.168.1.1
~ # cat /etc/init.d/rcS
#! /bin/sh
/bin/mount -a
echo "
_ _ _ _ _ _ _ _ _ _ _ _
\ _ _ _ _ _ ___
/ /__/ \ |_/
/ __ / - _ ___
/ / / / / /
_ _ _ _/ / / \_/ \_ ______
___________\___\__________________
"
for initscript in /etc/init.d/S[0-9][0-9]*
do
if [ -x $initscript ] ;
then
echo "[RCS]: $initscript"
$initscript
fi
done
ifconfig lo 127.0.0.1
ifconfig eth0 192.168.1.119 netmask 255.255.255.0;route add default gw 192.168.1.1
为防止出现ip没有分配完成但是执行挂载的情况
在/etc/profile文件添加~/mount.sh &
最后的&表示创建一个线程执行这个脚本(shell语法)
mount.sh 内容为
mount -t nfs -o nolock 192.168.1.230:/home/zfeng/hisi/hi3519a/Hi3519AV100_SDK_V2.0.1.0/smp/a53_linux /mnt
进行开机自动挂载
~ # mount -t nfs -o nolock 192.168.1.230:/home/zfeng/hisi/hi3519a/Hi3519AV100_SD
K_V2.0.1.0/smp/a53_linux /mnt
~ # ls /mnt/
drv mpp
hi3519a_smp.code-workspace osal
~ #
服务器能需要开启nfs服务,相关操作可参考我之前的文章
Hi3519v101通过NFS挂载到服务器启动
挂载上之后要把MMP路径下的lib、ko文件夹部署到单板
先把lib拷贝到/usr/lib/(用户库), cp lib/* /usr/lib/ -f 因为/lib是系统的库,用在系统的库下面不太合适
ubuntu端执行:
cp ko lib ~/rootfs/ -rf
开发板端执行:
cp /mnt/ko / -rf
cp /mnt/lib/* /usr/lib/ -rf
/mnt/mpp # cd /mnt/mpp/ko/
/mnt/mpp/ko # ls
extdrv hi3519av100_h265e.ko hi3519av100_vgs.ko
hi3519av100_acodec.ko hi3519av100_hdmi.ko hi3519av100_vi.ko
hi3519av100_adec.ko hi3519av100_ir.ko hi3519av100_vo.ko
hi3519av100_aenc.ko hi3519av100_isp.ko hi3519av100_vpss.ko
hi3519av100_ai.ko hi3519av100_ive.ko hi3519av100_wdt.ko
hi3519av100_aio.ko hi3519av100_jpegd.ko hi_cipher.ko
hi3519av100_ao.ko hi3519av100_jpege.ko hi_ipcm.ko
hi3519av100_avs.ko hi3519av100_nnie.ko hi_mipi_rx.ko
hi3519av100_base.ko hi3519av100_rc.ko hi_mipi_tx.ko
hi3519av100_chnl.ko hi3519av100_rgn.ko hi_osal.ko
hi3519av100_dis.ko hi3519av100_sys.ko hi_user.ko
hi3519av100_dpu_match.ko hi3519av100_tde.ko hi_virt-tty.ko
hi3519av100_dpu_rect.ko hi3519av100_vdec.ko hifb.ko
hi3519av100_dsp.ko hi3519av100_vedu.ko load3519av100
hi3519av100_gdc.ko hi3519av100_venc.ko sys_config.ko
hi3519av100_h264e.ko hi3519av100_vfmw.ko
/mnt/mpp/ko #
先加载load3519av100,此文件是把有用的ko都一次性加载。
/mnt/mpp/ko # ./load3519av100 -i
mmz_start: 0x32000000, mmz_size: 1760M
==========sensr0: imx347==========
==========sensr1: imx347==========
==========sensr2: imx347==========
==========sensr3: imx347==========
==========sensr4: imx347==========
Module himedia: init ok
Hisilicon Media Memory Zone Manager
hi_osal 1.0 init success!
load sys.ko for Hi3519AV100...OK!
load tde.ko for HI3519AV100...OK!
load region.ko for Hi3519AV100...OK!
load gdc.ko for Hi3519AV100...OK!
Load vgs.ko for Hi3519AV100...OK!
load dis.ko for Hi3519AV100...OK!
ISP Mod init!
Load vi.ko for Hi3519AV100...OK !
load vpss.ko for Hi3519AV100...OK!
load avs.ko for Hi3519AV100...OK!
load vo.ko for Hi3519AV100...OK!
load hifb.ko OK!
load rc.ko for Hi3519AV100...OK!
load venc.ko for Hi3519AV100...OK!
load chnl.ko for Hi3519AV100...OK!
load vedu.ko for Hi3519AV100...OK!
load h264e.ko for Hi3519AV100...OK!
load h265e.ko for Hi3519AV100...OK!
load jpege.ko for Hi3519AV100...OK!
load jpegd.ko ....OK!
Load hi_vfmw.ko ....OK
load vdec.ko ....OK
load ive.ko for Hi3519AV100...OK!
<ipcm> ##message recv thread run
<ipcm> ipcm detecting thread running!
load nnie.ko for Hi3519AV100...OK!
load dsp.ko for Hi3519AV100...OK!
load dpu_rect.ko for Hi3519AV100...OK!
load dpu_match.ko for Hi3519AV100...OK!
load hi_piris.ko OK!!
insert audio
load mipi_rx driver successful!
/mnt/mpp/ko #
在来到sample目录进行各个例子的操作。
/mnt/mpp/ko # cd ../sample/
/mnt/mpp/sample # ls
Makefile fisheye tde
Makefile.param hifb traffic_capture
audio lsc_online_cali vdec
avs region venc
awb_online_calibration scene_auto vgs
common smp_linux.mak vio
dis snap
dpu svp
/mnt/mpp/sample #
这里以snap抓拍例子演示
/mnt/mpp/sample # cd snap/
/mnt/mpp/sample/snap # ./sample_snap
Usage : ./sample_snap <index>
index:
0)double pipe offline, normal snap.
/mnt/mpp/sample/snap # ./sample_snap 0
[SAMPLE_COMM_VI_SetMipiAttr]-1423: ============= MipiDev 0, SetMipiAttr enWDRMode: 0
[Func]:cmos_set_wdr_mode [Line]:1061 [Info]:linear mode
===imx347 8M30fps 12bit LINE Init OK!===
[SAMPLE_COMM_ISP_Thread]-194: ISP Dev 0 running !
[Func]:cmos_set_wdr_mode [Line]:1061 [Info]:linear mode
[SAMPLE_COMM_ISP_Thread]-194: ISP Dev 1 running !
[SAMPLE_COMM_VO_StartChn]-544: u32Width:1920, u32Height:1080, u32Square:1
=======press any key to trigger=====
snap success!
---------------press Enter key to exit!---------------
[main]-419: program exit normally!
/mnt/mpp/sample/snap # ls
Makefile sample_snap.c snap_0.jpg
sample_snap sample_snap.o snap_thm_0.jpg
/mnt/mpp/sample/snap #
snap_0.jpg、snap_thm_0.jpg即为抓拍到的图片。
至此mpp部署完成。
mpp sample大部分都跟sensor相关,使用之前必须把sensor驱动与实际使用的sensor配置好。