NEXUS 5为驱动添加硬件抽象层

接着上个教程,同样用的罗老师的代码。
NEXUS 5为驱动添加硬件抽象层
添加头文件。
NEXUS 5为驱动添加硬件抽象层
添加源文件。
NEXUS 5为驱动添加硬件抽象层
初始化环境。

source build/envsetup.sh
lunch 
export PATH=/home/haidragon/Desktop/java-7-openjdk-amd64/bin/:$PATH

然后添加。 (代码有点老要修改下把所有的LOG宏前面加了一个字母A)
NEXUS 5为驱动添加硬件抽象层

mmm  ./hardware/libhardware/modules/freg/
make snod

NEXUS 5为驱动添加硬件抽象层
NEXUS 5为驱动添加硬件抽象层
然而驱动一般只有root用户才用访问,所以这里修改下权限。
找到ramdisk.img 文件 重新命名为.gz
命令操作如下:

haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ls
android-info.txt  cache.img       fake_packages        mkbootimg                 ramdisk.cpio.gz       recovery      symbols     unmkbootimg
boot.img          clean_steps.mk  ×××talled-files.txt  obj                       ramdisk.img           recovery.img  system      userdata.img
cache             data            kernel               previous_build_config.mk  ramdisk-recovery.img  root          system.img  zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ls
android-info.txt  cache.img       fake_packages        mkbootimg                 ramdisk.cpio.gz       recovery      symbols     unmkbootimg
boot.img          clean_steps.mk  ×××talled-files.txt  obj                       ramdisk.img           recovery.img  system      userdata.img
cache             data            kernel               previous_build_config.mk  ramdisk-recovery.img  root          system.img  zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ll
total 478708
drwxr-xr-x 10 haidragon haidragon      4096 Jun 15 00:16 ./
drwxr-xr-x  4 haidragon haidragon      4096 May 29 23:09 ../
-rw-r--r--  1 haidragon haidragon        25 May 29 21:51 android-info.txt
-rwxrw-rw-  1 haidragon haidragon   9078784 Jun 15 00:16 boot.img*
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:19 cache/
-rw-r--r--  1 haidragon haidragon  13668728 May 29 22:19 cache.img
-rw-r--r--  1 haidragon haidragon     40349 May 29 21:46 clean_steps.mk
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:19 data/
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:58 fake_packages/
-rw-r--r--  1 haidragon haidragon     67168 May 29 22:58 ×××talled-files.txt
-rw-r--r--  1 haidragon haidragon   8410192 Jun 15 00:16 kernel
-rwxr-xr-x  1 haidragon haidragon     58104 Jun  2 20:02 mkbootimg*
drwxr-xr-x 14 haidragon haidragon      4096 May 29 22:58 obj/
-rw-r--r--  1 haidragon haidragon       716 May 29 21:46 previous_build_config.mk
-rw-r--r--  1 haidragon haidragon    664636 Jun 15 00:16 ramdisk.cpio.gz
-rw-r--r--  1 haidragon haidragon    498995 May 29 22:23 ramdisk.img
-rw-r--r--  1 haidragon haidragon   1096536 May 29 22:39 ramdisk-recovery.img
drwxr-xr-x  3 haidragon haidragon      4096 May 29 22:39 recovery/
-rw-r--r--  1 haidragon haidragon   9506816 May 29 22:39 recovery.img
drwxr-xr-x  9 haidragon haidragon      4096 May 29 22:23 root/
drwxr-xr-x  4 haidragon haidragon      4096 May 29 22:21 symbols/
drwxr-xr-x 14 haidragon haidragon      4096 May 29 22:43 system/
-rw-r--r--  1 haidragon haidragon 297984228 May 29 22:58 system.img
-rwxr-xr-x  1 haidragon haidragon     13096 Jun  2 20:02 unmkbootimg*
-rw-r--r--  1 haidragon haidragon 140614516 May 29 22:19 userdata.img
-rw-r--r--  1 haidragon haidragon   8410664 Jun 15 00:16 zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.
ramdisk.cpio.gz  ramdisk.img      
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.
ramdisk.cpio.gz  ramdisk.img      
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.
ramdisk.cpio.gz  ramdisk.img      
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.img ./ramdisk.img.gz
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ls
android-info.txt  cache.img       fake_packages        mkbootimg                 ramdisk.cpio.gz       recovery      symbols     unmkbootimg
boot.img          clean_steps.mk  ×××talled-files.txt  obj                       ramdisk.img.gz        recovery.img  system      userdata.img
cache             data            kernel               previous_build_config.mk  ramdisk-recovery.img  root          system.img  zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ll
total 478708
drwxr-xr-x 10 haidragon haidragon      4096 Jun 15 01:38 ./
drwxr-xr-x  4 haidragon haidragon      4096 May 29 23:09 ../
-rw-r--r--  1 haidragon haidragon        25 May 29 21:51 android-info.txt
-rwxrw-rw-  1 haidragon haidragon   9078784 Jun 15 00:16 boot.img*
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:19 cache/
-rw-r--r--  1 haidragon haidragon  13668728 May 29 22:19 cache.img
-rw-r--r--  1 haidragon haidragon     40349 May 29 21:46 clean_steps.mk
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:19 data/
drwxr-xr-x  2 haidragon haidragon      4096 May 29 22:58 fake_packages/
-rw-r--r--  1 haidragon haidragon     67168 May 29 22:58 ×××talled-files.txt
-rw-r--r--  1 haidragon haidragon   8410192 Jun 15 00:16 kernel
-rwxr-xr-x  1 haidragon haidragon     58104 Jun  2 20:02 mkbootimg*
drwxr-xr-x 14 haidragon haidragon      4096 May 29 22:58 obj/
-rw-r--r--  1 haidragon haidragon       716 May 29 21:46 previous_build_config.mk
-rw-r--r--  1 haidragon haidragon    664636 Jun 15 00:16 ramdisk.cpio.gz
-rw-r--r--  1 haidragon haidragon    498995 May 29 22:23 ramdisk.img.gz
-rw-r--r--  1 haidragon haidragon   1096536 May 29 22:39 ramdisk-recovery.img
drwxr-xr-x  3 haidragon haidragon      4096 May 29 22:39 recovery/
-rw-r--r--  1 haidragon haidragon   9506816 May 29 22:39 recovery.img
drwxr-xr-x  9 haidragon haidragon      4096 May 29 22:23 root/
drwxr-xr-x  4 haidragon haidragon      4096 May 29 22:21 symbols/
drwxr-xr-x 14 haidragon haidragon      4096 May 29 22:43 system/
-rw-r--r--  1 haidragon haidragon 297984228 May 29 22:58 system.img
-rwxr-xr-x  1 haidragon haidragon     13096 Jun  2 20:02 unmkbootimg*
-rw-r--r--  1 haidragon haidragon 140614516 May 29 22:19 userdata.img
-rw-r--r--  1 haidragon haidragon   8410664 Jun 15 00:16 zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gunzip ./ramdisk.img.gz 
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mkdir ramdisk
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ cd ./ramdisk/
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ cpio -i -F ../ramdisk.img 
1760 blocks
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ rm -f ../ramdisk.img 
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ find . | cpio -o - H newc > ../ramdisk.img.unzip
cpio: Too many arguments
Try 'cpio --help' or 'cpio --usage' for more information.
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ find . | cpio -o -H newc > ../ramdisk.img.unzip
1760 blocks
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ cd ..
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gz
gzexe  gzip   
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gzip -c ./ramdisk.img.unzip >./ramdisk.img.gz
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ rm -f ./ramdisk.img.unzip 
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ rm -R ./ramdisk
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.img.gz ./ramdisk.img
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ ls
android-info.txt  cache.img       fake_packages        mkbootimg                 ramdisk.cpio.gz       recovery      symbols     unmkbootimg
boot.img          clean_steps.mk  ×××talled-files.txt  obj                       ramdisk.img           recovery.img  system      userdata.img
cache             data            kernel               previous_build_config.mk  ramdisk-recovery.img  root          system.img  zImage-dtb
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ 

把system.img和ramdisk.img 重新刷入手机。(ramdisk.img这个是要重新打包到boot.img)
效果:
NEXUS 5为驱动添加硬件抽象层

转载于:https://blog.51cto.com/haidragon/2409495

已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页