在Ubuntu上为Android 10 系统内置C可执行程序测试Linux内核驱动程序

本文记录了在使用罗升阳方法编译Android 10的HAL时遇到的头文件缺失、编译警告及打包问题。作者分享了全编译和手动push解决方法,还详述了如何处理模拟器挂载问题和启用可写系统以部署测试程序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

学习总纲:

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 用老罗的方法编译后出现的问题和修改当法

修改点如下:

  1. hello.c 中缺少头文件

#include <unistd.h>

  1. Android.mk 中缺少取消-Werror,-Wunused-parameter 警告

LOCAL_CFLAGS += -Wno-unused-parameter

  1. 特有问题:
    按照老罗的步骤:

        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”

如:

  1. emulator -kernel ./goldfish/arch/x86/boot/bzImage -writable-system
  2. adb root
  3. adb disable-verity
  4. adb reboot
  5. adb root
  6. adb remount
  7. adb shell
  8. mount -o rw,remount /system
  9. adb push ./out/target/product/generic_x86_64/system/bin/hello system/bin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值