开始踩坑
android零基础开发,有些本来不是大问题的地方,因为对android不熟悉卡了很久。
**持续更新中。。。 **
下载Android Studio 链接
相关工具下载网站网址
安装ADB
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb
测试安装是否成功
adb --version
查看USB设备ID,首先运行lsusb
指令查看现有的usb设备,然后插上Andriod板卡,再次运行lsusb
查看增加了那个设备。
Bus 001 Device 009: ID 18d1:4e40 Google Inc. Nexus 7 (fastboot)
创建adb_usb.ini文件,写入id
echo 0x18d1 > ~/.android/adb_usb.ini
添加权限,创建对应的rules
sudo vim /etc/udev/rules.d/70-android.rules
输入如下信息
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4e40", MODE="0666"
fastboot指令
adb reboot fastboot
fastboot flashing unlock
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flashing lock
fastboot reboot
adb指令
adb root
adb remount
adb shell
su
adb push xxx.jpg /data
编译Android源码
最难的是下载!!!
khadas下载教程
百度网盘下载基版本代码(链接:https://pan.baidu.com/s/1xu8B3EJC-YitSZPZlmIf2w 提取码:wllx )(里面有个说明),下载后的文件如下,包含readme:
khadas.tar.gz.00 khadas.tar.gz.04 khadas.tar.gz.08 khadas.tar.gz.12 khadas.tar.gz.16 khadas.tar.gz.20 khadas.tar.gz.24
khadas.tar.gz.01 khadas.tar.gz.05 khadas.tar.gz.09 khadas.tar.gz.13 khadas.tar.gz.17 khadas.tar.gz.21 readme.txt
khadas.tar.gz.02 khadas.tar.gz.06 khadas.tar.gz.10 khadas.tar.gz.14 khadas.tar.gz.18 khadas.tar.gz.22
khadas.tar.gz.03 khadas.tar.gz.07 khadas.tar.gz.11 khadas.tar.gz.15 khadas.tar.gz.19 khadas.tar.gz.23
下载完25个文件: khadas.tar.gz.00~khadas.tar.gz.24 并放在一个目录。
将分割后的压缩包解压命令如下:cat khadas.tar.gz.* | tar -zxv
这只是一个基版本,只有一个目录:.repo。里面包含了所有项目(VIM1,VIM2,VIM3,Edge等等),没办法,repo sync会同步所有分支。大小总共大概100G。
比如要下载VIM3 android 9.0代码:
repo init -u https://github.com/khadas/android_manifest.git -b khadas-vims-pie
如果出现类似如下错误
fatal: unable to access 'https://github.com/khadas/android_manifest.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
将https改为git重新同步试试。
为了解决sync时类似如下异常,可以看到error是找不到HAED的指向:
error.GitError: manifests rev-list (u'^0c25730......', 'HEAD', '--'): fatal: bad revision 'HEAD'
需要将HEAD指向应该指向的commit
cd .repo/manifests
git branch -av
remotes/m/khadas-vims-pie -> origin/khadas-vims-pie
remotes/origin/Mmallow 856410c update download link of svox repository to google
remotes/origin/Nougat 2f08215 Set function key adc value for VIM2 different versions
remotes/origin/Oreo b75302d fixup! Oreo: V171229
remotes/origin/khadas-edge-Qt 5e743f6 Khadas: Edge_Qt_V210521
remotes/origin/khadas-edge-nougat 402b195 update to Edge_Nougat_V191115
remotes/origin/khadas-edge-pie 16f0d2b Fix compile error
remotes/origin/khadas-vim3-pie 33144e9 fixup! Pie: V190823
remotes/origin/khadas-vims-nougat 2f08215 Set function key adc value for VIM2 different versions
remotes/origin/khadas-vims-pie 0c25730 fixup! Pie: V210128
remotes/origin/master f351208 fixup! update: V161211
remotes/origin/test 3142359 fixup! Pie: V190704
git reset --hard remotes/origin/khadas-vims-pie
若修改清华源在这一步里,
vim .repo/manifests/default.xml
将 https://android.googlesource.com/ 全部使用 https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/ 代替。
$ git diff
diff --git a/default.xml b/default.xml
index bd040d6..7456c40 100644
--- a/default.xml
+++ b/default.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
- <remote fetch="https://android.googlesource.com/" name="aosp" review="https://android.googlesource.com/"/>
+ <remote fetch="https://aosp.tuna.tsinghua.edu.cn/" name="aosp" review="https://aosp.tuna.tsinghua.edu.cn/"/>
<remote fetch="https://github.com/khadas/" name="github"/>
<default remote="github" revision="refs/tags/Vims-Pie-V210128" sync-c="true" sync-j="4"/>
同步代码,清华源建议采用-j4
repo sync -j4
repo start khadas-vims-pie-local --all
其他异常问题参考解决方案参考链接
清华镜像Git Repo 镜像使用帮助、Android 镜像使用帮助
编译
export ANDROID_BUILD_TYPE=64
export KERNEL_A32_SUPPORT=false
export PATH=/opt/toolchains/gcc-arm-none-eabi-6-2017-q2-update/bin:/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PATH
source build/envsetup.sh
lunch kvim3-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
TARGET_PRODUCT=kvim3
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-71-generic-x86_64-Ubuntu-18.04.5-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PPR1.180610.011
OUT_DIR=out
============================================
make -j16
编译bugs
- 1 缺少依赖库
[946/954] including vendor/amlogic/common/prebuilt/Android.mk ...
"no bootaccelerate source code, add prebuilts"
"no exoplayer source code, add prebuilts"
vendor/amlogic/common/prebuilt/libmedia/libavenhancements/Android.mk: error: libamffmpegcodec: No source files specified
build/make/core/prebuilt_internal.mk:35: error: done.
14:00:05 ckati failed with: exit status 1
措施
vendor/amlogic/common/prebuilt/libmedia/libavenhancements/Android.mk
48: LOCAL_MULTILIB := both --> LOCAL_MULTILIB := 32
- 2 坑了好久,实际错误原因时缺少依赖库,导致指定的module编译不过去,从报错里完全看不出来
ninja: error: 'out/target/product/kvim3/obj_arm/SHARED_LIBRARIES/libjnivendorfont_intermediates/export_includes', needed by 'out/target/product/kvim3/obj_arm/SHARED_LIBRARIES/libjnifont_tv_intermediates/import_includes', missing and no known rule to make it
14:49:42 ninja failed with: exit status 1
rm vendor/amlogic/common/apps/SubTitle/Android.mk
rm vendor/amlogic/common/arm_isp/app/v4l2_test_android/Android.mk
rm vendor/amlogic/common/frameworks/av/libaudioeffect/Virtualsurround/Android.mk # only 32bit xxx.a
# rm hardware/amlogic/camera/Android.mk
# rm hardware/amlogic/camera/vircam/Android.mk
hardware/amlogic/camera/v3/Android.mk
74: + NEED_ISP=false
- 3 不能把问题解决了,就把提出问题的人解决了。把报错的工具软件改掉,全返回正常。
VNDK library: android.hardware.configstore@1.0's ABI has INCOMPATIBLE CHANGES Please check compatiblity report at : out/soong/.intermediates/hardware/interfaces/configstore/1.0/android.hardware.configstore@1.0/android_arm64_armv8-a_vendor_shared/android.hardware.configstore@1.0.so.abidiff
参考Android 9 §版本解决VNDK library: XXX’s ABI has EXTENDING CHANGES
## modify development/vndk/tools/header-checker/header-abi-diff/src 中的 header_abi_diff.cpp
--- a/development/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp
+++ b/development/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp
@@ -182,21 +182,21 @@ int main(int argc, const char **argv) {
bool should_emit_warning_message = ShouldEmitWarningMessage(status);
if (should_emit_warning_message) {
- llvm::errs() << "******************************************************\n"
- << error_or_warning_str
- << "VNDK library: "
- << lib_name
- << "'s ABI has "
- << status_str
- << unreferenced_change_str
- << " Please check compatiblity report at : "
- << compatibility_report << "\n"
- << "******************************************************\n";
+// llvm::errs() << "******************************************************\n"
+// << error_or_warning_str
+// << "VNDK library: "
+// << lib_name
+// << "'s ABI has "
+// << status_str
+// << unreferenced_change_str
+// << " Please check compatiblity report at : "
+// << compatibility_report << "\n"
+// << "******************************************************\n";
}
- if (!advice_only && should_emit_warning_message) {
- return status;
- }
重新编译 development/vndk/tools/header-checker,编译命令如下:
mmm development/vndk/tools/header-checker/ -j32
616+0 records in
616+0 records out
630784 bytes (631 kB, 616 KiB) copied, 0.0032836 s, 192 MB/s
[ 66% 2/3] glob .
[100% 5/5] Install: out/host/linux-x86/bin/header-abi-diff
复制 out/host/linux-x86/bin/header-abi-diff 到 prebuilts/clang-tools/linux-x86/bin 中覆盖,命令如下:
cp out/host/linux-x86/bin/header-abi-diff prebuilts/clang-tools/linux-x86/bin/header-abi-diff
重新souurce lunhcer,再执行你需要修改的so文件,譬如我们这里的是liblog,我们编译一把:
make -j32 liblog
//编译结果
vendor/qcom/build/tasks/generate_extra_images.mk:558: warning: overriding commands for target `kernelclean'
device/qcom/common/generate_extra_images.mk:558: warning: ignoring old commands for target `kernelclean'
[100% 76/76] build out/host/linux-x86/obj32/SHARED_LIBRARIES/liblog_intermediates/liblog.so.toc
好了,大功告成可以愉快的修改VNDK的相关改动了。
- 4 提供的64位依赖有问题
vendor/amlogic/common/npu/service/../applib/nnrt/file_map_memory.hpp:38: error: undefined reference to 'vtable for nnrt::Memory'
prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
vendor/amlogic/common/npu/service/../applib/nnrt/file_map_memory.hpp:38: error: undefined reference to 'vtable for nnrt::Memory'
prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
vendor/amlogic/common/npu/service/../applib/nnrt/file_map_memory.hpp:39: error: undefined reference to 'vtable for nnrt::Memory'
prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
vendor/amlogic/common/npu/service/../applib/nnrt/file_map_memory.hpp:39: error: undefined reference to 'vtable for nnrt::Memory'
prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
external/libcxx/include/memory:2137: error: undefined reference to 'nnrt::Model::Model()'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Model::~Model()'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Model::~Model()'
external/libcxx/include/memory:3704: error: undefined reference to 'nnrt::Model::~Model()'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:252: error: undefined reference to 'nnrt::Model::setOperandValue(std::__1::shared_ptr<nnrt::op::Operand>, void const*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:256: error: undefined reference to 'nnrt::Model::setOperandValue(std::__1::shared_ptr<nnrt::op::Operand>, void const*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:269: error: undefined reference to 'nnrt::Model::setOperandValueFromMemory(std::__1::shared_ptr<nnrt::op::Operand>, nnrt::Memory const*, unsigned long, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:267: error: undefined reference to 'nnrt::Model::setOperandValue(std::__1::shared_ptr<nnrt::op::Operand>, void const*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:329: error: undefined reference to 'nnrt::Model::addOperand(std::__1::shared_ptr<nnrt::op::Operand>, unsigned int*)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:354: error: undefined reference to 'nnrt::Model::addOperation(nnrt::OperationType, unsigned int const*, unsigned int, unsigned int const*, unsigned int, unsigned int*)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:365: error: undefined reference to 'nnrt::Model::relax(bool)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:370: error: undefined reference to 'nnrt::Model::identifyInputsAndOutputs(unsigned int const*, unsigned int, unsigned int const*, unsigned int)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:377: error: undefined reference to 'nnrt::Model::getOperands(std::__1::vector<unsigned int, std::__1::allocator<unsigned int> > const&)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:398: error: undefined reference to 'nnrt::Model::getOperands(std::__1::vector<unsigned int, std::__1::allocator<unsigned int> > const&)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:406: error: undefined reference to 'nnrt::Execution::setOutput(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, void*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:404: error: undefined reference to 'nnrt::Execution::setInput(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, void const*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:431: error: undefined reference to 'nnrt::Execution::setOutput(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, void*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:439: error: undefined reference to 'nnrt::Execution::setOutputFromMemory(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, nnrt::Memory const*, unsigned long, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:429: error: undefined reference to 'nnrt::Execution::setInput(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, void const*, unsigned long)'
vendor/amlogic/common/npu/service/VsiPreparedModel.cpp:436: error: undefined reference to 'nnrt::Execution::setInputFromMemory(unsigned int, std::__1::shared_ptr<nnrt::op::Operand>, nnrt::Memory const*, unsigned long, unsigned long)'
external/libcxx/include/memory:2151: error: undefined reference to 'nnrt::Compilation::Compilation(nnrt::Model*)'
external/libcxx/include/memory:2151: error: undefined reference to 'nnrt::Execution::Execution(nnrt::Compilation*)'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Compilation::~Compilation()'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Compilation::~Compilation()'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Execution::~Execution()'
external/libcxx/include/memory:2131: error: undefined reference to 'nnrt::Execution::~Execution()'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
- 5 audio确实64位依赖库
hardware/amlogic/audio/audio_hal/audio_hw.c:4470: error: undefined reference to 'noise_evaluation'
hardware/amlogic/audio/audio_hal/audio_hw.c:11903: error: undefined reference to 'init_noise_gate'
hardware/amlogic/audio/audio_hal/audio_hw.c:11323: error: undefined reference to 'release_noise_gate'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
rm hardware/amlogic/LibAudio
rm hardware/amlogic/audio/audio_hal
- 6 编译过程中报错
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
make update-api
- 7 打包时报错
depmod: WARNING: could not open /home/test/khadas/out/target/product/kvim3/obj/PACKAGING/depmod_vendor_intermediates/lib/modules/0.0/modules.order: No such file or directory
depmod: WARNING: could not open /home/test/khadas/out/target/product/kvim3/obj/PACKAGING/depmod_vendor_intermediates/lib/modules/0.0/modules.builtin: No such file or directory
error: failed to build out/target/product/kvim3/vendor.img from out/target/product/kvim3/vendor
Error: '['mkuserimg_mke2fs.sh', '-s', 'out/target/product/kvim3/vendor', 'out/target/product/kvim3/vendor.img', 'ext4', 'vendor', '335544320', '-j', '0', '-D', 'out/target/product/kvim3/system', '-L', 'vendor', '-M', '0', 'out/target/product/kvim3/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin']' failed with exit code 4:
MKE2FS_CONFIG=./system/extras/ext4_utils/mke2fs.conf mke2fs -O ^has_journal -L vendor -m 0 -E android_sparse -t ext4 -b 4096 out/target/product/kvim3/vendor.img 81920
mke2fs 1.43.3 (04-Sep-2016)
Creating filesystem with 81920 4k blocks and 81984 inodes
Filesystem UUID: ece343f7-9e47-4aad-9751-b524bafcc8b2
Superblock backups stored on blocks:
32768
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
e2fsdroid -p out/target/product/kvim3/system -S out/target/product/kvim3/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin -f out/target/product/kvim3/vendor -a /vendor out/target/product/kvim3/vendor.img
__populate_fs: Could not allocate block in ext2 filesystem while writing file "ge2d_chip_check"
e2fsdroid: Could not allocate block in ext2 filesystem while populating file system
- 8 烧写镜像时错误
ID[16]
tplcmd[download store vendor sparse 341180564]
[MSG]flash LOGIC partCap 0x14000000B
ERR(../drivers/usb/gadget/v2_burning/v2_common/optimus_download.c)L709:imgSz 0x14560094 out of cap 0x14000000
ERR(../drivers/usb/gadget/v2_burning/v2_common/optimus_download.c)L1155:Fail in init download info
[info]failed:
修改设备树信息
common/arch/arm64/boot/dts/amlogic/partition_mbox_normal_P_64.dtsi
vendor:vendor
{
pname = "vendor";
size = <0x0 0x14000000>;
mask = <1>;
};
-->
vendor:vendor
{
pname = "vendor";
size = <0x0 0x1C000000>;
mask = <1>;
};
未完待续。。。