您的位置:首页 > 科技 > IT业 > Adroid或者Linux系统内核boot.img解压方法

Adroid或者Linux系统内核boot.img解压方法

2024/12/23 5:40:24 来源:https://blog.csdn.net/a2591748032/article/details/140718447  浏览:    关键词:Adroid或者Linux系统内核boot.img解压方法

我们经常需要查看内核编译的产物---boot.img里面的内容,那该如何查看呢?方法如下,本文采用倒叙法来写。

boot.img解压产物效果:


~/snap/Android_boot_image_editor/build/unzip_boot$ ls -l
total 44580
-rw-rw-r--  1 ubuntu20 ubuntu20     3472 JAN 1 20:14 boot.avb.json
-rw-rw-r--  1 ubuntu20 ubuntu20      973 JAN 1 20:14 boot.json
-rw-rw-r--  1 ubuntu20 ubuntu20   167923 JAN 1 20:14 dtb
-rw-rw-r--  1 ubuntu20 ubuntu20 15787699 JAN 1 20:14 kernel
-rw-rw-r--  1 ubuntu20 ubuntu20   164024 JAN 1 20:14 kernel_configs.txt
-rw-rw-r--  1 ubuntu20 ubuntu20        8 JAN 1 20:14 kernel_version.txt
-rw-rw-r--  1 ubuntu20 ubuntu20 20813312 JAN 1 20:14 ramdisk.img
-rw-rw-r--  1 ubuntu20 ubuntu20    37173 JAN 1 20:14 ramdisk.img_filelist.txt
-rw-rw-r--  1 ubuntu20 ubuntu20  8647450 JAN 1 20:14 ramdisk.img.gz
drwxrwxr-x 27 ubuntu20 ubuntu20     4096 JAN 1 20:14 root
 

一、环境准备

1.1 boot解压工具下载

git clone https://github.com/zbx911/Android_boot_image_editor.git

1.2 Linux环境变量安装

sudo apt install git device-tree-compiler lz4 xz-utils zlib1g-dev openjdk-17-jdk gcc g++ python3 python-is-python3 p7zip-full android-sdk-libsparse-utils erofs-utils

1.3 gradle下载安装

主要是配置gradle的url,否则会报各种异常错误。

配置gradle:(路径)Android_boot_image_editor/gradle/wrapper/gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.7-rc-3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

二、boot解压过程

执行: ./gradlew unpackDownloading https://mirrors.cloud.tencent.com/gradle/gradle-8.7-rc-3-bin.zip
............10%.............20%.............30%.............40%............50%.............60%.............70%.............80%.............90%............100%Welcome to Gradle 8.7-rc-3!Here are the highlights of this release:- Compiling and testing with Java 22- Cacheable Groovy script compilation- New methods in lazy collection propertiesFor more details see https://docs.gradle.org/8.7-rc-3/release-notes.htmlStarting a Gradle Daemon (subsequent builds will be faster)> Task :helper:compileKotlin
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:123:25 The value 'true' assigned to 'var bSuccess: Boolean defined in cfig.helper.CryptoHelper.KeyBox.Companion.parse4' is never used
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:127:29 The value 'false' assigned to 'var bSuccess: Boolean defined in cfig.helper.CryptoHelper.KeyBox.Companion.parse4' is never used
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:132:29 The value 'false' assigned to 'var bSuccess: Boolean defined in cfig.helper.CryptoHelper.KeyBox.Companion.parse4' is never used
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:502:43 Variable 'obj' initializer is redundant
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:521:29 Variable 'obj' is never used
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt:533:47 Variable 'obj' initializer is redundant
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/Launcher.kt:83:19 Variable 'cmd' is never used
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/ZipHelper.kt:120:37 'getter for nextZipEntry: ZipArchiveEntry!' is deprecated. Deprecated in Java
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/ZipHelper.kt:162:13 'constructor ZipFile(String!)' is deprecated. Deprecated in Java
w: file:///home/ubuntu20/snap/Android_boot_image_editor/helper/src/main/kotlin/cfig/helper/ZipHelper.kt:179:13 'constructor ZipFile(String!)' is deprecated. Deprecated in Java20:14:05.264 [main] INFO  rom.fdt.DTC - no more FDT header
20:14:05.267 [main] WARN  rom.fdt.DTC - Successfully parsed 0 FDT headers from build/unzip_boot/dtb, remainder: 187923 bytes
20:14:05.268 [main] INFO  cfig.bootimg.v2.BootV2 - dtb sz = 0
20:14:05.272 [main] INFO  avb.AVBInfo - parseFrom(FILE:boot.img) ...
20:14:05.287 [main] INFO  avb.AVBInfo - FILE:boot.img: Glance(footer=Footer(versionMajor=1, versionMinor=0, originalImageSize=24606720, vbMetaOffset=24608768, vbMetaSize=1664), vbMetaOffset=24608768).footer
20:14:05.371 [main] INFO  avb.AVBInfo - VBMeta: boot.img -> build/unzip_boot/boot.avb.json
20:14:05.552 [main] INFO  cfig.Avb - signed with release key
20:14:05.613 [main] INFO  cfig.bootimg.v2.BootV2 - Unpack Summary of boot.img
┌───────────────────────────────────────┬──────────────────────────────────────┐
│What                                   │Where                                 │
└───────────────────────────────────────┴──────────────────────────────────────┘
┌───────────────────────────────────────┬──────────────────────────────────────┐
│image info                             │build/unzip_boot/boot.json            │
├───────────────────────────────────────┼──────────────────────────────────────┤
│AVB info [verified]                    │build/unzip_boot/boot.avb.json        │
│\-- signing key                        │private release key                   │
├───────────────────────────────────────┼──────────────────────────────────────┤
│kernel                                 │build/unzip_boot/kernel               │
│\-- version [4.9]                      │build/unzip_boot/kernel_version.txt   │
│\-- config                             │build/unzip_boot/kernel_configs.txt   │
├───────────────────────────────────────┼──────────────────────────────────────┤
│ramdisk                                │build/unzip_boot/ramdisk.img.gz       │
│\-- extracted ramdisk rootfs           │build/unzip_boot/root                 │
├───────────────────────────────────────┼──────────────────────────────────────┤
│dtb                                    │build/unzip_boot/dtb                  │
└───────────────────────────────────────┴──────────────────────────────────────┘
20:14:05.677 [main] WARN  cfig.packable.PackableLauncher - 'unpack' sequence completed

三、boot.img打包

./gradlew pack

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com