Issue #107: accept the new change in dtc 1.6.1

pull/140/head v13
cfig 3 years ago
parent e14887192a
commit d7ea80a5c2
No known key found for this signature in database
GPG Key ID: B104C307F0FDABB7

@ -37,6 +37,9 @@ jobs:
- name: Unit Test - name: Unit Test
run: ./gradlew check && ./gradlew clean || true run: ./gradlew check && ./gradlew clean || true
- name: enable gradle native
run: sed -i "s/bHackingMode = false/bHackingMode = true/g" build.gradle.kts
# Runs a set of commands using the runners shell # Runs a set of commands using the runners shell
- name: Integration Test - name: Integration Test
run: | run: |

@ -182,12 +182,12 @@ If you want to edit the device-tree blob in place:
cp <your_vendor_boot_image> vendor_boot.img cp <your_vendor_boot_image> vendor_boot.img
cp <your_vbmeta_image> vbmeta.img cp <your_vbmeta_image> vbmeta.img
./gradlew unpack ./gradlew unpack
==> now you can edit build/unzip_boot/dtb.src directly ==> now you can edit build/unzip_boot/dtb.dts directly
./gradlew pack ./gradlew pack
``` ```
During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.src`. During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.dts`.
You can edit `dtb.src` directly, and it will be compiled to dtb duing repack stage. You can edit `dtb.dts` directly, and it will be compiled to dtb duing repack stage.
If you just want to replace the dtb with the one that is compiled outside this tool, please If you just want to replace the dtb with the one that is compiled outside this tool, please
@ -195,7 +195,7 @@ If you just want to replace the dtb with the one that is compiled outside this t
cp <your_vendor_boot_image> vendor_boot.img cp <your_vendor_boot_image> vendor_boot.img
cp <your_vbmeta_image> vbmeta.img cp <your_vbmeta_image> vbmeta.img
./gradlew unpack ./gradlew unpack
rm build/unzip_boot/dtb.src rm build/unzip_boot/dtb.dts
cp <your_dtb> build/unzip_boot/dtb cp <your_dtb> build/unzip_boot/dtb
./gradlew pack ./gradlew pack
``` ```

@ -182,7 +182,7 @@ class Common {
Helper.extractFile(s.srcFile, s.dumpFile, s.offset.toLong(), s.length) Helper.extractFile(s.srcFile, s.dumpFile, s.offset.toLong(), s.length)
//extract DTB //extract DTB
if (EnvironmentVerifier().hasDtc) { if (EnvironmentVerifier().hasDtc) {
DTC().decompile(s.dumpFile, s.dumpFile + ".src") DTC().decompile(s.dumpFile, s.dumpFile + "." + Helper.prop("config.dts_suffix"))
} }
} }

@ -80,6 +80,7 @@ data class BootV2(
private val log = LoggerFactory.getLogger(BootV2::class.java) private val log = LoggerFactory.getLogger(BootV2::class.java)
private val workDir = Helper.prop("workDir") private val workDir = Helper.prop("workDir")
private val mapper = ObjectMapper() private val mapper = ObjectMapper()
private val dtsSuffix = Helper.prop("config.dts_suffix")
fun parse(fileName: String): BootV2 { fun parse(fileName: String): BootV2 {
val ret = BootV2() val ret = BootV2()
@ -305,8 +306,8 @@ data class BootV2(
if (theDtb.size > 0) { if (theDtb.size > 0) {
it.addRule() it.addRule()
it.addRow("dtb", theDtb.file) it.addRow("dtb", theDtb.file)
if (File(theDtb.file + ".src").exists()) { if (File(theDtb.file + ".${dtsSuffix}").exists()) {
it.addRow("\\-- decompiled dts", theDtb.file + ".src") it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}")
} }
} }
} }
@ -386,8 +387,8 @@ data class BootV2(
} }
//refresh dtb size //refresh dtb size
dtb?.let { theDtb -> dtb?.let { theDtb ->
if (File(theDtb.file!! + ".src").exists()) { if (File(theDtb.file!! + ".${dtsSuffix}").exists()) {
check(DTC().compile(theDtb.file!! + ".src", theDtb.file!!)) { "fail to compile dts" } check(DTC().compile(theDtb.file!! + ".${dtsSuffix}", theDtb.file!!)) { "fail to compile dts" }
} }
theDtb.size = File(theDtb.file!!).length().toInt() theDtb.size = File(theDtb.file!!).length().toInt()
} }

@ -78,6 +78,7 @@ data class BootV2Dialects(
companion object { companion object {
private val log = LoggerFactory.getLogger(BootV2Dialects::class.java) private val log = LoggerFactory.getLogger(BootV2Dialects::class.java)
private val workDir = Helper.prop("workDir") private val workDir = Helper.prop("workDir")
private val dtsSuffix = Helper.prop("config.dts_suffix")
fun parse(fileName: String): BootV2Dialects { fun parse(fileName: String): BootV2Dialects {
val ret = BootV2Dialects() val ret = BootV2Dialects()
@ -313,8 +314,8 @@ data class BootV2Dialects(
if (theDtb.size > 0) { if (theDtb.size > 0) {
it.addRule() it.addRule()
it.addRow("dtb", theDtb.file) it.addRow("dtb", theDtb.file)
if (File(theDtb.file + ".src").exists()) { if (File(theDtb.file + ".${dtsSuffix}").exists()) {
it.addRow("\\-- decompiled dts", theDtb.file + ".src") it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}")
} }
} }
} }

@ -158,6 +158,7 @@ data class VendorBoot(
private val log = LoggerFactory.getLogger(VendorBoot::class.java) private val log = LoggerFactory.getLogger(VendorBoot::class.java)
private val workDir = Helper.prop("workDir") private val workDir = Helper.prop("workDir")
private val mapper = ObjectMapper() private val mapper = ObjectMapper()
private val dtsSuffix = Helper.prop("config.dts_suffix")
fun parse(fileName: String): VendorBoot { fun parse(fileName: String): VendorBoot {
val ret = VendorBoot() val ret = VendorBoot()
FileInputStream(fileName).use { fis -> FileInputStream(fileName).use { fis ->
@ -266,8 +267,8 @@ data class VendorBoot(
} }
} }
//update dtb //update dtb
if (File(this.dtb.file + ".src").exists()) { if (File(this.dtb.file + ".${dtsSuffix}").exists()) {
check(DTC().compile(this.dtb.file + ".src", this.dtb.file)) { "fail to compile dts" } check(DTC().compile(this.dtb.file + ".${dtsSuffix}", this.dtb.file)) { "fail to compile dts" }
} }
this.dtb.size = File(this.dtb.file).length().toInt() this.dtb.size = File(this.dtb.file).length().toInt()
//header //header
@ -421,8 +422,8 @@ data class VendorBoot(
} }
it.addRule() it.addRule()
it.addRow("dtb", this.dtb.file) it.addRow("dtb", this.dtb.file)
if (File(this.dtb.file + ".src").exists()) { if (File(this.dtb.file + ".${dtsSuffix}").exists()) {
it.addRow("\\-- decompiled dts", dtb.file + ".src") it.addRow("\\-- decompiled dts", dtb.file + ".${dtsSuffix}")
} }
if (this.bootconfig.size > 0) { if (this.bootconfig.size > 0) {
it.addRule() it.addRule()

@ -36,6 +36,7 @@ class DtboParser(val workDir: File) : IPackable {
private val log = LoggerFactory.getLogger(DtboParser::class.java) private val log = LoggerFactory.getLogger(DtboParser::class.java)
private val envv = EnvironmentVerifier() private val envv = EnvironmentVerifier()
private val dtboMaker = Helper.prop("dtboMaker") private val dtboMaker = Helper.prop("dtboMaker")
private val dtsSuffix = Helper.prop("config.dts_suffix")
override fun capabilities(): List<String> { override fun capabilities(): List<String> {
return listOf("^dtbo\\.img$") return listOf("^dtbo\\.img$")
@ -139,7 +140,7 @@ class DtboParser(val workDir: File) : IPackable {
if (envv.hasDtc) { if (envv.hasDtc) {
for (i in 0 until Integer.parseInt(props.getProperty("dt_entry_count"))) { for (i in 0 until Integer.parseInt(props.getProperty("dt_entry_count"))) {
val inputDtb = "$dtbPath.$i" val inputDtb = "$dtbPath.$i"
val outputSrc = File(outDir + "/" + File(inputDtb).name + ".src").path val outputSrc = File(outDir + "/" + File(inputDtb).name + ".${dtsSuffix}").path
DTC().decompile(inputDtb, outputSrc) DTC().decompile(inputDtb, outputSrc)
} }
} else { } else {

@ -152,6 +152,7 @@ class Dtbo(
private val log = LoggerFactory.getLogger(Dtbo::class.java) private val log = LoggerFactory.getLogger(Dtbo::class.java)
private val outDir = Helper.prop("workDir") private val outDir = Helper.prop("workDir")
private val dtsSuffix = Helper.prop("config.dts_suffix")
} }
fun extractVBMeta(): Dtbo { fun extractVBMeta(): Dtbo {
@ -186,7 +187,7 @@ class Dtbo(
.toInt() .toInt()
// Part II - a // Part II - a
for (index in 0 until dtEntries.size) { for (index in 0 until dtEntries.size) {
DTC().compile("${outDir}dt/dt.${index}.src", "${outDir}dt/dt.${index}") DTC().compile("${outDir}dt/dt.${index}.${dtsSuffix}", "${outDir}dt/dt.${index}")
} }
// Part II - b // Part II - b
var offset = DtboHeader.SIZE + (header.entryCount * DeviceTreeTableEntry.SIZE) var offset = DtboHeader.SIZE + (header.entryCount * DeviceTreeTableEntry.SIZE)
@ -221,7 +222,7 @@ class Dtbo(
it.addRow("image info", outDir + info.output.removeSuffix(".img") + ".json") it.addRow("image info", outDir + info.output.removeSuffix(".img") + ".json")
it.addRule() it.addRule()
it.addRow("device-tree blob (${this.header.entryCount} blobs)", "${outDir}dt/dt.*") it.addRow("device-tree blob (${this.header.entryCount} blobs)", "${outDir}dt/dt.*")
it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.src") it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.${dtsSuffix}")
it.addRule() it.addRule()
it.addRow("AVB info", Avb.getJsonFileName(info.output)) it.addRow("AVB info", Avb.getJsonFileName(info.output))
it.addRule() it.addRule()

@ -11,3 +11,4 @@ mkbootimg = aosp/system/tools/mkbootimg/mkbootimg.py
dtboMaker = aosp/system/libufdt/utils/src/mkdtboimg.py dtboMaker = aosp/system/libufdt/utils/src/mkdtboimg.py
payloadDir = build/payload/ payloadDir = build/payload/
config.allow_cpio_duplicate = true config.allow_cpio_duplicate = true
config.dts_suffix = dts

@ -78,7 +78,7 @@ def verifySingleJson(jsonFile, func = None):
subprocess.check_call(gradleWrapper + " pack", shell = True) subprocess.check_call(gradleWrapper + " pack", shell = True)
for k, v in verifyItems["hash"].items(): for k, v in verifyItems["hash"].items():
log.info("%s : %s" % (k, v)) log.info("%s : %s" % (k, v))
unittest.TestCase().assertEqual(v, hashFile(k)) unittest.TestCase().assertIn(hashFile(k), v.split())
try: try:
subprocess.check_call(gradleWrapper + " clear", shell = True) subprocess.check_call(gradleWrapper + " clear", shell = True)
except Exception as e: except Exception as e:
@ -161,9 +161,8 @@ def main():
verifySingleJson("%s/issue_59/recovery.json" % resDir2, func = lambda: shutil.rmtree("build/unzip_boot/root", ignore_errors = False)) verifySingleJson("%s/issue_59/recovery.json" % resDir2, func = lambda: shutil.rmtree("build/unzip_boot/root", ignore_errors = False))
# Issue 71: dtbo # Issue 71: dtbo
if platform.system() != "Darwin": if platform.system() != "Darwin":
pass verifySingleDir(resDir2, "issue_71")
#verifySingleDir(resDir2, "issue_71") verifySingleDir(resDir2, "issue_71/redfin")
#verifySingleDir(resDir2, "issue_71/redfin")
else: else:
log.info("dtbo not fully supported on MacOS, skip testing") log.info("dtbo not fully supported on MacOS, skip testing")
# Issue 83: init_boot # Issue 83: init_boot

@ -1 +1 @@
Subproject commit 0f9f57cb3b25ab299acfeb3d2e80b2ad488ff17a Subproject commit d683034c3e83818b3a1264331b281df650fc2e6b

@ -1 +1 @@
Subproject commit 03c9b422e4cc418e2484b7bfeef97d8f3e920db9 Subproject commit be8c5a2fb19b43ba2b1a8c8d3e29b0d3bbaec958
Loading…
Cancel
Save