Skip to contentSkip to conversation

Fix device tree node naming

ImageBuilder Michal Orzel 3 participants 3 messages Oct 21, 2024

lore
Share & tools
lore
#0 lore raw

A device tree node is named as follows: node-name@unit-address. The unit-address must match the first address specified in the reg property or be omitted if there's no reg property.

Fix the following issues:
1) domU modules are named as: node-name0xunit-address. Fix the naming to follow the device tree spec.
2) dom0 kernel and ramdisk, despite having the reg property do not have unit addresses specified. Fix it.

---
 scripts/uboot-script-gen | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
scripts/uboot-script-gen +23 -16
index f8a087b881ce..f10e5f4a49bf 100755
@@ -106,11 +106,12 @@ function add_device_tree_kernel()
     local addr=$2
     local size=$3
     local bootargs=$4
+    local node_name="module@${addr#0x}"
 
-    dt_mknode "$path" "module$addr"
-    dt_set "$path/module$addr" "compatible" "str_a" "multiboot,kernel multiboot,module"
-    dt_set "$path/module$addr" "reg" "hex"  "$(split_addr_size $addr $size)"
-    dt_set "$path/module$addr" "bootargs" "str" "$bootargs"
+    dt_mknode "$path" "$node_name"
+    dt_set "$path/$node_name" "compatible" "str_a" "multiboot,kernel multiboot,module"
+    dt_set "$path/$node_name" "reg" "hex"  "$(split_addr_size $addr $size)"
+    dt_set "$path/$node_name" "bootargs" "str" "$bootargs"
 }
 
 
@@ -119,10 +120,11 @@ function add_device_tree_ramdisk()
     local path=$1
     local addr=$2
     local size=$3
+    local node_name="module@${addr#0x}"
 
-    dt_mknode "$path"  "module$addr"
-    dt_set "$path/module$addr" "compatible" "str_a" "multiboot,ramdisk multiboot,module"
-    dt_set "$path/module$addr" "reg" "hex"  "$(split_addr_size $addr $size)"
+    dt_mknode "$path"  "$node_name"
+    dt_set "$path/$node_name" "compatible" "str_a" "multiboot,ramdisk multiboot,module"
+    dt_set "$path/$node_name" "reg" "hex"  "$(split_addr_size $addr $size)"
 }
 
 
@@ -131,10 +133,11 @@ function add_device_tree_passthrough()
     local path=$1
     local addr=$2
     local size=$3
+    local node_name="module@${addr#0x}"
 
-    dt_mknode "$path"  "module$addr"
-    dt_set "$path/module$addr" "compatible" "str_a" "multiboot,device-tree multiboot,module"
-    dt_set "$path/module$addr" "reg" "hex"  "$(split_addr_size $addr $size)"
+    dt_mknode "$path"  "$node_name"
+    dt_set "$path/$node_name" "compatible" "str_a" "multiboot,device-tree multiboot,module"
+    dt_set "$path/$node_name" "reg" "hex"  "$(split_addr_size $addr $size)"
 }
 
 function add_device_tree_mem()
@@ -314,17 +317,21 @@ function xen_device_tree_editing()
 
     if test "$DOM0_KERNEL"
     then
-        dt_mknode "/chosen" "dom0"
-        dt_set "/chosen/dom0" "compatible" "str_a" "xen,linux-zimage xen,multiboot-module multiboot,module"
-        dt_set "/chosen/dom0" "reg" "hex" "$(split_addr_size $dom0_kernel_addr $dom0_kernel_size)"
+        local node_name="dom0@${dom0_kernel_addr#0x}"
+
+        dt_mknode "/chosen" "$node_name"
+        dt_set "/chosen/$node_name" "compatible" "str_a" "xen,linux-zimage xen,multiboot-module multiboot,module"
+        dt_set "/chosen/$node_name" "reg" "hex" "$(split_addr_size $dom0_kernel_addr $dom0_kernel_size)"
         dt_set "/chosen" "xen,dom0-bootargs" "str" "$DOM0_CMD"
     fi
 
     if test "$DOM0_RAMDISK" && test $ramdisk_addr != "-"
     then
-        dt_mknode "/chosen" "dom0-ramdisk"
-        dt_set "/chosen/dom0-ramdisk" "compatible" "str_a" "xen,linux-initrd xen,multiboot-module multiboot,module"
-        dt_set "/chosen/dom0-ramdisk" "reg" "hex" "$(split_addr_size $ramdisk_addr $ramdisk_size)"
+        local node_name="dom0-ramdisk@${ramdisk_addr#0x}"
+
+        dt_mknode "/chosen" "$node_name"
+        dt_set "/chosen/$node_name" "compatible" "str_a" "xen,linux-initrd xen,multiboot-module multiboot,module"
+        dt_set "/chosen/$node_name" "reg" "hex" "$(split_addr_size $ramdisk_addr $ramdisk_size)"
     fi
 
     i=0
Signature · 1 line
2.25.1
Reviewed-by
#1 lore raw
Quoted 11 lines · Michal Orzel

A device tree node is named as follows: node-name@unit-address. The unit-address must match the first address specified in the reg property or be omitted if there's no reg property.

Fix the following issues:
1) domU modules are named as: node-name0xunit-address. Fix the naming to follow the device tree spec.
2) dom0 kernel and ramdisk, despite having the reg property do not have unit addresses specified. Fix it.

#2 lore raw
Quoted 11 lines · Jason Andryuk
Quoted 10 lines · Michal Orzel

A device tree node is named as follows: node-name@unit-address. The unit-address must match the first address specified in the reg property or be omitted if there's no reg property.

Fix the following issues:
1) domU modules are named as: node-name0xunit-address. Fix the naming to follow the device tree spec.
2) dom0 kernel and ramdisk, despite having the reg property do not have unit addresses specified. Fix it.

Quoted 3 lines
Quoted 1 line