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