Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E6EFCCD195 for ; Fri, 17 Oct 2025 19:33:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E39E83849; Fri, 17 Oct 2025 21:33:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="Fq5hqShJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8CB1383869; Fri, 17 Oct 2025 21:33:32 +0200 (CEST) Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 771978383F for ; Fri, 17 Oct 2025 21:33:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=anshuld@ti.com Received: from lelvem-sh01.itg.ti.com ([10.180.77.71]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTP id 59HJXQBi349620; Fri, 17 Oct 2025 14:33:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1760729607; bh=swudU51LQNsyufx1LXOMpMizy4pwZoGFxaqj+WaFsEY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Fq5hqShJ+YzURZC4Khpot/H1AoCfIbn58MMtgvmwOEgN6IO4fWr1lDBpigQX2ZYrf QILUTZ8qC7Id7OZb3Ek8YRlna00b1L+n/DrOBjjYfx55yttAhsu/SeZQphUYF1fW96 tfpQ+hvUO2/xkFsmc8RefoNdG2MO8yKAlNTxpRxk= Received: from DLEE206.ent.ti.com (dlee206.ent.ti.com [157.170.170.90]) by lelvem-sh01.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 59HJXQ702627244 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Oct 2025 14:33:26 -0500 Received: from DLEE207.ent.ti.com (157.170.170.95) by DLEE206.ent.ti.com (157.170.170.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 17 Oct 2025 14:33:26 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Fri, 17 Oct 2025 14:33:26 -0500 Received: from localhost (dhcp-172-24-233-105.dhcp.ti.com [172.24.233.105]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 59HJXPj21801612; Fri, 17 Oct 2025 14:33:26 -0500 From: Anshul Dalal To: CC: Anshul Dalal , , , , , , , , , , , , Subject: [PATCH v4 3/7] spl: ubi: refactor spl_ubi_load_image for falcon mode Date: Sat, 18 Oct 2025 01:03:08 +0530 Message-ID: <20251017193318.4124997-4-anshuld@ti.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017193318.4124997-1-anshuld@ti.com> References: <20251017193318.4124997-1-anshuld@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- common/spl/spl_ubi.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file 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 #include +#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; -- 2.51.0