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

[ImageBuilder v2] Make DEVICE_TREE optional parameter


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Tue, 12 Aug 2025 18:33:50 +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=JHkduoHjGrrLbmr5Rlfx5Axcfh82wYY/BjtQ5rAPZAM=; b=MUiEtkRT0Aan6SRDcxerPrjjHMimC7lkgCLLLhgyG8v4BD5iZyUiN3Db/KOtBaHBjl67kGHVYor4TqWDFpN+RNXLq4qcjBMhPo4FF4R5o/DoFMKYpewrFn2wf5t3Yzqy9ZbZ1PFph6Tns8yqFXk9CXPu9tO9bwsikAxc+BTmK9jMrE3OajYubnH6K4JeLzMQ2Sq6G9zoemh1pZXlOEz9YzCz90SpzZdwb/lTtQ0GqZfAWer/xd1sA68WXOLEBjK20zmnY6S58S2lZu+//TWTovPeWyazAuU+DABrFDEy3oUbExVuV99dqgBqQAzWmJb1/PYccuFWSWgpUTcv/MV0vQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f6FSYr2v1A43zoC/GVccpTLejm0phoSB2/oxCPiVyLCgt02ZEpgeynYAt0B/UlbXUd7jKDTsq92ALAJOMZ/sIlBTyUP98LV4Zv1fWxSXTCYyTIb52aiIYrbZdE3cmfBaEB50tUwzqwmFiEiFZiyqRcveBbZLnaLRdpVkyrDSAQYLi4Syzx3hZUdz7vpSXLspL+9Y3tLV5wswKSOgZpaO+Hg11s5HpnXrmt/Lyita41LEO32e3GPNDW+3UtMChaparSswpRMX8sHO0eUzpPbZmLa7y7amWwFEUZcjfGD6iJ/27GAqRobHcMRTw1kxRPN4OuLGP4iT/vGuICcHnLU17g==
  • Cc: <sstabellini@xxxxxxxxxx>, <michal.orzel@xxxxxxx>, <andrei.cherechesu@xxxxxxx>, <dmukhin@xxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Delivery-date: Tue, 12 Aug 2025 17:34:19 +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, user should provide '-s' as the addresses and
sizes should be computed dynamically from U-Boot.

Also, fixed uboot-script-gen to set host_kernel_addr when BOOT_CMD="none" and
'-s' is not used.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
This patch should be applied after the previous patch.
"[ImageBuilder v2] Add config option to use separate load commands for..."

Changes from :-

v1 :- 1. Check that user provides '-s' when DEVICE_TREE is not set, instead of
setting CALC silently.

2. Set 'host_fdt_addr' to '\${fdtcontroladdr}' when DEVICE_TREE is not set.

3. Add a fix for BOOT_CMD="none".
 
 README.md                |  5 ++++-
 scripts/uboot-script-gen | 29 +++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 59919df..fc448e0 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,10 @@ 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. If user does not set this
+  option, then '-s' should be provided to ensure that addresses and sizes are
+  calculated dynamically by uboot.
 
 - 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 656de72..be61fc4 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -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"
     then
         if test "$CALC"; then
             return
@@ -1674,6 +1674,16 @@ fi
 
 rm -f $UBOOT_SOURCE $UBOOT_SCRIPT
 
+if test -z "$DEVICE_TREE"
+then
+    if test -z "$CALC"
+    then
+       echo "DEVICE_TREE is unset and -s is not specified"
+       exit 1
+    fi
+    echo "setenv host_fdt_addr \${fdtcontroladdr}" >> $UBOOT_SOURCE
+fi
+
 if test "$FIT"
 then
     echo 'fit_addr=$fileaddr' >>  $UBOOT_SOURCE
@@ -1721,9 +1731,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"
+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
 
@@ -1751,8 +1765,11 @@ then
     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 -z "$CALC"
+    then
+        echo "setenv host_kernel_addr $kernel_addr" >> $UBOOT_SOURCE
+        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®.