Sky37E 編譯過程問題解決
1. 编译Uboot錯誤
(1) 依賴庫(工具)缺失
編譯過程中會出現錯誤:
anyka@anyka-VirtualBox:~/project/AK37E_SDK_V1.02/os$ ./build_uboot.sh
FLASH_TYPE=NOR, CHIP_SERIES=AK37E
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
/bin/sh: 1: bison: not found
解決方法:
sudo apt-get install bison
編譯過程中會出現錯誤:
anyka@anyka-VirtualBox:~/project/AK37E_SDK_V1.02/os$ ./build_uboot.sh
FLASH_TYPE=NOR, CHIP_SERIES=AK37E
CLEAN scripts/basic
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
/bin/sh: 1: flex: not found
解决方法:
sudo apt-get install flex
(2) 編譯提示錯誤
編譯過程中會出现如下错误:
FLASH_TYPE=NOR, CHIP_SERIES=AK37E
make: arm-anykav500-linux-uclibcgnueabi-gcc: Command not found
/bin/sh: 1: arm-anykav500-linux-uclibcgnueabi-gcc: not found
dirname: missing operand
此跟踪发现,主要是uboot中Makefile配置:
ARCH = arm
CROSS_COMPILE ?= arm-anykav500-linux-uclibcgnueabi-
而编译脚本中(build_uboot.sh):
# 先进行编译前的清理
make distclean
make clean
这样因为默认工具链(arm-anykav500-linux-uclibcgnueabi-)不存在时,会出现如上面错误.
科学的修复办法:
# 先进行编译前的清理
make distclean CROSS_COMPILE=arm-anykav500-eabi-
make clean CROSS_COMPILE=arm-anykav500-eabi-
添加指定工具链(两处地方,编译spl、uboot都需要添加)。
另外,如果使用SDK顶端的脚本清空sdk时 auto_build.sh -c
,同样也会报错,
原理相同,需要同样的修改脚本:
# 清理uboot
echo "****************Clean uboot******************"
cd os/uboot
echo "****************Clean uboot******************"
make clean
make distclean
echo "[ OK ]"
cd -
echo "[ OK ]"
修改为(添加工具链配置):
# 清理uboot
echo "****************Clean uboot******************"
cd os/uboot
echo "****************Clean uboot******************"
make clean CROSS_COMPILE=arm-anykav500-eabi-
make distclean CROSS_COMPILE=arm-anykav500-eabi-
echo "[ OK ]"
cd -
echo "[ OK ]"
2. 編譯Kernel出現問題(單獨編譯Kernel時)
如果單獨編譯kernel時(./build_kernel.sh
),會出現異常:
anyka@anyka-VirtualBox:~/project/AK37E_SDK_V1.02/os$ ./build_kernel.sh
FLASH_TYPE=NOR, WIFI_TYPE=atbm6031, SENSOR_TYPE=0, SCREEN_TYPE=icn85xx_v1_0_2, CHIP_SERIES=AK37E
./build_kernel.sh: line 34: test: =: unary operator expected
查看脚本(build_kernel):
33 build_kernel() {
34 if test $BUILD_KERNEL = 'y' ; then
35 pwd
36 cd ./kernel_rtt/bsp/anyka
37
bash語法存在問題,修改為:
34 build_kernel() {
35 if [ "$BUILD_KERNEL" == 'y' ] ; then
36 pwd
37 cd ./kernel_rtt/bsp/anyka
38
修改完成后,運行編譯脚本瞬間完成,查看發現根本沒有運行編譯流程,修改脚本:
7 # 获取配置参数
8 BUILD_UBOOT=`awk -F= '/^BUILD_UBOOT/{gsub(" ","",$2); printf $2}' ../config.mk`
9 BUILD_DRV=`awk -F= '/^BUILD_DRV/{gsub(" ","",$2); printf $2}' ../config.mk`
10 BUILD_KERNEL=`awk -F= '/^BUILD_KERNEL/{gsub(" ","",$2); printf $2}' ../config.mk`
11 BUILD_PLATFORM=`awk -F= '/^BUILD_PLATFORM/{gsub(" ","",$2); printf $2}' ../config.mk`
12 WIFI_TYPE=`awk -F= '/^WIFI_TYPE/{gsub(" ","",$2); printf $2}' ../config.mk`
13 SENSOR_TYPE=`awk -F= '/^SENSOR_TYPE/{gsub(" ","",$2); printf $2}' ../config.mk`
14 SCREEN_TYPE=`awk -F= '/^SCREEN_TYPE/{gsub(" ","",$2); printf $2}' ../config.mk`
15 CHIP_SERIES=`awk -F= '/^CHIP_SERIES/{gsub(" ","",$2); printf $2}' ../config.mk`
16 CHIP_TYPE=`awk -F= '/^CHIP_TYPE/{gsub(" ","",$2); printf $2}' ../config.mk`
17
18 BUILD_KERNEL='y'
主要在最後加入BUILD_KERNEL='y'
,這是個是因../config.mk
根本就沒有配置相關變量.
接著編譯會出現:
anyka@anyka-VirtualBox:~/project/AK37E_SDK_V1.02/os$ ./build_kernel.sh
FLASH_TYPE=NOR, WIFI_TYPE=atbm6031, SENSOR_TYPE=0, SCREEN_TYPE=icn85xx_v1_0_2, CHIP_SERIES=AK37E
/home/anyka/project/AK37E_SDK_V1.02/os
scons: Reading SConscript files ...
Build kernel, use config : anyka_ak37e_defconfig !
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
Install compiled library... rt-thread.a
scons: done building targets.
cp: cannot create regular file '../../../../workspace/os': No such file or directory
/home/anyka/project/AK37E_SDK_V1.02/os
從結果看,會存在相關目標路徑錯誤,脚本操作如下:
56 if [ $? -ne 0 ]; then
57 echo -e "\033[31mKernel built failed! Aborting\033[0m"
58 exit 1
59 fi
60
61 cp ../../librt-thread.a ../../../../workspace/os
62 cd -
修改為:
56 if [ $? -ne 0 ]; then
57 echo -e "\033[31mKernel built failed! Aborting\033[0m"
58 exit 1
59 fi
60
61 #cp ../../librt-thread.a ../../../../workspace/os
62 cp ../../librt-thread.a ../../../
63 cd -
主要調整輸出路徑.