Make DEVICE_TREE optional parameter
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.
--- README.md | 3 ++- scripts/uboot-script-gen | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-)
README.md +2 -1
@@ -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.
scripts/uboot-script-gen +19 -7
@@ -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"
Signature · 1 line
2.25.1
Quoted 9 lines · Ayan Kumar Halder
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_TREEis not present, $CALC is set as the addresses and sizes should be computed dynamically from U-Boot.
I would prefer if we did not automatically enable $CALC. If it doesn't work without $CALC enabled, we could add a check for it and print an error and exit. I would prefer that then enabling $CALC silently.
Also I don't think we should use the check ${DEVICE_TREE+x}. I'd prefer to stick with the existing checks based on test ${DEVICE_TREE}.
The rest looks OK.
It might be possible to simplify this patch down to this (untested). The last chunk of the diff is actually an unrelated fix, it looks like we didn't test BOOT_CMD="none" when the -s option was introduced.
What do you think?
scripts/uboot-script-gen +20 -5
@@ -1646,6 +1646,15 @@ if test "$FIT" then echo 'fit_addr=$fileaddr' >> $UBOOT_SOURCE fi +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 memaddr=$(( $MEMORY_START + $offset )) # 12582912 is 0xc00000, 12MB
@@ -1689,9 +1698,12 @@ 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
@@ -1719,8 +1731,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"
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Ayan Kumar Halder
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.
Quoted 8 lines
Quoted 5 lines
This is an enhancement on top of the following commit:-
uboot-script-gen: Dynamically compute addr and size when loading bina…When
DEVICE_TREEis not present, $CALC is set as the addresses and sizes should be computed dynamically from U-Boot.I would prefer if we did not automatically enable $CALC. If it doesn't work without $CALC enabled, we could add a check for it and print an error and exit. I would prefer that then enabling $CALC silently.
Ack
Quoted 3 lines
Also I don't think we should use the check ${DEVICE_TREE+x}. I'd prefer to stick with the existing checks based on test ${DEVICE_TREE}.
Ack
Quoted 8 lines
The rest looks OK.
It might be possible to simplify this patch down to this (untested). The last chunk of the diff is actually an unrelated fix, it looks like we didn't test BOOT_CMD="none" when the -s option was introduced.
What do you think?
Slightly changed the chunk. With that it works well.
I have sent "[ImageBuilder v2] Make DEVICE_TREE optional parameter" for review.
- Ayan