diff mbox series

[ImageBuilder,v3,3/3] uboot-script-gen: Enable not adding boot command to script

Message ID 20220713163044.3541661-4-andrei.cherechesu@oss.nxp.com (mailing list archive)
State New, archived
Headers show
Series Add extra ImageBuilder features | expand

Commit Message

Andrei Cherechesu July 13, 2022, 4:30 p.m. UTC
From: Andrei Cherechesu <andrei.cherechesu@nxp.com>

If the "BOOT_CMD" variable is set to "none" inside the config
file, the boot command (i.e. "booti") will not by added to the
generated script, to allow the user to customize the u-boot env
or the device-tree after executing the script commands and before
actually booting.

Added commands to store the addresses where the Xen image and
device-tree file are loaded, in 'host_kernel_addr' and 'host_fdt_addr'
variables, if BOOTCMD = "none".

The `booti` command can then be executed as part of the 'bootcmd' variable
in u-boot, which should contain:
	1. fetching the generated u-boot script
	2. executing the script
	3. running `booti ${host_kernel_addr} - ${host_fdt_addr}` command

Signed-off-by: Andrei Cherechesu <andrei.cherechesu@nxp.com>
---
 README.md                |  5 ++++-
 scripts/uboot-script-gen | 16 +++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

Comments

Stefano Stabellini July 27, 2022, 8:13 p.m. UTC | #1
On Wed, 13 Jul 2022, Andrei Cherechesu (OSS) wrote:
> From: Andrei Cherechesu <andrei.cherechesu@nxp.com>
> 
> If the "BOOT_CMD" variable is set to "none" inside the config
> file, the boot command (i.e. "booti") will not by added to the
> generated script, to allow the user to customize the u-boot env
> or the device-tree after executing the script commands and before
> actually booting.
> 
> Added commands to store the addresses where the Xen image and
> device-tree file are loaded, in 'host_kernel_addr' and 'host_fdt_addr'
> variables, if BOOTCMD = "none".
> 
> The `booti` command can then be executed as part of the 'bootcmd' variable
> in u-boot, which should contain:
> 	1. fetching the generated u-boot script
> 	2. executing the script
> 	3. running `booti ${host_kernel_addr} - ${host_fdt_addr}` command
> 
> Signed-off-by: Andrei Cherechesu <andrei.cherechesu@nxp.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Given that this patch is non-controversial, I committed it before patch
#1. The small part affecting the "$dynamic_loading_opt" case will need
rebasing.


> ---
>  README.md                |  5 ++++-
>  scripts/uboot-script-gen | 16 +++++++++++++---
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/README.md b/README.md
> index 3566a6d..07ad432 100644
> --- a/README.md
> +++ b/README.md
> @@ -81,7 +81,10 @@ Where:
>  
>  - BOOT_CMD specifies the u-boot command used to boot the binaries.
>    By default, it is 'booti'. The acceptable values are 'booti', 'bootm'
> -  and 'bootefi'.
> +  and 'bootefi' and 'none'. If the value is 'none', the BOOT_CMD is not
> +  added to the boot script, and the addresses for the Xen binary and the
> +  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.
>  
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index f72551a..6a8a2b8 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -966,7 +966,7 @@ function check_depends()
>  
>  function check_boot_cmd()
>  {
> -    if ! [[ " bootm booti bootefi " =~ " ${BOOT_CMD}" ]]
> +    if ! [[ " bootm booti bootefi none " =~ " ${BOOT_CMD}" ]]
>      then
>          echo "\"BOOT_CMD=$BOOT_CMD\" is not valid"
>          exit 1
> @@ -1251,9 +1251,19 @@ fi
>  
>  if test "$dynamic_loading_opt"
>  then
> -    echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE
> +    if [ "$BOOT_CMD" != "none" ]
> +    then
> +        echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE
> +    fi
>  else
> -    echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE
> +    if [ "$BOOT_CMD" != "none" ]
> +    then
> +        echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE
> +    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
> +    fi
>  fi
>  
>  if test "$FIT"
> -- 
> 2.35.1
>
diff mbox series

Patch

diff --git a/README.md b/README.md
index 3566a6d..07ad432 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,10 @@  Where:
 
 - BOOT_CMD specifies the u-boot command used to boot the binaries.
   By default, it is 'booti'. The acceptable values are 'booti', 'bootm'
-  and 'bootefi'.
+  and 'bootefi' and 'none'. If the value is 'none', the BOOT_CMD is not
+  added to the boot script, and the addresses for the Xen binary and the
+  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.
 
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index f72551a..6a8a2b8 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -966,7 +966,7 @@  function check_depends()
 
 function check_boot_cmd()
 {
-    if ! [[ " bootm booti bootefi " =~ " ${BOOT_CMD}" ]]
+    if ! [[ " bootm booti bootefi none " =~ " ${BOOT_CMD}" ]]
     then
         echo "\"BOOT_CMD=$BOOT_CMD\" is not valid"
         exit 1
@@ -1251,9 +1251,19 @@  fi
 
 if test "$dynamic_loading_opt"
 then
-    echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE
+    if [ "$BOOT_CMD" != "none" ]
+    then
+        echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE
+    fi
 else
-    echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE
+    if [ "$BOOT_CMD" != "none" ]
+    then
+        echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE
+    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
+    fi
 fi
 
 if test "$FIT"