diff mbox series

[v2,2/6] common: spl: ram: Add LOAD_FIT_FULL support

Message ID 20260902-riscv-full-fit-support-v2-2-493e904a129e@maquefel.me
State Under Review
Delegated to: Tim Ouyang
Headers show
Series RISC-V SPL: fix OpenSBI FULL FIT loading | expand

Commit Message

Nikita Shubin Sept. 2, 2026, 6:31 a.m. UTC
The simple FIT loader lacks support for full image verification
(CONFIG_SPL_FIT_FULL_CHECK). The full parser (spl_load_fit_image)
provides this feature.

Enable it when CONFIG_SPL_LOAD_FIT_FULL is selected. If the full load
fails, fall back to the simple loader to preserve compatibility.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
 common/spl/spl_ram.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 0c501cf02f2..8f63a46373f 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -81,11 +81,22 @@  static int spl_ram_load_image(struct spl_image_info *spl_image,
 
 	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
 	    image_get_magic(header) == FDT_MAGIC) {
-		struct spl_load_info load;
-
 		debug("Found FIT\n");
-		spl_load_init(&load, spl_ram_load_read, NULL, 1);
-		ret = spl_load_simple_fit(spl_image, &load, 0, header);
+		/* by default, assume failure and fall back to simple FIT */
+		int ret = -1;
+
+		if (CONFIG_IS_ENABLED(LOAD_FIT_FULL)) {
+			ret = spl_load_fit_image(spl_image, header);
+			if (ret)
+				debug("Loading FULL FIT failed, trying SIMPLE FIT\n");
+		}
+
+		if (ret) {
+			struct spl_load_info load;
+
+			spl_load_init(&load, spl_ram_load_read, NULL, 1);
+			ret = spl_load_simple_fit(spl_image, &load, 0, header);
+		}
 	} else {
 		ulong u_boot_pos = spl_get_image_pos();