From 4fc035694cdd5b57e73c148654d3cb991ecf9014 Mon Sep 17 00:00:00 2001 From: Brian Woods Date: Mon, 19 Jul 2021 15:28:28 -0700 Subject: Add support for device tree overlays Device tree overlaps support in u-boot means that adding overlay support at boot time is easy. Simply loading the files via tftp/scsi/fit etc and then applying the overlays before the normal imagebuilder fdt edits at boot time allows for applying overlays without changing the device tree files. Signed-off-by: Brian Woods Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- scripts/uboot-script-gen | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index 2fad339..de7f00f 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -111,6 +111,16 @@ function device_tree_editing() then echo "fdt addr $device_tree_addr" >> $UBOOT_SOURCE echo "fdt resize 1024" >> $UBOOT_SOURCE + + if test $NUM_DT_OVERLAY && test $NUM_DT_OVERLAY -gt 0 + then + i=0 + while test $i -lt $NUM_DT_OVERLAY + do + echo "fdt apply ${dt_overlay_addr[$i]}" >> $UBOOT_SOURCE + i=$(( $i + 1 )) + done + fi fi dt_set "/chosen" "\#address-cells" "hex" "0x2" dt_set "/chosen" "\#size-cells" "hex" "0x2" @@ -515,6 +525,23 @@ do i=$(( $i + 1 )) done +if test $NUM_DT_OVERLAY && test $NUM_DT_OVERLAY -gt 0 +then + i=0 + while test $i -lt $NUM_DT_OVERLAY + do + if [ ! -f "${DT_OVERLAY[$i]}" ] + then + echo "Can not find ${DT_OVERLAY[$i]}, exiting" + cleanup_and_return_err + fi + check_file_type "${DT_OVERLAY[$i]}" "Device Tree Blob" + dt_overlay_addr[$i]=$memaddr + load_file "${DT_OVERLAY[$i]}" "host_fdto${i}" + i=$(( $i + 1 )) + done +fi + check_file_type $DEVICE_TREE "Device Tree Blob" device_tree_addr=$memaddr load_file $DEVICE_TREE "host_fdt" @@ -642,6 +669,28 @@ then fi i=$(( $i + 1 )) done + fdt_line="fdt = \"host_fdt\"" + if test $NUM_DT_OVERLAY && test $NUM_DT_OVERLAY -gt 0 + then + i=0 + while test $i -lt $NUM_DT_OVERLAY + do + cat >> "$its_file" <<- EOF + host_fdto${i} { + description = "host fdt overlay ${i}"; + data = /incbin/("${DT_OVERLAY[$i]}"); + type = "flat_dt"; + arch = "arm64"; + compression = "none"; + load = <${dt_overlay_addr[$i]}>; + $fit_algo + }; + EOF + fdt_line+=", \"host_fdto${i}\"" + i=$(( $i + 1 )) + done + fi + fdt_line+=";" # script for fit if test "$LOAD_CMD" = "imxtract" then @@ -666,7 +715,7 @@ then config { description = "Xen"; kernel = "host_xen"; - fdt = "host_fdt"; + $fdt_line loadables = $load_files; }; }; -- cgit v1.2.3