DSP

hevc移植/优化-day 2:dsp工程创建及测试

2019-07-13 17:36发布

1、linux内核,使用arago linux 2.6.39 2、buildroot ,使用git最新版本 make menuconfig
make TARGET_DIR=/opt/nfs/minirootfs
只需选择busybox包,设置串口输出设备ttyO2,设置使用的工具链。

3 、生成dsp端codec工程
XDC_INSTALL_DIR=/media/work/sdk/dvsdk_dm3730/xdctools_3_16_03_36
CGT_C64P_INSTALL_DIR=/media/work/sdk/dvsdk_dm3730/cgt6x_6_1_14
XDCPATH="/media/work/sdk/dvsdk_dm3730/biosutils_1_02_02/packages;/media/work/sdk/dvsdk_dm3730/codec-engine_2_26_02_11/packages;/media/work/sdk/dvsdk_dm3730/edma3lld_01_11_00_03/packages;/media/work/sdk/dvsdk_dm3730/framework-components_2_26_00_01/packages;/media/work/sdk/dvsdk_dm3730/local_power_manager_linux_1_24_02_09/packages;/media/work/sdk/dvsdk_dm3730/xdais_6_26_01_03/packages;/media/work/sdk/dvsdk_dm3730/dsplink_linux_1_65_00_03;${XDC_INSTALL_DIR}/packages" ${XDC_INSTALL_DIR}/xs ti.sdo.ce.wizards.gencodecpkg --cgtools=${CGT_C64P_INSTALL_DIR}
设置好相关参数,如选择ividdec2接口等。
到生成的目录中make编译生成hevcdec.a64P 4 、生成dsp server工程

XDC_INSTALL_DIR=/media/work/sdk/dvsdk_dm3730/xdctools_3_16_03_36
XDCPATH="/media/work/sdk/dvsdk_dm3730/dspbios_5_41_03_17/packages;/media/work/sdk/dvsdk_dm3730/biosutils_1_02_02/packages;/media/work/sdk/dvsdk_dm3730/codec-engine_2_26_02_11/packages;/media/work/sdk/dvsdk_dm3730/edma3lld_01_11_00_03/packages;/media/work/sdk/dvsdk_dm3730/framework-components_2_26_00_01/packages;/media/work/sdk/dvsdk_dm3730/local_power_manager_linux_1_24_02_09/packages;/media/work/sdk/dvsdk_dm3730/xdais_6_26_01_03/packages;/media/work/sdk/dvsdk_dm3730/dsplink_linux_1_65_00_03;${XDC_INSTALL_DIR}/packages;/media/develop/git/hevc_dsp" ${XDC_INSTALL_DIR}/xs ti.sdo.ce.wizards.genserver
设置cpu,server包含的编码器等参数。

默认参数将产生错误:
Configuration error: Combined memory entries (starting with ADDRDSPVI
RT = 0x87300000) does not have a size that is a multiple of 4KB. Size is 128.

 修改memmap.tci,len改为0x1000。
var mem_ext = [
{
    comment:    "RESET_VECTOR: off-chip memory for the reset vector table",
    name:       "RESET_VECTOR",
    base:       0x87300000,
    len:        0x00001000,
    space:      "code/data"
},
 重新编译server,hevcapp

到生成的目录中make编译生成hevcserver.x64P, 此文件即dsp端加载的镜像文件,运行时与应与应用程序处于同一目录。
 注意此步骤依赖于前一步生成的解码器静态库hevcdec.a64P

5 、 编译dsp的arm端驱动(cmemk.ko,dsplinkk.ko,lpm_omap3530.ko,sdmak.ko)。直接在dvsdk目录下运行make。
 make cmem_clean sdma_clean dsplink_arm_clean lpm_clean
 make cmem sdma dsplink_arm lpm
 make cmem_install sdma_install dsplink_install lpm_install
6、修改/创建loadmodule.sh: CMEM_MODPARAMS="phys_start=0x85000000 phys_end=0x86000000 pools=20x4096,10x131072,2x1048576allowOverlap=1" VER=`uname -r`                                                                      
MODULE_DIR=/lib/modules/$VER/kernel/drivers/dsp/                                    
insmod $MODULE_DIR/cmemk.ko $CMEM_MODPARAMS                                         
chmod 666 /dev/cmem                                                                 
insmod $MODULE_DIR/dsplinkk.ko                                                      
chmod 666 /dev/dsplink                                                              
insmod $MODULE_DIR/lpm_omap3530.ko                                                  
chmod 666 /dev/lpm* 

7 、arm端对dsp端的算法调用。此步骤较为复杂,可参考ce_xxxx/examples/ti/sdo/ce/examples/apps/video2_copy下的代码来实现。 创建cfg及bld文件。 cfg文件内容: var osalGlobal = xdc.useModule('ti.sdo.ce.osal.Global');
osalGlobal.runtimeEnv = osalGlobal.DSPLINK_LINUX;

var Engine = xdc.useModule('ti.sdo.ce.Engine');
var myEngine = Engine.createFromServer(
    "engine_hevc",
    "bin/hevcserver.x64P",
    "xmu.server.hevcserver"
);

bld文件 var GCArmv5T = xdc.useModule('gnu.targets.arm.GCArmv5T');
GCArmv5T.LONGNAME = 'bin/arm-none-linux-gnueabi-gcc';
GCArmv5T.platform = "ti.platforms.evm3530";
GCArmv5T.rootDir = "/media/work/sdk/Sourcery_G++_Lite";

Build.targets = [
]; 对应的xdctool运行命令: XDCTOOLS_DIR="/media/work/sdk/dvsdk_dm3730/xdctools_3_16_03_36"
export XDCPATH="/media/work/sdk/dvsdk_dm3730/codec-engine_2_26_02_11/packages;/media/work/sdk/dvsdk_dm3730/edma3lld_01_11_00_03/packages;/media/work/sdk/dvsdk_dm3730/framework-components_2_26_00_01/packages;/media/work/sdk/dvsdk_dm3730/local_power_manager_linux_1_24_02_09/packages;/media/work/sdk/dvsdk_dm3730/xdais_6_26_01_03/packages;/media/work/sdk/dvsdk_dm3730/dsplink_linux_1_65_00_03;/media/work/sdk/dvsdk_dm3730/linuxutils_2_26_02_05/packages;/media/develop/git/hevc_dsp"
${XDCTOOLS_DIR}/xs xdc.tools.configuro -o cfg_tmp -t gnu.targets.arm.GCArmv5T -p ti.platforms.evm3530 -b app.bld remote.cfg
awk 'BEGIN{isEnd=0} /^SECTIONS/{isEnd=1} {if(isEnd==0) print }' cfg_tmp/linker.cmd > linker.tmp 简易makefile:
CROSS_COMPILE?=arm-none-linux-gnueabi- CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)gcc LDFLAGS=-lpthread CFLAGS=-O2 all:hevcapp compiler.opt linker.cmd codec_cfg.o:app.bld remote.cfg ./xdc.sh sed -e 's#cfg_tmp/package/cfg/remote_xv5T.ov5T#codec_cfg.o#' cfg_tmp/linker.cmd > linker.cmd mv cfg_tmp/compiler.opt compiler.opt mv cfg_tmp/package/cfg/remote_xv5T.ov5T codec_cfg.o $(RM) -rf cfg_tmp/ CE_CFLAGS=$(shell cat compiler.opt) %.o:%.c $(CC) -c {1}lt; -o $@ $(CFLAGS) $(CE_CFLAGS) hevcapp:linker.cmd hevcapp.o $(LD) -o $@ $(LDFLAGS) .PHONY:clean clean: $(RM) compiler.opt linker.cmd codec_cfg.o hevcapp $(RM) *.o $(RM) *~
make生成hevcapp后与x64P文件一同拷到nfs目录下,测试时需先运行loadmodule.sh加载cmem,dsplink,lpm等模块。 NOTE:测试时设置环境变量CE_DEBUG=[1|2|3]可以开启测试的trace功能。