1 #!/bin/bash 2 3 if [ -z "${ANDROID_HOST_OUT}" ]; then 4 echo 'ANDROID_HOST_OUT not set. Please run lunch' 5 exit 1 6 fi 7 8 ANDROID_HOST_BIN_LOCATION=${ANDROID_HOST_OUT}/bin 9 10 adb root 11 12 tmpdir=$(mktemp -d) 13 trap 'rm -rf ${tmpdir};' EXIT 14 15 cd $tmpdir 16 17 #find out the location to read the DTBO image from 18 boot_suffix=$(adb wait-for-device shell getprop ro.boot.slot_suffix) 19 dtbo_partition="/dev/block/bootdevice/by-name/dtbo" 20 dtbo_path=$dtbo_partition$boot_suffix 21 22 #read the dtbo image and the final device tree from device 23 adb pull $dtbo_path dtbo.img > /dev/null 24 adb pull /sys/firmware/fdt final_dt > /dev/null 25 26 #decompile the DTBO image 27 mkdtimg_path="${ANDROID_HOST_BIN_LOCATION}/mkdtimg" 28 $mkdtimg_path dump dtbo.img -b dumped_dtbo > /dev/null 29 30 #Get the index of the overlay applied from the kernel command line 31 overlay_idx=$(adb shell cat /proc/cmdline | grep -o "androidboot.dtbo_idx=[^ ]*" | cut -d "=" -f 2) 32 arg="" 33 for idx in ${overlay_idx//,/ } 34 do 35 arg="${arg}dumped_dtbo.${idx} " 36 done 37 38 #verify that the overlay was correctly applied 39 verify_bin_path="${ANDROID_HOST_BIN_LOCATION}/ufdt_verify_overlay_host" 40 $verify_bin_path final_dt $arg 41 result=$? 42 43 if [[ "$result" -eq "0" ]]; then 44 echo "Overlay was verified successfully" 45 else 46 echo "Incorrect overlay application" 47 fi 48 49 exit $result 50 51