[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ImageBuilder] Make DEVICE_TREE optional parameter


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Thu, 7 Aug 2025 16:46:14 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5uxN93jMk7+Z4rEDJjTVZeidtGtjL4eNpluKhEjyj30=; b=ApjKnzVQmUjvPKIjDIPVocfM/IT/ZONBY9DhwYPSlbo6N2DzkIX5KIWuI88LQwbflSK0HU7jGFLW0lUmlHjAEax9g0fewBQS6+lPMDi6bZW9I7UJtSxLbIbsiV1TAtE54EsI/lYJ6IQeeaFtKg7d/8PGKy1Yyw07hUCVKbsW4YakQoJkjEhW2iRX4dOAwtztJrXpzE7Au3st+e8cF3eo0SZyAJWa7JwBEr3uvQDM+AtL5yB2GxErSAuIsqs8NkgR48j2WYk6K8c9ctdb++Kvglcm0Rat2/JM+T+uOdanTI90r40XApRYWdpywbg1xiDTfrakuCID1VHyhASta8fpdQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XnywDfJ0dsy+T66+K6LZC02TYMRbbQD5KlusqjC4ts45can3t3O98u3FtUJpTzhxhFoNmen2xYc+0Dvu10QiPzIW7/uaJTWwn8UWvWNKzK6ZfAg3/DhFKVQHSr7hZ5DRJfvzkLkQzBg4jQFKRbTU8CN9Lt/FDtVwuwzoRyNDGXFc9DjY1CXxA2dYOIssPFTCvZmC+6WXxA9yKDO6R6bQ9j0+94g955On3bbO5qwUH26Ndh+L4LsavsBYNlepaLrO2nG9ntvGA5u0P07bm0WC5OtMaWhavR09h6fBeHgGyWrrA4Ou1geUBS9F3M42/k0xY/YIeNjzSbd/M2V6197xIA==
  • Cc: <sstabellini@xxxxxxxxxx>, <michal.orzel@xxxxxxx>, <andrei.cherechesu@xxxxxxx>, <dmukhin@xxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Delivery-date: Thu, 07 Aug 2025 15:46:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

There are systems where device tree binary is passed by the U-Boot as
$fdtcontroladdr. In such cases, no external device tree binary is provided
during uboot script generation.

This is an enhancement on top of the following commit:-
uboot-script-gen: Dynamically compute addr and size when loading bina…

When DEVICE_TREE is not present, $CALC is set as the addresses and sizes should
be computed dynamically from U-Boot.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
 README.md                |  3 ++-
 scripts/uboot-script-gen | 26 +++++++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 4be6efb..d80bdc9 100644
--- a/README.md
+++ b/README.md
@@ -90,7 +90,8 @@ Where:
   DTB are stored in 'host_kernel_addr' and 'host_fdt_addr' u-boot
   env variables respectively, to be used manually when booting.
 
-- DEVICE_TREE specifies the DTB file to load.
+- DEVICE_TREE specifies the DTB file to load. If not set, then $fdtcontroladdr
+  is used as the address of the DTB loaded by u-boot.
 
 - XEN specifies the Xen hypervisor binary to load. Note that it has to
   be a regular Xen binary, not a u-boot binary.
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index fed53aa..9fe4a55 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -560,7 +560,7 @@ function device_tree_editing()
     if test $UBOOT_SOURCE
     then
         if test "$CALC"; then
-            echo "fdt addr \${host_fdt_addr}" >> $UBOOT_SOURCE
+            echo "fdt addr \${fdtcontroladdr}" >> $UBOOT_SOURCE
         else
             echo "fdt addr $device_tree_addr" >> $UBOOT_SOURCE
         fi
@@ -591,7 +591,7 @@ function device_tree_editing()
 
 function fill_reserved_spaces_from_dtb()
 {
-    if [ ! -f $DEVICE_TREE ]
+    if test ! -f $DEVICE_TREE || test -z ${DEVICE_TREE+x}
     then
         if test "$CALC"; then
             return
@@ -1502,6 +1502,11 @@ check_depends
 declare -A DOMU_VCPU_HARD_AFFINITY
 source "$cfg_file"
 
+if test -z ${DEVICE_TREE+x}
+then
+    CALC=y
+fi
+
 SCRIPT_PATH=$(dirname "$0")
 source "$SCRIPT_PATH/common"
 source "$SCRIPT_PATH/xen_dt_domu"
@@ -1703,9 +1708,13 @@ then
     done
 fi
 
-check_file_type $DEVICE_TREE "Device Tree Blob"
-device_tree_addr=$memaddr
-load_file $DEVICE_TREE "host_fdt" "$XEN_LOAD"
+if test ${DEVICE_TREE+x}
+then
+    check_file_type $DEVICE_TREE "Device Tree Blob"
+    device_tree_addr=$memaddr
+    load_file $DEVICE_TREE "host_fdt" "$XEN_LOAD"
+fi
+
 bitstream_load_and_config  # bitstream is loaded last but used first
 device_tree_editing $device_tree_addr
 
@@ -1727,14 +1736,17 @@ fi
 if [ "$BOOT_CMD" != "none" ]
 then
     if test "$CALC"; then
-        echo "$BOOT_CMD \${host_kernel_addr} $([ "$BOOT_CMD" = "bootefi" ] || 
echo '-') \${host_fdt_addr}" >> $UBOOT_SOURCE
+        echo "$BOOT_CMD \${host_kernel_addr} $([ "$BOOT_CMD" = "bootefi" ] || 
echo '-') \${fdtcontroladdr}" >> $UBOOT_SOURCE
     else
         echo "$BOOT_CMD $kernel_addr $([ "$BOOT_CMD" = "bootefi" ] || echo 
'-') $device_tree_addr" >> $UBOOT_SOURCE
     fi
 else
     # skip boot command but store load addresses to be used later
     echo "setenv host_kernel_addr $kernel_addr" >> $UBOOT_SOURCE
-    echo "setenv host_fdt_addr $device_tree_addr" >> $UBOOT_SOURCE
+    if test ${DEVICE_TREE+x}
+    then
+        echo "setenv host_fdt_addr $device_tree_addr" >> $UBOOT_SOURCE
+    fi
 fi
 
 if test "$FIT"
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.