Skip to content
Snippets Groups Projects

[KERNEL][D18] Add new class to test devicetree overlay combinations during build

Open Jonas Höppner requested to merge d18-dtb-overlay-test into kirkstone
Files
3
+ 79
0
# Support to apply a given set of overlays directly after the build
# to detect errors before actually using the overlays on the device
#
# The overlays to test are described in the 'DEVICETREE_OVERLAY_COMBINATIONS'
# variable containing several lines in the format
# dtb:dtbo:dtbo:...
# where dtb and the dtbo may contain '*' or other patterns (interpreted by 'find').
# each overlay found for dtbo is applied to each dtb found with the dtb pattern.
# Results are not stored
DEPENDS += "dtc-native"
DEVICETREE_OVERLAY_COMBINATIONS ?= ""
do_kernel_devicetree_overlay_test() {
ret=0
dtb_base_path="${B}/arch/${ARCH}/boot/dts/"
OLDIFS="$IFS"
newline="
"
IFS="${newline}"
combinations=""
for c in ${DEVICETREE_OVERLAY_COMBINATIONS};
do
cnext="${c}"
cc=""
while [ -n "$cnext" ]; # Loop as long cnext is not empty
do
cthis="${cnext%%:*}" # 1st element, split by ':'
cnext="${cnext#"$cthis"}" # remove 1st element
cnext="${cnext#:}" # remove leading ':', if any
# Resolve to full path, let 'find' expand wildcards
fthis="$(find "$dtb_base_path" -path "*${cthis}")"
if [ -z "${fthis}" ];then
echo "Failed to find devicetrees for pattern: ${cthis}"
ret=1
continue
fi
ccp="$cc";
cc=""
for file in $fthis;do
# For debug remove the full path, this breaks the fdtoverlay step
# but gives better readable logs for debugging
# file="${file#"$dtb_base_path"}"
if [ -z "$ccp" ];then
cc="${cc}${file}${newline}"
else
for ccline in $ccp; do
# do not add file twice:
case "${ccline}" in *"${file}"*) continue; esac
# store a new combination
cc="${cc}${ccline} ${file}${newline}"
done
fi
done
done
combinations="${combinations}${cc}"
done
echo "Expanded devicetree overlay combinations:"
echo "$combinations"
set -x
for c in $combinations;do
IFS="$OLDIFS"
if ! fdtoverlay -v -i $c -o /dev/null
then
echo "Failed to apply overlay combination $c"
ret=1
fi
done
return $ret
}
addtask kernel_devicetree_overlay_test after do_compile before do_populate_sysroot
Loading