hal linux 手册_Android驱动开发---Linux Kernel/HAL Layer/Jni Layer实例全集

本文详细介绍了Android驱动开发的过程,从Linux内核驱动创建设备节点,到AOSP应用的构建,再到HAL层的实现和JNI接口封装。通过实例展示了如何在Android系统中添加、测试驱动,并实现上层服务和UI应用的交互。涉及的关键步骤包括:内核驱动的Kconfig、Makefile配置,AOSP应用的Android.mk构建,以及HAL层接口的定义和实现。
摘要由CSDN通过智能技术生成

本人在开发Android Nfc POS之初,探索调试了一番驱动,目前在Nexus 5X 7.1.1上已经调成,之前的步骤可以参考我发的文章,Android驱动开发经验分享如下。

1. Linux 内核驱动实例

以下均在Android Linux内核目录下操作, 在drivers目录下创建驱动目录hello

这个目下要创建3个文件,hello.c, Makefile and Kconfig

1.1 hello.c

cd drivers

mkdir hello

vim hello.c

code as follows:

/*linux kernel driver: hello.c => /dev/hello */

/create the device file: /sys/class/hello/hello/

please find the code in the below. here skip the code to make the page clean and clear.

** 1.2 Makefile**

Create the Makefile and add:

obj-y += hello.o

1.3 Kconfig

Create Kconfig and add:

config HELLO

tristate "Eric: First Android Driver"

default n

help

This is the first Android driver.

this file is used when we make menuconfig.

1.4 Modify drivers/Makefile

Add following in the end

obj-y += hello.o

1.5 Add the driver into system configuration

Before we build the kernal, we need to config the system.

1.5.1 Modify arch/arm64/Kconfig

Add following in the end

source "drivers/hello/Kconfig"

It seems that this config not work, may be skipped.

1.5.2 Modify drivers/Kconfig

Following the menu:

menu "Device Drivers"

Please add

source "drivers/hello/Kconfig"

1.5.3 Modify drivers/Kconfig

make menuconfig

To enble the menu 'Eric: First Android Driver' in the "Device Drivers" item.

And save , then to build the linux kernel code.

2. 测试驱动

以下是需要操作的目录在AOSP目录下

2.1 create the application on externel

在external下创建hello目录

目录下将有两个文件:hello.c and Android.mk

cd external

mkdir hello

vim hello.c

/* AOSP app : ./external/hello.c =>/system/bin/hello*/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值