關鍵詞:android 4.0 user eng camera nand 串口
平台資訊:
核心:linux3.0
系統:android4.0.3
平台:S5PV310(samsung exynos 4210)
問題描述:android4.0編譯模式由eng變成user後出現如下問題:
1、設定中wifi開關選項沒有了(開啟、關閉選項);
2、不能安裝應用程式apk;
3、camera提示插入sd卡(實際sd卡、nand正常掛載);
4、串口終端有資訊輸出,但是不能操作(只能看到核心輸出資訊,敲鍵盤沒反應)。
一、Android 編譯選項eng、user、userdebug,我們先看一下幾種模式的不同吧
eng: 為了開發而包含了很多工具;
user:出廠時候面向使用者的 ;
userdebug:開啟了一些debug選項 ;
三種模式的解釋:
http://www.kandroid.org/online-pdk/guide/build_system.html#androidBuildVariants
1、eng 工程模式
This is the default flavor. A plain make is the same as make eng.
Installs modules tagged with: eng, debug, user, and/or development.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files, in addition to tagged APKs.
ro.secure=0
ro.debuggable=1 //開啟串口調試
ro.kernel.android.checkjni=1
adb is enabled by default.
2、user 使用者模式
make user
This is the flavor intended to be the final release bits.
Installs modules tagged with user.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files; tags are ignored for APK modules.
ro.secure=1
ro.debuggable=0 //關閉串口調試,我們所說的第4個問題,串口不能操作,就是這個地方的控制的
adb is disabled by default.
3、userdebug 使用者偵錯模式
make userdebug
The same as user, except:
Also installs modules tagged with debug.
ro.debuggable=1 //開啟串口調試
adb is enabled by default.
二、更改編譯指令碼build_android.sh
找到下面指令碼,改為user模式:
eng模式為: echo make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-eng echo make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-enguser模式為: echo make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-user echo make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-user
三、問題分析、解決
1、對2、3兩個問題分析
不能安裝應用程式apk; camera提示插入sd卡(實際sd卡、nand正常掛載);
感覺是nand、sd卡的許可權不,查看許可權:
shell@android:/mnt $ la -ladrwxr-xr-x root system 2000-01-01 14:38 asecdrwxr-xr-x root system 2000-01-01 14:38 obbd---rwxr-x system sdcard_rw 1970-01-01 00:00 sdcard //sd卡許可權d---rwxr-x system sdcard_rw 1970-01-01 00:00 sdcard2//nand許可權drwx------ root root 2000-01-01 14:38 secured--------- system system 2000-01-01 14:38 usb
2、對比編譯產生的system,發現問題
發現有system/etc/permissions在兩種模式下有所不同,編譯成user時4.0.3_r1/out/target/product/smdkv310/system/etc/permissions/少了一些xml檔案,
如:android.hardware.camera.xml、android.hardware.wifi.xml、platform.xml等
我們知道out目錄下產生的檔案,是在其它地方copy過來的,找到這些xml檔案在源頭在:4.0.3_r1/frameworks/base/data/etc中,查看4.0.3_r1/frameworks/base/data/etc/ndrAoid.mk編譯選項,發現一些問題:
########################include $(CLEAR_VARS)LOCAL_MODULE := platform.xmlLOCAL_MODULE_TAGS := engLOCAL_MODULE_CLASS := ETC# This will install the file in /system/etc/permissions#LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissionsLOCAL_SRC_FILES := $(LOCAL_MODULE)include $(BUILD_PREBUILT)
LOCAL_MODULE_TAGS := eng這個值為eng,所以在user模式下編譯時間,對應的檔案不做copy,LOCAL_MODULE_TAGS:= user時編譯時間出錯。編譯指令碼太深入的話,我也看不懂裡面的東西,所以想了一種比較簡單的方法,編譯時間不判斷模式,直接copy檔案:
3、在device.mk中加入copy操作,解決問題
我們在4.0.3_r1/device/samsung/smdkv310/deivce.mk中加入copy命令,如下:
PRODUCT_COPY_FILES += \frameworks/base/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml\frameworks/base/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml\frameworks/base/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml\frameworks/base/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml\frameworks/base/data/etc/platform.xml:system/etc/permissions/platform.xml\frameworks/base/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml
編譯完成後要檢查一下4.0.3_r1/out/target/product/smdkv310/system/etc/permissions/這個目錄下,是否把frameworks/base/data/etc/目錄下的xml檔案複製過來。
注意:燒錄時,清除userdata\cache兩個分區,這裡面會記憶一些系統資訊,不清除的話,還是會出現錯誤現象。
前三個問題解決,我們再看下第四個問題:
4、串口的操作選擇(debugable使能)
問題:串口終端有資訊輸出,但是不能操作(只能看到核心輸出資訊,敲鍵盤沒反應)。
這個問題也是無意間發現的,其實在user模式下,串口本來就不能操作的,也就是說這是正常的現象,但是我們考慮到在試產過程中總會出現一些問題,要用到串口跟蹤資訊,所以還是想找到原因:
(1)default.prop
我們對比下default.prop在兩種模式編譯下的差異:
user模式下,串口不可用:shell@android:/ $ cat default.prop ## ADDITIONAL_DEFAULT_PROPERTIES#ro.secure=1ro.allow.mock.location=0ro.debuggable=0 //這個值為0也就是說不能用debug,所以串口就不能使用persist.sys.usb.config=mass_storageshell@android:/ $ user模式下,串口可用:shell@android:/ # cat default.prop ## ADDITIONAL_DEFAULT_PROPERTIES#ro.secure=0ro.allow.mock.location=1ro.debuggable=1 //這個值為1,所以串口可以操作使用persist.sys.usb.config=mass_storage,adb
(2)、全域搜尋,找到對這個值設定的位置4.0.3_r1/build/core/main.mk
更改:4.0.3_r1/build/core/main.mk
ifeq (true,$(strip $(enable_target_debugging))) # Target is more debuggable and adbd is on by default ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1//eng模式下 # Include the debugging/testing OTA keys in this build. INCLUDE_TEST_OTA_KEYS := trueelse # !enable_target_debugging # Target is less debuggable and adbd is off by defaultADDITIONAL_DEFAULT_PROPERTIES +=ro.debuggable=1//user模式下,原來為0,現在改為1endif # !enable_target_debugging
關於user、eng這兩種模式,BSP中應該都支援,也許我們拿到的BSP不全,這裡面的問題只是針對user、eng編譯裡的個別問題。我不能詳細的分析,一方面我做驅動方面的工作,對系統方面瞭解有限,另一方面BSP編譯規則一般是由晶片廠去做這部分工作。希望對遇到相同問題的“同學”有所協助,自己也做一點備忘記錄。