22. 編譯報錯分析

常見編譯報錯彙總

關鍵字:
	error:
	make[
	FAILED:
	multiple definition

1. 攝像頭兼容個數超過16個 - 增大爲18個
	alps\kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\kd_sensorlist.h
	#define MAX_NUM_OF_SUPPORT_SENSOR 16
	ACDK_KD_SENSOR_INIT_FUNCTION_STRUCT kdSensorList[MAX_NUM_OF_SUPPORT_SENSOR]=
	{
		...
	}
	
	報錯log: 
	excess elements in array initializer(給數組塞了超過初始化個數的元素)
	In file included from alps/kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6735m/kd_sensorlist.c:39:0:
	alps/kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6735m/kd_sensorlist.h:677:5: error: excess elements in array initializer [-Werror]
		 {T4KA3_SENSOR_ID, SENSOR_DRVNAME_T4KA3_MIPI_RAW, T4KA3_MIPI_RAW_SensorInit},
			 ^
2. 安卓5.1 新增驅動需要在alps\kernel-3.10\drivers\misc\mediatek\Kconfig.drivers中建宏

3. makefile從安卓6.0移植到安卓5.1,需要修改
	參照同一目錄其他Makefile修改

4. 缺少頭文件包含 - (安卓5.1)
	fae提供的代碼qma6981.c, 沒有包含包含頭文件accel.h, 導致編譯移植報結構體struct sensor_init_info定義不一致
	+	#include <accel.h>
	
	報錯log: 
	alps/kernel-3.10/drivers/misc/mediatek/accelerometer/qma6981/qma6981.c: In function 'qma6981_init':
	alps/kernel-3.10/drivers/misc/mediatek/accelerometer/qma6981/qma6981.c:2091:2: error: implicit declaration of function 'acc_driver_add' [-Werror=implicit-function-declaration]
	  acc_driver_add(&qma6981_init_info);
	  ^

5. 報錯信息爲轉義字符 - 服務器加密問題 - 重啓編譯服務器
	報錯log: 
	Line 2780: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:1: error: stray '\24' in program
	Line 2784: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:3: error: stray '#' in program
	Line 2787: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:1: error: unknown type name 'b'
	Line 2790: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:6: error: null character(s) ignored [-Werror]
	Line 2793: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:1: error: stray '\272' in program
	Line 2796: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:1: error: stray '\1' in program
	Line 2816: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:13: error: stray '\210' in program
	Line 2817: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:13: error: stray '\207' in program
	Line 2818: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:13: error: stray '\22' in program
	Line 2819: ./build/core/combo/include/arch/linux-arm/AndroidConfig.h:1:13: error: stray '\320' in program

6. 兩個.c文件中重複定義 - 修改其中一個名字
	報錯log: 
	alps/kernel/mediatek/custom/out/kernel/accelerometer/mxc622x.c:1319: multiple definition of `gsensor_operate'
	mediatek/custom/out/kernel/accelerometer/mxc400x.o:alps/kernel/mediatek/custom/out/kernel/accelerometer/mxc400x.c:1845: first defined here
	make[4]: *** [mediatek/custom/out/kernel/built-in.o] Error 1
	
7. 編譯服務器空間不足 - [No space left on device] - 清除服務器多餘存儲
	例1:
	cp: writing `out/target/product/magc6580_we_t_n/obj/EXECUTABLES/e2fsck_intermediates/quota.P': No space left on device
	cp: failed to extend `out/target/product/magc6580_we_t_n/obj/EXECUTABLES/e2fsck_intermediates/quota.P': No space left on device
	sed: couldn't write 47 items to stdout: No space left on device
	[ 53% 19897/36901] Export includes file:  -- out/target/product/magc6580_we_t_n/obj/EXECUTABLES/e2fsck_intermediates/export_includes
	[ 53% 19898/36901] target SharedLib: libart (out/target/product/magc6580_we_t_n/obj/SHARED_LIBRARIES/libart_intermediates/LINKED/libart.so)
	FAILED: /bin/bash -c "prebuilts/clang/host/linux-x86/clang-2690385/bin/clang++ -nostdlib -Wl,-soname,libart.so -Wl,--gc-sections -shared  -Lout/target/product/magc6580_we_t_n/obj/lib 
	out/target/product/magc6580_we_t_n/obj/lib/crtbegin_so.o   
	
	例2:
	FAILED: /bin/bash -c "out/host/linux-x86/bin/acp -fp out/target/product/magc6737m_65_n/obj/lib/libart.so out/target/product/magc6737m_65_n/system/lib64/libart.so"
	acp: failed writing 'out/target/product/magc6737m_65_n/system/lib64/libart.so': No space left on device
	[ 63% 28774/45356] target  C: racoon <= external/ipsec-tools/src/racoon/genlist.c
	FAILED: /bin/bash -c "(PWD=/proc/self/cwd prebuilts/misc/linux-x86/ccache/ccache prebuilts/clang/host/linux-x86/clang-2690385/bin/clang 
	fatal error: error in backend: IO failure on output stream.
	[ 63% 28774/45356] target SharedLib: libart-compiler (out/target/product/magc6737m_65_n/obj/SHARED_LIBRARIES/libart-compiler_intermediates/LINKED/libart-compiler.so)
	FAILED: /bin/bash -c "prebuilts/clang/host/linux-x86/clang-2690385/bin/clang++ -nostdlib -Wl,-soname,libart-compiler.so -Wl,--gc-sections -shared  -Lout/target/product/magc6737m_65_n/obj/lib 
	out/target/product/magc6737m_65_n/obj/lib/crtbegin_so.o      
	out/target/product/magc6737m_65_n/obj/SHARED_LIBRARIES/libart-compiler_intermediates/compiled_method.o 

8. BoardConfig.mk分區不足

	!!!默認的分區,及大小是寫在alps/device/mediatek/build/build/tools/ptgen/MT6737M/partition_table_MT6737M.xls中
	此中方式只能修改大小,不能重新劃分分區
	
	1. 修改alps/device/haocheng/hct6580_we_a_l/BoardConfig.mk 在最後添加:
		BOARD_MTK_SYSTEM_SIZE_KB :=  1835008				// 需要比文件夾略大: alps\out\target\product\hct6580_weg_a_l\system
		BOARD_MTK_USERDATA_SIZE_KB :=  786432				// 注意大小是16的倍數
	2. rm –rf out\target\product\$PROJECT_NAME \obj\PTGEN	// 【重要】裏面有分區表,不刪除不會生效!!!
	3. source xxx; lunch xxx; make lk;						// 【重要】重新生成 MT6580_Android_scatter.txt	
	4. 查看【system】分區大小是否成功改變
		vi out/target/product/hct6580_weg_a_l/MT6580_Android_scatter.txt
			partition_index: SYS19
			partition_name: system			// 關鍵字[system]
			file_name: system.img
			is_download: true
			type: EXT4_IMG
			linear_start_addr: 0xa800000
			physical_start_addr: 0xa800000
		-	partition_size: 0x60000000		// 原本報錯的時候
		+	partition_size: 0x70000000		// 修改之後生成
			region: EMMC_USER
			storage: HW_STORAGE_EMMC
			boundary_check: true
			is_reserved: false
			operation_type: UPDATE
			reserve: 0x00
	5. Make snod 或 make systemimage	

	log:
	Target system fs image: out/target/product/hct6580_weg_a_l/obj/PACKAGING/systemimage_intermediates/system.img
	error: ext4_allocate_best_fit_partial: failed to allocate 3060 blocks, out of space?
	error: failed to build out/target/product/hct6580_weg_a_l/obj/PACKAGING/systemimage_intermediates/system.img from out/target/product/hct6580_weg_a_l/system
	Running:  mkuserimg.sh -s out/target/product/hct6580_weg_a_l/system out/target/product/hct6580_weg_a_l/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 1610612736 out/target/product/hct6580_weg_a_l/root/file_contexts
	Out of space? the tree size of out/target/product/hct6580_weg_a_l/system is (MB): 
	1511	out/target/product/hct6580_weg_a_l/system
	The max is 1536 MB.
	make: *** [out/target/product/hct6580_weg_a_l/obj/PACKAGING/systemimage_intermediates/system.img] Error 1

	#### make failed to build some targets (01:03:06 (hh:mm:ss)) ####

9. android.mk
	./vendor/mediatek/proprietary/hardware/sensor/Android.mk:59: *** commands commence before first target
	
	在C/C++語言中,可以用\來換行,此時要注意,在一行的最後面加上\, 而這個\後面不能再有任何字符,哪怕是空格,也不允許,否則出錯。
    對於makefile,也有類似的原則,最近寫makefile,一不小心,在\後多了個空格,結果編譯出現:commands commence before first target
	
10. kernel-3.18\arch\arm64\configs\k37mv1_64_bsp_debug_defconfig、k37mv1_64_bsp_defconfig
	-	CONFIG_FRAME_WARN=1400
	+	CONFIG_FRAME_WARN=1500
	
	函數調用棧過深,內核配置的棧緩存不夠用
	
	報錯log:
	/home/android009/liuzhigou/code0_alps_o1_mp1_v662_R2_32_to_64_user/alps/kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6735m/kd_sensorlist.c: In function ‘CAMERA_HW_Ioctl’:
	/home/android009/liuzhigou/code0_alps_o1_mp1_v662_R2_32_to_64_user/alps/kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6735m/kd_sensorlist.c:3643:1: error: the frame size of 1456 bytes is larger than 1400 bytes [-Werror=frame-larger-than=]
	 }
	 ^
	cc1: all warnings being treated as errors
	make[6]: *** [drivers/misc/mediatek/imgsensor/src/mt6735m/kd_sensorlist.o] Error 1
	make[5]: *** [drivers/misc/mediatek/imgsensor/src/mt6735m] Error 2
	make[4]: *** [drivers/misc/mediatek/imgsensor/src] Error 2
	make[4]: *** Waiting for unfinished jobs....	
	
	





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章