From 232aa4cf51234218c3bb9b01e2b874513677daa8 Mon Sep 17 00:00:00 2001 From: Michal Orzel Date: Tue, 13 Sep 2022 14:09:18 +0200 Subject: Add support for lopper to generate partial dts Currently ImageBuilder can compile and merge partial dts obtained from a repository specified using PASSTHROUGH_DTS_REPO. With the recent changes done in the lopper, we can use it to generate partial dts automatically (to some extent as this is still an early support). Introduce LOPPER_PATH option to specify a path to a lopper.py script, the main script in the Lopper repository, that if set, will invoke lopper to generate partial dts for the passthrough devices specified in DOMU_PASSTHROUGH_PATHS. Introduce LOPPER_CMD option to specify custom command line arguments (if needed) for lopper's extract assist. Example usage: LOPPER_PATH="/home/user/lopper/lopper.py" DOMU_PASSTHROUGH_PATHS[0]="/axi/spi@ff0f0000 /axi/serial@ff010000" Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini --- scripts/common | 77 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 18 deletions(-) (limited to 'scripts/common') diff --git a/scripts/common b/scripts/common index ccad03d..2dd98fb 100644 --- a/scripts/common +++ b/scripts/common @@ -9,6 +9,9 @@ # - NUM_DOMUS # - DOMU_PASSTHROUGH_PATHS # - DOMU_PASSTHROUGH_DTB +# - LOPPER_PATH +# - LOPPER_CMD +# - DEVICE_TREE tmp_files=() tmp_dirs=() @@ -99,31 +102,41 @@ function compile_merge_partial_dts() local tmp local tmpdts local file + local node local i local j - if [[ "$repo" =~ .*@.*:.* ]] + if test "$repo" then - tmp=`mktemp -d` - tmp_dirs+=($tmp) - - echo "Cloning git repo \"$git_repo\"" - git clone "$repo" $tmp - if test $? -ne 0 + # Partial dts will be obtained from PASSTHROUGH_DTS_REPO + if [[ "$repo" =~ .*@.*:.* ]] then - echo "Error occurred while cloning \"$git_repo\"" - return 1 - fi + tmp=`mktemp -d` + tmp_dirs+=($tmp) - repo=$tmp - fi + echo "Cloning git repo \"$git_repo\"" + git clone "$repo" $tmp + if test $? -ne 0 + then + echo "Error occurred while cloning \"$git_repo\"" + return 1 + fi - if test -z "$dir" - then - dir="." + repo=$tmp + fi + + if test -z "$dir" + then + dir="." + fi + partial_dts_dir="$repo"/"$dir" + else + # Partial dts will be generated by the lopper + tmp=`mktemp -d` + tmp_dirs+=($tmp) + partial_dts_dir="$tmp" fi - partial_dts_dir="$repo"/"$dir" i=0 while test $i -lt $NUM_DOMUS do @@ -133,6 +146,34 @@ function compile_merge_partial_dts() return 1 fi + if test -z "$repo" + then + # Generate partial dts using lopper + for devpath in ${DOMU_PASSTHROUGH_PATHS[$i]} + do + node=${devpath##*/} + file="$partial_dts_dir"/"$node".dts + + # Execute lopper with the following assists: + # - extract: used to take the target node, extract it from the + # system device tree, chase the phandle references and place + # it in a new extracted tree structure, + # - extract-xen: used to perform Xen specific modifications + # on the extracted tree structure e.g. adding "xen,path", + # "xen,reg", interrupt-parent properties. + # For additional information, please see the lopper's README + # file as well as usage of the mentioned assists. + $LOPPER_PATH --permissive -f $DEVICE_TREE \ + -- extract -t $devpath $LOPPER_CMD \ + -- extract-xen -t $node -o $file + + if test $? -ne 0 + then + return 1 + fi + done + fi + sanity_check_partial_dts "${DOMU_PASSTHROUGH_PATHS[$i]}" "$partial_dts_dir" if test $? -ne 0 then @@ -146,8 +187,8 @@ function compile_merge_partial_dts() for devpath in ${DOMU_PASSTHROUGH_PATHS[$i]} do - file=${devpath##*/} - file="$partial_dts_dir"/"$file".dts + node=${devpath##*/} + file="$partial_dts_dir"/"$node".dts # All the subsequent dts files should not have dts version mentioned if test $j -gt 1 -- cgit v1.2.3