fix: boot a linux kernel as preloaded bl33 image

Fix the CI boot flow that incorrectly assumes a successful Linux
kernel boot when booting a preloaded kernel image.

To boot the kernel using initrd as a ram file system the kernel
requires the "initrd_start" and "initrd_end" properties in the
chosen node of the device tree. The "initrd_end" property can be
derived from the actual initrd file (using its size). The
"INITRD_PATH" build time variable will initiate the insertion of the
initrd properties in to the device tree. Additionally this variable
takes the location of an initrd file to determine its size.

Change-Id: Idd9b5f9e5f1142a8ed1b8901d6a7c0d095d4850a
Signed-off-by: Salman Nabi <salman.nabi@arm.com>
diff --git a/expect-lava/linux-bl33.exp b/expect-lava/linux-bl33.exp
index b7b1c23..949fea7 100644
--- a/expect-lava/linux-bl33.exp
+++ b/expect-lava/linux-bl33.exp
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2021 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2025 Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -19,3 +19,11 @@
 # 2. Command line passed via the "/chosen" node
 expect_string+=('i;Machine model: FVP Base')
 expect_string+=('i;Kernel command line: console=ttyAMA0')
+
+# Check if the injected initrd values are correct and working
+expect_string+=('i;Unpacking initramfs...')
+expect_string+=('i;Freeing initrd memory')
+
+# Check if linux booted successfully and we have access to the linux terminal
+expect_string+=('i;Freeing unused kernel memory')
+expect_string+=('i;/ # ')
diff --git a/expect/linux-bl33.exp b/expect/linux-bl33.exp
index 13a4d8c..5d94de3 100644
--- a/expect/linux-bl33.exp
+++ b/expect/linux-bl33.exp
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2021 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2025 Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -24,4 +24,12 @@
 expect_re "Machine model: FVP Base" "Linux successfully identified the machine model"
 expect_string "Kernel command line: console=ttyAMA0" "Linux received the correct command line"
 
+# Check if the injected initrd values are correct and working
+expect_string "Unpacking initramfs..." "Linux found the initrd values in the chosen node"
+expect_string "Freeing initrd memory" "Linux successfully unpacked the initrd"
+
+# Check if Linux booted successfully and we have access to the Linux terminal
+expect_string "Freeing unused kernel memory" "Linux kernel boot success"
+expect_string "/ # " "The user has access to the Linux terminal"
+
 exit_uart 0
diff --git a/group/tf-l2-boot-tests-misc/fvp-linux-as-bl33:fvp-linux.bl33-dtb-aemv8a.linux.bl33-debug b/group/tf-l2-boot-tests-misc/fvp-linux-as-bl33:fvp-linux.bl33-aemv8a.linux.bl33-debug
similarity index 100%
rename from group/tf-l2-boot-tests-misc/fvp-linux-as-bl33:fvp-linux.bl33-dtb-aemv8a.linux.bl33-debug
rename to group/tf-l2-boot-tests-misc/fvp-linux-as-bl33:fvp-linux.bl33-aemv8a.linux.bl33-debug
diff --git a/run_config/fvp-aemv8a.linux.bl33 b/run_config/fvp-aemv8a.linux.bl33
index d4a57d5..a568095 100644
--- a/run_config/fvp-aemv8a.linux.bl33
+++ b/run_config/fvp-aemv8a.linux.bl33
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2025, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -14,8 +14,8 @@
 	local model="base-aemv8a"
 
 	model="$model" \
-		dtb_addr="0x80070000" \
 		kernel_addr="0x80080000" \
+		initrd_addr="0x84000000" \
 		gen_model_params
 
 	model="$model" gen_fvp_yaml
diff --git a/run_config/fvp-linux.bl33 b/run_config/fvp-linux.bl33
index f023adc..449c5e5 100644
--- a/run_config/fvp-linux.bl33
+++ b/run_config/fvp-linux.bl33
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2025, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -9,6 +9,15 @@
 	image="kernel" type="fvp-busybox-uboot" get_boot_image
 }
 
+pre_tf_build() {
+	image="initrd" type="default" get_boot_image
+
+	# Remove u-boot header from the initrd and archive
+	dd if=$workspace/initrd.bin of=$workspace/nu.bin bs=64 skip=1 status="none"
+	mv $workspace/nu.bin $workspace/initrd.bin
+	archive_file "$workspace/initrd.bin"
+}
+
 generate_lava_job_template() {
 	uart="0" file="linux-bl33.exp" track_expect
 
diff --git a/tf_config/fvp-linux-as-bl33 b/tf_config/fvp-linux-as-bl33
index f61d1f5..3e52cba 100644
--- a/tf_config/fvp-linux-as-bl33
+++ b/tf_config/fvp-linux-as-bl33
@@ -1,5 +1,6 @@
-ARM_PRELOADED_DTB_BASE=0x80070000
 ARM_LINUX_KERNEL_AS_BL33=1
 CROSS_COMPILE=aarch64-none-elf-
 PLAT=fvp
 PRELOADED_BL33_BASE=0x80080000
+INITRD_PATH=${workspace}/initrd.bin
+INITRD_BASE=0x84000000