系统移植相关, so 相关
mount -o rw,remount /system
armeabiv-v7a
arm64-v8a
armeabi
在设计SDK 中,需要兼容以上
如果arm64-v8a,有先找arm64-v8a 下的so ,如果没有报错,因此,保持arm64-v8a &armeabiv-v7a 一致, so 要保持 同一软件平台,例如C++ 11等等
device board:
getprop |grep abi
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]
[ro.vendor.qti.core_ctl_max_cpu]: [4]
[ro.vendor.qti.core_ctl_min_cpu]: [2]
举例:找到自己平台的配置
include device/htc/flounder/BoardConfig.mk
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_CPU_SMP := true
TARGET_ARCH := arm
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a15
TARGET_2ND_ARCH :=
TARGET_2ND_ARCH_VARIANT :=
TARGET_2ND_CPU_ABI :=
TARGET_2ND_CPU_ABI2 :=
TARGET_2ND_CPU_VARIANT :=
# Re-enable emulator for 32-bit
BUILD_EMULATOR := true
板子:
cat /proc/cpuinfo
Processor : AArch64 Processor rev 12 (aarch64)
processor : 0
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x7
CPU part : 0x803
CPU revision : 12
processor : 1
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x7
CPU part : 0x803
CPU revision : 12
processor : 2
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x7
CPU part : 0x803
CPU revision : 12
processor : 3
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x7
CPU part : 0x803
CPU revision : 12
processor : 4
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x6
CPU part : 0x802
CPU revision : 13
processor : 5
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x6
CPU part : 0x802
CPU revision : 13
processor : 6
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x6
CPU part : 0x802
CPU revision : 13
processor : 7
BogoMIPS : 38.40
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
CPU implementer : 0x51
CPU architecture: 8
CPU variant : 0x6
CPU part : 0x802
CPU revision : 13
Hardware : Qualcomm Technologies, Inc SDA845
/**
*
* [获取cpu类型和架构]
*
* @return
* 三个参数类型的数组,第一个参数标识是不是ARM架构,第二个参数标识是V6还是V7架构,第三个参数标识是不是neon指令集
*/
public static Object[] getCpuArchitecture() {
if ((Integer) mArmArchitecture[1] != -1) {
return mArmArchitecture;
}
.........
}
调用 getCpuArchitecture
/*
* 获取FFpeg解码库的名称(如果是插件,会涉及到一个向下兼容的问题,例如:如果当前cpu是V7neo,而又没有neon的解码库,必须要做向下兼容出来
* ,如果有V7的库就加载V7的库,有V6的库就加载V6的)
*/
public static String getFFmpegLibName(Context context) {
if (LIB_FFMPEG_NAME != null) {
return LIB_FFMPEG_NAME;
}
Object[] arch = getCpuArchitecture(); -----》根据不同的cpu 架构给定不同的库
String libDir = getNativeLibraryDir(context);
String libSysDir = "/system/lib";
if ("ARM".equals(arch[0])) {
try {
}
java apk: 崩溃一般的log
E/AndroidRuntime: FATAL EXCEPTION: Thread-5
引用so 找不到:
”UnsatisfiedLinkError”,”dlopen: failed“ , 注意system/lib/ vendor/lib ....lib64
REF:https://blog.csdn.net/andrewblog/article/details/43601303
出现下面log:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Intent.getI...
REF:https://www.jianshu.com/p/0e9578d8bcac
高通平台如何build so ,mk 文件
LOCAL_SRC_FILES_arm
LOCAL_SRC_FILES_arm64
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libandroid
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES_arm := ../../../../$(PRODUCT_OUT)/obj/PACKAGING/pdk_fusion_intermediates/system/lib/libandroid.so
LOCAL_SRC_FILES_arm64 := ../../../../$(PRODUCT_OUT)/obj/PACKAGING/pdk_fusion_intermediates/system/lib64/libandroid.so
LOCAL_MULTILIB := both
include $(BUILD_PREBUILT)
如何集成apk文件, apk 已经build 好, apk 重新签名后,在进行打包,因此lib 含在apk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MULTILIB := both
LOCAL_MODULE_TARGET_ARCH:= arm
LOCAL_MODULE := testname
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_SUFFIX := .apk
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/app
include $(BUILD_PREBUILT)
平台如何copy 文件 到 system/lib .前提是已经有了so , 可以在平台使用
PRODUCT_COPY_FILES += \
vendor/nreal/NrealSlam/libs.so:$(TARGET_OUT)/system/lib/lib.so
---------------------------------------other method-----------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) \
LOCAL_MODULE := AAA.conf \
LOCAL_MODULE_CLASS := AAA \
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc \
LOCAL_SRC_FILES :=$(LOCAL_MODULE) \
include $(BUILD_PREBUILT)
上面的就是copy AAA.conf 文件到 OUT 下面的 etc目录,这个目录常用来存放配置相关文件。
对系统签名的理解:
LOCAL_CERTIFICATE = ?
1、testkey:普通APK,默认情况下使用。
2、platform:该APK完成一些系统的核心功能。经过对系统中存在的文件夹的访问测试,这种方式编译出来的APK所在进程的UID为system。
3、shared:该APK需要和home/contacts进程共享数据。
4、media:该APK是media/download系统中的一环。
未指定的默认用testkey
build/make/core/base_rules.mk
LOCAL_MODULE_PATH
: 在mk 中使用 的说明
my_module_path := $(my_module_path)/$(LOCAL_MODULE)
ifeq ($(my_module_path),) --> 是否定义在apk 的mk 中,LOCAL_MODULE相关联
install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
install_path_var := $(install_path_var)_PRIVILEGED
endif
my_module_path := $($(install_path_var))
ifeq ($(strip $(my_module_path)),)
$(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
endif
endif
ifneq ($(my_module_relative_path),)
my_module_path := $(my_module_path)/$(my_module_relative_path)
endif
endif
更多32 64 apk移植问题,armeabi-v7a
Android——APK 在32bit/64bit平台 动态库问题
================property maxlen ===============
error: ro.build.fingerprint cannot exceed 91 bytes
出现这种错误时候进行修改prop 长度
build/tools/post_process_props.py
#PROP_VALUE_MAX = 91
PROP_VALUE_MAX = 100
bionic/libc/include/sys/system_properties.h
//#define PROP_VALUE_MAX 91
#define PROP_VALUE_MAX 100
frameworks/native/cmds/installd/installd_deps.h
//constexpr size_t kPropertyValueMax = 91u;
constexpr size_t kPropertyValueMax = 100u;
除了以上修改,可能在build 过程中,出现更多的报错 property_get ......
就是修改获取property 的buffer , 修改成:PROPERTY_VALUE_MAX
举例:
char ifprop[PROPERTY_VALUE_MAX];
if (property_get("wifi.interface", ifprop, defIfname)) {
src = ifprop;
}
====================如何修改userdata 分区的大小========
如何修改系统的userdata(64G---->128G)
device/qcom/sdm845/BoardConfig.mk
how to do:
sdm845:/proc # cat partitions |grep sda8
8 8 110639052 sda8
(110639052-16)*1024 = 110639036*1024=113294372864
16Kbyte 是硬盘节点的加密数据,因此要去掉
+#64G
+#BOARD_USERDATAIMAGE_PARTITION_SIZE := 49310000000
+#128G
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 113294372864
====================build kernel 报错========
rm -rf out/target/product/sdm845/obj/kernel , 然后重新build
===================backtrace 分析==================
首先要source lunch
source
lunch
#LINUX/android$ stack log_backtrace.txt
device/qcom/msmnile/BoardConfig.mk:216: warning: warning for parse error in an unevaluated line: *** commands commence before first target.
Searching for native crashes in crash but no backtrace.txt
Reading symbols from LINUX/android/out/target/product/msmnile/symbols
signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 2440 (AsyncTask #1), pid 2297 (com.android.nfc)
Revision: '0'
pid: 2297, tid: 2440, name: AsyncTask #1 >>> com.android.nfc <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
x0 0000000000000000 x1 0000000000000988 x2 0000000000000006 x3 0000000000000008
x4 8080808080000000 x5 8080808080000000 x6 8080808080000000 x7 0000008080808080
x8 0000000000000083 x9 57776ab775a5b0b1 x10 0000000000000000 x11 fffffffc7ffffbdf
x12 0000000000000001 x13 0000000000000018 x14 ffffffffffffffff x15 00003c9367d4f216
x16 0000007f0cdd72b8 x17 0000007f0ccf8ce0 x18 0000000000000010 x19 00000000000008f9
x20 0000000000000988 x21 0000007e70403a98 x22 0000007e719f2770 x23 0000007e70404588
x24 0000007e70403a78 x25 0000007e713c34e0 x26 0000007e713c3d60 x27 0000007e70403fa9
x28 0000007e713935fc x29 0000007e70403a60
Using arm64 toolchain from: LINUX/android/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
Stack Trace:
RELADDR FUNCTION FILE:LINE
000000000002233c abort+116 bionic/libc/bionic/abort.cpp:73
000000000002a7cc android::nfaDeviceManagementCallback(unsigned char, tNFA_DM_CBACK_DATA*)+3060 vendor/nxp/opensource/commonsys/packages/apps/Nfc/nci/SN100x/jni/NativeNfcManager.cpp:1168
0000000000028324 nfa_dm_nfc_response_cback(unsigned short, tNFC_RESPONSE*)+740 vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/nfa/dm/nfa_dm_act.cc:?
v--------------> nfc_ncif_event_status(unsigned short, unsigned char) vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/nfc/nfc/nfc_ncif.cc:563
00000000000850fc nfc_ncif_cmd_timeout()+280 vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/nfc/nfc/nfc_ncif.cc:127
0000000000089e5c nfc_process_timer_evt()+188 vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/nfc/nfc/nfc_task.cc:146
000000000008a664 nfc_task(unsigned int)+688 vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/nfc/nfc/nfc_task.cc:449
00000000000bc878 gki_task_entry(void*)+244 vendor/nxp/opensource/commonsys/external/libnfc-nci/SN100x/src/gki/ulinux/gki_ulinux.cc:96
000000000009223c __pthread_start(void*)+36 bionic/libc/bionic/pthread_create.cpp:254
0000000000023bf8 __start_thread+68 bionic/libc/bionic/clone.cpp:52
-----------------------------------------------------
====================设定property 系统自动启动服务============
demo
android/device/qcom/common/rootdir/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := kill_process.sh
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := ETC
LOCAL_SRC_FILES := etc/kill_process.sh
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
include $(BUILD_PREBUILT)
android/device/qcom/sdm845/init.target.rc
service kill_process /vendor/bin/kill_process.sh
class main
user root
oneshot
disabled
on property:ai.glass.plug=0
start kill_process
android/device/qcom/sepolicy/common/file_contexts
/(vendor|system/vendor)/bin/kill_process\.sh u:object_r:qti_init_shell_exec:s0
kill_process.sh
#!/system/bin/sh
log -p v -t "xxx" "kill_process.sh START"
while true
do
sleep 10
am start Activity
sleep 270
am force-stop ai.xxx.xxx
done
# am force-stop ai.third.example