学习总纲:
Android10 硬件抽象层(HAL)概要介绍和学习计划
编译环境:
- android 版本 - android-10.0.0_r41
- 架构 - aosp_x86_64-eng
- 内核分支:android-goldfish-4.14-gchips
参考教材:
罗升阳:https://blog.youkuaiyun.com/luoshengyang/article/details/6571210
依赖前文:https://blog.youkuaiyun.com/silently_frog/article/details/124184244
目的
记录android 10 用老罗的方法编译后出现的问题和修改当法
修改点如下:
- hello.c 中缺少头文件
#include <unistd.h>
- Android.mk 中缺少取消-Werror,-Wunused-parameter 警告
LOCAL_CFLAGS += -Wno-unused-parameter
-
特有问题:
按照老罗的步骤:mmm ./external/hello
在out/target/product/generic_x86_64/system/bin目录下,生存了hello文件make snod
将其打包到system.img中,运行模拟器:
emulator -kernel ./goldfish/arch/x86/boot/bzImage发现system/bin下面没有hello的测试程序
解决方法:
方法1: 执行全编译make -j8
方法2:手动push
adb push ./out/target/product/generic_x86_64/system/bin/hello system/bin
按照网上的方法执行:adb remount 重新挂载文件系统,获得可写的权限。但是发生了如下错误:
adb remount 挂载不上
Skip mounting partition: /product
Skip mounting partition: /product_services
Skip mounting partition: /product
Skip mounting partition: /product_services
Skip mounting partition: /product
Skip mounting partition: /product_services
W DM_DEV_STATUS failed for scratch: No such device or address
E [liblp]No device named scratch
[liblp]Partition scratch will resize from 0 bytes to 820367360 bytes
E [liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 540 bytes failed: Operation not permitted
E [libfs_mgr]add partition scratch
Skip mounting partition: /product
Skip mounting partition: /product_services
...
W DM_DEV_STATUS failed for scratch: No such device or address
E [liblp]No device named scratch
[liblp]Partition scratch will resize from 0 bytes to 820367360 bytes
E [liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 540 bytes failed: Operation not permitted
E [libfs_mgr]add partition scratch
Skip mounting partition: /product
Skip mounting partition: /product_services
...
W DM_DEV_STATUS failed for scratch: No such device or address
Skip mounting partition: /product
Skip mounting partition: /product_services
E Can not mount overlayfs for partitions: No such file or directory
Skip mounting partition: /product
Skip mounting partition: /product_services
E failed to remount partition dev:/dev/block/dm-0 mnt:/: Read-only file system
E Consider providing all the dependencies to enable overlayfs
E failed to remount partition dev:/dev/block/dm-1 mnt:/vendor: Read-only file system
E Consider providing all the dependencies to enable overlayfs
/system/bin/remount exited with status 10
remount failed
解决方法:运行模拟器时添加 “-writable-system”
如:
- emulator -kernel ./goldfish/arch/x86/boot/bzImage -writable-system
- adb root
- adb disable-verity
- adb reboot
- adb root
- adb remount
- adb shell
- mount -o rw,remount /system
- adb push ./out/target/product/generic_x86_64/system/bin/hello system/bin