aboutsummaryrefslogtreecommitdiff
path: root/scripts/uboot-script-gen
diff options
context:
space:
mode:
authorAyan Kumar Halder2021-12-17 15:48:55 +0000
committerStefano Stabellini2021-12-17 15:21:49 -0800
commit7379d0b05b11519ecbe586017939ed1b0a6871c4 (patch)
treec0c39b7f4789beb88e7de320d2546ebb8a58e18b /scripts/uboot-script-gen
parentdd6fdb71a5bdde8022f03cc9fd42e47cf762fa66 (diff)
Refactor uboot-script-gen
Extract some of the functions from uboot-script-gen into common. This will be sourced by disk_image(in subsequent patch) which will invoke the functions for generating dtb. common will have access to all the environment variables defined in the Imagebuilder config file as described in README.md Signed-off-by: Ayan Kumar Halder <ayankuma@xilinx.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Diffstat (limited to 'scripts/uboot-script-gen')
-rwxr-xr-xscripts/uboot-script-gen157
1 files changed, 3 insertions, 154 deletions
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index f511c7f..967cf6d 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -3,161 +3,7 @@
offset=$((2*1024*1024))
filesize=0
prog_req=(mkimage file fdtput mktemp awk)
-tmp_files=()
-tmp_dirs=()
-function remove_tmp_files()
-{
- for i in "${tmp_files[@]}"
- do
- rm -r "$i"
- done
-
- for i in "${tmp_dirs[@]}"
- do
- rm -rf "$i"
- done
-}
-
-function sanity_check_partial_dts()
-{
- local domU_passthrough_path="$1"
- local repo="$2"
- local dir="$3"
- local address_cells_val
- local size_cells_val
- local tmpdtb
- local val
- local file
-
- for devpath in $domU_passthrough_path
- do
- file=${devpath##*/}
- file="$repo"/"$dir"/"$file".dts
-
- if ! test -f "$file"
- then
- echo "Device tree \"$file\" is not present"
- cleanup_and_return_err
- fi
-
- tmpdtb=`mktemp`
- dtc -I dts -O dtb -o $tmpdtb "$file"
- tmp_files+=($tmpdtb)
-
- val=$(fdtget $tmpdtb /passthrough \#address-cells)
- if test -z "$address_cells_val"
- then
- address_cells_val="$val"
- else
- if test "$address_cells_val" -ne "$val"
- then
- echo "Address cells mismatch for ${DOMU_PASSTHROUGH_PATHS[$i]}"
- cleanup_and_return_err
- fi
- fi
-
- val=$(fdtget $tmpdtb /passthrough \#size-cells)
- if test -z "$size_cells_val"
- then
- size_cells_val="$val"
- else
- if test "$size_cells_val" -ne "$val"
- then
- echo "Size cells mismatch for ${DOMU_PASSTHROUGH_PATHS[$i]}"
- cleanup_and_return_err
- fi
- fi
- done
-}
-
-function compile_merge_partial_dts()
-{
- local repo=$(echo "$1" | awk '{print $1}')
- local dir=$(echo "$1" | awk '{print $2}')
- local tmp
- local tmp_dtb_dir
-
- if [[ "$repo" =~ .*@.*:.* ]]
- then
- tmp=`mktemp -d`
- tmp_dirs+=($tmp)
-
- echo "Cloning git repo \"$git_repo\""
- git clone "$repo" $tmp
- if [ $? -ne 0 ]
- then
- echo "Error occurred while cloning \"$git_repo\""
- cleanup_and_return_err
- fi
-
- repo=$tmp
- fi
-
- tmp_dtb_dir=`mktemp -d "partial-dtbs-XXX"`
-
- if test -z "$dir"
- then
- dir="."
- fi
-
- i=0
- while test $i -lt $NUM_DOMUS
- do
- if test -z "${DOMU_PASSTHROUGH_PATHS[$i]}"
- then
- echo "DOMU_PASSTHROUGH_PATHS[$i] is not defined"
- cleanup_and_return_err
- fi
-
- sanity_check_partial_dts "${DOMU_PASSTHROUGH_PATHS[$i]}" "$repo" "$dir"
-
- tmp=`mktemp "$tmp_dtb_dir/partial-dts-domU$i-XXX"`
- tmp_files+=($tmp)
-
- j=1
-
- for devpath in ${DOMU_PASSTHROUGH_PATHS[$i]}
- do
- file=${devpath##*/}
- file="$repo"/"$dir"/"$file".dts
-
- echo "/include/ \"$file\"" >> "$tmp"
-
- # All the subsequent dts files should not have dts version mentioned
- if [ $j -gt 1 ]
- then
- sed -i '/\/dts-v/d' "$file"
- fi
-
- j=$(( $j + 1 ))
- done
-
- dtc -I dts -O dtb -o "$tmp".dtb "$tmp"
- if [ $? -ne 0 ]
- then
- echo "Could not compile \"$tmp\""
- cleanup_and_return_err
- fi
-
- if test "${DOMU_PASSTHROUGH_DTB[$i]}"
- then
- echo "Can't set both PASSTHROUGH_DTS_REPO and DOMU_PASSTHROUGH_DTB"
- cleanup_and_return_err
- fi
-
- DOMU_PASSTHROUGH_DTB[$i]="$tmp".dtb
-
- i=$(( $i + 1 ))
- done
-}
-
-function cleanup_and_return_err()
-{
- rm -f $UBOOT_SOURCE $UBOOT_SCRIPT
- remove_tmp_files
- exit 1
-}
function dt_mknode()
{
@@ -940,6 +786,9 @@ check_depends
source "$cfg_file"
+SCRIPT_PATH=$(dirname "$0")
+source "$SCRIPT_PATH/common"
+
# command line overrides
LOAD_CMD=${load_opt:-$LOAD_CMD}
EFI=${efi_opt:-$EFI}