summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAnshul Dalal <[email protected]>2025-10-18 01:03:08 +0530
committerTom Rini <[email protected]>2025-10-20 10:14:00 -0600
commit81951cfffdc85e07ddeb2fa33a1a0fbbac6806f0 (patch)
tree9a52ee418a93ee6d305a9b0cb2b7264acb16f5e8 /common
parent2909b3bff076746938389b2ef320eea68c2b93db (diff)
spl: ubi: refactor spl_ubi_load_image for falcon mode
This patch moves the falcon mode handling logic out of spl_ubi_load_image to spl_ubi_load_image_os, this allows for cleaner handling for fallback to U-Boot in case falcon mode fails. Signed-off-by: Anshul Dalal <[email protected]>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_ubi.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index a8d3f43b452..4aecad3470c 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -11,6 +11,32 @@
#include <ubispl.h>
#include <spl.h>
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT)
+int spl_ubi_load_image_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
+ struct ubispl_info *info)
+{
+ struct legacy_img_hdr *header;
+ struct ubispl_load volumes[2];
+ int err;
+
+ volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID;
+ volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR;
+ volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID;
+ volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
+
+ err = ubispl_load_volumes(info, volumes, 2);
+ if (err)
+ return err;
+
+ header = (struct legacy_img_hdr *)volumes[0].load_addr;
+ spl_parse_image_header(spl_image, bootdev, header);
+ puts("Linux loaded.\n");
+
+ return 0;
+}
+#endif
+
int spl_ubi_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
@@ -46,21 +72,15 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
#if CONFIG_IS_ENABLED(OS_BOOT)
if (!spl_start_uboot()) {
- volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID;
- volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR;
- volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID;
- volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
+ ret = spl_ubi_load_image_os(spl_image, bootdev, &info);
+ if (!ret)
+ return 0;
- ret = ubispl_load_volumes(&info, volumes, 2);
- if (!ret) {
- header = (struct legacy_img_hdr *)volumes[0].load_addr;
- spl_parse_image_header(spl_image, bootdev, header);
- puts("Linux loaded.\n");
- goto out;
- }
- puts("Loading Linux failed, falling back to U-Boot.\n");
+ printf("%s: Failed in falcon boot: %d", __func__, ret);
+ printf("Fallback to U-Boot\n");
}
#endif
+
header = spl_get_load_buffer(-sizeof(*header), sizeof(header));
#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
volumes[0].vol_id = -1;