diff --git a/README.md b/README.md
index 57622e1..f000ffc 100644
--- a/README.md
+++ b/README.md
@@ -53,15 +53,16 @@ Well done you did it! The last step is to star this repo :smile
## Supported ROM image types
-| Image Type | file names | platforms | note |
-| --------------- | ----------------------------------- |-------------|-------------------------|
-| boot | boot.img, init_boot.img, boot(-debug|-test-harness).img | all | |
-|vendor boot | vendor_boot.img, vendor_boot-debug.img, vendor_kernel_boot.img | all | |
-| recovery | recovery.img, recovery-two-step.img | all | |
-| vbmeta | vbmeta.img, vbmeta_system.img etc. | all | |
-| dtbo | dtbo.img | linux & mac | |
-| sparse images | system.img, vendor.img, product.img etc.| linux | |
-| OTA payload | payload.bin | all | Windows git-bash |
+| Image Type | file names | platforms | note |
+| --------------- |----------------------------------------------------------------|-------------|-------------------------|
+| boot | boot.img, init_boot.img, boot-debug.img, boot-test-harness.img | all | |
+|vendor boot | vendor_boot.img, vendor_boot-debug.img, vendor_kernel_boot.img | all | |
+| recovery | recovery.img, recovery-two-step.img | all | |
+| vbmeta | vbmeta.img, vbmeta_system.img etc. | all | |
+| dtbo | dtbo.img | linux & mac | |
+| dtb | *.dtb | linux & mac | |
+| sparse images | system.img, vendor.img, product.img etc. | linux | |
+| OTA payload | payload.bin | all | Windows git-bash |
Please note that the boot.img MUST follows AOSP verified boot flow, either [Boot image signature](https://source.android.com/security/verifiedboot/verified-boot#signature_format) in VBoot 1.0 or [AVB HASH footer](https://android.googlesource.com/platform/external/avb/+/master/README.md#The-VBMeta-struct) (a.k.a. AVB) in VBoot 2.0.
@@ -69,6 +70,7 @@ Please note that the boot.img MUST follows AOSP verified boot flow, either [Boot
| Device Model | Manufacturer | Compatible | Android Version | Note |
|--------------------------------|--------------|----------------------|--------------------------|------|
+| Pixel 7 (panther) | Google | Y | 13 (TQ2A.230505.002)
2023)| |
| ADT-3 (adt3) | Askey/Google | Y | 12 (spp2.210219.010) | amlogic inside,
Android TV |
| Pixel 3 (blueline) | Google | Y | 12 (spp2.210219.008,
2021)| |
| Pixel 3 (blueline) | Google | Y | 11 (RP1A.200720.009,
2020)| [more ...](doc/additional_tricks.md#pixel-3-blueline) |
@@ -156,7 +158,7 @@ Please note that to use 'gradle flash', your host machine must be connectted to
- edit device-tree blob(dtb) inside vendor_boot.img
+ How to edit device tree blob(dtb) inside vendor_boot.img
If you want to edit the device-tree blob in place:
@@ -184,6 +186,55 @@ cp build/unzip_boot/dtb
+
+
+ How to pull device tree blob(dtb) from a rooted device
+
+If you have a rooted device and want to pull /proc/device-tree
+```bash
+touch fake.dtb
+./gradlew pull
+```
+This tool will copy `dtc` to the target device via `adb`, and dump the dtb and dts file. Eventually you should get something like this
+```
++--------+------------------------------+
+| What | Where |
++--------+------------------------------+
+| source | /proc/device-tree |
++--------+------------------------------+
+| DTB | panther.dtb |
++--------+------------------------------+
+| DTS | build/unzip_boot/panther.dts |
++--------+------------------------------+
+
+```
+
+
+
+
+
+ How to work edit device tree blob(dtb) file
+
+If you have a dtb file and want to edit its content
+```bash
+cp .
+./gradlew unpack
+```
+This tool will decompile it and put the decompiled source to build/unzip_boot.
+
+```
+ Unpack Summary of panther.dtb
++------+------------------------------+
+| What | Where |
++------+------------------------------+
+| DTB | panther.dtb |
++------+------------------------------+
+| DTS | build/unzip_boot/panther.dts |
++------+------------------------------+
+```
+
+
+
working with system.img
@@ -255,11 +306,10 @@ https://android.googlesource.com/platform/system/core/+/refs/heads/master/libspa
Android Nexus/Pixle factory images
https://developers.google.cn/android/images
-This project is developed with products by Jetbrains.
+
+This project is developed with products by Jetbrains.
-
-
diff --git a/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt b/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt
new file mode 100644
index 0000000..ebbd76c
--- /dev/null
+++ b/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt
@@ -0,0 +1,83 @@
+package packable
+
+import cfig.bootimg.Common
+import cfig.helper.Helper
+import cfig.helper.Helper.Companion.check_call
+import cfig.helper.Helper.Companion.check_output
+import cfig.helper.Helper.Companion.deleteIfExists
+import cfig.packable.IPackable
+import cfig.utils.DTC
+import org.slf4j.LoggerFactory
+import java.io.File
+
+class DeviceTreeParser : IPackable {
+ override fun capabilities(): List {
+ return listOf("^.*\\.dtb$")
+ }
+ override val loopNo: Int
+ get() = 1
+
+ override fun unpack(fileName: String) {
+ super.clear()
+ log.info("unpacking $fileName")
+ val outFile = workDir + fileName.removeSuffix(".dtb") + "." + Helper.prop("config.dts_suffix")
+ DTC().decompile(fileName, outFile)
+
+ //print summary
+ val prints: MutableList> = mutableListOf()
+ prints.add(Pair("DTB", fileName))
+ prints.add(Pair("DTS", outFile))
+ log.info("\n\t\t\tUnpack Summary of {}\n{}\n", fileName, Common.table2String(prints))
+ }
+
+ override fun pack(fileName: String) {
+ log.info("packing $fileName")
+ val outFile = workDir + fileName.removeSuffix(".dtb") + "." + Helper.prop("config.dts_suffix")
+ check(DTC().compile(outFile, "$fileName.new")) { "fail to compile dts" }
+
+ //print summary
+ val prints: MutableList> = mutableListOf()
+ prints.add(Pair("DTS", outFile))
+ prints.add(Pair("updated DTB", "$fileName.new"))
+ log.info("\n\t\t\tPack Summary of {}\n{}\n", fileName, Common.table2String(prints))
+ }
+
+ override fun pull(fileName: String, deviceName: String) {
+ //prepare
+ super.clear()
+ File(workDir).mkdir()
+
+ //pull
+ "adb root".check_call()
+ "adb push tools/bin/dtc-android /data/vendor/dtc-android".check_call()
+ val hw = "adb shell getprop ro.hardware".check_output()
+ log.info("ro.hardware=$hw")
+ "adb shell /data/vendor/dtc-android -I fs /proc/device-tree -o /data/vendor/file.to.pull".check_call()
+ "adb pull /data/vendor/file.to.pull $workDir$hw.dts".check_call()
+ "adb shell /data/vendor/dtc-android -I fs -O dtb /proc/device-tree -o /data/vendor/file.to.pull".check_call()
+ "adb pull /data/vendor/file.to.pull $hw.dtb".check_call()
+ "adb shell rm /data/vendor/file.to.pull".check_call()
+ "adb shell rm /data/vendor/dtc-android".check_call()
+ if (fileName != "$hw.dtb") {
+ File(fileName).delete()
+ log.warn("deleting intermediate dtb file: $fileName")
+ }
+
+ //print summary
+ val prints: MutableList> = mutableListOf()
+ prints.add(Pair("source", "/proc/device-tree"))
+ prints.add(Pair("DTB", "$hw.dtb"))
+ prints.add(Pair("DTS", "$workDir$hw.dts"))
+ log.info("\n\t\t\tPull Summary of {}\n{}\n", "$hw.dtb", Common.table2String(prints))
+ }
+
+ fun clear(fileName: String) {
+ super.clear()
+ listOf(".new").forEach {
+ "$fileName$it".deleteIfExists()
+ }
+ }
+
+ private val log = LoggerFactory.getLogger(DeviceTreeParser::class.java)
+ private val workDir = Helper.prop("workDir")
+}
\ No newline at end of file
diff --git a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
index 8df350b..a143868 100644
--- a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
+++ b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
@@ -16,6 +16,7 @@ package cfig.packable
import cfig.utils.SparseImgParser
import org.slf4j.LoggerFactory
+import packable.DeviceTreeParser
import java.io.File
import java.util.regex.Pattern
import kotlin.reflect.KClass
@@ -30,7 +31,8 @@ fun main(args: Array) {
val packablePool = mutableMapOf, KClass>()
listOf(
DtboParser(), VBMetaParser(), BootImgParser(), SparseImgParser(), VendorBootParser(), PayloadBinParser(),
- MiscImgParser()
+ MiscImgParser(),
+ DeviceTreeParser()
).forEach {
@Suppress("UNCHECKED_CAST")
packablePool.put(it.capabilities(), it::class as KClass)
diff --git a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
index 51c69e4..1d1b84a 100644
--- a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
+++ b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
@@ -15,13 +15,10 @@
package cfig.packable
import avb.AVBInfo
-import avb.alg.Algorithms
import cfig.Avb
-import cfig.helper.CryptoHelper
import cfig.helper.Dumpling
import cfig.helper.Helper
import cfig.helper.Helper.Companion.deleteIfExists
-import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import org.slf4j.LoggerFactory
import java.io.File
diff --git a/integrationTest.py b/integrationTest.py
index c877230..ce1a081 100755
--- a/integrationTest.py
+++ b/integrationTest.py
@@ -180,6 +180,8 @@ def main():
verifySingleDir(resDir2, "issue_117_xz_crc")
# Issue 122: ramdisk.img, boot image v0
verifySingleDir(resDir2, "issue_122_ramdisk_img")
+ # Issue 123: dtb
+ verifySingleDir(resDir2, "issue_123_dtb")
log.info(successLogo)
diff --git a/src/integrationTest/resources_2 b/src/integrationTest/resources_2
index 5fdce9c..517ca7a 160000
--- a/src/integrationTest/resources_2
+++ b/src/integrationTest/resources_2
@@ -1 +1 @@
-Subproject commit 5fdce9cd65d5b286f8c15fffe3ae142b64e0013a
+Subproject commit 517ca7a72425c6b8b913feea0b505f07879549c9
diff --git a/tools/bin/dtc-android b/tools/bin/dtc-android
new file mode 100755
index 0000000..575c6a2
Binary files /dev/null and b/tools/bin/dtc-android differ