From: Petr Hodina <[email protected]>

The existing SAVE_PREV_BL_FDT_ADDR / SAVE_PREV_BL_INITRAMFS_START_ADDR
options surface the chained FDT base and an initramfs pointer in env,
but the kernel command-line ABL had already prepared in
/chosen/bootargs is silently dropped the moment U-Boot starts.

Signed-off-by: Petr Hodina <[email protected]>
---
 arch/arm/lib/save_prev_bl_data.c | 15 ++++++++++++++-
 boot/Kconfig                     |  8 ++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/save_prev_bl_data.c b/arch/arm/lib/save_prev_bl_data.c
index 4357acaef6c..5ad607a6251 100644
--- a/arch/arm/lib/save_prev_bl_data.c
+++ b/arch/arm/lib/save_prev_bl_data.c
@@ -66,7 +66,9 @@ int save_prev_bl_data(void)
 
        if (IS_ENABLED(CONFIG_SAVE_PREV_BL_FDT_ADDR))
                env_set_addr("prevbl_fdt_addr", (void *)reg0);
-       if (!IS_ENABLED(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR))
+
+       if (!IS_ENABLED(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) &&
+           !IS_ENABLED(CONFIG_SAVE_PREV_BL_BOOTARGS))
                return 0;
 
        node = fdt_path_offset(fdt_blob, "/chosen");
@@ -75,6 +77,17 @@ int save_prev_bl_data(void)
                                        __func__, reg0);
                return -ENODATA;
        }
+
+       if (IS_ENABLED(CONFIG_SAVE_PREV_BL_BOOTARGS)) {
+               const char *bootargs = fdt_getprop(fdt_blob, node, "bootargs",
+                                                  NULL);
+
+               if (bootargs && *bootargs)
+                       env_set("bootargs", bootargs);
+       }
+
+       if (!IS_ENABLED(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR))
+               return 0;
        /*
         * linux,initrd-start property might be either 64 or 32 bit,
         * depending on primary bootloader implementation.
diff --git a/boot/Kconfig b/boot/Kconfig
index ae6f09a6ede..92ecc89e06f 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -2036,6 +2036,14 @@ config SAVE_PREV_BL_INITRAMFS_START_ADDR
          If no initramfs was provided by previous bootloader, no env variables
          will be created.
 
+config SAVE_PREV_BL_BOOTARGS
+       depends on ARM
+       bool "Save /chosen/bootargs from the previous bootloader's FDT into 
$bootargs"
+       help
+         When u-boot is chain-loaded from a primary bootloader that already
+         populated /chosen/bootargs in the device tree it handed off (Android
+         ABL) copy that string into U-Boot's bootargs environment variable.
+
 menu "Configuration editor"
 
 config CEDIT

-- 
2.55.0


Reply via email to