SSC9381G SDK python2与python3兼容编译报错问题

        SSC9381G是星宸科技2020年10月25日发布的一款智能外设及娱乐—猫头鹰系列芯片, 搭载其自研AI处理器IPU。主要用于会议场景下广角畸变矫正、人脸签到、语音自动翻译等功能。刚好,最近在对这个平台进行预研,在此做点笔记。

        在参考官方手册编译SSC9381的SDK的时候,发现了一些编译问题,基本定位是python版本不一致导致,目前已解决,在此做一下记录,以免遗忘。(如果能用python2建议最好还是用python2,目前项目才刚开始,python3虽然编译过了,但是还没有进行验证,不确定还有没有什么隐藏的坑)

编译环境: Ubuntu16.04   sdk版本:SSC9351_9381_339G_USBCamera_SDK_V00024

默认python版本:python3.8

1. 编译boot:

问题一:print用法python2与python3不兼容

scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
  GCC version: 9.1.0
  MVXV
  CHK     include/generated/timestamp_autogenerated.h
chip_id I6E
  UPD     include/generated/timestamp_autogenerated.h
  File "ms_gen_mvxv_h.py", line 20
    print 'ERROR: must specify output header file!!'
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('ERROR: must specify output header file!!')?
Makefile:1151: recipe for target 'include/config/uboot.release' failed
make: *** [include/config/uboot.release] Error 1 

解决方法:添加print后的字符串打印用 ()

SSC9381G SDK python2与python3兼容编译报错问题_第1张图片

2. 编译kernel:

问题一: python读取二进制文件时出错

#update builtin DTB
  IMAGE   arch/arm/boot/Image
  BNDTB arch/arm/boot/dts/infinity6e-ssc013a-s01a.dtb
Traceback (most recent call last):
  File "scripts/ms_builtin_dtb_update.py", line 13, in
    dtb=dtb_file.read()
  File "/usr/local/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte

#update Image-fpga DTB
Traceback (most recent call last):
  File "scripts/ms_bin_option_update_int.py", line 11, in
    value=long(sys.argv[3])
NameError: name 'long' is not defined
arch/arm/boot/Makefile:82: recipe for target 'arch/arm/boot/zImage' failed
make[2]: *** [arch/arm/boot/zImage] Error 1
arch/arm/Makefile:330: recipe for target 'zImage' failed
make[1]: *** [zImage] Error 2
make[1]: Leaving directory '/home/disk/fangye/setup_package/ss9381G/SSC9351_9381_339G_USBCamera_SDK_V00024/test/kernel'
makefile:17: recipe for target 'GNUmakefile' failed
make: *** [GNUmakefile] Error 2

解决办法:以二进制只读方式打开文件,查找字符串转换为二进制。

SSC9381G SDK python2与python3兼容编译报错问题_第2张图片

问题二:long类型转换找不到定义

#update Image-fpga DTB
Traceback (most recent call last):
  File "scripts/ms_bin_option_update_int.py", line 11, in
    value=long(sys.argv[3])
NameError: name 'long' is not defined
arch/arm/boot/Makefile:82: recipe for target 'arch/arm/boot/zImage' failed
make[2]: *** [arch/arm/boot/zImage] Error 1
arch/arm/Makefile:330: recipe for target 'zImage' failed
make[1]: *** [zImage] Error 2
make[1]: Leaving directory '/home/disk/fangye/setup_package/ss9381G/SSC9351_9381_339G_USBCamera_SDK_V00024/test/kernel'
makefile:17: recipe for target 'GNUmakefile' failed
make: *** [GNUmakefile] Error 2

 解决办法:python3不在支持long类型,直接用int类型替代即可。

SSC9381G SDK python2与python3兼容编译报错问题_第3张图片

问题三:字符串类型与字节类型不匹配

#update Image-fpga DTB
Traceback (most recent call last):
  File "scripts/ms_bin_option_update_int.py", line 15, in
    offset=fmap.find(name)
TypeError: a bytes-like object is required, not 'str'
arch/arm/boot/Makefile:82: recipe for target 'arch/arm/boot/zImage' failed
make[2]: *** [arch/arm/boot/zImage] Error 1
arch/arm/Makefile:330: recipe for target 'zImage' failed
make[1]: *** [zImage] Error 2
make[1]: Leaving directory '/home/disk/fangye/setup_package/ss9381G/SSC9351_9381_339G_USBCamera_SDK_V00024/test/kernel'
makefile:17: recipe for target 'GNUmakefile' failed
make: *** [GNUmakefile] Error 2

 解决办法:将str转为二进制即可

SSC9381G SDK python2与python3兼容编译报错问题_第4张图片

 

project和sdk目录的编译不需要修改什么,直接参考如下编译脚本:

#!/bin/bash

ARCH="arm"
CROSS_COMPILE="arm-linux-gnueabihf-9.1.0-"

BOOT_CONFIG="infinity6e_ufu_spinand_defconfig"
KERNEL_CONFIG="infinity6e_ssc013a_s01a_spinand_usbcam_defconfig"
PROJECT_CONFIG="./configs/usbcam/i6e/spinand.glibc-squashfs.013a.256x256.bga"

BOOT_IMAGE_PATH="./u-boot_spinand.xz.img.bin"
KERNEL_IMAGE_PATH="./arch/arm/boot/uImage.xz"

BOOT_RELEASE_PATH="../project/board/i6e/boot/spinand/uboot"
KERNEL_RELEASE_PATH="../project/release/usbcam/i6e/013A/glibc/9.1.0/bin/kernel/spinand/uImage.xz"

boot(){
	cd boot
	declare -x ARCH=$ARCH
	declare -x CROSS_COMPILE=$CROSS_COMPILE
#	make $BOOT_CONFIG
	make clean
	make -j8
	cp $BOOT_IMAGE_PATH $BOOT_RELEASE_PATH
	make clean
	cd ..
}

kernel(){
	cd kernel
	declare -x ARCH=$ARCH
	declare -x CROSS_COMPILE=$CROSS_COMPILE
#	make $KERNEL_CONFIG
	make clean
	make -j8
	cp $KERNEL_IMAGE_PATH $KERNEL_RELEASE_PATH
#	make clean
	cd ..
}

project(){
	cd project
	./setup_config.sh $PROJECT_CONFIG
	make clean
	make image
	cd ..
}

sdk(){
	cd sdk/verify/mi_demo/source/
	make clean
	make uvc
	make install
	make clean
	cd ../../../../
}

module(){
#	cp kernel/modules/*  project/release/usbcam/i6e/common/glibc/9.1.0/modules/4.9.84/
        cp kernel/modules/*  project/kbuild/4.9.84/i6e/configs/usbcam/013A/glibc/9.1.0/spinand/modules
	echo "cp kernel/modules/*  project/kbuild/4.9.84/i6e/configs/usbcam/013A/glibc/9.1.0/spinand/modules"
}

case "$1" in
"")
	boot;
	kernel;
	project;
	sdk;
	;;
"boot")
	boot
	;;
"kernel")
	kernel
	;;
"project")
	project
	;;
"sdk")
	sdk
	;;
"module")
	module
	;;
esac

PS:不要在project 和 sdk目录下创建仓库,makefile会判断.git目录,导致你无法编译。

你可能感兴趣的:(Linux基础学习,Python学习)