Jump to content

QCDT: Difference between revisions

From postmarketOS Wiki
link to dtbtool
Rewrite to make use of the device wizard and pmbootstrap bootimg_analyze
Line 1: Line 1:
The <code>mozilla-flame</code> and other devices have the [[Glossary#dtb|dtb]] appended to the [[Glossary#boot.img|boot.img]].<br />
Some Androids only accept [[Glossary#boot.img|boot.img]] files in the QCDT format, which means the [[Glossary#dtb|dtb]] is appended to the end of it (and not at the end of the kernel, as with most other Android devices).
To find out if your device boots <code>qcdt</code> <code>boot.img</code> files, run <code>extract-dtb</code> (packaged for pmOS) on a known-working <code>boot.img</code> (e.g. from TWRP or LineageOS).


'''Check PR [https://github.com/postmarketOS/pmbootstrap/pull/356/files #356] for example usage''' of how it is implemented right now, and [https://github.com/postmarketOS/pmbootstrap/issues/323 #323] for the related discussion. In case you are implementing this for another device, please edit this article and put it more in a step-by-step format.
== Does my device need a QCDT boot.img file? ==
Analyze a known working boot.img file with pmbootstrap to find out, if it has the QCDT format or not. You can get such a file from downloading a TWRP image (it is directly in the boot.img format!) or by downloading a full Android ROM for your device and extracting the boot.img file.
<syntaxhighlight lang="shell-session">
$ pmbootstrap bootimg_analyze /path/to/boot.img
</syntaxhighlight>


Some approaches that can help debug appended DTB issues:
If this prints <code>deviceinfo_bootimg_qcdt="true"</code>, then you have a QCDT device.


== Properly package a QCDT device ==
The easiest way is using <code>pmbootstrap init</code> to generate a new device, and let it analyze the boot.img file in the process. It will adjust the device and linux package as necessary. But if you want to do it manually:
* Set <code>deviceinfo_bootimg_qcdt="true"</code> in the [[deviceinfo]]
* Adjust your <code>linux-</code> APKBUILD to generate the <code>/boot/dt.img</code> (look at other QCDT devices to see how it's done, grep for qcdt in aports)
== Debugging ==
* Hook up the [[serial UART]] and see what kind of debug output the bootloader provides
* Hook up the [[serial UART]] and see what kind of debug output the bootloader provides
* Repack the boot image with a working <code>dt.img</code> from another distribution (stock, Lineage, recovery, etc.)
* Repack the boot image with a working <code>dt.img</code> from another distribution (stock, Lineage, recovery, etc.)


=== Repack Procedure ===
=== Repack procedure ===
You need <code>mkbootimg</code> and <code>unpackbootimg</code> tools which are already packaged in pmbootstrap.
You need <code>mkbootimg</code> and <code>unpackbootimg</code> tools which are already packaged in pmbootstrap.


<pre>$ ./pmbootstrap build mkbootimg unpackbootimg
<syntaxhighlight lang="shell-session">
$ ./pmbootstrap build mkbootimg unpackbootimg
$ ./unpackbootimg -i $SOMEDIR/boot.img-$vendor-$name -o pmos
$ ./unpackbootimg -i $SOMEDIR/boot.img-$vendor-$name -o pmos
$ ./unpackbootimg -i $OTHERDIR/boot.img -o other
$ ./unpackbootimg -i $OTHERDIR/boot.img -o other
$ cp other/boot.img-dt pmos/boot.img-$vendor-$name-dt
$ cp other/boot.img-dt pmos/boot.img-$vendor-$name-dt
$ ./mkbootimg -o boot.repack.img -r pmos/boot.img-$vendor-$name-</pre>
$ ./mkbootimg -o boot.repack.img -r pmos/boot.img-$vendor-$name-
</syntaxhighlight>
You can also get these from https://github.com/efidroid/build/tree/master/tools
You can also get these from https://github.com/efidroid/build/tree/master/tools


=== See also ===
== See also ==
* [[dtbtool]]
* [[dtbtool]]
* {{github|323}} related discussion
* {{github|356}} first implementation

Revision as of 00:54, 19 January 2018

Some Androids only accept boot.img files in the QCDT format, which means the dtb is appended to the end of it (and not at the end of the kernel, as with most other Android devices).

Does my device need a QCDT boot.img file?

Analyze a known working boot.img file with pmbootstrap to find out, if it has the QCDT format or not. You can get such a file from downloading a TWRP image (it is directly in the boot.img format!) or by downloading a full Android ROM for your device and extracting the boot.img file.

$ pmbootstrap bootimg_analyze /path/to/boot.img

If this prints deviceinfo_bootimg_qcdt="true", then you have a QCDT device.

Properly package a QCDT device

The easiest way is using pmbootstrap init to generate a new device, and let it analyze the boot.img file in the process. It will adjust the device and linux package as necessary. But if you want to do it manually:

  • Set deviceinfo_bootimg_qcdt="true" in the deviceinfo
  • Adjust your linux- APKBUILD to generate the /boot/dt.img (look at other QCDT devices to see how it's done, grep for qcdt in aports)

Debugging

  • Hook up the serial UART and see what kind of debug output the bootloader provides
  • Repack the boot image with a working dt.img from another distribution (stock, Lineage, recovery, etc.)

Repack procedure

You need mkbootimg and unpackbootimg tools which are already packaged in pmbootstrap.

$ ./pmbootstrap build mkbootimg unpackbootimg
$ ./unpackbootimg -i $SOMEDIR/boot.img-$vendor-$name -o pmos
$ ./unpackbootimg -i $OTHERDIR/boot.img -o other
$ cp other/boot.img-dt pmos/boot.img-$vendor-$name-dt
$ ./mkbootimg -o boot.repack.img -r pmos/boot.img-$vendor-$name-

You can also get these from https://github.com/efidroid/build/tree/master/tools

See also