本文共 7858 字,大约阅读时间需要 26 分钟。
接着上个教程,同样用的罗老师的代码。
添加头文件。添加源文件。初始化环境。source build/envsetup.shlunch export PATH=/home/haidragon/Desktop/java-7-openjdk-amd64/bin/:$PATH
然后添加。 (代码有点老要修改下把所有的LOG宏前面加了一个字母A)
mmm ./hardware/libhardware/modules/freg/make snod然而驱动一般只有root用户才用访问,所以这里修改下权限。找到ramdisk.img 文件 重新命名为.gz命令操作如下:
haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lsandroid-info.txt cache.img fake_packages mkbootimg ramdisk.cpio.gz recovery symbols unmkbootimgboot.img clean_steps.mk ×××talled-files.txt obj ramdisk.img recovery.img system userdata.imgcache data kernel previous_build_config.mk ramdisk-recovery.img root system.img zImage-dtbhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lsandroid-info.txt cache.img fake_packages mkbootimg ramdisk.cpio.gz recovery symbols unmkbootimgboot.img clean_steps.mk ×××talled-files.txt obj ramdisk.img recovery.img system userdata.imgcache data kernel previous_build_config.mk ramdisk-recovery.img root system.img zImage-dtbhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lltotal 478708drwxr-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.mkdrwxr-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.imgdrwxr-xr-x 3 haidragon haidragon 4096 May 29 22:39 recovery/-rw-r--r-- 1 haidragon haidragon 9506816 May 29 22:39 recovery.imgdrwxr-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-dtbhaidragon@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.gzhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lsandroid-info.txt cache.img fake_packages mkbootimg ramdisk.cpio.gz recovery symbols unmkbootimgboot.img clean_steps.mk ×××talled-files.txt obj ramdisk.img.gz recovery.img system userdata.imgcache data kernel previous_build_config.mk ramdisk-recovery.img root system.img zImage-dtbhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lltotal 478708drwxr-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.mkdrwxr-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.imgdrwxr-xr-x 3 haidragon haidragon 4096 May 29 22:39 recovery/-rw-r--r-- 1 haidragon haidragon 9506816 May 29 22:39 recovery.imgdrwxr-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-dtbhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gunzip ./ramdisk.img.gz haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mkdir ramdiskhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ cd ./ramdisk/haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ cpio -i -F ../ramdisk.img 1760 blockshaidragon@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.unzipcpio: Too many argumentsTry 'cpio --help' or 'cpio --usage' for more information.haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ find . | cpio -o -H newc > ../ramdisk.img.unzip1760 blockshaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead/ramdisk$ cd ..haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gzgzexe gzip haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ gzip -c ./ramdisk.img.unzip >./ramdisk.img.gzhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ rm -f ./ramdisk.img.unzip haidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ rm -R ./ramdiskhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ mv ./ramdisk.img.gz ./ramdisk.imghaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$ lsandroid-info.txt cache.img fake_packages mkbootimg ramdisk.cpio.gz recovery symbols unmkbootimgboot.img clean_steps.mk ×××talled-files.txt obj ramdisk.img recovery.img system userdata.imgcache data kernel previous_build_config.mk ramdisk-recovery.img root system.img zImage-dtbhaidragon@ubuntu:~/Desktop/android/out/target/product/hammerhead$
把system.img和ramdisk.img 重新刷入手机。(ramdisk.img这个是要重新打包到boot.img)
效果:转载于:https://blog.51cto.com/haidragon/2409495