Skip to content

Commit d7ea80a

Browse files
committed
Issue #107: accept the new change in dtc 1.6.1
1 parent e148871 commit d7ea80a

File tree

12 files changed

+32
-24
lines changed

12 files changed

+32
-24
lines changed

.github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- name: Unit Test
3838
run: ./gradlew check && ./gradlew clean || true
3939

40+
- name: enable gradle native
41+
run: sed -i "s/bHackingMode = false/bHackingMode = true/g" build.gradle.kts
42+
4043
# Runs a set of commands using the runners shell
4144
- name: Integration Test
4245
run: |

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,20 @@ If you want to edit the device-tree blob in place:
182182
cp <your_vendor_boot_image> vendor_boot.img
183183
cp <your_vbmeta_image> vbmeta.img
184184
./gradlew unpack
185-
==> now you can edit build/unzip_boot/dtb.src directly
185+
==> now you can edit build/unzip_boot/dtb.dts directly
186186
./gradlew pack
187187
```
188188

189-
During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.src`.
190-
You can edit `dtb.src` directly, and it will be compiled to dtb duing repack stage.
189+
During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.dts`.
190+
You can edit `dtb.dts` directly, and it will be compiled to dtb duing repack stage.
191191

192192
If you just want to replace the dtb with the one that is compiled outside this tool, please
193193

194194
```bash
195195
cp <your_vendor_boot_image> vendor_boot.img
196196
cp <your_vbmeta_image> vbmeta.img
197197
./gradlew unpack
198-
rm build/unzip_boot/dtb.src
198+
rm build/unzip_boot/dtb.dts
199199
cp <your_dtb> build/unzip_boot/dtb
200200
./gradlew pack
201201
```

bbootimg/src/main/kotlin/bootimg/Common.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class Common {
182182
Helper.extractFile(s.srcFile, s.dumpFile, s.offset.toLong(), s.length)
183183
//extract DTB
184184
if (EnvironmentVerifier().hasDtc) {
185-
DTC().decompile(s.dumpFile, s.dumpFile + ".src")
185+
DTC().decompile(s.dumpFile, s.dumpFile + "." + Helper.prop("config.dts_suffix"))
186186
}
187187
}
188188

bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ data class BootV2(
8080
private val log = LoggerFactory.getLogger(BootV2::class.java)
8181
private val workDir = Helper.prop("workDir")
8282
private val mapper = ObjectMapper()
83+
private val dtsSuffix = Helper.prop("config.dts_suffix")
8384

8485
fun parse(fileName: String): BootV2 {
8586
val ret = BootV2()
@@ -305,8 +306,8 @@ data class BootV2(
305306
if (theDtb.size > 0) {
306307
it.addRule()
307308
it.addRow("dtb", theDtb.file)
308-
if (File(theDtb.file + ".src").exists()) {
309-
it.addRow("\\-- decompiled dts", theDtb.file + ".src")
309+
if (File(theDtb.file + ".${dtsSuffix}").exists()) {
310+
it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}")
310311
}
311312
}
312313
}
@@ -386,8 +387,8 @@ data class BootV2(
386387
}
387388
//refresh dtb size
388389
dtb?.let { theDtb ->
389-
if (File(theDtb.file!! + ".src").exists()) {
390-
check(DTC().compile(theDtb.file!! + ".src", theDtb.file!!)) { "fail to compile dts" }
390+
if (File(theDtb.file!! + ".${dtsSuffix}").exists()) {
391+
check(DTC().compile(theDtb.file!! + ".${dtsSuffix}", theDtb.file!!)) { "fail to compile dts" }
391392
}
392393
theDtb.size = File(theDtb.file!!).length().toInt()
393394
}

bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ data class BootV2Dialects(
7878
companion object {
7979
private val log = LoggerFactory.getLogger(BootV2Dialects::class.java)
8080
private val workDir = Helper.prop("workDir")
81+
private val dtsSuffix = Helper.prop("config.dts_suffix")
8182

8283
fun parse(fileName: String): BootV2Dialects {
8384
val ret = BootV2Dialects()
@@ -313,8 +314,8 @@ data class BootV2Dialects(
313314
if (theDtb.size > 0) {
314315
it.addRule()
315316
it.addRow("dtb", theDtb.file)
316-
if (File(theDtb.file + ".src").exists()) {
317-
it.addRow("\\-- decompiled dts", theDtb.file + ".src")
317+
if (File(theDtb.file + ".${dtsSuffix}").exists()) {
318+
it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}")
318319
}
319320
}
320321
}

bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ data class VendorBoot(
158158
private val log = LoggerFactory.getLogger(VendorBoot::class.java)
159159
private val workDir = Helper.prop("workDir")
160160
private val mapper = ObjectMapper()
161+
private val dtsSuffix = Helper.prop("config.dts_suffix")
161162
fun parse(fileName: String): VendorBoot {
162163
val ret = VendorBoot()
163164
FileInputStream(fileName).use { fis ->
@@ -266,8 +267,8 @@ data class VendorBoot(
266267
}
267268
}
268269
//update dtb
269-
if (File(this.dtb.file + ".src").exists()) {
270-
check(DTC().compile(this.dtb.file + ".src", this.dtb.file)) { "fail to compile dts" }
270+
if (File(this.dtb.file + ".${dtsSuffix}").exists()) {
271+
check(DTC().compile(this.dtb.file + ".${dtsSuffix}", this.dtb.file)) { "fail to compile dts" }
271272
}
272273
this.dtb.size = File(this.dtb.file).length().toInt()
273274
//header
@@ -421,8 +422,8 @@ data class VendorBoot(
421422
}
422423
it.addRule()
423424
it.addRow("dtb", this.dtb.file)
424-
if (File(this.dtb.file + ".src").exists()) {
425-
it.addRow("\\-- decompiled dts", dtb.file + ".src")
425+
if (File(this.dtb.file + ".${dtsSuffix}").exists()) {
426+
it.addRow("\\-- decompiled dts", dtb.file + ".${dtsSuffix}")
426427
}
427428
if (this.bootconfig.size > 0) {
428429
it.addRule()

bbootimg/src/main/kotlin/packable/DtboParser.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class DtboParser(val workDir: File) : IPackable {
3636
private val log = LoggerFactory.getLogger(DtboParser::class.java)
3737
private val envv = EnvironmentVerifier()
3838
private val dtboMaker = Helper.prop("dtboMaker")
39+
private val dtsSuffix = Helper.prop("config.dts_suffix")
3940

4041
override fun capabilities(): List<String> {
4142
return listOf("^dtbo\\.img$")
@@ -139,7 +140,7 @@ class DtboParser(val workDir: File) : IPackable {
139140
if (envv.hasDtc) {
140141
for (i in 0 until Integer.parseInt(props.getProperty("dt_entry_count"))) {
141142
val inputDtb = "$dtbPath.$i"
142-
val outputSrc = File(outDir + "/" + File(inputDtb).name + ".src").path
143+
val outputSrc = File(outDir + "/" + File(inputDtb).name + ".${dtsSuffix}").path
143144
DTC().decompile(inputDtb, outputSrc)
144145
}
145146
} else {

bbootimg/src/main/kotlin/utils/Dtbo.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Dtbo(
152152

153153
private val log = LoggerFactory.getLogger(Dtbo::class.java)
154154
private val outDir = Helper.prop("workDir")
155+
private val dtsSuffix = Helper.prop("config.dts_suffix")
155156
}
156157

157158
fun extractVBMeta(): Dtbo {
@@ -186,7 +187,7 @@ class Dtbo(
186187
.toInt()
187188
// Part II - a
188189
for (index in 0 until dtEntries.size) {
189-
DTC().compile("${outDir}dt/dt.${index}.src", "${outDir}dt/dt.${index}")
190+
DTC().compile("${outDir}dt/dt.${index}.${dtsSuffix}", "${outDir}dt/dt.${index}")
190191
}
191192
// Part II - b
192193
var offset = DtboHeader.SIZE + (header.entryCount * DeviceTreeTableEntry.SIZE)
@@ -221,7 +222,7 @@ class Dtbo(
221222
it.addRow("image info", outDir + info.output.removeSuffix(".img") + ".json")
222223
it.addRule()
223224
it.addRow("device-tree blob (${this.header.entryCount} blobs)", "${outDir}dt/dt.*")
224-
it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.src")
225+
it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.${dtsSuffix}")
225226
it.addRule()
226227
it.addRow("AVB info", Avb.getJsonFileName(info.output))
227228
it.addRule()

bbootimg/src/main/resources/general.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ mkbootimg = aosp/system/tools/mkbootimg/mkbootimg.py
1111
dtboMaker = aosp/system/libufdt/utils/src/mkdtboimg.py
1212
payloadDir = build/payload/
1313
config.allow_cpio_duplicate = true
14+
config.dts_suffix = dts

integrationTest.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def verifySingleJson(jsonFile, func = None):
7878
subprocess.check_call(gradleWrapper + " pack", shell = True)
7979
for k, v in verifyItems["hash"].items():
8080
log.info("%s : %s" % (k, v))
81-
unittest.TestCase().assertEqual(v, hashFile(k))
81+
unittest.TestCase().assertIn(hashFile(k), v.split())
8282
try:
8383
subprocess.check_call(gradleWrapper + " clear", shell = True)
8484
except Exception as e:
@@ -161,9 +161,8 @@ def main():
161161
verifySingleJson("%s/issue_59/recovery.json" % resDir2, func = lambda: shutil.rmtree("build/unzip_boot/root", ignore_errors = False))
162162
# Issue 71: dtbo
163163
if platform.system() != "Darwin":
164-
pass
165-
#verifySingleDir(resDir2, "issue_71")
166-
#verifySingleDir(resDir2, "issue_71/redfin")
164+
verifySingleDir(resDir2, "issue_71")
165+
verifySingleDir(resDir2, "issue_71/redfin")
167166
else:
168167
log.info("dtbo not fully supported on MacOS, skip testing")
169168
# Issue 83: init_boot

src/integrationTest/resources_2

Submodule resources_2 updated from 03c9b42 to be8c5a2

0 commit comments

Comments
 (0)