QCDT

From postmarketOS
(Redirected from Deviceinfo bootimg qcdt)

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 and package the /boot/dt.img (look at other QCDT devices to see how it's done, grep for qcdt in aports)

Examples

Note For all SoC vendors: add install -Dm644 "$_outdir/arch/$_carch/boot/"dt.img "$pkgdir"/boot/dt.img in package()

Qualcomm

  • Add dtbtool to makedepends of linux-* package
  • Add dtbTool -s 2048 -p "scripts/dtc/" -o "$_outdir/arch/$_carch/boot"/dt.img "$_outdir/arch/$_carch/boot/" in build()

Spreadtrum

  • Add dtbtool-sprd to makedepends of linux-* package
  • Add dtbTool-sprd -s 2048 -p "scripts/dtc/" -o "$_outdir/arch/$_carch/boot"/dt.img "$_outdir/arch/$_carch/boot/dts/" in build()

Exynos

  • Add dtbtool-exynos to makedepends of linux-* package
  • Add
dtbTool-exynos --pagesize 2048 \
	--platform 0x50a6 \
	--subtype  0x217584da \
	-o "$_outdir/arch/$_carch/boot/dt.img" \
	"$_outdir/arch/$_carch/boot/dts/exynos8890-herolte_eur_open_04.dtb" \ # list of device tree binaries
	"$_outdir/arch/$_carch/boot/dts/exynos8890-herolte_eur_open_08.dtb" \ # adjust filenames to ones related to your device
	"$_outdir/arch/$_carch/boot/dts/exynos8890-herolte_eur_open_09.dtb"

in build()

Note Note: At least one Samsung device with a MediaTek SoC also needs dtbTool-exynos.

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.)

Compare the appended dtb files

$ pmbootstrap install
$ pmbootstrap chroot -r -- mkdir -p /tmp/extract-dtb-known-working
$ sudo cp known_working_boot.img ~/.local/var/pmbootstrap/chroot_rootfs_*/tmp/extract-dtb-known-working/boot.img
$ pmbootstrap chroot -r
# apk add extract-dtb
# mkdir -p /tmp/extract-dtb-pmOS
# ls /boot/
# cp /boot/boot.img-* /tmp/extract-dtb-pmOS/boot.img
# cd /tmp/extract-dtb-pmOS
# extract-dtb boot.img
# cd /tmp/extract-dtb-known-working
# extract-dtb boot.img
Now compare the output in both temp folders.
Is there the same amount of dtb files, and are the files the same?
If not, then the QCDT generation went wrong.

Repack procedure

Note Please update these instructions when trying them out as they seem outdated, check the --help pages of the tools for help.

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

$ sudo mkdir -p ~/.local/var/pmbootstrap/chroot_native/tmp/bootimg_repack
$ sudo cp pmos-boot.img ~/.local/var/pmbootstrap/chroot_native/tmp/bootimg_repack/
$ sudo cp other-.img ~/.local/var/pmbootstrap/chroot_native/tmp/bootimg_repack/
$ pmbootstrap chroot --add=mkbootimg-osm0sis
# cd /tmp/bootimg_repack
# unpackbootimg -i pmos-boot.img -o pmos
# unpackbootimg -i other-boot.img -o other
$ cp other/boot.img-dt pmos/boot.img-$vendor-$name-dt
$ mkbootimg-osm0sis -o boot.repack.img -r pmos/boot.img-$vendor-$name-

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

abootimg is packaged for postmarketOS as well, which allows to repackage the boot.img files without extracting them.

See also