From patchwork Fri Feb 13 20:24:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1854 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771014309; bh=KYE0MRTIiLQF3eKwD2+2Z5YMs8XjFIj3wLV1zvkOUFw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cJrVzdS357xKOZa5+1eDSU/WEy0N0zASaUIyb4mpCSTiV1bZgOawKg7eWqtQ7rx2n kzJw6h2pW2CBuWt0hZAa1o120m/ue+7R5xPMDojIp3A0Tce/fof5j3kQgzJ84tk1vc QrBGkjQbko+GsvQPKdbNVR+qOeBWJ32OojgfqaltPiJdvFC7xLMiFdKG4PURKJmdfY WvDkUO/iq2dCpewoPfRv76AShHoXO0ifSBTGgF3GVhMeTRZPLxUTDqAl/p9e6j9dtD A1X12hrUE+IyL0ZbFY6BtaG9KR/kZ0HlgRZeEf2etzUewF6OH9BXYHIjqp2NuhsTw5 RmnysR30ax67Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C78069B3A for ; Fri, 13 Feb 2026 13:25:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HPJgmHVHhWGg for ; Fri, 13 Feb 2026 13:25:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771014309; bh=KYE0MRTIiLQF3eKwD2+2Z5YMs8XjFIj3wLV1zvkOUFw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cJrVzdS357xKOZa5+1eDSU/WEy0N0zASaUIyb4mpCSTiV1bZgOawKg7eWqtQ7rx2n kzJw6h2pW2CBuWt0hZAa1o120m/ue+7R5xPMDojIp3A0Tce/fof5j3kQgzJ84tk1vc QrBGkjQbko+GsvQPKdbNVR+qOeBWJ32OojgfqaltPiJdvFC7xLMiFdKG4PURKJmdfY WvDkUO/iq2dCpewoPfRv76AShHoXO0ifSBTGgF3GVhMeTRZPLxUTDqAl/p9e6j9dtD A1X12hrUE+IyL0ZbFY6BtaG9KR/kZ0HlgRZeEf2etzUewF6OH9BXYHIjqp2NuhsTw5 RmnysR30ax67Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4991A69B2D for ; Fri, 13 Feb 2026 13:25:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771014307; bh=Qp7PqeoRI58JWGmBtat4jQ3EeCixNzBb9kS3oD9Csqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UtT+rtTP0xUbObicFDBkCYavp8VtM0lPA3qtj3mV9fKvs4jqTVmiRQUUPOFKIEDjv KRnoAwhLgpy9vDoA/wBkj1c6SteauAXO51sPs+DXBZg490SXuID5kZrbLZWB4K0e0I V+hkNxdb/DuKfgPYyLS90i1N5OSF0h93YEA7uMBZL0Yxp4NVDQeVjrkZc7p0VX1bOm mjwvzE4U0bKzjVotwM6Ti/4xHfpqXCKY0pkMZBOaaRlS+cHmTtBZNybmqLE3MZPrzi Dxc1uec9FNW9YPQi1eaqwMCbK+ubC0+kRrRTTPxLv+5kreHz4mQbbsNrFxTe4nhs3S iRFj1t7vZp5WA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D3BB69B2D; Fri, 13 Feb 2026 13:25:07 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id BIR3OGCkANq8; Fri, 13 Feb 2026 13:25:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771014301; bh=oSw/aW2kr6glHcP9Q6H4AO7KfVlJqiPPVc2ZJoz1fFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGPVakU95f09UYQB0cF6FxZDinzlwFHMcqF4Z4DZD1NjT1d/8shh2Am9ZlOVO0Dp5 zj57Yu+K8geVn4O9SVFP0IGN8No2pEMuqVIx5MoXXRiOBttpjxFNhBFiozT7hjDYah jQkXuZ12gNh8BjKqFQXfKPC6WueKtSaSZJc4hsTc3y3nij/8GrLWko01sF+YFnobut 3qj+5JcVElspcqSARE5CERs4woj/HJrzovwW+9PYkSKquQTjaK8QEdCBf6P18uz+Dz JS2+ch4mkwRZTsdYPswtp3cYNRQ+GmWewBv5WPle81GMNdNu2dpsRb1K9dDZbAPddC pGQKBypx5CK7g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6A4A669A66; Fri, 13 Feb 2026 13:25:01 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 13 Feb 2026 13:24:12 -0700 Message-ID: <20260213202417.223068-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260213202417.223068-1-sjg@u-boot.org> References: <20260213202417.223068-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CY65I7AK3574GM7CG7N7AVLWYGL63NQM X-Message-ID-Hash: CY65I7AK3574GM7CG7N7AVLWYGL63NQM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 7/8] bls: Add 'fit' field for FIT image support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The BLS parser only accepts 'linux' as the kernel field. This does not distinguish between a plain kernel image and a FIT image, making it harder for the bootmethod to handle them differently. Add a 'fit' field as an alternative to 'linux' for specifying a FIT image path. The parser now accepts either 'linux' or 'fit' as the required kernel field. When both are present, 'fit' takes priority in the bootmethod. Add a parser unit test for a fit-only entry. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- boot/bls_parse.c | 12 +++++++++--- boot/bootmeth_bls.c | 7 ++++++- include/bls.h | 7 +++++-- test/boot/bls_parse.c | 24 ++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/boot/bls_parse.c b/boot/bls_parse.c index 9a067736655..1e4f6330430 100644 --- a/boot/bls_parse.c +++ b/boot/bls_parse.c @@ -26,6 +26,7 @@ enum bls_token_t { TOK_TITLE = 0, TOK_VERSION, TOK_LINUX, + TOK_FIT, TOK_OPTIONS, TOK_INITRD, TOK_DEVICETREE, @@ -42,6 +43,7 @@ static const char *const bls_token_names[] = { [TOK_TITLE] = "title", [TOK_VERSION] = "version", [TOK_LINUX] = "linux", + [TOK_FIT] = "fit", [TOK_OPTIONS] = "options", [TOK_INITRD] = "initrd", [TOK_DEVICETREE] = "devicetree", @@ -224,6 +226,10 @@ int bls_parse_entry(const char *buf, size_t size, struct bls_entry *entry) /* Point into buffer */ entry->kernel = value; break; + case TOK_FIT: + /* Point into buffer */ + entry->fit = value; + break; case TOK_OPTIONS: /* Multiple times - allocate and concatenate */ if (bls_append_str(&entry->options, value)) @@ -267,10 +273,10 @@ int bls_parse_entry(const char *buf, size_t size, struct bls_entry *entry) /* * Validate required fields: BLS spec requires at least one of - * 'linux' or 'efi'. We only support 'linux' for Type #1 entries. + * 'linux' or 'efi'. We also accept 'fit' for FIT images. */ - if (!entry->kernel) { - log_err("BLS entry missing required 'linux' field\n"); + if (!entry->kernel && !entry->fit) { + log_err("BLS entry missing required 'linux' or 'fit' field\n"); return -EINVAL; } diff --git a/boot/bootmeth_bls.c b/boot/bootmeth_bls.c index 2c66e14c641..13353906fff 100644 --- a/boot/bootmeth_bls.c +++ b/boot/bootmeth_bls.c @@ -202,7 +202,12 @@ static int bls_entry_init(struct bls_entry *entry, struct bootflow *bflow, } /* Register discovered images (not yet loaded, addr=0) */ - if (entry->kernel) { + if (entry->fit) { + if (!bootflow_img_add(bflow, entry->fit, + (enum bootflow_img_t)IH_TYPE_KERNEL, + 0, 0)) + return log_msg_ret("imf", -ENOMEM); + } else if (entry->kernel) { if (!bootflow_img_add(bflow, entry->kernel, (enum bootflow_img_t)IH_TYPE_KERNEL, 0, 0)) diff --git a/include/bls.h b/include/bls.h index eb32b323f1a..e00b5998999 100644 --- a/include/bls.h +++ b/include/bls.h @@ -24,8 +24,9 @@ * * @title: Human-readable name (points into buffer) * @version: OS version string (points into buffer) - * @kernel: Kernel path or FIT image - required (points into buffer) + * @kernel: Kernel path - required unless @fit is set (points into buffer) * Can include FIT config syntax: path#config + * @fit: FIT image path - required unless @kernel is set (points into buffer) * @options: Kernel command line - ALLOCATED, must be freed * Multiple options lines are concatenated with spaces * @initrds: List of initrd paths (alist of char * pointing into buffer) @@ -41,6 +42,7 @@ struct bls_entry { char *title; char *version; char *kernel; + char *fit; char *options; /* Allocated */ struct alist initrds; /* list of char * into buffer */ char *devicetree; @@ -70,7 +72,8 @@ struct bls_entry { * Supported fields: * title - Human-readable name * version - OS version string - * linux - Kernel path (required) + * linux - Kernel path (required unless 'fit' is present) + * fit - FIT image path (required unless 'linux' is present) * options - Kernel command line (allocated, can appear multiple times) * initrd - Initramfs path (can appear multiple times) * devicetree - Device tree blob path diff --git a/test/boot/bls_parse.c b/test/boot/bls_parse.c index 01da816aee8..63ae60d6091 100644 --- a/test/boot/bls_parse.c +++ b/test/boot/bls_parse.c @@ -137,6 +137,30 @@ static int bls_test_parse_unknown_field(struct unit_test_state *uts) } UNIT_TEST(bls_test_parse_unknown_field, 0, bootstd); +/* Test FIT-only entry (no linux field) */ +static int bls_test_parse_fit(struct unit_test_state *uts) +{ + struct bls_entry entry; + char buf[] = + "title FIT Test\n" + "version 1.0\n" + "fit /boot/image.fit\n" + "options root=/dev/sda\n" + "initrd /initrd.img\n"; + + ut_assertok(bls_parse_entry(buf, sizeof(buf) - 1, &entry)); + ut_asserteq_str("FIT Test", entry.title); + ut_assertnull(entry.kernel); + ut_asserteq_str("/boot/image.fit", entry.fit); + ut_asserteq_str("root=/dev/sda", entry.options); + ut_asserteq(1, entry.initrds.count); + + bls_entry_uninit(&entry); + + return 0; +} +UNIT_TEST(bls_test_parse_fit, 0, bootstd); + /* Test all supported fields */ static int bls_test_parse_all_fields(struct unit_test_state *uts) {