Download oracle java 6 : http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
chose : Linux x64 68.75 MB "jdk-6u45-linux-x64.bin"
# sudo chmode 777 jdk-6u45-linux-x64.bin
# ./jdk-6u45-linux-x64.bin
# export JAVA_HOME=/home/bin/jdk1.6.0_45 (change to your java path)
# export JRE_HOME=${JAVA_HOME}/jre
# export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
# export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:$PATH
Modify : build/core/main.mk
+ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 4.1))
$(warning ********************************************************************************)
$(warning * You are using version $(MAKE_VERSION) of make.)
$(warning * Android can only be built by versions 3.81 and 3.82.)
$(warning * see https://source.android.com/source/download.html)
$(warning ********************************************************************************)
$(error stopping)
+endif
2017年6月1日 星期四
[Android] Generate the test key pairs
About key
A. 簽名類型
android的標準簽名key有:
testkey, media, platform, shared
以上的四種,可以在源碼的/build/target/product/security/裡面看到對應的金鑰,其中shared.pk8代表私密金鑰,shared.x509.pem公開金鑰,一定是"成對"出現的。
其中testkey是作為android編譯的時候默認的簽名key,如果系統中的apk的android.mk中沒有設置LOCAL_CERTIFICATE的值,就默認使用testkey。
而如果設置成:
LOCAL_CERTIFICATE := platform
就代表使用platform來簽名,這樣的話這個apk就擁有了和system相同的簽名,因為系統級別的簽名也是使用的platform來簽名,此時使用android:sharedUserId="android.uid.system"才有用!
最後我們需要將testkey置換成releasekey。
B. 製作Release key
subject='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
mkdir ~/.android-certs
for x in releasekey platform shared media; do \
./development/tools/make_key ~/.android-certs/$x "$subject"; \
done
C ---> Country Name (2 letter code)
ST ---> State or Province Name (full name)
L ---> Locality Name (eg, city)
O ---> Organization Name (eg, company)
OU ---> Organizational Unit Name (eg, section)
CN ---> Common Name (eg, your name or your server’s hostname)
emailAddress ---> Contact email address
另外在使用上面的make_key腳本生成key的過程中會提示輸入password,直接enter,不要密碼!否則build的過程因為多執行緒會build失敗。(後面會介紹強制使用密碼方法)
將生成的key複製到/build/target/product/security/ 底下,testkey可以不留。
僅需一個人產生即可,其他人複製同一份security key使用,避免使用不同簽章而在燒錄過程驗證不過。
C. 修改系統默認簽名key
若LOCAL_CERTIFICATE沒有設定的話,系統預設會直接使用testkey為APK簽章。
修改預設使用的testkey為releasekey
android4.4/build/core/config.mk
修正前:
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
修正後:
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/releasekey
/build/core/makefile
修正前:
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
BUILD_VERSION_TAGS += test-keys
修正後:
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/releasekey)
BUILD_VERSION_TAGS += release-keys
===================================================================
如果你在產生key的過程有輸入password
build/tools/signapk/SignApk.java 在這隻檔案
private static String readPassword(File keyFile) {
Console console;
char[] pwd;
if((console = System.console()) != null &&
(pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){
return String.valueOf(pwd);
} else {
//return null;
+ return String.valueOf(password);<<加入這段 強制回傳你設置的密碼
}
}
這樣就可以解決build失敗的狀況
-----------------------------------------------------------------------------------------------------------------
build/core/config.mk
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif
-----------------------------------------------------------------------------------------------------------------
in your project.mk
PRODUCT_DEFAULT_DEV_CERTIFICATE := \
device/xxx/testkey
===================================================================
How do I change the KEY path and the RSA for DM-verity?
===================================================================
development/tools/make_key verity '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
out/host/linux-x86/bin/generate_verity_key -convert verity.x509.pem verity_key
mv verity_key.pub verity_key
-----------------------------------------------------------------------------------------------------------------
copy build/target/product/verity.mk to project_path/
ifdef PRODUCT_VERITY_SIGNING_KEY
PRODUCT_VERITY_SIGNING_KEY := $(PRODUCT_VERITY_SIGNING_KEY)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/verity
endif
-----------------------------------------------------------------------------------------------------------------
in your project.mk
PRODUCT_VERITY_SIGNING_KEY := \
device/xxx/verity
DISTTOOLS += \
$(HOST_OUT_EXECUTABLES)/generate_verity_key
# setup dm-verity configs.
ifneq ($(BUILD_TARGET_DEVICE),sd)
PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/mmcblkxxx
$(call inherit-product, project_path/verity.mk)
else
PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/mmcblkxxx
$(call inherit-product, project_path/verity.mk)
endif
-----------------------------------------------------------------------------------------------------------------
key都建立完成後 應該要有
testkey.pk8 testkey.pem
media.pk8 media.pem
platform.pk8 platform.pem
shared.pk8 shared.pem
verity.pk8 verity.pem.
verity_key
共九個檔案
A. 簽名類型
android的標準簽名key有:
testkey, media, platform, shared
以上的四種,可以在源碼的/build/target/product/security/裡面看到對應的金鑰,其中shared.pk8代表私密金鑰,shared.x509.pem公開金鑰,一定是"成對"出現的。
其中testkey是作為android編譯的時候默認的簽名key,如果系統中的apk的android.mk中沒有設置LOCAL_CERTIFICATE的值,就默認使用testkey。
而如果設置成:
LOCAL_CERTIFICATE := platform
就代表使用platform來簽名,這樣的話這個apk就擁有了和system相同的簽名,因為系統級別的簽名也是使用的platform來簽名,此時使用android:sharedUserId="android.uid.system"才有用!
最後我們需要將testkey置換成releasekey。
B. 製作Release key
subject='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
mkdir ~/.android-certs
for x in releasekey platform shared media; do \
./development/tools/make_key ~/.android-certs/$x "$subject"; \
done
C ---> Country Name (2 letter code)
ST ---> State or Province Name (full name)
L ---> Locality Name (eg, city)
O ---> Organization Name (eg, company)
OU ---> Organizational Unit Name (eg, section)
CN ---> Common Name (eg, your name or your server’s hostname)
emailAddress ---> Contact email address
另外在使用上面的make_key腳本生成key的過程中會提示輸入password,直接enter,不要密碼!否則build的過程因為多執行緒會build失敗。(後面會介紹強制使用密碼方法)
將生成的key複製到/build/target/product/security/ 底下,testkey可以不留。
僅需一個人產生即可,其他人複製同一份security key使用,避免使用不同簽章而在燒錄過程驗證不過。
C. 修改系統默認簽名key
若LOCAL_CERTIFICATE沒有設定的話,系統預設會直接使用testkey為APK簽章。
修改預設使用的testkey為releasekey
android4.4/build/core/config.mk
修正前:
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
修正後:
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/releasekey
/build/core/makefile
修正前:
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
BUILD_VERSION_TAGS += test-keys
修正後:
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/releasekey)
BUILD_VERSION_TAGS += release-keys
===================================================================
如果你在產生key的過程有輸入password
build/tools/signapk/SignApk.java 在這隻檔案
private static String readPassword(File keyFile) {
Console console;
char[] pwd;
if((console = System.console()) != null &&
(pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){
return String.valueOf(pwd);
} else {
//return null;
+ return String.valueOf(password);<<加入這段 強制回傳你設置的密碼
}
}
這樣就可以解決build失敗的狀況
-----------------------------------------------------------------------------------------------------------------
build/core/config.mk
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif
-----------------------------------------------------------------------------------------------------------------
in your project.mk
PRODUCT_DEFAULT_DEV_CERTIFICATE := \
device/xxx/testkey
===================================================================
How do I change the KEY path and the RSA for DM-verity?
===================================================================
development/tools/make_key verity '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
out/host/linux-x86/bin/generate_verity_key -convert verity.x509.pem verity_key
mv verity_key.pub verity_key
-----------------------------------------------------------------------------------------------------------------
copy build/target/product/verity.mk to project_path/
ifdef PRODUCT_VERITY_SIGNING_KEY
PRODUCT_VERITY_SIGNING_KEY := $(PRODUCT_VERITY_SIGNING_KEY)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/verity
endif
-----------------------------------------------------------------------------------------------------------------
in your project.mk
PRODUCT_VERITY_SIGNING_KEY := \
device/xxx/verity
DISTTOOLS += \
$(HOST_OUT_EXECUTABLES)/generate_verity_key
# setup dm-verity configs.
ifneq ($(BUILD_TARGET_DEVICE),sd)
PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/mmcblkxxx
$(call inherit-product, project_path/verity.mk)
else
PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/mmcblkxxx
$(call inherit-product, project_path/verity.mk)
endif
-----------------------------------------------------------------------------------------------------------------
key都建立完成後 應該要有
testkey.pk8 testkey.pem
media.pk8 media.pem
platform.pk8 platform.pem
shared.pk8 shared.pem
verity.pk8 verity.pem.
verity_key
共九個檔案
[Android] Debug
看cpu頻率相關資訊:
/sys/devices/system/cpu/
in android 6:
logcat -b kernel
Screencasting/Mirroring an Android Device Screen onto your Desktop under Ubuntu/Linux Mint
http://www.upubuntu.com/2015/09/screencastingmirroring-android-device.html
/sys/devices/system/cpu/
in android 6:
logcat -b kernel
Screencasting/Mirroring an Android Device Screen onto your Desktop under Ubuntu/Linux Mint
http://www.upubuntu.com/2015/09/screencastingmirroring-android-device.html
[Android] Android
===========================================================
init
system/core/init
readme.txt
keywords.h -init command
===========================================================
Android 6:
查詢相對應的Key_code
frameworks/base/data/keyboards/Generic.kl
處理Key_Event
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
158 /* KEY_BACK */
172 /* KEY_HOMEPAGE */
580 /* APP_SWITCH */
/frameworks/base/core/res/res/values/config.xml
===========================================================
Disable the software navigation bar
<bool name="config_showNavigationBar">false</bool>
Check the device init.rc don't "setprop sys.device.type tablet"
If deivetpye is tablet, the mHasNavigationBar will be true.
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
mHasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
mHasNavigationBar = true;
}
//if device type is tablet force enable NavigationBar and forbid NavigationBar move
String deviceType = SystemProperties.get("sys.device.type");
if (! "".equals(deviceType) && deviceType.equals("tablet")) {
mNavigationBarCanMove = false;
mHasNavigationBar = true;
}
===========================================================
Screen flip
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
if (mForceDefaultOrientation) {
return Surface.ROTATION_0;
}
+ return Surface.ROTATION_180;
synchronized (mLock) {
===========================================================
init
system/core/init
readme.txt
keywords.h -init command
===========================================================
Android 6:
查詢相對應的Key_code
frameworks/base/data/keyboards/Generic.kl
處理Key_Event
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
158 /* KEY_BACK */
172 /* KEY_HOMEPAGE */
580 /* APP_SWITCH */
/frameworks/base/core/res/res/values/config.xml
===========================================================
Disable the software navigation bar
<bool name="config_showNavigationBar">false</bool>
Check the device init.rc don't "setprop sys.device.type tablet"
If deivetpye is tablet, the mHasNavigationBar will be true.
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
mHasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
mHasNavigationBar = true;
}
//if device type is tablet force enable NavigationBar and forbid NavigationBar move
String deviceType = SystemProperties.get("sys.device.type");
if (! "".equals(deviceType) && deviceType.equals("tablet")) {
mNavigationBarCanMove = false;
mHasNavigationBar = true;
}
===========================================================
Screen flip
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
if (mForceDefaultOrientation) {
return Surface.ROTATION_0;
}
+ return Surface.ROTATION_180;
synchronized (mLock) {
===========================================================
[Android] screencap
screencap 可以從 command line 擷取螢幕畫面。screencap [-p] [<FILENAME>]
提供 FILENAME 時表示要把畫面直接寫到手機的記憶卡,否則會輸出到 STDOUT。
加
加
-p 或 FILENAME 以 .png 結尾時,畫面會輸出成 PNG 格式(預設採用 frame buffer 的原始格式)。例如:$ adb shell screencap -p /sdcard/screen.png
$ adb pull /sdcard/screen.png
$ adb shell rm /sdcard/screen.png
利用
screencap 沒有給定 FILENAME 時會將畫面輸出到 STDOUT 的特性,可以將上面多個步驟合併成一行指令:$ adb shell screencap -p | sed 's/\r$//' > screen.png
後面用
sed 多做一層加工,是因為 adb shell 會將 \n 轉成 \r\n 的關係,必須將 \r\n (0x0d0a) 反轉回 \r (0x0a) 才行。實務上,再用 alias 包裝起來會比較方便:$ alias and-screencap="adb shell screencap -p | sed 's/\r$//'"
$ and-screencap > screen.png #
之後就可以用
and-screencap > <FILENAME> 直接將畫面存成電腦上的檔案 FILENAME,不需要在手機記憶卡產生暫存檔。完整的用法
$ screencap -h
usage: screencap [-hp] [FILENAME]
-h: this message
-p: save the file as a png.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
[Android] [Recovery]
===========================================================
Recovery klog
===========================================================
If you find : denied { write } for pid=183 comm="recovery" name="kmsg"
Moditfy : myandroid/external/sepolicy/recovery.te
Add : allow recovery kmsg_device:chr_file rw_file_perms;
----------------------------------------------------------------------------------------------------
recovery.cpp
#define RECOVERY_KLOG_LEVEL KLOG_INFO_LEVEL
in main to add :
klog_init();
klog_set_level(RECOVERY_KLOG_LEVEL
common.h
#include <cutils/klog.h>
#define LOGE(...) KLOG_INFO("<recovery>E", __VA_ARGS__); fprintf(stdout, "E:" __VA_ARGS__)
#define LOGW(...) KLOG_WARNING("<recovery>W", __VA_ARGS__); fprintf(stdout, "W:" __VA_ARGS__)
#define LOGI(...) KLOG_INFO("<recovery>I", __VA_ARGS__); fprintf(stdout, "I:" __VA_ARGS__)
#define LOGV(...) KLOG_INFO("<recovery>V", __VA_ARGS__); fprintf(stdout, "V:" __VA_ARGS__)
#define LOGD(...) KLOG_INFO("<recovery>D", __VA_ARGS__); fprintf(stdout, "D:" __VA_ARGS__)
screen_ui.cpp
in ScreenRecoveryUI::Print to add :
KLOG_INFO("<recovery>UI", "%s", buf);
===========================================================
Make /tmp/recovery.log & /tmp/last_install accessible
===========================================================
If you find : denied { open } for pid=194 comm="adbd" path="/tmp/recovery.log" dev="tmpfs"
adb pull /tmp/recovery.log
message : failed to copy '/tmp/recovery.log' to './recovery.log': Permission denied
adb pull /tmp/last_install
message : failed to copy '/tmp/last_install' to './last_install': Permission denied
Moditfy : external/sepolicy/adbd.te
Add : allow adbd tmpfs:file { open };
----------------------------------------------------------------------------------------------------
recovery.cpp
in main to add :
+chmod(TEMPORARY_LOG_FILE, 0644);
install.cpp
in main :
if (install_log) {
fputs(path, install_log);
fputc('\n', install_log);
+chmod(install_file, 0644);
}
===========================================================
Support recovery shell console
===========================================================
mksh/reboot/toubox Android.mk
LOCAL_STATIC_LIBRARIES += libc
LOCAL_FORCE_STATIC_EXECUTABLE := true
----------------------------------------------------------------------------------------------------
build/core/Makefile
recovery_ash_binary := $(call intermediates-dir-for,EXECUTABLES,ash)/ash
recovery_reboot_binary := $(call intermediates-dir-for,EXECUTABLES,rreboot)/rreboot
recovery_toybox_binary := $(call intermediates-dir-for,EXECUTABLES,rtoybox)/rtoybox
recovery_toybox_tools := \
youtools(ex. cat) \
recovery_toybox_symlinks := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(recovery_toybox_tools))
define build-recoveryimage-target
@echo ----- Making recovery image ------
$(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
$(hide) cp -f $(recovery_ash_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
$(hide) cp -f $(recovery_reboot_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/reboot
$(hide) cp -f $(recovery_toybox_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
$(hide) $(foreach t,$(recovery_toybox_symlinks),ln -sf rtoybox $(t);)
$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_ash_binary) $(recovery_reboot_binary) $(recovery_toybox_binary) \
----------------------------------------------------------------------------------------------------
recovery/etc/init.rc
service console /sbin/ash
class core
console
user root
group root
seclabel u:r:recovery:s0
on property:ro.debuggable=1
start console
on property:service.adb.root=1
start console
===========================================================
===========================================================
----------------------------------------------------------------------------------------------------
===========================================================
===========================================================
----------------------------------------------------------------------------------------------------
Recovery klog
===========================================================
If you find : denied { write } for pid=183 comm="recovery" name="kmsg"
Moditfy : myandroid/external/sepolicy/recovery.te
Add : allow recovery kmsg_device:chr_file rw_file_perms;
----------------------------------------------------------------------------------------------------
recovery.cpp
#define RECOVERY_KLOG_LEVEL KLOG_INFO_LEVEL
in main to add :
klog_init();
klog_set_level(RECOVERY_KLOG_LEVEL
common.h
#include <cutils/klog.h>
#define LOGE(...) KLOG_INFO("<recovery>E", __VA_ARGS__); fprintf(stdout, "E:" __VA_ARGS__)
#define LOGW(...) KLOG_WARNING("<recovery>W", __VA_ARGS__); fprintf(stdout, "W:" __VA_ARGS__)
#define LOGI(...) KLOG_INFO("<recovery>I", __VA_ARGS__); fprintf(stdout, "I:" __VA_ARGS__)
#define LOGV(...) KLOG_INFO("<recovery>V", __VA_ARGS__); fprintf(stdout, "V:" __VA_ARGS__)
#define LOGD(...) KLOG_INFO("<recovery>D", __VA_ARGS__); fprintf(stdout, "D:" __VA_ARGS__)
screen_ui.cpp
in ScreenRecoveryUI::Print to add :
KLOG_INFO("<recovery>UI", "%s", buf);
===========================================================
Make /tmp/recovery.log & /tmp/last_install accessible
===========================================================
If you find : denied { open } for pid=194 comm="adbd" path="/tmp/recovery.log" dev="tmpfs"
adb pull /tmp/recovery.log
message : failed to copy '/tmp/recovery.log' to './recovery.log': Permission denied
adb pull /tmp/last_install
message : failed to copy '/tmp/last_install' to './last_install': Permission denied
Moditfy : external/sepolicy/adbd.te
Add : allow adbd tmpfs:file { open };
----------------------------------------------------------------------------------------------------
recovery.cpp
in main to add :
+chmod(TEMPORARY_LOG_FILE, 0644);
install.cpp
in main :
if (install_log) {
fputs(path, install_log);
fputc('\n', install_log);
+chmod(install_file, 0644);
}
===========================================================
Support recovery shell console
===========================================================
mksh/reboot/toubox Android.mk
LOCAL_STATIC_LIBRARIES += libc
LOCAL_FORCE_STATIC_EXECUTABLE := true
----------------------------------------------------------------------------------------------------
build/core/Makefile
recovery_ash_binary := $(call intermediates-dir-for,EXECUTABLES,ash)/ash
recovery_reboot_binary := $(call intermediates-dir-for,EXECUTABLES,rreboot)/rreboot
recovery_toybox_binary := $(call intermediates-dir-for,EXECUTABLES,rtoybox)/rtoybox
recovery_toybox_tools := \
youtools(ex. cat) \
recovery_toybox_symlinks := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(recovery_toybox_tools))
define build-recoveryimage-target
@echo ----- Making recovery image ------
$(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
$(hide) cp -f $(recovery_ash_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
$(hide) cp -f $(recovery_reboot_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/reboot
$(hide) cp -f $(recovery_toybox_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
$(hide) $(foreach t,$(recovery_toybox_symlinks),ln -sf rtoybox $(t);)
$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_ash_binary) $(recovery_reboot_binary) $(recovery_toybox_binary) \
----------------------------------------------------------------------------------------------------
recovery/etc/init.rc
service console /sbin/ash
class core
console
user root
group root
seclabel u:r:recovery:s0
on property:ro.debuggable=1
start console
on property:service.adb.root=1
start console
===========================================================
===========================================================
----------------------------------------------------------------------------------------------------
===========================================================
===========================================================
----------------------------------------------------------------------------------------------------
[Android] sepolicy
/external/sepolicy/file_contexts
add :
/system/bin/abc u:object_r:abc_exec:s0
you can add
/external/sepolicy/abc.te
in abc.te
type abc, domain;
type abc_exec, exec_type, file_type;
init_daemon_domain(abc);
add :
/system/bin/abc u:object_r:abc_exec:s0
you can add
/external/sepolicy/abc.te
in abc.te
type abc, domain;
type abc_exec, exec_type, file_type;
init_daemon_domain(abc);
[Android] Android編譯系統參考手冊
build/core/binary.mk
定義了將asm,c,cpp,yacc,lex源代碼編譯為目標文件的基本規則
模塊想生成某類型目標時不會直接包含該makefile,但如果生成二進製程序,會間接包含該makefile
dynamic_binary.mk, executable.mk,host_executable.mk,host_shared_library.mk
host_static_library.mk,prebuilt.mk,raw_executable.mk,shared_library.mk,static_library.mk
等makefile都會包含binary.mk
所有的目標文件將添加到$(all_objects)變量裡
模塊想生成某類型目標時不會直接包含該makefile,但如果生成二進製程序,會間接包含該makefile
dynamic_binary.mk, executable.mk,host_executable.mk,host_shared_library.mk
host_static_library.mk,prebuilt.mk,raw_executable.mk,shared_library.mk,static_library.mk
等makefile都會包含binary.mk
所有的目標文件將添加到$(all_objects)變量裡
LOCAL_SDK_VERSION
build/core/java.mk裡定義該變量
LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION)
如果定義了LOCAL_SDK_VERSION,那麼不能定義LOCAL_NDK_VERSION,否則會提示LOCAL_NDK_VERSION is now retired
如果定義了LOCAL_SDK_VERSION,那麼不能定義LOCAL_IS_HOST_MODULE,否則提示LOCAL_SDK_VERSION cannot be used in host module
因為編譯app時,常需要編譯jni代碼
示例:LOCAL_SDK_VERSION: 9
LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION)
如果定義了LOCAL_SDK_VERSION,那麼不能定義LOCAL_NDK_VERSION,否則會提示LOCAL_NDK_VERSION is now retired
如果定義了LOCAL_SDK_VERSION,那麼不能定義LOCAL_IS_HOST_MODULE,否則提示LOCAL_SDK_VERSION cannot be used in host module
因為編譯app時,常需要編譯jni代碼
示例:LOCAL_SDK_VERSION: 9
HISTORICAL_NDK_VERSIONS_ROOT
ndk的路徑,在config.mk裡定義:
HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
即prebuilts/ndk
HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
即prebuilts/ndk
my_ndk_source_root
my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
示例:HISTORICAL_NDK_VERSIONS_ROOT: prebuilts/ndk
示例: my_ndk_source_root : prebuilts/ndk/current/sources
示例:HISTORICAL_NDK_VERSIONS_ROOT: prebuilts/ndk
示例: my_ndk_source_root : prebuilts/ndk/current/sources
my_ndk_version_root
my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH)
示例:
my_ndk_source_root : prebuilts/ndk/current/current
示例:
my_ndk_source_root : prebuilts/ndk/current/current
LOCAL_NDK_STL_VARIANT
示例:
LOCAL_NDK_STL_VARIANT := system
LOCAL_NDK_STL_VARIANT := system
my_ndk_stl_include_path
示例:prebuilts/ndk/current/sources/cxx-stl/system/include
my_ndk_stl_shared_lib_fullpath
示例:
prebuilts/ndk/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
prebuilts/ndk/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
my_ndk_stl_shared_lib
示例:
my_ndk_stl_shared_lib := -lstlport_shared
my_ndk_stl_shared_lib := -lstlport_shared
my_ndk_stl_static_lib
示例:prebuilts/ndk/current/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
LOCAL_SYSTEM_SHARED_LIBRARIES
ifdef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
LOCAL_SYSTEM_SHARED_LIBRARIES :=
endif
else
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
endif
endif
示例:
TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES:libc libstdc++ libm
LOCAL_SYSTEM_SHARED_LIBRARIES:libc libstdc++ libm
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
LOCAL_SYSTEM_SHARED_LIBRARIES :=
endif
else
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
endif
endif
示例:
TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES:libc libstdc++ libm
LOCAL_SYSTEM_SHARED_LIBRARIES:libc libstdc++ libm
Function: insert-liblog
使得包含了libcutils或者libutils的模塊,也包含liblog,並使得liblog排在前面
LOCAL_SHARED_LIBRARIES
表示模塊要鏈接的動態鏈接庫
ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
endif
示例:frameworks/av/media/mtp模塊
Android .mk LOCAL_SHARED_LIBRARIES := libutils libcutils libusbhost libbinder
最終:LOCAL_SHARED_LIBRARIES: libutils liblog libcutils libusbhost libbinder
ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
endif
示例:frameworks/av/media/mtp模塊
Android .mk LOCAL_SHARED_LIBRARIES := libutils libcutils libusbhost libbinder
最終:LOCAL_SHARED_LIBRARIES: libutils liblog libcutils libusbhost libbinder
LOCAL_STATIC_LIBRARIES
表示模塊要鏈接的靜態庫
ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
endif
示例:external/busybox/Android.mk
LOCAL_STATIC_LIBRARIES := libcutils libc libm
最終:
LOCAL_STATIC_LIBRARIES := libcutils libc libm liblog
ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
endif
示例:external/busybox/Android.mk
LOCAL_STATIC_LIBRARIES := libcutils libc libm
最終:
LOCAL_STATIC_LIBRARIES := libcutils libc libm liblog
LOCAL_WHOLE_STATIC_LIBRARIES
鏈接時會將LOCAL_WHOLE_STATIC_LIBRARIES類型的靜態鏈接庫的所有目標代碼放入最終目標文件裡,而不去掉
These are the static libraries that you want to include in your module without allowing the linker to remove dead code from them. This is mostly useful if you want to add a static library to a shared library and have the static library's content exposed from the shared library.
ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog ,$(LOCAL_WHOLE_STATIC_LIBRARIES))
endif
示例:
dalvik/vm/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz
最終
LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz liblog
These are the static libraries that you want to include in your module without allowing the linker to remove dead code from them. This is mostly useful if you want to add a static library to a shared library and have the static library's content exposed from the shared library.
ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog ,$(LOCAL_WHOLE_STATIC_LIBRARIES))
endif
示例:
dalvik/vm/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz
最終
LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz liblog
installed_shared_library_module_names
安裝的動態鏈接庫名字,用於定義依賴的動態鏈接庫
ifdef LOCAL_SDK_VERSION
# Get the list of INSTALLED libraries as module names.
# We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
# they may cusomize their install path with LOCAL_MODULE_PATH
installed_shared_library_module_names : = \
$(LOCAL_SHARED_LIBRARIES)
else
installed_shared_library_module_names := \
$(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES)
ifdef LOCAL_SDK_VERSION
# Get the list of INSTALLED libraries as module names.
# We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
# they may cusomize their install path with LOCAL_MODULE_PATH
installed_shared_library_module_names : = \
$(LOCAL_SHARED_LIBRARIES)
else
installed_shared_library_module_names := \
$(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES)
LOCAL_SYSTEM_SHARED_LIBRARIES
Used while building the base libraries: libc, libm, libdl.
Usually it should be set to "none," as it is in $(CLEAR_VARS).
When building these libraries, it's set to the ones they link against. For example, libc , libstdc++ and libdl don't link against anything, and libm links against libc. Normally, when the value is none, these libraries are automatically linked in to executables and libraries,
so you don't need to specify them manually.
示例:
libc libstdc++ libm
Usually it should be set to "none," as it is in $(CLEAR_VARS).
When building these libraries, it's set to the ones they link against. For example, libc , libstdc++ and libdl don't link against anything, and libm links against libc. Normally, when the value is none, these libraries are automatically linked in to executables and libraries,
so you don't need to specify them manually.
示例:
libc libstdc++ libm
LOCAL_REQUIRED_MODULES
本模塊依賴的模塊
Set LOCAL_REQUIRED_MODULES to any number of whitespace-separated module names, like "libblah" or "Email".
If this module is installed, all of the modules that it requires will be installed as well.
This can be used to , eg, ensure that necessary shared libraries
or providers are installed when a given app is installed
示例:
LOCAL_REQUIRED_MODULES += $(installed_shared_library_module_names)
Set LOCAL_REQUIRED_MODULES to any number of whitespace-separated module names, like "libblah" or "Email".
If this module is installed, all of the modules that it requires will be installed as well.
This can be used to , eg, ensure that necessary shared libraries
or providers are installed when a given app is installed
示例:
LOCAL_REQUIRED_MODULES += $(installed_shared_library_module_names)
LOCAL_CLANG
表示編譯C代碼
LOCAL_CFLAGS
表示編譯C代碼時用的參數
LOCAL_LDFLAGS
表示鏈接時用的參數
CLANG
C編譯器
CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX)
CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX)
CLANG_CXX
C++編譯器
CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX)
CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX)
LOCAL_ENABLE_APROF
編譯動態鏈接庫時用到
LOCAL_ASFLAGS
Explicitly declare assembly-only __ASSEMBLY__ macro for
assembly source
LOCAL_ASFLAGS += -D__ASSEMBLY__
assembly source
LOCAL_ASFLAGS += -D__ASSEMBLY__
LOCAL_INTERMEDIATE_TARGETS
編譯動態鏈接庫時用,
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
LOCAL_GENERATED_SOURCES
編譯時生成的源代碼文件,像aidl將專為java代碼
proto_generated_cc_sources
定義了將.proto編譯為.cc的目標
proto_generated_objects
定義了將 proto代碼編譯後的c代碼編譯為目標文件的目標
yacc_cpps
利用yacc將.y文件編譯為.cpp文件
yacc_objects
將.y文件編譯的.cpp文件編譯為目標文件
lex_cpps
利用lex將.l文件編譯為.cpp文件
lex_objects
利用lex將lex編譯出來的.cpp編譯為目標文件
cpp_objects
將cpp編譯為目標文件
gen_cpp_objects
將生成的Cpp編譯為目標文件
gen_s_objects
將彙編代碼.s,.S編譯為目標文件
c_objects
將c代碼編譯為目標文件
gen_c_objects
將生成的C文件編譯為目標文件
objc_sources
將objectc代碼(以.m結尾)編譯為目標文件
asm_objects_S
將彙編代碼編譯[.S]為目標文件
asm_objects_s
將彙編代碼編譯[.s]為目標文件
import_includes
需要include的頭文件
內容示例:-I system/core/fs_mgr/include
內容示例:-I system/core/fs_mgr/include
all_objects
要編譯的目標集合
some rules depend on asm_objects being first. If your code depends on
being first, it's reasonable to require it to be assembly.
all_objects := \
$(asm_objects) \
$(cpp_objects) \
$(gen_cpp_objects) \
$ (gen_asm_objects) \
$(c_objects) \
$(gen_c_objects) \
$(objc_objects) \
$(yacc_objects) \
$(lex_objects) \
$(proto_generated_objects) \
$(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES ))
some rules depend on asm_objects being first. If your code depends on
being first, it's reasonable to require it to be assembly.
all_objects := \
$(asm_objects) \
$(cpp_objects) \
$(gen_cpp_objects) \
$ (gen_asm_objects) \
$(c_objects) \
$(gen_c_objects) \
$(objc_objects) \
$(yacc_objects) \
$(lex_objects) \
$(proto_generated_objects) \
$(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES ))
LOCAL_COPY_HEADERS
需要拷貝至安裝目錄的頭文件集合,你需要同時定義LOCAL_COPY_HEADERS_TO
LOCAL_COPY_HEADERS_TO
需要拷貝頭頭文件至哪個安裝目錄
LOCAL_CC
你可以通過LOCAL_CC定義一個不同的C編譯器
LOCAL_CXX
你可以通過LOCAL_CXX定義一個不同的C++編譯器
LOCAL_ASSET_FILES
編譯Android Package(app)程序時,通常用LOCAL_ASSET_FILES,表示assets目錄的所有文件
通常使用方式:
LOCAL_ASSET_FILES += $(call find-subdir-assets)
通常使用方式:
LOCAL_ASSET_FILES += $(call find-subdir-assets)
LOCAL_NO_DEFAULT_COMPILER_FLAGS
通常為C或者C++源代碼文件的編譯提供了默認的頭文件目錄和flag,可以通過LOCAL_NO_DEFAULT_COMPILER_FLAGS設置不使用這些東東
LOCAL_JAVACFLAGS
額外的編譯java用的flags
示例:
LOCAL_JAVACFLAGS += -Xlint:deprecation
示例:
LOCAL_JAVACFLAGS += -Xlint:deprecation
LOCAL_JAVA_LIBRARIES
當鏈接java app程序和庫時, LOCAL_JAVA_LIBRARIES指定了哪些java類將被包含,
目前只有LOCAL_JAVA_LIBRARIES := core framework
注意目前編譯app設置LOCAL_JAVA_LIBRARIES是不必要的,也不被允許的,在include $(BUILD_PACKAGE)時
合適的庫都會被包含進來
目前只有LOCAL_JAVA_LIBRARIES := core framework
注意目前編譯app設置LOCAL_JAVA_LIBRARIES是不必要的,也不被允許的,在include $(BUILD_PACKAGE)時
合適的庫都會被包含進來
LOCAL_LDFLAGS
額外的鏈接flag
記住flag的順序很重要,需要在所有平台都測試,否則容易出錯
記住flag的順序很重要,需要在所有平台都測試,否則容易出錯
LOCAL_LDLIBS
額外的動態鏈接庫
LOCAL_LDLIBS allows you to specify additional libraries that are not part of the build for your executable or library.
Specify the libraries you want in -lxxx format; they're passed directly to the link line.
However, keep in mind that there will be no dependency generated for these libraries.
It's most useful in simulator builds where you want to use a library preinstalled on the host.
The linker (ld) is a particularly fussy beast,
so it's sometimes necessary to pass other flags here if you're doing something sneaky.
Some examples:
LOCAL_LDLIBS += -lcurses -lpthread
LOCAL_LDLIBS += -Wl,-z,origin
LOCAL_LDLIBS allows you to specify additional libraries that are not part of the build for your executable or library.
Specify the libraries you want in -lxxx format; they're passed directly to the link line.
However, keep in mind that there will be no dependency generated for these libraries.
It's most useful in simulator builds where you want to use a library preinstalled on the host.
The linker (ld) is a particularly fussy beast,
so it's sometimes necessary to pass other flags here if you're doing something sneaky.
Some examples:
LOCAL_LDLIBS += -lcurses -lpthread
LOCAL_LDLIBS += -Wl,-z,origin
LOCAL_NO_MANIFEST
如果你的packege沒有manifest,可以設置LOCAL_NO_MANIFEST:=true
一般資源包會這麼做
一般資源包會這麼做
LOCAL_PACKAGE_NAME
App名字
示例: Dialer, Contacts, etc.
This will probably change or go away when we switch to an ant-based build system for the apps.
示例: Dialer, Contacts, etc.
This will probably change or go away when we switch to an ant-based build system for the apps.
LOCAL_POST_PROCESS_COMMAND
你可以為主機上的可執行程序添加一條命令,這條命令在這個模塊被鏈接後執行
You might have to go through some contortions to get variables right because of early or late variable evaluation:
module := $(HOST_OUT_EXECUTABLES) /$(LOCAL_MODULE)
LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\
-d __WXMAC__ -o $(module) Carbon.r
You might have to go through some contortions to get variables right because of early or late variable evaluation:
module := $(HOST_OUT_EXECUTABLES) /$(LOCAL_MODULE)
LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\
-d __WXMAC__ -o $(module) Carbon.r
LOCAL_PREBUILT_EXECUTABLES
預編譯好的可執行程序,一般通過include $(BUILD_PREBUILT)設置
會將預編譯好的程序拷貝直接拷貝至安裝目錄
會將預編譯好的程序拷貝直接拷貝至安裝目錄
LOCAL_PREBUILT_LIBS
預編譯好的庫,當使用including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT)
會將LOCAL_PREBUILT_LIBS所指的庫拷貝到安裝目錄
會將LOCAL_PREBUILT_LIBS所指的庫拷貝到安裝目錄
LOCAL_UNSTRIPPED_PATH
沒有strip的程序存放路徑,通常放在symbols目錄
Instructs the build system to put the unstripped version of the module somewhere
other than what's normal for its type.
Usually, you override this because you overrode LOCAL_MODULE_PATH for an executable or a shared library.
If you overrode LOCAL_MODULE_PATH, but not LOCAL_UNSTRIPPED_PATH, an error will occur.
Instructs the build system to put the unstripped version of the module somewhere
other than what's normal for its type.
Usually, you override this because you overrode LOCAL_MODULE_PATH for an executable or a shared library.
If you overrode LOCAL_MODULE_PATH, but not LOCAL_UNSTRIPPED_PATH, an error will occur.
LOCAL_MODULE_PATH
表示模塊生成後的程序安裝路徑,設置該變量後,必須設置LOCAL_UNSTRIPPED_PATH,如果是預編譯的類型,則不用設置
Instructs the build system to put the module somewhere other than what's normal for its type.
If you override this, make sure you also set LOCAL_UNSTRIPPED_PATH
if it's an executable or a shared library so the unstripped binary has somewhere to go.
An error will occur if you forget to.
Instructs the build system to put the module somewhere other than what's normal for its type.
If you override this, make sure you also set LOCAL_UNSTRIPPED_PATH
if it's an executable or a shared library so the unstripped binary has somewhere to go.
An error will occur if you forget to.
LOCAL_YACCFLAGS
額外的yacc編譯器flag
Any flags to pass to invocations of yacc for your module.
A known limitation here is that the flags will be the same for all invocations of YACC for your module.
This can be fixed. If you ever need it to be, just ask.
LOCAL_YACCFLAGS := -p kjsyy
Any flags to pass to invocations of yacc for your module.
A known limitation here is that the flags will be the same for all invocations of YACC for your module.
This can be fixed. If you ever need it to be, just ask.
LOCAL_YACCFLAGS := -p kjsyy
LOCAL_ADDITIONAL_DEPENDENCIES
額外的依賴
If your module needs to depend on anything else that isn't actually built in to it,
you can add those make targets to LOCAL_ADDITIONAL_DEPENDENCIES.
Usually this is a workaround for some other dependency that isn't created automatically.
If your module needs to depend on anything else that isn't actually built in to it,
you can add those make targets to LOCAL_ADDITIONAL_DEPENDENCIES.
Usually this is a workaround for some other dependency that isn't created automatically.
LOCAL_BUILT_MODULE
表示編譯鏈接後的目標文件(文件路徑+文件名),存放在臨時目錄
When a module is built, the module is created in an intermediate directory then copied to its final location.
LOCAL_BUILT_MODULE is the full path to the intermediate file.
See LOCAL_INSTALLED_MODULE for the path to the final installed location of the module.
When a module is built, the module is created in an intermediate directory then copied to its final location.
LOCAL_BUILT_MODULE is the full path to the intermediate file.
See LOCAL_INSTALLED_MODULE for the path to the final installed location of the module.
LOCAL_HOST
表示是在模塊生成的文件是在主機上的程序
Set by the host_xxx.make includes to tell base_rules.make
and the other includes that we're building for the host.
Kenneth did this as part of openbinder, and I would like to clean it up so the rules,
includes and definitions aren't duplicated for host and target.
Set by the host_xxx.make includes to tell base_rules.make
and the other includes that we're building for the host.
Kenneth did this as part of openbinder, and I would like to clean it up so the rules,
includes and definitions aren't duplicated for host and target.
LOCAL_INSTALLED_MODULE
表示模塊的安裝路徑+文件名 ,存放在安裝目錄
The fully qualified path name of the final location of the module.
See LOCAL_BUILT_MODULE for the location of the intermediate file that the make rules should actually be constructing.
The fully qualified path name of the final location of the module.
See LOCAL_BUILT_MODULE for the location of the intermediate file that the make rules should actually be constructing.
LOCAL_REPLACE_VARS
Used in some stuff remaining from the openbinder for building scripts with particular values set,
LOCAL_SCRIPTS
Used in some stuff remaining from the openbinder build system that we might find handy some day.
LOCAL_STRIP_MODULE
表示該模塊生成的目標是否需要被strip
Calculated in base_rules.make to determine if this module should actually be stripped or not,
based on whether LOCAL_STRIPPABLE_MODULE is set, and whether the combo is configured to ever strip modules.
With Iliyan's stripping tool, this might change.
Calculated in base_rules.make to determine if this module should actually be stripped or not,
based on whether LOCAL_STRIPPABLE_MODULE is set, and whether the combo is configured to ever strip modules.
With Iliyan's stripping tool, this might change.
LOCAL_STRIPPABLE_MODULE
表示模塊生成的文件是否能被Strip,只有可執行程序和動態鏈接庫可以被strip
Set by the include makefiles if that type of module is strippable.
Executables and shared libraries are.
Set by the include makefiles if that type of module is strippable.
Executables and shared libraries are.
all_libraries
all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
2017年5月1日 星期一
[Ubuntu] SmartSVN
add java path:
SMARTSVN_JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/jre"
check the java path:
if [ "$SMARTSVN_JAVA_HOME" = "" ] && [ -f "/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java" ] ; then
SMARTSVN_JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java"
fi
modifty the max memory:
SmartSVN version 8:
if [ "$SMARTSVN_MAX_HEAP_SIZE" = "" ] ; then
SMARTSVN_MAX_HEAP_SIZE=2048m
fi
SmartSVN version 9:
_GC_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=25 -Xmx2048m"
http://tecadmin.net/install-subversion-1-9-on-ubuntu/
$ sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu `lsb_release -cs` svn19" >> /etc/apt/sources.list.d/subversion19.list'
$ sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get upgrade subversion
svn: File has inconsistent newlines
Project->Setting->Working copy->EOL-style
Default EOL-style- > As is(no conversion)
[Ubuntu] Setting
//right click open terminal in folder
apt-get install nautilus-open-terminal
nautilus -q…
//change the folder name chinese to english
LANG=C xdg-user-dirs-gtk-update
//disable overlay scroll bars to normal
gsettings set com.canonical.desktop.interface scrollbar-mode normal
//java install
openjdk:
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk
oracle:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
//If have error
sudo dpkg -P oracle-java7-installer
sudo apt-get -f install
//Install Cinnamon 2.4 in Ubuntu "14.04"
sudo add-apt-repository ppa:tsvetko.tsvetkov/cinnamon
sudo apt-get update
sudo apt-get install cinnamon
//show trash icon on desktop
gsettings set org.gnome.nautilus.desktop trash-icon-visible true
//USB permission for adb and fastboot
/etc/udev/rules.d/51-android.rules
//I.MX
sudo apt-get install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git-core curl u-boot-tools mtd-utils android-tools-fsutils m4 libxml2-utils bison xsltproc flex gperf gcc g++ build-essential gcc-multilib lzma android-tools-adb qt4-qmake libqt4-dev lib32stdc++6 lib32z1 lib32z1-dev cmake texinfo chrpath libsdl1.2-dev
//ccache
sudo apt-get install -y ccache &&\
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc &&\
source ~/.bashrc && echo $PATH
home/.profile
add :
export USE_CCACHE=1
export CCACHE_DIR=/<path_of_your_choice>/.ccache
ccache -F 0 set maximum number of files in cache to N (use 0 for no limit)
ccache -M 0 set maximum size of cache to SIZE (use 0 for no limit; available suffixes: G, M and K; default suffix: G)
ccache -C -z Empty the cache and reset the stats
ccache -s show statistics summary
//Atom
config.cson
packages
//minicom
sudo apt-get install minicom
.bashrc .thunderbird
//Atom
sudo apt-get install cscope ctags
package:
atom-beautify,atom-cscope,atom-ctags,color-picker,editorconfig
config.cson
packages
//WD=-1, Errno=No space left on device (ENOSPC)
cat /proc/sys/fs/inotify/max_user_watches (Which is typically 8192 by default.)
To increase your limit, type this:
sudo sysctl fs.inotify.max_user_watches=16384
To permanently set this limit, type this:
echo 16384 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
//software
classicmenu,Shutter,Smartsvn,Smartgit,BeyondCompare,VirtualBox,Atom
//ubuntu16.04
新酷音 : sudo apt-get install fcitx-chewing
sudo apt-get install ibus-zhuyin #注音輸入法
//Upgrade to LibreOffice
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
//revert the changes
sudo apt-get install ppa-purge
sudo ppa-purge ppa:libreoffice/ppa
//Thunderbird
lightning
lookout
//51-Android.rules
/etc/udev/rules.d
//USB permission for adb and fastboot
/etc/udev/rules.d/51-android.rules
//I.MX
sudo apt-get install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git-core curl u-boot-tools mtd-utils android-tools-fsutils m4 libxml2-utils bison xsltproc flex gperf gcc g++ build-essential gcc-multilib lzma android-tools-adb qt4-qmake libqt4-dev lib32stdc++6 lib32z1 lib32z1-dev cmake texinfo chrpath libsdl1.2-dev
//ccache
sudo apt-get install -y ccache &&\
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc &&\
source ~/.bashrc && echo $PATH
home/.profile
add :
export USE_CCACHE=1
export CCACHE_DIR=/<path_of_your_choice>/.ccache
ccache -F 0 set maximum number of files in cache to N (use 0 for no limit)
ccache -M 0 set maximum size of cache to SIZE (use 0 for no limit; available suffixes: G, M and K; default suffix: G)
ccache -C -z Empty the cache and reset the stats
ccache -s show statistics summary
//Atom
config.cson
packages
//minicom
sudo apt-get install minicom
sudo adduser USERNAME dialout
//Backup.bashrc .thunderbird
//Atom
sudo apt-get install cscope ctags
package:
atom-beautify,atom-cscope,atom-ctags,color-picker,editorconfig
packages
//WD=-1, Errno=No space left on device (ENOSPC)
cat /proc/sys/fs/inotify/max_user_watches (Which is typically 8192 by default.)
To increase your limit, type this:
sudo sysctl fs.inotify.max_user_watches=16384
To permanently set this limit, type this:
echo 16384 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
//software
classicmenu,Shutter,Smartsvn,Smartgit,BeyondCompare,VirtualBox,Atom
//ubuntu16.04
新酷音 : sudo apt-get install fcitx-chewing
sudo apt-get install ibus-zhuyin #注音輸入法
//Upgrade to LibreOffice
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
//revert the changes
sudo apt-get install ppa-purge
sudo ppa-purge ppa:libreoffice/ppa
//Thunderbird
lightning
lookout
//51-Android.rules
/etc/udev/rules.d
[Ubuntu] Minicom & Oracle VM Permission denied
Cannot open /dev/ttyUSB0: Permission denied
Solution:
$ sudo adduser youracct dialout
Verification:
$ groups
$ sudo adduser youracct dialout
Verification:
$ groups
youracct dialout
Oracle VM USB can't work or not find:
Solution:
$ sudo adduser youracct vboxusers
Verification:
$ groups
youracct adm dialout cdrom sudo dip plugdev lpadmin sambashare "vboxusers"
Oracle VM USB can't work or not find:
Solution:
$ sudo adduser youracct vboxusers
Verification:
$ groups
youracct adm dialout cdrom sudo dip plugdev lpadmin sambashare "vboxusers"
[Ubuntu] Ubuntu 16.04 LTS - Install Android Tools
1. Install Android tools
# sudo apt-get install android-tools-adb android-tools-fastboot
2. Update to latest ADB and fastboot
# adb version
Android Debug Bridge version 1.0.32
# wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
# sudo unzip -d /usr/local/sbin platform-tools-latest-linux.zip
# sudo wget -O /usr/local/sbin/adb https://raw.githubusercontent.com/NicolasBernaerts/ubuntu- scripts/master/android/adb
# sudo wget -O /usr/local/sbin/fastboot https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/fastboot
# sudo chmod +x /usr/local/sbin/platform-tools/adb /usr/local/sbin/adb
# sudo chmod +x /usr/local/sbin/platform-tools/fastboot /usr/local/sbin/fastboot
# adb version
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
Installed as /usr/local/sbin/platform-tools/adb
refer : http://bernaerts.dyndns.org/linux/74-ubuntu/354-ubuntu-xenial-android-adb-fastboot-qtadb
# sudo apt-get install android-tools-adb android-tools-fastboot
2. Update to latest ADB and fastboot
# adb version
Android Debug Bridge version 1.0.32
# wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
# sudo unzip -d /usr/local/sbin platform-tools-latest-linux.zip
# sudo wget -O /usr/local/sbin/adb https://raw.githubusercontent.com/NicolasBernaerts/ubuntu- scripts/master/android/adb
# sudo wget -O /usr/local/sbin/fastboot https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/fastboot
# sudo chmod +x /usr/local/sbin/platform-tools/adb /usr/local/sbin/adb
# sudo chmod +x /usr/local/sbin/platform-tools/fastboot /usr/local/sbin/fastboot
# adb version
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
Installed as /usr/local/sbin/platform-tools/adb
refer : http://bernaerts.dyndns.org/linux/74-ubuntu/354-ubuntu-xenial-android-adb-fastboot-qtadb
2017年4月1日 星期六
[U-boot] bootenv set
//For android
In include/android_image.h - #define ANDR_BOOT_ARGS_SIZE 512
//Kernel command line
In include/android_image.h - #define ANDR_BOOT_ARGS_SIZE 512
char append_bootargs[ANDR_BOOT_ARGS_SIZE];
sprintf(append_bootargs, "androidboot.revision=%u", get_board_rev());
env_set("append_bootargs", append_bootargs);
In common/image-android.c- will to get the append_bootargsandroid_image_get_kernel()
{
...
/* Add 'append_bootargs' to hold some paramemters which need to be appended
* to bootargs */
char *append_bootargs = env_get("append_bootargs");
...
}
//Kernel command line
char commandline[2048];
char *bootargs = env_get("bootargs");
if (bootargs)
snprintf(commandline, 2048, "board_rev=%u %s", get_board_rev(), bootargs);
else
sprintf(commandline, "board_rev=%u", get_board_rev());
env_set("bootargs", commandline);
In arch/arm/lib/bootm.c- will to get the commandlinestatic void boot_prep_linux(bootm_headers_t *images)
{
char *commandline = env_get("bootargs");
...
}
[U-boot] [I.MX6] bootenv emmc set error
If you bootarg set error ,can clear by mfg_tool
but you need know the emmc block address
MFG_tools/Profiles/Linux/OS Firmware/ucl2.xml
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
The persistent storage, where the block comes from, is platform-specific. Some common storage options (and source file handling that storage option):
seek 是略過 of (output file) 所指定的檔案 的 bs * count 大小 然後才開始寫入
bs 大小 default 是 512 bytes, 切記 count 一要給!
dd 常用的參數如下:
if=FILE:指定輸入檔案名稱(input file)為 FILE
of=FILE:指定輸出檔案名稱(output file)為 FILE
ibs=BYTES:指定輸入區塊大小(input block size),一次讀取 BYTES 位元組的資料,預設為 512 位元組
obs=BYTES:指定輸出區塊大小(output block size),一次寫入 BYTES 位元組的資料,預設為 512 位元組
bs=BYTES:指定 block size,一次讀取與寫入 BYTES 位元組的資料,此選項會覆蓋 ibs 與 obs 的設定
cbs=BYTES:一次轉換 BYTES 位元組的資料
count=N:只處理 N 個輸入區塊,每個區塊的大小為 ibs
seek=N:在輸出時跳過輸出檔案的前 N 個區塊,每個區塊的大小為 obs
skip=N:在輸入時跳過輸入檔案的前 N 個區塊,每個區塊的大小為 ibs
conv=CONVS:指定資料的轉換選項,如果一次要指定多種轉換,則以逗點分隔
but you need know the emmc block address
MFG_tools/Profiles/Linux/OS Firmware/ucl2.xml
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
The persistent storage, where the block comes from, is platform-specific. Some common storage options (and source file handling that storage option):
NOR flash common/env_flash.c
SPI flash common/env_sf.c
MMC common/env_mmc.c
CONFIG_ definitions in include/configs/yourboard.h will determine the details.#define CONFIG_SYS_ENV_SECT_SIZE (128 << 10) /* 128 KiB */
#define CONFIG_ENV_OFFSET SMNAND_ENV_OFFSET
#define CONFIG_ENV_ADDR SMNAND_ENV_OFFSET
skip 是略過 if (input file) 所指定的檔案 的 bs * count 大小 然後才開始讀入seek 是略過 of (output file) 所指定的檔案 的 bs * count 大小 然後才開始寫入
bs 大小 default 是 512 bytes, 切記 count 一要給!
dd 常用的參數如下:
if=FILE:指定輸入檔案名稱(input file)為 FILE
of=FILE:指定輸出檔案名稱(output file)為 FILE
ibs=BYTES:指定輸入區塊大小(input block size),一次讀取 BYTES 位元組的資料,預設為 512 位元組
obs=BYTES:指定輸出區塊大小(output block size),一次寫入 BYTES 位元組的資料,預設為 512 位元組
bs=BYTES:指定 block size,一次讀取與寫入 BYTES 位元組的資料,此選項會覆蓋 ibs 與 obs 的設定
cbs=BYTES:一次轉換 BYTES 位元組的資料
count=N:只處理 N 個輸入區塊,每個區塊的大小為 ibs
seek=N:在輸出時跳過輸出檔案的前 N 個區塊,每個區塊的大小為 obs
skip=N:在輸入時跳過輸入檔案的前 N 個區塊,每個區塊的大小為 ibs
conv=CONVS:指定資料的轉換選項,如果一次要指定多種轉換,則以逗點分隔
[u-boot] logo background color setting
此logo背景色在圖中所使用比例最高
再由 bmp_logo_bitmap 判定0x24為背景色
在對應至 bmp_logo_palette 可得知0x24 is 0x0FFF
經過下列運算,可得知背景色為 0xf0
在此處如果 *CONFIG_SYS_CONSOLE_FG_COL* & *CONFIG_SYS_CONSOLE_BG_COL*
皆有定義,則會使用所定義之 背景/前景 顏色填入
因此我在project.h加入下方的定義,來完成背景色的填充
再由 bmp_logo_bitmap 判定0x24為背景色
在對應至 bmp_logo_palette 可得知0x24 is 0x0FFF
out/uboot/include/bmp_logo_data.hunsigned short bmp_logo_palette[] = {0x0000, 0x0FFF, 0x0666, 0x0666, 0x0FFF, 0x0666, 0x0666, 0x0F00,0x0F00, 0x0FFF, 0x0FFF, 0x0F00, 0x0666, 0x0666, 0x0000, 0x0F00,0x0666, 0x0666, 0x0E11, 0x0F00, 0x0FFF, 0x0FFF, 0x0F00, 0x0FFF,...}unsigned char bmp_logo_bitmap[] = {0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,...}
經過下列運算,可得知背景色為 0xf0
uboot-imx/drivers/video/cfb_console.cfor (i = 0; i < VIDEO_LOGO_COLORS; i++) {logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;logo_green[i] = (bmp_logo_palette[i] & 0x00f0);logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4;}
在此處如果 *CONFIG_SYS_CONSOLE_FG_COL* & *CONFIG_SYS_CONSOLE_BG_COL*
皆有定義,則會使用所定義之 背景/前景 顏色填入
uboot-imx/include/video_fb.h#if defined(CONFIG_SYS_CONSOLE_FG_COL) && defined(CONFIG_SYS_CONSOLE_BG_COL)#define CONSOLE_BG_COL CONFIG_SYS_CONSOLE_BG_COL#define CONSOLE_FG_COL CONFIG_SYS_CONSOLE_FG_COL#else#define CONSOLE_BG_COL 0x00#define CONSOLE_FG_COL 0xa0#endif
因此我在project.h加入下方的定義,來完成背景色的填充
#define CONFIG_SYS_CONSOLE_FG_COL 0xa0 #define CONFIG_SYS_CONSOLE_BG_COL 0xf0
[bootargs environment]Enable hdmi and uart console
For IMX 6Q
add:
androidboot.selinux=disabled androidboot.dm_verity=disabled
modify:
video=mxcfb1:dev=hdmi,1920x1080M@60,bpp=32
add:
androidboot.selinux=disabled androidboot.dm_verity=disabled
modify:
video=mxcfb1:dev=hdmi,1920x1080M@60,bpp=32
[U-boot] logo
在有實現LCD顯示和LCD命令行終端的U-boot中,默認情況下在左上角都有顯示一個logo,如果是atmel的芯片,就會有atmel的logo,三星的則是denx的logo。如果想把它改成自己喜歡的或者公司的logo,則只要作簡單的修改便可以實現。
一,圖片的放置路徑
所有的開機logo都放在了/tools/logos之下,所以,把你需要顯示的logo圖片(bmp格式)也放置到該目錄下。根據你所設置的顯示幀緩存的大小,圖片大小有所限制。使用這種方法還有一個限制是:圖片只能是8bpp的bmp圖(參考uboot源碼)。Tekkman文章中所說的“所替換的logo必須和原來的大小、格式一模一樣,否則會出現u-boot使用過程中宕機重啟的後果”,我自己親測中並未遇到,當然,我也並沒有做足夠的測試,只是這並不需要和原圖的大小一模一樣。
二,修改Makefile文件
修改/tools目錄下的Makefile文件
三、圖片的轉換腳本
在製作圖片前,請您現確認您的Linux主機上安裝了Netpbm工具包。
使用方法: (腳本名) ( 待處理的JPG圖片名) (輸出文件名)
自定義u-boot的開機logo的方法
refer : http://blog.chinaunix.net/uid-9688646-id-1998453.html
一,圖片的放置路徑
所有的開機logo都放在了/tools/logos之下,所以,把你需要顯示的logo圖片(bmp格式)也放置到該目錄下。根據你所設置的顯示幀緩存的大小,圖片大小有所限制。使用這種方法還有一個限制是:圖片只能是8bpp的bmp圖(參考uboot源碼)。Tekkman文章中所說的“所替換的logo必須和原來的大小、格式一模一樣,否則會出現u-boot使用過程中宕機重啟的後果”,我自己親測中並未遇到,當然,我也並沒有做足夠的測試,只是這並不需要和原圖的大小一模一樣。
二,修改Makefile文件
修改/tools目錄下的Makefile文件
把denx.bmp 替換為你需要顯示的logo圖片的文件名,保存退出,重新編譯uboot。ifeq ($(LOGO_BMP),) LOGO_BMP= logos/denx.bmp endif
三、圖片的轉換腳本
在製作圖片前,請您現確認您的Linux主機上安裝了Netpbm工具包。
sudo apt-get install netpbm
jpegtopnm logo.jpg | ppmquant 31 | ppmtobmp -bpp 8 > logo.bmp
U-Boot中的Splash Screen
U-Boot配置
在U-Boot中使用Splash Screen,可以實現U-Boot啟動後,在LCD上顯示自定義圖片,起到友好的界面顯示作用。使用Splash Screen需要在配置文件中使能BMP圖片功能和SPLASH功能:
#define CONFIG_CMD_BMP
#define CONFIG_SPLASH_SCREEN
#define CONFIG_SPLASH_SCREEN
實例
並且要定義splashimage變量以及在splash變量所定義的地址存放bmp圖片。以2MB的SST30VF1601為例,工32個扇區,規劃如下:
項目
|
地址範圍
|
扇區
|
大小
|
說明
|
U-Boot
|
0x0000 0000 ~ 0x0010 0000
|
0~15
|
1M
| |
參數
|
0x0010 0000 ~ 0x0018 0000
|
16~23
|
512K
| |
splashimage
|
0x0018 0000 ~ 0x0020 0000
|
24~31
|
512K
|
操作
現在要實現splash screen,需要進行操作,先下載一個圖片到內存中,然後擦除FLASH的splashimage區域,接著將圖片寫入splashimage區域,最後設置並保存splashimage環境變量即可。
U-Boot> tftp a0008000 logo.bmp ;下載文件到內存
U-Boot> erase 1:23-31 ;擦除Flash的splashimage區域
U-Boot> cp.b a0008000 00180000 $filesize ;將logo寫到Flash的splashimage區域
U-Boot> setenv splashimage 00180000 ;設置splashimage環境變量
U-Boot> saveenv ;保存環境變量
u-boot啟動後,輸入bmp d $splashimage即可在LCD上顯示logo圖片。為了實現開機就顯示logo,可以修改common/lcd.c文件,在其中加入實現bmp d $splashimage的代碼即可。
自定義u-boot的開機logo的方法
ifeq ($(LOGO_BMP),) LOGO_BMP= logos/denx.bmp endif ifeq ($(VENDOR), atmel) LOGO_BMP= logos/atmel.bmp endif ifeq ($(VENDOR),ronetix) LOGO_BMP= logos/ronetix.bmp endif
refer : http://blog.chinaunix.net/uid-9688646-id-1998453.html
訂閱:
文章 (Atom)