July 31, 2015

How to extract a dts from an Android Phone

How to extract a dts from an Android Phone

1) Get its boot.img

    $ adb pull /dev/block/bootdevice/by-name/boot boot.img

2) Find out which dts is the device using

    $ adb logcat # the device's boot process, watch the first few lines.
   
3) split the boot.img in its components

    $ # wget http://www.enck.org/tools/split_bootimg_pl.txt -O split_bootimg.pl
    $ split_bootimg.pl boot.img
  
4) Look for the correct dtb on the boot image

    a) hexdump -C -v boot.img-dtb |less
    b) On this hexdump, search for "d0 0d fe ed"
    c) there are probably several occurrences, choose the one matching what the device is using (point (2))
    d) take note of the address where it is
   
5) convert the address from hex to binary

    $ # https://github.com/ARivottiC/aliases.sh has conversion aliases
    $ hex2dec address

6) extract the correct dtb from the bunch

    $ dd if=boot.img-dtb of=correct.dtb bs=the_result_from_5 skip=1

7) convert dtb to dts

    $ # look for dtc on the $OUT of an android build
    $ dtc -I dtb -O dts -o correct.dts correct.dtb