From patchwork Tue Apr 21 18:34:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2228 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=1776796547; bh=lz3W7MCZuUSCQG8pt5r1HfafPjr/7OO2me/zmpUYdno=; 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=KDX/2kxhx09SdZlky1u9gRp6SQgFBkLUIKJFYcw+3aqxT9zu6q5+puLDFUAj7x8ty T0GOan7qN1kTgXTWMnSEai/p+/fsPN5z3Bm9Nhlfj8AZx8ifyNuTrsn4qEBRFS/EEh LHAirUhc1jgRC21sbDBZTWE4vXT/3fUNAn5fXKbg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5D0F96A608 for ; Tue, 21 Apr 2026 12:35:47 -0600 (MDT) 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 K7ihO3agkhHX for ; Tue, 21 Apr 2026 12:35:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796547; bh=lz3W7MCZuUSCQG8pt5r1HfafPjr/7OO2me/zmpUYdno=; 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=KDX/2kxhx09SdZlky1u9gRp6SQgFBkLUIKJFYcw+3aqxT9zu6q5+puLDFUAj7x8ty T0GOan7qN1kTgXTWMnSEai/p+/fsPN5z3Bm9Nhlfj8AZx8ifyNuTrsn4qEBRFS/EEh LHAirUhc1jgRC21sbDBZTWE4vXT/3fUNAn5fXKbg= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 45F4B6A528 for ; Tue, 21 Apr 2026 12:35:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796544; bh=sdsa7EYJYMTs7Egikmf0L8kSNuSgbbfzpElnApgCs70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtQtro/x1lCYGvITe+iyiTIuiAfmjzv8XDY9qkPLqHohUaj9nWSdOnaH0Ive7uOZd Rn2GB4qQqt+gUVj9pBpNCK4glv3NVQK1mVbBG93xln/SpMFim4TVKCHAllwE/x7vb/ A3OqJwlvIGLSV8xbecuLvMMPoroQG8aR3x35NLY4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A64B76A604; Tue, 21 Apr 2026 12:35:44 -0600 (MDT) 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 QPLUHweXDjOU; Tue, 21 Apr 2026 12:35:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796543; bh=KrOHRHPlwjaWGnVnR1ywtvwQEw0ODalog/Y2FZB4yNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DK0qmOZZsCnCpOWhieAFCbdx7kYxGH8dPYFBA8S2goMmZY2JBKg/EtHSpDyAbTq71 xCaK7G9KfH6UxOYxP+5ZvwniFK/UFFw6jGvYjUP9m3ErQSDCHncNoCpxGC89nLfcli YTor9yIwJUsUM0BHoR9Y/mQ2eWnkhGQ42jwiCfD0= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id E87F36A60D; Tue, 21 Apr 2026 12:35:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:42 -0600 Message-ID: <20260421183511.2044469-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BKBSD6ZJXR2TLFPXM7JLNQSGBAXOWPVL X-Message-ID-Hash: BKBSD6ZJXR2TLFPXM7JLNQSGBAXOWPVL 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/16] test: py: Always consume {lab ready} marker in lab mode 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 _wait_for_boot_prompt() loops on either '=>' or on the labgrid '{lab ready in s: }' marker, breaking on whichever arrives first. In lab mode U-Boot prints '=>' before labgrid emits the marker, so the plain prompt wins the race and the marker stays in the receive buffer. The marker has the U-Boot banner embedded in it, so the very next command run in the test scans forward, trips the main_signon bad-pattern inside the marker and aborts with: Failed to get echo on console (cmd 'boot':rem ''): main_signon In lab mode, only wait for the '{lab ready...}' marker (plus the autoboot prompt so we can interrupt it). Drop the raw '=>' match from that path so the marker and its embedded banner are always consumed before the test runs its first command. The non-lab flow is unchanged. Signed-off-by: Simon Glass --- test/py/console_base.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/test/py/console_base.py b/test/py/console_base.py index 7f044b587b6..1afeee50c81 100644 --- a/test/py/console_base.py +++ b/test/py/console_base.py @@ -331,25 +331,38 @@ class ConsoleBase(): if not self.lab_mode: self._wait_for_banner(loop_num) self.u_boot_version_string = self.after + # In lab mode the '{lab ready in s: }' marker is + # the authoritative ready signal and must be consumed so + # the embedded banner does not trip the signon bad-pattern + # when the next command runs. Skip the plain '=>' prompt + # match in that case. + if self.lab_mode: + wait_patterns = [pattern_ready_prompt, + pattern_stop_autoboot_prompt] + else: + wait_patterns = [self.prompt_compiled, pattern_ready_prompt, + pattern_stop_autoboot_prompt] + ready_idx = wait_patterns.index(pattern_ready_prompt) + autoboot_idx = wait_patterns.index(pattern_stop_autoboot_prompt) + base = len(wait_patterns) while True: - m = self.expect([self.prompt_compiled, pattern_ready_prompt, - pattern_stop_autoboot_prompt] + self.bad_patterns) - if m == 0: + m = self.expect(wait_patterns + self.bad_patterns) + if not self.lab_mode and m == 0: self.log.info(f'Found ready prompt {m}') break - if m == 1: + if m == ready_idx: m = pattern_ready_prompt.search(self.after) self.u_boot_version_string = m.group(2) self.log.info('Lab: Board is ready') self.timeout = self.get_default_timeout() break - if m == 2: + if m == autoboot_idx: self.log.info(f'Found autoboot prompt {m}') self.p.send(' ') continue if not self.lab_mode: raise BootFail('Missing prompt / ready message on console: ' + - self.bad_pattern_ids[m - 3]) + self.bad_pattern_ids[m - base]) self.log.info('U-Boot is ready') finally: From patchwork Tue Apr 21 18:34:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2230 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=1776796552; bh=6mdk27D8OKoqEq007cx7lw09CkOxWFq7kIqLGnDvZxs=; 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=TZP/hU63xwFi5HpRwu91VS8m1slfhrLQXA5UyNVaFMfFIZU+9F435+tvUtKKuJLXE 01gF9W2mAIJeXy5RxhuFddpKzYOEXnoI7sHAlqZKJOTmXQNw0kuKMpW7mOyPH68k7W jjen3AvXNhRvxiItDa+t/ovDNCQoLn0SKqm0SbdU= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9426D6A613 for ; Tue, 21 Apr 2026 12:35:52 -0600 (MDT) 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 kFnbE3K4Lryf for ; Tue, 21 Apr 2026 12:35:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796552; bh=6mdk27D8OKoqEq007cx7lw09CkOxWFq7kIqLGnDvZxs=; 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=TZP/hU63xwFi5HpRwu91VS8m1slfhrLQXA5UyNVaFMfFIZU+9F435+tvUtKKuJLXE 01gF9W2mAIJeXy5RxhuFddpKzYOEXnoI7sHAlqZKJOTmXQNw0kuKMpW7mOyPH68k7W jjen3AvXNhRvxiItDa+t/ovDNCQoLn0SKqm0SbdU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C9336A604 for ; Tue, 21 Apr 2026 12:35:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796549; bh=TU8vW3sfOsGElFkaXvkkgAI2znq26ZdsTiAt7yJLn8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9vAyaShvum/L2Ywh4khQi0ZqNEvyrLxnUSFmK2VVXhsJjbVmOYTlTpijnXn66so2 +Vg07xwvz3iqqxyKVuwK1dMKD7+5Mab3jh4LkDK3B556/Qdra1BgR8skGx6wlwcoW3 38C8ZVZG/W2Z+yl8NpWc6A8VPnkUga0Mm27cZaUw= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9CA26A604; Tue, 21 Apr 2026 12:35:49 -0600 (MDT) 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 JReMZA6a1uH3; Tue, 21 Apr 2026 12:35:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796544; bh=VTFyW3fC6sIqhu7N+msh59gADGS18iyscaOi6SB5i8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdJx5cf9AbVP89Z59FEUyGGq5XvtdSdCeiKFQi5qPdIFcGq9EoOwIgI1QHQ3DRob6 ZhBi+D+4HRRbgs7cVr0Gwx6fc3yvET6S+iarerkXDIaN0LMU0W/WbmzTT7Etm0Ko16 zPxq9SwSKQy3z4WA45adaP/lgCHg+yoRxPl765xQ= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 0D3336A603; Tue, 21 Apr 2026 12:35:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:43 -0600 Message-ID: <20260421183511.2044469-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XHJCHDDSZONRJDBQ7C4SHMW4QOOCLCZE X-Message-ID-Hash: XHJCHDDSZONRJDBQ7C4SHMW4QOOCLCZE 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/16] fs: Move generic VFS stubs out of ext4l 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 Linux-port shims alloc_inode_sb(), free_page(), sb_set_blocksize(), d_make_root() and iput() live in fs/ext4l/stub.c, which is only built when CONFIG_FS_EXT4L is set. Nothing in those five functions is ext4-specific; they are also called by code under fs/isofs, so building U-Boot with CONFIG_FS_ISOFS=y and CONFIG_FS_EXT4L=n produces an image with five unresolved externals. Calling into isofs at runtime jumps through a NULL function pointer and triggers a #UD on x86. Move the five functions into fs/linux_fs.c, which is already compiled when CONFIG_FS_LINUX is set (auto-selected by FS_ISOFS or FS_EXT4L). Also add for struct dentry - the behaviour is unchanged for ext4l-only builds. Signed-off-by: Simon Glass --- fs/ext4l/stub.c | 74 +++------------------------------------- fs/linux_fs.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 70 deletions(-) diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 6fe8398623e..df2a72bc731 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -337,11 +337,7 @@ int inode_generic_drop(struct inode *inode) return 0; } -void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, - gfp_t gfp) -{ - return kmem_cache_alloc(cache, gfp); -} +/* alloc_inode_sb() is now in fs/linux_fs.c */ /* inode_set_iversion is now a macro in linux/iversion.h */ @@ -381,10 +377,7 @@ unsigned long get_zeroed_page(gfp_t gfp) return (unsigned long)p; } -void free_page(unsigned long addr) -{ - free((void *)addr); -} +/* free_page() is now in fs/linux_fs.c */ /* Trace stubs */ void trace_ext4_error(struct super_block *sb, const char *func, unsigned int line) @@ -460,19 +453,7 @@ void fs_put_dax(void *dax, void *holder) { } -/* Block size */ -int sb_set_blocksize(struct super_block *sb, int size) -{ - /* Validate block size */ - if (size != 1024 && size != 2048 && size != 4096) - return 0; - - /* Update superblock fields */ - sb->s_blocksize = size; - sb->s_blocksize_bits = ffs(size) - 1; - - return size; -} +/* sb_set_blocksize() is now in fs/linux_fs.c */ /* strscpy_pad is now a macro in linux/string.h */ /* kmemdup_nul is now in lib/string.c */ @@ -501,54 +482,7 @@ void generic_set_sb_d_ops(struct super_block *sb) { } -/** - * d_make_root() - Create a root dentry for an inode - * @inode: Inode to create dentry for - * Return: Allocated dentry or NULL on failure - */ -struct dentry *d_make_root(struct inode *inode) -{ - struct dentry *de; - - if (!inode) - return NULL; - - de = kzalloc(sizeof(struct dentry), GFP_KERNEL); - if (!de) { - iput(inode); - return NULL; - } - - de->d_inode = inode; - de->d_sb = inode->i_sb; - de->d_name.name = "/"; - de->d_name.len = 1; - - return de; -} - -/** - * iput() - Release a reference to an inode - * @inode: Inode to release - * - * Decrements the inode reference count. When the reference count reaches - * zero and the inode has no links, the inode is evicted (freed). - */ -void iput(struct inode *inode) -{ - if (!inode) - return; - - if (atomic_dec_and_test(&inode->i_count)) { - /* Last reference - check if inode should be evicted */ - if (inode->i_nlink == 0 && inode->i_sb && - inode->i_sb->s_op && inode->i_sb->s_op->evict_inode) { - inode->i_sb->s_op->evict_inode(inode); - /* Sync dirty buffers after eviction */ - bh_cache_sync(); - } - } -} +/* d_make_root() and iput() are now in fs/linux_fs.c */ /* percpu_init_rwsem is now in linux/percpu.h */ diff --git a/fs/linux_fs.c b/fs/linux_fs.c index 04f4c551f0b..db2b3b3942a 100644 --- a/fs/linux_fs.c +++ b/fs/linux_fs.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -657,3 +658,91 @@ const struct file_operations generic_ro_fops = { const struct inode_operations page_symlink_inode_operations = { }; + +/** + * alloc_inode_sb() - Allocate an inode associated with a super block + * @sb: Super block the inode will belong to + * @cache: kmem_cache to allocate from + * @gfp: Allocation flags + * Return: Newly allocated inode, or NULL on failure + */ +void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, + gfp_t gfp) +{ + return kmem_cache_alloc(cache, gfp); +} + +/** + * free_page() - Free a single page previously obtained via get_zeroed_page() + * @addr: Address returned by get_zeroed_page() + */ +void free_page(unsigned long addr) +{ + free((void *)addr); +} + +/** + * sb_set_blocksize() - Validate and record the block size on a super block + * @sb: Super block to update + * @size: Block size in bytes (must be 1024, 2048 or 4096) + * Return: @size on success, 0 on invalid block size + */ +int sb_set_blocksize(struct super_block *sb, int size) +{ + if (size != 1024 && size != 2048 && size != 4096) + return 0; + + sb->s_blocksize = size; + sb->s_blocksize_bits = ffs(size) - 1; + + return size; +} + +/** + * d_make_root() - Create a root dentry for an inode + * @inode: Inode to create a dentry for + * Return: Allocated dentry, or NULL on failure (the inode is released on + * failure via iput()) + */ +struct dentry *d_make_root(struct inode *inode) +{ + struct dentry *de; + + if (!inode) + return NULL; + + de = kzalloc(sizeof(*de), GFP_KERNEL); + if (!de) { + iput(inode); + return NULL; + } + + de->d_inode = inode; + de->d_sb = inode->i_sb; + de->d_name.name = "/"; + de->d_name.len = 1; + + return de; +} + +/** + * iput() - Release a reference to an inode + * @inode: Inode to release + * + * Decrement the inode reference count. When the reference count reaches + * zero and the inode has no links, evict the inode via its super block + * operations and flush any dirty buffers. + */ +void iput(struct inode *inode) +{ + if (!inode) + return; + + if (atomic_dec_and_test(&inode->i_count)) { + if (inode->i_nlink == 0 && inode->i_sb && + inode->i_sb->s_op && inode->i_sb->s_op->evict_inode) { + inode->i_sb->s_op->evict_inode(inode); + bh_cache_sync(); + } + } +} From patchwork Tue Apr 21 18:34:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2229 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=1776796552; bh=PaUvXkFIciP/qVsK8sQOvV8z0lBYbiyfebrojDEPO/0=; 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=jaau7iTLkcd7v5ThmxSgXYgvimc5pw6i64FCrq8dNHLb11A/U9qkGD6sR62tZYh1B N6QZPoLrC2ObGtA0H1+wBBWX3zMvvf9aOPv2hk7c+R+lGN69PvxVulwBHZCUSLR8OJ 65jIUh2p/8txPwrSprxp272VHB6zrc2awuCzs7Y0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 08A386A601 for ; Tue, 21 Apr 2026 12:35:52 -0600 (MDT) 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 zpQuGnJil7TA for ; Tue, 21 Apr 2026 12:35:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796551; bh=PaUvXkFIciP/qVsK8sQOvV8z0lBYbiyfebrojDEPO/0=; 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=hRU8OjUy8BeMI0uXrjtM42RReWbNX3XbyIU/7xchfE6kgEjK/ySXzTTgjx8Vmy4Gp rzsCBGYhuD+rnp8ZWfzhwW0M7KbHHv2hoqb8BTDV6GVyM/xiVbeftaPRGWIBt8Gjn8 AEe6XYUADvkStDyr9nHqGzJwC3+nUEz8RarzpaMo= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E97116A603 for ; Tue, 21 Apr 2026 12:35:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796549; bh=8Cn1cePR6h5fN0q+tjnlr+TfQ/wPhtOZqNE/5E4tZgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjN1XuLEmv13a2GCDnQkt1tN1qBjxYsTaWxNPtO1SQNtSf0vWPc31wKHqs9NsuwW4 FqSpR1VlaAOgAV547IddQTGUvSnJW+Ekx6Zznf4qjULFNMd6VmR2MSKrHOpDV01/63 gw1OEk0PfsPY3o8YeEAShpAFPl63uk1sDdnJKFXE= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9C876A601; Tue, 21 Apr 2026 12:35:49 -0600 (MDT) 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 pDXBZBOmnm6k; Tue, 21 Apr 2026 12:35:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796549; bh=q3yoBPYwmwNTZ1R7baEns8oQPS96Kqkz5Zncq97/ycU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ix8il2neuXg3nGzqxalO9Xb652mpMWCBFRcn9I25+L5q5AfJLRi58WFmkys954fa+ mQBCsgWleVPKGYWuSzdjuDxLhlAtA/9TAt9Y6x4MFaT1/00aMB+jmJZaKtCXOmpz7+ e+JuXPodEMxTvbtZT1OhSc7tBZmeLbiSTAbhW804= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 07FCD6A528; Tue, 21 Apr 2026 12:35:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:44 -0600 Message-ID: <20260421183511.2044469-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: O57UPHE4KRMUSQPTDIKLGOHOLIVHDXEL X-Message-ID-Hash: O57UPHE4KRMUSQPTDIKLGOHOLIVHDXEL 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/16] fs: Add sb_bread_uncached() for streaming reads 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 existing sb_bread() path populates a global buffer-head cache in sb_getblk() and brelse() does not evict cached entries. That is the right trade-off for ext4l, where journal and metadata blocks are re-read from a small working set, but it is a disaster for filesystems that stream large files: every block read is retained, each allocation carries a buffer_head, a folio and a data buffer, and the malloc heap fills up long before the read completes. Add sb_bread_uncached() which allocates a fresh buffer_head, reads the block, and returns it without touching the cache. Callers release the buffer with brelse() exactly as before; since buffer_cached() is not set, brelse() now frees the buffer immediately. Signed-off-by: Simon Glass --- fs/linux_fs.c | 26 ++++++++++++++++++++++++++ include/linux/buffer_head.h | 14 ++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/fs/linux_fs.c b/fs/linux_fs.c index db2b3b3942a..8f36b96a74e 100644 --- a/fs/linux_fs.c +++ b/fs/linux_fs.c @@ -472,6 +472,32 @@ struct buffer_head *sb_bread(struct super_block *sb, sector_t block) return bh; } +struct buffer_head *sb_bread_uncached(struct super_block *sb, sector_t block) +{ + struct buffer_head *bh; + int ret; + + if (!sb) + return NULL; + + bh = alloc_buffer_head_with_data(sb->s_blocksize); + if (!bh) + return NULL; + + bh->b_blocknr = block; + bh->b_bdev = sb->s_bdev; + + ret = linux_fs_read_block(sb, block, sb->s_blocksize, bh->b_data); + if (ret) { + free_buffer_head(bh); + return NULL; + } + + set_buffer_uptodate(bh); + + return bh; +} + /** * bdev_getblk() - Get buffer via block_device * @bdev: Block device diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index e844402500d..aad6dec3542 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -178,6 +178,20 @@ static inline void put_bh(struct buffer_head *bh) void brelse(struct buffer_head *bh); void __brelse(struct buffer_head *bh); +/** + * sb_bread_uncached() - Read a block without inserting it in the buffer cache + * @sb: Super block + * @block: Block number + * + * Same as sb_bread() but skips the buffer-head cache. Useful for streaming + * reads of large file contents where caching every block would exhaust the + * malloc heap before the read completes. Caller must release with brelse(), + * which frees the buffer immediately since it is not cached. + * + * Return: Buffer head with valid data, or NULL on error + */ +struct buffer_head *sb_bread_uncached(struct super_block *sb, sector_t block); + /* * Buffer operation stubs - U-Boot is single-threaded */ From patchwork Tue Apr 21 18:34:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2231 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=1776796557; bh=E5ZG1rkLoGc5BsKGl+1nLbj96Ae/wlirzpKiaTuv3b4=; 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=jYPGDo2FdcApG+Uy1EJaR4bflcpE4c2KbALZg/jZjyYyHLFb5aTyrUiBiNxXn6bqZ 49zxy2lNlhioiR5B0x6In1r8C74EC1DQSKmtw9NS1ZWhQb/pNSaMEbTt4MUY7/CHss CJW0pD8vQzaSH9i/x95E4R0ABW/ATug3PLWSCm/U= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6707B6A601 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) 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 bWP9UZP5rIO7 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796557; bh=E5ZG1rkLoGc5BsKGl+1nLbj96Ae/wlirzpKiaTuv3b4=; 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=jYPGDo2FdcApG+Uy1EJaR4bflcpE4c2KbALZg/jZjyYyHLFb5aTyrUiBiNxXn6bqZ 49zxy2lNlhioiR5B0x6In1r8C74EC1DQSKmtw9NS1ZWhQb/pNSaMEbTt4MUY7/CHss CJW0pD8vQzaSH9i/x95E4R0ABW/ATug3PLWSCm/U= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 50F656A603 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796554; bh=7aLV8u2kobfE1fsRBnoO7vHay3h9x84jFe2yxx35E90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mraMBEYZzBSk5hb4mbZZUkNWe3B52xYyMbn7+K5lhViuaxr7ij4X1VdqY4SB3E3DO oPp20BADVYaeHVf/X3kC8kbxGlQTzTx4COvxNeHqJ0HUf9xLy9tIPcdFPJP3o9WqN7 5gpjTv933pVQBhVtBg8jCA5cI4UXRphvgvlKesbs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED9066A601; Tue, 21 Apr 2026 12:35:54 -0600 (MDT) 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 ukbh_aAWZ8dX; Tue, 21 Apr 2026 12:35:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796550; bh=TLjfsP1AhEjfK2GHBhVEVVQRgP9TuzEemroyR5E2qes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNfZlPFlBnkv3Enz8q0lfGPQDYG5o3fwEgWgHQdJnCHv/DTnxfsoplj76fAaXTaNY EOaWVXf8dlemMAXw++5a7wJwmIl2X5jHOXbKUPEZUCRnVA+gVD0WwmooZVtASrCveU VVtEHddlUUj5GVyPQp/2oeyjamIQhVq9IcizLOR4= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 1A1486A528; Tue, 21 Apr 2026 12:35:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:45 -0600 Message-ID: <20260421183511.2044469-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SI3GCLBWAEFZ3A2YD2DHPKOKXRFBN5AA X-Message-ID-Hash: SI3GCLBWAEFZ3A2YD2DHPKOKXRFBN5AA 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/16] fs: isofs: Read file content via the uncached path 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 isofs_read() streams whole files through isofs_bread(), which goes through sb_bread() and therefore populates the shared buffer-head cache. For a multi-megabyte kernel or initrd this exhausts the U-Boot malloc heap after a few megabytes (each cached block costs roughly sizeof(buffer_head) + sizeof(folio) + blocksize) and the read fails partway through with -EIO before the file is fully read. Introduce isofs_bread_uncached() alongside isofs_bread() and use it for file content reads in the interface layer. Directory traversal still uses the cached path because repeated metadata lookups benefit from it; only the streaming file read changes. Signed-off-by: Simon Glass --- fs/isofs/inode.c | 8 ++++++++ fs/isofs/interface.c | 9 +++++++-- fs/isofs/isofs.h | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 3d9e9301a9f..7639471edf2 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -811,6 +811,14 @@ struct buffer_head *isofs_bread(struct inode *inode, sector_t block) return sb_bread(inode->i_sb, blknr); } +struct buffer_head *isofs_bread_uncached(struct inode *inode, sector_t block) +{ + sector_t blknr = isofs_bmap(inode, block); + if (!blknr) + return NULL; + return sb_bread_uncached(inode->i_sb, blknr); +} + static int isofs_read_folio(struct file *file, struct folio *folio) { return mpage_read_folio(folio, isofs_get_block); diff --git a/fs/isofs/interface.c b/fs/isofs/interface.c index 6f07f9951f1..5f8cc749e08 100644 --- a/fs/isofs/interface.c +++ b/fs/isofs/interface.c @@ -478,8 +478,13 @@ int isofs_read(const char *filename, void *buf, loff_t offset, loff_t len, block = offset / blksize; blk_off = offset % blksize; - /* Read the block using isofs_bread (handles block mapping) */ - bh = isofs_bread(inode, block); + /* + * Use the uncached read path: the buffer cache is shared + * across the whole VFS layer, and populating it from a + * streaming file read of an arbitrarily large file would + * exhaust the malloc heap before the read completes. + */ + bh = isofs_bread_uncached(inode, block); if (!bh) return -EIO; diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index 95d85f58733..7382bcc62b5 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h @@ -126,6 +126,22 @@ int get_acorn_filename(struct iso_directory_record *, char *, struct inode *); extern struct dentry *isofs_lookup(struct inode *, struct dentry *, unsigned int flags); extern struct buffer_head *isofs_bread(struct inode *, sector_t); + +/** + * isofs_bread_uncached() - Read a file block without populating the cache + * + * Mirrors isofs_bread() but uses sb_bread_uncached() so the block is freed + * the moment the caller drops its reference. Useful for streaming large + * files (e.g. the casper kernel/initrd), where caching every block would + * exhaust the U-Boot malloc heap long before the read completes. + * + * @inode: Inode the block belongs to + * @block: Logical block number within the inode + * Return: buffer_head with the block contents, or NULL if the logical + * block does not map to a disk block + */ +extern struct buffer_head *isofs_bread_uncached(struct inode *inode, + sector_t block); extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long); struct inode *__isofs_iget(struct super_block *sb, From patchwork Tue Apr 21 18:34:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2232 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=1776796561; bh=xJArPCOJBn8hED5uv5qWYo9pkX6Iyqgo/vMlJpkOIMI=; 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=XJZr+bEzy2MFllFo5ZJI9Wdkh38xBW3FXhhCcRguaK4skvP8s5oyI3x5mka7B4eCP mA/IxPC6PuM+7kcBT2krhhUJPfwx1mQxWtJHOBmjaRTx8a8rAoy1D/2HOxARKS/mpT 8Spy7NI+0VeJy2Hb+RQluybQHYy5FwZFdJ+BbPss= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFEE46A608 for ; Tue, 21 Apr 2026 12:36:01 -0600 (MDT) 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 S89UlmCoDI3M for ; Tue, 21 Apr 2026 12:36:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796561; bh=xJArPCOJBn8hED5uv5qWYo9pkX6Iyqgo/vMlJpkOIMI=; 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=XJZr+bEzy2MFllFo5ZJI9Wdkh38xBW3FXhhCcRguaK4skvP8s5oyI3x5mka7B4eCP mA/IxPC6PuM+7kcBT2krhhUJPfwx1mQxWtJHOBmjaRTx8a8rAoy1D/2HOxARKS/mpT 8Spy7NI+0VeJy2Hb+RQluybQHYy5FwZFdJ+BbPss= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE3E26A603 for ; Tue, 21 Apr 2026 12:36:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796559; bh=GBuHXAZwy4/GjzYFDSY3kQgdqjDKPDodxGSGbegFFPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qR/xFig3wpyZwqSydZ8M8aWlQt8PCvYST20Oj3b0tP6oG+BYekvQ1GjR/vFFX0Ld+ SwiIRK30Ob7qMr958PseByFfRTNG+6HXaDQTYbq6H59t3DXRQLLiBZGD07HibDLJsQ Cuuy84vOEnqIslj738XUiuTPaK9A/ehUN/MR6W78= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6C9A66A601; Tue, 21 Apr 2026 12:35:59 -0600 (MDT) 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 IxsMQKSIV_5j; Tue, 21 Apr 2026 12:35:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796555; bh=vdxXvwDIo0UG+2150j0KQUWi/CQqCa0PJ6yq7g3PoCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUF4CyMMS/JgnYTAAhlZI8QawryvhbuRQrW/RlOUnYIdsVJ+lJBybMGrgyHbQ2g7o Ukld/vbu1k6JBDN0TE0dsryJvzT8sGb2ojMP4PrWmRgUglSKhl+EQfUf3bhmIYQ2ym TFYXtKcZzj4Ri1oCY2Ry79HL4BOLAegdt/SPQ8go= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 1008D6A528; Tue, 21 Apr 2026 12:35:55 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:46 -0600 Message-ID: <20260421183511.2044469-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RG46AR6LVDZ6LBNFIN2CF6KGF4MGI63P X-Message-ID-Hash: RG46AR6LVDZ6LBNFIN2CF6KGF4MGI63P 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/16] fs: isofs: Treat the filesystem as starting at block 0 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 isofs_probe() takes a disk_partition and, when present, translates every subsequent block address by the partition's start LBA. That matches ext4 and FAT semantics but not ISO 9660: an ISO 9660 image always places its primary volume descriptor at absolute block 16 (byte 32768), regardless of any surrounding GPT or MBR layout. Hybrid Ubuntu live ISOs emitted by modern xorriso expose the ISO 9660 session as GPT partition 1, starting at LBA 64 to leave room for the protective MBR and GPT header. Mounting such a partition through fs_set_blk_dev_with_part() currently makes isofs_probe() read the 'primary volume descriptor' from partition_start + 16 blocks, miss the "CD001" signature and return -EINVAL. The bootflow iterator then skips partition 1 entirely, so Boot Loader Specification entries placed in the ISO 9660 tree (e.g. the /loader/entry.conf written by scripts/ubuntu-iso-to-uboot.py) are never discovered and the boot silently falls back to an EFI direct boot or fails altogether. Pin bd_part_start and the PVD read offset to 0 so the ISO 9660 driver always sees absolute disk offsets. Interactive 'ls' on a CD drive with no partition table still works because the starting LBA is already 0 in that case. Signed-off-by: Simon Glass --- fs/isofs/interface.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/isofs/interface.c b/fs/isofs/interface.c index 5f8cc749e08..9346ce12431 100644 --- a/fs/isofs/interface.c +++ b/fs/isofs/interface.c @@ -107,10 +107,17 @@ int isofs_probe(struct blk_desc *fs_dev_desc, goto err_free_sb; } - /* Initialise super_block fields */ + /* + * ISO 9660 images always start at absolute block 0 of the device, + * even when accessed via a GPT partition whose start LBA is non-zero + * (e.g. a hybrid ISO where partition 1 covers the ISO 9660 session + * but begins at LBA 64 because of the protective MBR + GPT header). + * Pin bd_part_start to 0 so callers that translate filesystem block + * numbers through bd_part_start reach the real data. + */ sb->s_bdev->bd_super = sb; sb->s_bdev->bd_blk = fs_dev_desc->bdev; - sb->s_bdev->bd_part_start = fs_partition ? fs_partition->start : 0; + sb->s_bdev->bd_part_start = 0; sb->s_blocksize = ISOFS_BLOCK_SIZE; sb->s_blocksize_bits = ISOFS_BLOCK_BITS; sb->s_flags = SB_RDONLY; /* ISO 9660 is always read-only */ @@ -123,9 +130,8 @@ int isofs_probe(struct blk_desc *fs_dev_desc, memset(&ifs.partition, '\0', sizeof(ifs.partition)); ifs.mounted = true; - /* Read first sector to verify it's an ISO filesystem */ - part_offset = fs_partition ? - (loff_t)fs_partition->start * fs_dev_desc->blksz : 0; + /* Read the primary volume descriptor at absolute block 16 */ + part_offset = 0; buf = malloc(ISOFS_BLOCK_SIZE); if (!buf) { From patchwork Tue Apr 21 18:34:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2233 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=1776796567; bh=LrXXZ8Bg4sSNp58c3CHm5aM+KPo5BoOsI77ZGOm61z8=; 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=E9cX5ZYrGe6riEj6ayzrJbrJ6IC24eGvL/L3DALwapSryq1Q4APcm49BNRb0k0XAN oqXNsOtxCBSrfHtEPkZ6aGQa3MGjwZn6vkimZUnzd5qb7dlEPJ34Ge7itGrMOMlTQO T0YZHsWvt6KFcnPcAzl0JifJE8aA9XESLyU+BLAY= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E9A856A608 for ; Tue, 21 Apr 2026 12:36:07 -0600 (MDT) 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 HNCwdSgaUOgE for ; Tue, 21 Apr 2026 12:36:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796567; bh=LrXXZ8Bg4sSNp58c3CHm5aM+KPo5BoOsI77ZGOm61z8=; 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=E9cX5ZYrGe6riEj6ayzrJbrJ6IC24eGvL/L3DALwapSryq1Q4APcm49BNRb0k0XAN oqXNsOtxCBSrfHtEPkZ6aGQa3MGjwZn6vkimZUnzd5qb7dlEPJ34Ge7itGrMOMlTQO T0YZHsWvt6KFcnPcAzl0JifJE8aA9XESLyU+BLAY= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D83E56A601 for ; Tue, 21 Apr 2026 12:36:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796566; bh=0Kdv4eh8HHeiICjJ1VIlfwWd8mLNaYVQvxxKvrxZNLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CzbA9m3TAfUHUUrikt2IBNgOP54e9PMMGsYbzug6fsuwtRapXXUxOI9eGeTmUP1dk n2+c8ZuKR6INtDAXopjU62QJakYJgYXRG1XJc13uXbHaEFelAbz8wx8LEzk1t3n3Hg qP2FVueAzic6z7I4N3V87qAiPHc/5FGRyT1/doBg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52C6C6A601; Tue, 21 Apr 2026 12:36:06 -0600 (MDT) 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 6Bm0G8tztp_U; Tue, 21 Apr 2026 12:36:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796560; bh=5aVUie2LhgYXNu2JE+Qp4JMs0bq4MLa0SytNcW4ULdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YKpkQQXx/5ezFQDaMts6NYtCRHyGIKo7tz9R0IISRHbJmnsDTw9bLy6JqYZwClu/r joLkh1IFbhdNN8AR8uVob92vjRf0q+OvBFLKwGGOg/GaVnv8zvj83S7AjpdAUqRqC2 2KdXOrZ4Pemaf1Aa7RL5I/n5QLSbCFc9HK01/RT8= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 058DA6A528; Tue, 21 Apr 2026 12:35:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:47 -0600 Message-ID: <20260421183511.2044469-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6KVTU4JK5C2VBPLV23DM3RU2ZZ7YGUNF X-Message-ID-Hash: 6KVTU4JK5C2VBPLV23DM3RU2ZZ7YGUNF 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/16] part: Add Extended Boot Loader Partition GUID 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 Boot Loader Specification names two partition types as homes for Type #1 boot entries: the EFI System Partition and the Extended Boot Loader Partition (XBOOTLDR), whose GPT type GUID is bc13c2ff-59e6-4262-a352-b275fd6f7172 (from the BLS spec). U-Boot already defines the ESP GUID but not XBOOTLDR - add it alongside PARTITION_SYSTEM_GUID so the bootflow layer can recognise it. Signed-off-by: Simon Glass --- include/part_efi.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/part_efi.h b/include/part_efi.h index fb402df6f13..7dac8da32e8 100644 --- a/include/part_efi.h +++ b/include/part_efi.h @@ -35,6 +35,14 @@ #define PARTITION_SYSTEM_GUID \ EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \ 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) +/* + * Extended Boot Loader Partition (XBOOTLDR), defined by the + * Boot Loader Specification: + * https://uapi-group.org/specifications/specs/boot_loader_specification/ + */ +#define PARTITION_XBOOTLDR_GUID \ + EFI_GUID(0xbc13c2ff, 0x59e6, 0x4262, \ + 0xa3, 0x52, 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72) #define LEGACY_MBR_PARTITION_GUID \ EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \ 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F) From patchwork Tue Apr 21 18:34:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2234 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=1776796573; bh=feQ7MqF9l2Q0Fyx1VvkTqHISIOAPL69iDG8BS1W9Cxk=; 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=nmhv4nlQC4SzcmmN8AZawLn8+b+XoUESBNCENqXOcIXnApU3ysIlt+b99SNQYh4Yb YfKn+SvPFcbhKaqjhCKUtGTGjveasHGzMBJPjWISIUSWJhsLlUTJt7pXsUGInP/m4j lmdHDuftXSo7xUpeZeEWOqevSNP8T0+Q1tZF0w28= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A41F6A60B for ; Tue, 21 Apr 2026 12:36:13 -0600 (MDT) 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 s6YAUQDTljZL for ; Tue, 21 Apr 2026 12:36:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796573; bh=feQ7MqF9l2Q0Fyx1VvkTqHISIOAPL69iDG8BS1W9Cxk=; 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=nmhv4nlQC4SzcmmN8AZawLn8+b+XoUESBNCENqXOcIXnApU3ysIlt+b99SNQYh4Yb YfKn+SvPFcbhKaqjhCKUtGTGjveasHGzMBJPjWISIUSWJhsLlUTJt7pXsUGInP/m4j lmdHDuftXSo7xUpeZeEWOqevSNP8T0+Q1tZF0w28= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 88F6D6A604 for ; Tue, 21 Apr 2026 12:36:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796570; bh=wRfNxOXqqKjypyxIu5nvpjq2TUMUhxkWxTv0n2diN+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PUXpkGKbiMz4byIEOfy1dgyeY61IlSTIZlBZaZnac/9/WNgGTvbxbYkDaE0tIyFK0 4kvdftnadQcLG8tmY8PC6SDgvQj+5hgUaNYkr4KLBfOvNAfgLH1XMeNJdblHKQ16p9 OeMKzbI4NSC+b6xsgsjC/fh2NRgpVKWn8OlOnl9o= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79D9F6A604; Tue, 21 Apr 2026 12:36:10 -0600 (MDT) 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 B0QZSFULpBBg; Tue, 21 Apr 2026 12:36:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796565; bh=BEPzagjqquG2qPP4ScynZU5y3o/OQip15q7Ymou0BYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpC/7j8OfnpDCXI1rB7sdgqle5Fh04WOFPid/cPI62dEj9WvjE542gdKH64vhMsdv NWQqTvoUKXz59MtGKG0DLH2pHArbZSfOr8TKjlKDTlou14GvnfbLGvMLztyrby2b1v Py00qO6VgBLxhKasYGjUcfPJzJ4En27B4geYrrKs= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id F272C6A603; Tue, 21 Apr 2026 12:36:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:48 -0600 Message-ID: <20260421183511.2044469-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VFNCUES3IVCNO6HKFAIJNWIUEBLDTV5Q X-Message-ID-Hash: VFNCUES3IVCNO6HKFAIJNWIUEBLDTV5Q 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/16] part: Add a BLS target-partition check 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 Boot Loader Specification places Type #1 entries on the ESP, the Extended Boot Loader Partition (XBOOTLDR), or an MBR type 0xea partition. Discovery is by partition type only; the spec never mentions the GPT or MBR 'bootable' flag. Add a small helper that identifies those three cases so the bootflow layer can scan them for loader/entry.conf regardless of bootable attribute. Keep it in disk/part.c alongside part_get_bootable(), with a trivial stub for !CONFIG_PARTITIONS builds. Also add a sandbox unit test that exercises the helper with the three partition type identifiers the spec calls out (ESP, XBOOTLDR and MBR 0xea), plus a few negative cases covering a common Linux partition type and a stray Linux MBR sys_ind, and verifies that the GUID match is case-insensitive. Signed-off-by: Simon Glass --- disk/part.c | 21 +++++++++++++++++++++ include/part.h | 17 +++++++++++++++++ test/dm/part.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/disk/part.c b/disk/part.c index 2ddbf50ee6c..e22dabc4090 100644 --- a/disk/part.c +++ b/disk/part.c @@ -882,3 +882,24 @@ int part_get_bootable(struct blk_desc *desc) return 0; } + +bool part_is_bls_target(const struct disk_partition *info) +{ + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { + const char *guid = disk_partition_type_guid(info); + + /* EFI System Partition */ + if (!strcasecmp(guid, "c12a7328-f81f-11d2-ba4b-00a0c93ec93b")) + return true; + /* Extended Boot Loader Partition (XBOOTLDR) */ + if (!strcasecmp(guid, "bc13c2ff-59e6-4262-a352-b275fd6f7172")) + return true; + } + + /* MBR/DOS disks: BLS uses partition type 0xea */ + if (IS_ENABLED(CONFIG_DOS_PARTITION) && + disk_partition_sys_ind(info) == 0xea) + return true; + + return false; +} diff --git a/include/part.h b/include/part.h index 6c9558e2c71..3ecf6d8e165 100644 --- a/include/part.h +++ b/include/part.h @@ -755,6 +755,20 @@ int part_get_type_by_name(const char *name); */ int part_get_bootable(struct blk_desc *desc); +/** + * part_is_bls_target() - Check whether a partition holds BLS boot entries + * + * The Boot Loader Specification defines two GPT partition types as homes + * for Type #1 entries (the ESP and the Extended Boot Loader Partition) and + * one MBR type ID (0xea). This helper returns true when @info names one of + * them, so the caller can scan the partition for loader/entries/.conf + * (or loader/entry.conf) regardless of any 'bootable' flag. + * + * @info: Partition information + * Return: true if the partition is an ESP, XBOOTLDR or MBR-0xea partition + */ +bool part_is_bls_target(const struct disk_partition *info); + /** * part_driver_lookup_type() - Look up the partition driver for a blk device * @@ -783,6 +797,9 @@ static inline struct part_driver *part_driver_get_first(void) static inline bool part_get_bootable(struct blk_desc *desc) { return false; } +static inline bool part_is_bls_target(const struct disk_partition *info) +{ return false; } + static inline struct part_driver *part_driver_lookup_type(struct blk_desc *desc) { return NULL; } diff --git a/test/dm/part.c b/test/dm/part.c index caae23bd4aa..02f36c0803a 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -109,6 +109,48 @@ static int dm_test_part_bootable(struct unit_test_state *uts) } DM_TEST(dm_test_part_bootable, UTF_SCAN_FDT); +static int dm_test_part_is_bls_target(struct unit_test_state *uts) +{ + struct disk_partition info; + + /* GPT: ESP type GUID */ + memset(&info, '\0', sizeof(info)); + disk_partition_set_type_guid(&info, + "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"); + ut_asserteq(true, part_is_bls_target(&info)); + + /* GPT: XBOOTLDR type GUID */ + memset(&info, '\0', sizeof(info)); + disk_partition_set_type_guid(&info, + "bc13c2ff-59e6-4262-a352-b275fd6f7172"); + ut_asserteq(true, part_is_bls_target(&info)); + + /* GPT: GUID match must be case-insensitive */ + memset(&info, '\0', sizeof(info)); + disk_partition_set_type_guid(&info, + "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"); + ut_asserteq(true, part_is_bls_target(&info)); + + /* GPT: a Linux filesystem partition is not a BLS target */ + memset(&info, '\0', sizeof(info)); + disk_partition_set_type_guid(&info, + "0fc63daf-8483-4772-8e79-3d69d8477de4"); + ut_asserteq(false, part_is_bls_target(&info)); + + /* MBR: BLS partition type 0xea */ + memset(&info, '\0', sizeof(info)); + info.sys_ind = 0xea; + ut_asserteq(true, part_is_bls_target(&info)); + + /* MBR: a Linux partition (0x83) is not a BLS target */ + memset(&info, '\0', sizeof(info)); + info.sys_ind = 0x83; + ut_asserteq(false, part_is_bls_target(&info)); + + return 0; +} +DM_TEST(dm_test_part_is_bls_target, 0); + static int do_get_info_test(struct unit_test_state *uts, struct blk_desc *dev_desc, int part, int part_type, struct disk_partition const *reference) From patchwork Tue Apr 21 18:34:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2235 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=1776796574; bh=pYj94UQaU/yYC3KooNFxSS1+EhyVLQiFBAe+HlO5A78=; 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=U+8vgEHnL/G5ijVzChOC4ZJaALUs2HNE/noEVL9gyW+mqUC3WtgNSlgz2pnwEQvA+ XTUTRgCEh6DUmTErMqjQTPmobZmzLR88dqpIREmhgVvHWL6IHOgj5qsBZfpQxo11ru r7JAk/3Dk1hDydVGYhKz+ShQK2U7UKQk7Lw3CkqM= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0668B6A608 for ; Tue, 21 Apr 2026 12:36:14 -0600 (MDT) 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 K2gNjst7emPB for ; Tue, 21 Apr 2026 12:36:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796573; bh=pYj94UQaU/yYC3KooNFxSS1+EhyVLQiFBAe+HlO5A78=; 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=oxC4lNZesg7ce2Qvm11WJltqZ6Z85xHtYoWhPOpvehwbPadDn3D2VMGtwx+BiRvoN vcDEF9VNuWlk4Q47IYic6GMIU+N2v/xG2ykE8b2TYA1Ow+YXFD3wdY+hyHh6xgX7Yf vNxUPM/3cynppOMuWS5Gy50I6j9mt43Eh7TBc4D0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA0B26A619 for ; Tue, 21 Apr 2026 12:36:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796570; bh=UqF2bbC6Tn5WBVornf5bgPEIbuzVogV17wzS+3R/o5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bb4Q+75MyEpBYaM/SYGbQoYm9KyK+NpET6nMpv2uGek/piAS0MZbvRn5aBQ4J4xK/ 0jPOsiQ37ylh01M2y4EEJ9AMFlCXdzXBP4XWZvFgacU4mrKCXxc6+ePuckuJJtpbCg npU5ijXOjfLz6JdkGXaS5/ouU8C1I9som5KE8ATI= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF6ED6A603; Tue, 21 Apr 2026 12:36:10 -0600 (MDT) 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 uhT85nsx2uPn; Tue, 21 Apr 2026 12:36:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796570; bh=PZed5p9M4q3I7FxuXm0TqD3yWB4Wvute41vcgDa3BGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TftiT5RUY+ovmks5WTCp3Kc7Ufo+CpdHo7O7e4LLGBDSUvuunjFE8ugyVhh2kC1S6 V8vA2k7ucYWTL6qjy5Y4aDmkgUtslGl5imNMCF95xSjgZ2UFzBXyGTVRmhZGxUhhuZ ptQASaPE6Zy/B0MOIboQAEsLuw+QC6M2vDulP5RM= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 3EE886A601; Tue, 21 Apr 2026 12:36:10 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:49 -0600 Message-ID: <20260421183511.2044469-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3FQ4IPZFEM6QLVHR3VES7Q7HXMMFSM2R X-Message-ID-Hash: 3FQ4IPZFEM6QLVHR3VES7Q7HXMMFSM2R 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/16] bootstd: Also scan BLS target partitions by type 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 Boot Loader Specification says a boot loader should discover Type #1 entries by locating the ESP and XBOOTLDR partitions (or an MBR type 0xea partition) and reading loader/entry*.conf from them. It never mentions the bootable attribute. U-Boot's bootflow iterator currently skips any non-bootable partition once a bootable one has been seen, which means a disk with only an ESP and no 'bootable' flag (e.g. some hybrid media layouts) is not scanned for BLS entries at all. Also call part_is_bls_target() when deciding to skip, so ESP and XBOOTLDR partitions are always tried regardless of the flag. Existing bootable-partition behaviour is unchanged. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index faed1f3e5df..91d27d1e212 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -167,10 +167,16 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, * for filesystems or partition contents on this disk */ - /* if there are bootable partitions, scan only those */ + /* + * If there are bootable partitions, scan only those, plus any Boot + * Loader Specification target partitions (ESP, XBOOTLDR, MBR 0xea) + * which BLS discovery requires regardless of the bootable attribute. + */ } else if ((iter->flags & BOOTFLOWIF_ONLY_BOOTABLE) && iter->first_bootable >= 0 && - (iter->first_bootable ? !info.bootable : iter->part != 1)) { + (iter->first_bootable ? !info.bootable : iter->part != 1) && + !(CONFIG_IS_ENABLED(BOOTMETH_BLS) && + part_is_bls_target(&info))) { log_debug("Skipping non-bootable partition %d\n", iter->part); return log_msg_ret("boot", -EINVAL); } else { From patchwork Tue Apr 21 18:34:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2236 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=1776796577; bh=DEz1Dtu9niW0lOKlhxcJpDR8Djxjc5mQlWBFKYiE0lA=; 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=s/5evJorvk4zYWzeeQLixqQJ2N7DNG0Huli9m34GjBY+pImQd3cxzrJd3BkEJQQTZ 3f8IEoilrBggp3kqaIXSPDIWOxhXK58Zs4Ob9uykOoLiPHRYUXrwX62kYOEzm/oMs6 frOZR4CCgy0Gn98NrBf5l8Xozye29i+eDpuejwMk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E84B6A601 for ; Tue, 21 Apr 2026 12:36:17 -0600 (MDT) 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 KAwI_KbejuYd for ; Tue, 21 Apr 2026 12:36:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796577; bh=DEz1Dtu9niW0lOKlhxcJpDR8Djxjc5mQlWBFKYiE0lA=; 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=s/5evJorvk4zYWzeeQLixqQJ2N7DNG0Huli9m34GjBY+pImQd3cxzrJd3BkEJQQTZ 3f8IEoilrBggp3kqaIXSPDIWOxhXK58Zs4Ob9uykOoLiPHRYUXrwX62kYOEzm/oMs6 frOZR4CCgy0Gn98NrBf5l8Xozye29i+eDpuejwMk= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5EF866A604 for ; Tue, 21 Apr 2026 12:36:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796576; bh=zGr8+98aIfv8KTVyOi2tk2Ywy4DKT2i2Zt+lWb/F/Ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAixjJBVD+n9ttmAtppWo//iAEVMxUhcPBUsBaeFkrWS122P8CiE+bdDRiYTDZIe5 ox0bE3MnP+Evd6Ok7MZTmrcf32djESO8qBch38Em/dK2+6OVVuzuWi54okyshz/OSK hDbajn/N37KV8ZPNzb0fgZfsNxEaDxTKsz4YOPjc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5D95C6A604; Tue, 21 Apr 2026 12:36:16 -0600 (MDT) 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 GAHjUXHT2Wmj; Tue, 21 Apr 2026 12:36:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796571; bh=U6XWvtIt6ag4OX4dXHuUh7DTclvHrltYKtzl+CenXqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ppQ/yNS93JUlqwIzJ4aufPkkQU2ipTfROA/Q++vOfwfPe/XUMXAUO7+vthrKzgtpE 8ToGi4EWIRzlT0CweyKnwWIj6PiyMgAyqdEpfdHkAAvjBmaUhXBJhkTb/wuqVbhA5i muJCpecyosAPRKwtSCHlj8Zpx/ueILe1Kv350k2I= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 46EF16A601; Tue, 21 Apr 2026 12:36:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:50 -0600 Message-ID: <20260421183511.2044469-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CICZMVRYTHMDCET36UPUL5VHQTNSEPYY X-Message-ID-Hash: CICZMVRYTHMDCET36UPUL5VHQTNSEPYY 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] configs: efi-x86_app64: Scan all partitions at autoboot 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 EFI x86 app target is designed for booting installation media and live images from whatever disk the firmware chain-loads it from. Many of those layouts (for example the hybrid ISO 9660 produced by modern Ubuntu installers) place the BLS entry, kernel and initrd on a data partition that is neither an ESP nor an XBOOTLDR, so the strict BLS partition-type discovery introduced for bootmeth_bls does not reach them. Override the default bootcmd so autoboot passes -p to bootflow scan, which visits every partition on each bootdev rather than just bootable and BLS-target ones. This only affects this board; the global default remains 'bootflow scan -lb'. Signed-off-by: Simon Glass --- configs/efi-x86_app64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/efi-x86_app64_defconfig b/configs/efi-x86_app64_defconfig index 50c700e20c5..cf9114021e8 100644 --- a/configs/efi-x86_app64_defconfig +++ b/configs/efi-x86_app64_defconfig @@ -22,6 +22,7 @@ CONFIG_BOOTMETH_BLS=y CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_BOOTCOMMAND="bootflow scan -lpb" CONFIG_SYS_PBSIZE=532 CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_CONSOLE_PAGER is not set From patchwork Tue Apr 21 18:34:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2237 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=1776796582; bh=DuXwPXPZr22jALdpFOPADZhLFyJkD2Vd/RcSBeXhgqM=; 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=DqSrl/3Tk/umqdSvFRWNoru4RZY3rdnrF/wc2MkZJDeMYqVB3YRHjXYZApz8KrkQV j7maSjZqRK7ttm421fdVK/U1CMhRzSjvmoLJFhwZhg7XbbesH3JPdpVewIKI4v33Ex 7ZFkguRCNnRbQSFgOcUoM+rRL9jQ35AMkGOBm3dc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 307166A60B for ; Tue, 21 Apr 2026 12:36:22 -0600 (MDT) 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 RPpU9q2oTh3r for ; Tue, 21 Apr 2026 12:36:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796582; bh=DuXwPXPZr22jALdpFOPADZhLFyJkD2Vd/RcSBeXhgqM=; 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=DqSrl/3Tk/umqdSvFRWNoru4RZY3rdnrF/wc2MkZJDeMYqVB3YRHjXYZApz8KrkQV j7maSjZqRK7ttm421fdVK/U1CMhRzSjvmoLJFhwZhg7XbbesH3JPdpVewIKI4v33Ex 7ZFkguRCNnRbQSFgOcUoM+rRL9jQ35AMkGOBm3dc= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1DEEC6A604 for ; Tue, 21 Apr 2026 12:36:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796580; bh=UA1r678TsVeh22Gw9sSyOAswElFoBsyJMDnvO6GYuIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3xNHtg2fSMFMfbmzk8A7FtCas8knebCRQ9L23g5q2XLyqk41p8TZrXx4PGbekByQ Gu97LQD2h2IY2NiB23GOIq6kqse4dVoOQLeHTK5DebzZkr0Kp/gFG/9jW4B3XkGqQ3 OWC9OuDFy99WYX/1FFD5Gt0SF3G9c1JZcmmKXPi4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B11806A601; Tue, 21 Apr 2026 12:36:20 -0600 (MDT) 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 FzvCbqZYwJSF; Tue, 21 Apr 2026 12:36:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796576; bh=6379nUBM7+JA/c8ikMFp6jcyp0p0LscyLVU2/E2tYeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqC1AS6OJUTRTnep8+BKw32hCPu3Nr5KUKUXuK3u4qaTBJY0s60EA3yksOhnfeCD4 WCyZRGfTMkr1ptcZPiiN+MQVhcdQ6GhZdJSZkSl8maREqv5201Klu2R+MJFgGHZ1BJ VF/1PjhPeM6MFt3fo8aUK+1N6UyAM0fnmkSZojJE= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 396126A603; Tue, 21 Apr 2026 12:36:16 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:51 -0600 Message-ID: <20260421183511.2044469-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LF7ICI23PHIM5HBKTVJWLIYOB4DPNLRH X-Message-ID-Hash: LF7ICI23PHIM5HBKTVJWLIYOB4DPNLRH 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/16] scripts: ubuntu-iso-to-uboot: Drop kernel/initrd ESP copy 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 script copies /casper/vmlinuz and /casper/initrd onto the rewritten EFI system partition because BLS paths resolve against the partition holding loader/entry.conf and, before isofs streaming was fixed, U-Boot could not reach the ISO 9660 partition cleanly. With isofs streaming now fixed and the BLS iterator covering all partitions on this target, those two copies are no longer needed. Drop the kernel and initrd copy, shrink the ESP to 4 MiB (enough for the U-Boot binary), and instead add /loader/entry.conf to the ISO 9660 tree in the same xorriso pass via its -map predicate. The kernel and initrd stay where Ubuntu places them on the ISO 9660 side; U-Boot reads them directly via its isofs driver. The resulting ISO no longer duplicates ~90 MiB of kernel and initrd data. Update the documentation to match. Signed-off-by: Simon Glass --- doc/usage/os/ubuntu-live.rst | 110 +++++++++++---------------------- scripts/ubuntu-iso-to-uboot.py | 104 ++++++++++--------------------- 2 files changed, 71 insertions(+), 143 deletions(-) -- 2.43.0 diff --git a/doc/usage/os/ubuntu-live.rst b/doc/usage/os/ubuntu-live.rst index bd4e85e4c8a..fad476b4832 100644 --- a/doc/usage/os/ubuntu-live.rst +++ b/doc/usage/os/ubuntu-live.rst @@ -3,17 +3,16 @@ Booting Ubuntu live ISOs via U-Boot =================================== -U-Boot can replace GRUB as the bootloader on an Ubuntu live ISO. The -stock ISO has an appended EFI system partition (ESP) containing shim, -GRUB and their configuration. ``scripts/ubuntu-iso-to-uboot.py`` rewrites -that ESP with a U-Boot EFI application, a :doc:`Boot Loader Specification -Type #1 ` entry and the casper kernel and initrd, leaving the -rest of the ISO untouched so casper still finds its squashfs by disc -label at runtime. - -The flow only touches the appended partition. BIOS El Torito, the -grub2 MBR, the GPT layout and the ISO 9660 tree are preserved verbatim -by xorriso's ``-boot_image any replay`` +U-Boot can replace GRUB as the bootloader on an Ubuntu live ISO. +``scripts/ubuntu-iso-to-uboot.py`` rewrites the ISO so the appended EFI +system partition holds a U-Boot EFI application and the ISO 9660 tree +carries a :doc:`Boot Loader Specification Type #1 ` entry +pointing at the casper kernel and initrd that Ubuntu already places on +the disc. + +All other boot records (BIOS El Torito, grub2 MBR, GPT layout) are +preserved verbatim by xorriso's ``-boot_image any replay``, and casper +still finds its squashfs by disc label at runtime. Host prerequisites ------------------ @@ -26,17 +25,17 @@ Building the U-Boot EFI application ----------------------------------- The ``efi-x86_app64`` target enables ``CONFIG_BOOTMETH_BLS=y``, -``CONFIG_FS_ISOFS=y`` and ``CONFIG_JOLIET=y`` by default, so no -Kconfig tweaks are required. Build with:: +``CONFIG_FS_ISOFS=y`` and ``CONFIG_JOLIET=y`` by default, so no Kconfig +tweaks are required. Build with:: make O=/tmp/b/efi-x86_app64 efi-x86_app64_defconfig make O=/tmp/b/efi-x86_app64 -j$(nproc) -The output is ``/tmp/b/efi-x86_app64/u-boot-app.efi``, a PE32+ x86_64 EFI -application. +The output is ``/tmp/b/efi-x86_app64/u-boot-app.efi``, a PE32+ x86_64 +EFI application. If ``rustc`` is not installed, also disable the rust example build -before ``make``:: +before the main ``make``:: scripts/config --file /tmp/b/efi-x86_app64/.config \\ -d RUST_EXAMPLES -d EXAMPLES @@ -58,13 +57,14 @@ The script: 1. Reads the input ISO's boot record with ``xorriso -report_el_torito`` to pick up the volume label and the EFI system partition GUID. -2. Extracts ``/casper/vmlinuz`` and ``/casper/initrd`` via ``xorriso -osirrox`` -3. Builds a fresh FAT32 ESP (auto-sized to fit) containing - ``/EFI/BOOT/BOOTX64.EFI`` (the U-Boot app), ``/casper/vmlinuz``, - ``/casper/initrd`` and ``/loader/entry.conf`` -4. Writes a new ISO with ``xorriso -indev ... -outdev ... -boot_image - any replay -append_partition 2 ...``, replacing the original ESP - while preserving all other boot metadata. +2. Builds a small FAT ESP (4 MiB by default) containing just + ``/EFI/BOOT/BOOTX64.EFI`` -- the U-Boot EFI application. +3. Writes a new ISO with + ``xorriso -indev ... -outdev ... -boot_image any replay + -append_partition 2 ... -map entry.conf /loader/entry.conf``, + which replaces the original ESP and adds ``/loader/entry.conf`` to + the ISO 9660 tree. The kernel and initrd stay in ``/casper/`` on the + ISO 9660 tree; U-Boot reads them directly via its isofs driver. Relevant options: @@ -72,14 +72,15 @@ Relevant options: * ``-o PATH`` -- the output ISO (required). * ``-a ARGS`` -- override the kernel command line written to ``loader/entry.conf``. The default is - ``console=ttyS0,115200 console=tty0 --- quiet``, which logs the kernel output - serial and video. Duplicate the ``console=`` arguments after ``---`` as well - if you want casper and the running system logged to serial too. + ``console=ttyS0,115200 console=tty0 --- quiet``, which logs the + kernel to serial and video. Duplicate the ``console=`` arguments + after ``---`` as well if you want casper and the running system + logged to serial too. * ``-k PATH`` / ``-i PATH`` -- override the kernel and initrd paths inside the ISO if a distribution uses something other than ``casper/vmlinuz`` and ``casper/initrd``. -* ``-s MiB`` -- force an ESP size; the default auto-sizes to fit the - kernel, initrd and U-Boot app with 16 MiB of headroom. +* ``-s MiB`` -- force an ESP size; the default is 4 MiB, enough for the + U-Boot binary. * ``-t TITLE`` -- override the BLS entry title. Testing under QEMU + OVMF @@ -95,60 +96,23 @@ Testing under QEMU + OVMF The expected boot trace on the serial console is roughly:: - BdsDxe: loading Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0) - BdsDxe: starting Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0) - Laceboot EFI App (using allocated RAM address 6beef000) starting - - U-Boot Concept 2026.02 - - CPU: x86_64, vendor , device 0h - Model: EFI x86 Application - DRAM: 256 MiB - Core: 22 devices, 13 uclasses, devicetree: separate - EFI: disks 2, partitions 3 - Loading Environment from FAT... Unable to use efi 0:0... - Video: 1280x800x32 @ 0 - Hit any key to stop autoboot: 2 - Hit any key to stop autoboot: 1 - Hit any key to stop autoboot: 0 - Scanning for bootflows in all bootdevs - Seq Method State Uclass Part Ent E Name Filename - --- ----------- ------ -------- ---- --- - ------------------------ ---------------- - Hunting with: fs + ... Scanning bootdev 'efi_media_0.bootdev': - 0 bls ready pci 2 0 efi_media_0.bootdev.part_ /loader/entry.conf - ** Booting bootflow 'efi_media_0.bootdev.part_2' with bls + 0 bls ready pci 1 0 efi_media_0.bootdev.part_ /loader/entry.conf + ** Booting bootflow 'efi_media_0.bootdev.part_1' with bls Retrieving file: /casper/vmlinuz Retrieving file: /casper/initrd - Valid Boot Flag - Magic signature found - Linux kernel version 6.8.0-41-generic (buildd@lcy02-amd64-100) #41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 2 20:41:06 UTC 2024 - Building boot_params at 90000 - Loading bzImage at address 100000 (14926336 bytes) - Initial RAM disk at linear address 8000000, size 47a003e (75104318 bytes) - Kernel command line: "console=ttyS0,115200 console=tty0 --- console=ttyS0,115200 quiet" - + Linux kernel version 6.8.0-41-generic ... Ubuntu Starting kernel ... - ... - - -Why the kernel and initrd live on the ESP ------------------------------------------ - -BLS paths are resolved against the partition holding ``loader/entry.conf`` - -OVMF only exposes the EFI system partition as an ``EFI_BLOCK_IO`` protocol -handle on CD media, so U-Boot's ``efi_media`` bootdev cannot see the ISO 9660 -partition directly and would fail to resolve ``/casper/vmlinuz`` if the entry -were placed there. Copying the kernel and initrd onto the ESP sidesteps this; -the ISO 9660 side remains bootable in its own right, and casper finds its -squashfs on the original media at runtime. +The bootflow appears on ``part_1`` -- the ISO 9660 partition -- because +``entry.conf`` lives in the ISO 9660 tree and U-Boot reads kernel and +initrd from the same partition via isofs. See also -------- -* :doc:`/usage/bls` — the U-Boot Boot Loader Specification bootmeth. +* :doc:`/usage/bls` -- the U-Boot Boot Loader Specification bootmeth. * `Boot Loader Specification `_. diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py index ec32ac7b0dd..ec2e3cdd2c3 100755 --- a/scripts/ubuntu-iso-to-uboot.py +++ b/scripts/ubuntu-iso-to-uboot.py @@ -8,17 +8,18 @@ the EFI system partition. Each entry names a kernel, initrd and command line; U-Boot's BOOTMETH_BLS scans the ESP and presents them in its boot menu, replacing the shim/grub chain that Ubuntu ships by default. -The ISO's appended EFI System Partition is replaced with a fresh ESP -containing: +Two things change in the rewritten ISO: - /EFI/BOOT/BOOTX64.EFI U-Boot EFI app (built with CONFIG_BOOTMETH_BLS=y) - /casper/vmlinuz copied from the input ISO - /casper/initrd copied from the input ISO - /loader/entry.conf BLS Type #1 entry pointing at the above + EFI system partition /EFI/BOOT/BOOTX64.EFI replaced with the U-Boot + EFI app + ISO 9660 tree /loader/entry.conf added, pointing at the + existing /casper/vmlinuz + and /casper/initrd -The ISO9660 tree is preserved unchanged, so casper still finds its squashfs -by disc label at runtime. All other boot records (BIOS El Torito, grub2 MBR, -GPT layout) are preserved by xorriso's -boot_image any replay. +The kernel and initrd stay where Ubuntu put them. U-Boot reads them off +the ISO 9660 partition directly via its isofs driver. All other boot +records (BIOS El Torito, grub2 MBR, GPT layout) are preserved by +xorriso's -boot_image any replay. Quick start (run from the root of the U-Boot tree):: @@ -114,65 +115,32 @@ def parse_boot_report(iso: Path) -> tuple[str, str]: return m_vol.group(1), m_esp.group(1) -def extract_from_iso(iso: Path, src: str, dst: Path) -> None: - """Pull a single file out of the ISO9660 tree via xorriso -osirrox""" - dst.parent.mkdir(parents=True, exist_ok=True) - command.run( - 'xorriso', '-osirrox', 'on', '-indev', str(iso), - '-extract', f'/{src.lstrip("/")}', str(dst), - ) - - -def build_esp( - esp_path: Path, - size_mib: int, - uboot_efi: Path, - vmlinuz: Path, - initrd: Path, - entry_conf: str, -) -> None: - """Create a fresh FAT32 ESP at esp_path populated with BLS + kernel. +def build_esp(esp_path: Path, size_mib: int, uboot_efi: Path) -> None: + """Create a fresh FAT ESP containing only the U-Boot EFI application. Args: esp_path (Path): Output file to hold the new ESP image size_mib (int): Size of the ESP in mebibytes uboot_efi (Path): U-Boot EFI app to install as /EFI/BOOT/BOOTX64.EFI - vmlinuz (Path): Kernel image to install under /casper/vmlinuz - initrd (Path): Initrd image to install under /casper/initrd - entry_conf (str): Contents for /loader/entry.conf (BLS Type #1) """ with esp_path.open('wb') as f: f.truncate(size_mib * MIB) - command.output('mkfs.vfat', '-F32', '-n', 'ESP', str(esp_path)) - command.run('mmd', '-i', str(esp_path), - '::EFI', '::EFI/BOOT', '::loader', '::casper') - - def put(src: Path, dst: str) -> None: - command.run('mcopy', '-i', str(esp_path), str(src), f'::{dst}') - - put(uboot_efi, 'EFI/BOOT/BOOTX64.EFI') - put(vmlinuz, 'casper/vmlinuz') - put(initrd, 'casper/initrd') - - entry = Path(esp_path.parent) / 'entry.conf' - entry.write_text(entry_conf) - put(entry, 'loader/entry.conf') - - -def auto_esp_size(files: list[Path], headroom_mib: int = 16) -> int: - """Sum file sizes + headroom, round up to MiB, floor at 64 MiB (FAT32)""" - total = sum(f.stat().st_size for f in files) + headroom_mib * MIB - mib = (total + MIB - 1) // MIB - return max(mib, 64) + # FAT12 is enough for the small ESP we emit (just a U-Boot binary). + command.output('mkfs.vfat', '-F12', '-n', 'ESP', str(esp_path)) + command.run('mmd', '-i', str(esp_path), '::EFI', '::EFI/BOOT') + command.run('mcopy', '-i', str(esp_path), str(uboot_efi), + '::EFI/BOOT/BOOTX64.EFI') def repack_iso( in_iso: Path, out_iso: Path, esp_img: Path, esp_guid: str, + entry_conf: Path, ) -> None: - """Stream the input ISO to a new ISO, replacing partition 2's data. + """Stream the input ISO to a new ISO with the ESP and BLS entry replaced. -boot_image any replay preserves every other boot record (BIOS El Torito, - grub2 MBR, GPT layout); only the bytes behind partition 2 are rewritten + grub2 MBR, GPT layout); only the bytes behind partition 2 are rewritten, + plus /loader/entry.conf is added to the ISO 9660 tree. """ command.run( 'xorriso', @@ -180,6 +148,7 @@ def repack_iso( '-outdev', str(out_iso), '-boot_image', 'any', 'replay', '-append_partition', '2', esp_guid, str(esp_img), + '-map', str(entry_conf), '/loader/entry.conf', '-commit', ) @@ -202,7 +171,7 @@ def main() -> None: p.add_argument('-t', '--title', default=None, help='BLS entry title (default: derived from volume label)') p.add_argument('-s', '--esp-size', type=int, default=None, - help='ESP size in MiB (default: auto-size to fit)') + help='ESP size in MiB (default: 4 MiB)') args = p.parse_args() if not args.iso.is_file(): @@ -220,27 +189,22 @@ def main() -> None: with tempfile.TemporaryDirectory(prefix='iso2uboot.') as td: work = Path(td) - vmlinuz = work / 'vmlinuz' - initrd = work / 'initrd' - print(f'=> Extracting /{args.kernel} and /{args.initrd}') - extract_from_iso(args.iso, args.kernel, vmlinuz) - extract_from_iso(args.iso, args.initrd, initrd) - - esp_mib = args.esp_size or auto_esp_size([vmlinuz, initrd, args.uboot]) + esp_mib = args.esp_size or 4 print(f'=> Building {esp_mib} MiB ESP') - - entry_conf = f'''\ -title {title} -linux /casper/vmlinuz -initrd /casper/initrd -options {args.cmdline} -''' esp = work / 'esp.img' - build_esp(esp, esp_mib, args.uboot, vmlinuz, initrd, entry_conf) + build_esp(esp, esp_mib, args.uboot) + + entry = work / 'entry.conf' + entry.write_text( + f'title {title}\n' + f'linux /{args.kernel}\n' + f'initrd /{args.initrd}\n' + f'options {args.cmdline}\n' + ) print(f'=> Repacking to {args.out}') - repack_iso(args.iso, args.out, esp, esp_guid) + repack_iso(args.iso, args.out, esp, esp_guid, entry) size_mib = args.out.stat().st_size / MIB print(f'=> Done: {args.out} ({size_mib:.1f} MiB)') From patchwork Tue Apr 21 18:34:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2238 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=1776796587; bh=kRWSn7CIqGanK1SkdWX7+Xzox0FSN72gCJzaT55wUKk=; 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=dcPs0JZhqjRT8ljHVyJJ8qqKrV2OJGv5xYND0TnpCRUQCF1S1qpmLrOibIV0y+EKW HcWR8f9+btdyV5f9Z4fbThsicLNpm3hslAR45jAII4jBF7FCSDLy3EVVIEFYqtQnqq bxfq68upnl5ukzGWpAiH6Z1em9zIVXgf2gnpQ6bk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C040C6A60B for ; Tue, 21 Apr 2026 12:36:27 -0600 (MDT) 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 IwEHCiRC5Uya for ; Tue, 21 Apr 2026 12:36:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796587; bh=kRWSn7CIqGanK1SkdWX7+Xzox0FSN72gCJzaT55wUKk=; 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=dcPs0JZhqjRT8ljHVyJJ8qqKrV2OJGv5xYND0TnpCRUQCF1S1qpmLrOibIV0y+EKW HcWR8f9+btdyV5f9Z4fbThsicLNpm3hslAR45jAII4jBF7FCSDLy3EVVIEFYqtQnqq bxfq68upnl5ukzGWpAiH6Z1em9zIVXgf2gnpQ6bk= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AFB516A604 for ; Tue, 21 Apr 2026 12:36:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796585; bh=euG+Gr/Kx2jADoDehn6lbCSMxwk05UvQA9Oz9LbAn9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPLWe1+84LJPKNouUZP/YC/TEGT31eX+m48gTBge2drwexFAITpRM5GxE83vK95gq XelR1xjpxGL9v/Nl5TMffS7uN6pB6pAX7SksGNnb6wArKnjV9hOWAMHPwRnId8a8fj iMqfr2i2m9bBAcONw/G913dYFK+C+8UXq1Kp2/bs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A2A386A603; Tue, 21 Apr 2026 12:36:25 -0600 (MDT) 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 xBUmvmsp1XBC; Tue, 21 Apr 2026 12:36:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796581; bh=gJn+OJ2RtFY58lb+J7pvcYNiJZQPmmSmTynS0CGev1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnGYwSciuW8zJDNPkZtJ9wzIprwewuV9xPnY16iOl0Y78VZWkrkHLaJZ+wl1YYym7 fpyaXrmyzGeY15+mDhB+p64qQi8UDBKC18pqO54VeWKPAX4SYKK52MlEB3nuhjvi+n VNBlf4BAdeQOBnK3OtGd1TCngqo61BY/uN5vxr0g= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 451FF6A601; Tue, 21 Apr 2026 12:36:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:52 -0600 Message-ID: <20260421183511.2044469-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PHDW27WGBF52IE7Q7EOFVWM5HDCPT2X3 X-Message-ID-Hash: PHDW27WGBF52IE7Q7EOFVWM5HDCPT2X3 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/16] scripts: ubuntu-iso-to-uboot: Strip unused GRUB binaries 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 Ubuntu ISO carries shim, grubx64 and the MOK manager under /EFI/boot/ in the ISO 9660 tree. UEFI firmware loads BOOTX64.EFI from the appended ESP, which the script replaces with u-boot-app.efi, so those three binaries sit unused. Extend the xorriso pass with three -find ... -exec rm -- steps to remove them. -find is silent on no match, so the script still works on distributions shipping a different set of files. The BIOS El Torito image under /boot/grub/ is untouched, so legacy boot still chains into GRUB. Update the documentation to match. Signed-off-by: Simon Glass --- doc/usage/os/ubuntu-live.rst | 6 ++++++ scripts/ubuntu-iso-to-uboot.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/usage/os/ubuntu-live.rst b/doc/usage/os/ubuntu-live.rst index fad476b4832..991d79a9454 100644 --- a/doc/usage/os/ubuntu-live.rst +++ b/doc/usage/os/ubuntu-live.rst @@ -65,6 +65,12 @@ The script: which replaces the original ESP and adds ``/loader/entry.conf`` to the ISO 9660 tree. The kernel and initrd stay in ``/casper/`` on the ISO 9660 tree; U-Boot reads them directly via its isofs driver. +4. Strips the shim, GRUB and MOK manager binaries + (``/EFI/boot/{bootx64,grubx64,mmx64}.efi``) from the ISO 9660 tree. + The UEFI firmware loads ``BOOTX64.EFI`` from the appended ESP, so + the ISO 9660 copies are unused dead weight. The BIOS El Torito + image under ``/boot/grub/`` is left in place, so legacy-BIOS boot + still chains into GRUB as before. Relevant options: diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py index ec2e3cdd2c3..df38833a4c6 100755 --- a/scripts/ubuntu-iso-to-uboot.py +++ b/scripts/ubuntu-iso-to-uboot.py @@ -140,7 +140,13 @@ def repack_iso( -boot_image any replay preserves every other boot record (BIOS El Torito, grub2 MBR, GPT layout); only the bytes behind partition 2 are rewritten, - plus /loader/entry.conf is added to the ISO 9660 tree. + plus /loader/entry.conf is added to the ISO 9660 tree, and the shim, + GRUB and MokManager copies under /EFI/boot/ are removed since U-Boot + supplies the UEFI boot path via the appended ESP. The BIOS El Torito + path still uses /boot/grub/ so legacy boot continues to work. + + -find is tolerant of missing files: if a distribution does not ship + one of these binaries, the call is a no-op. """ command.run( 'xorriso', @@ -149,6 +155,9 @@ def repack_iso( '-boot_image', 'any', 'replay', '-append_partition', '2', esp_guid, str(esp_img), '-map', str(entry_conf), '/loader/entry.conf', + '-find', '/EFI/boot', '-name', 'bootx64.efi', '-exec', 'rm', '--', + '-find', '/EFI/boot', '-name', 'grubx64.efi', '-exec', 'rm', '--', + '-find', '/EFI/boot', '-name', 'mmx64.efi', '-exec', 'rm', '--', '-commit', ) From patchwork Tue Apr 21 18:34:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2239 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=1776796592; bh=fKW5aMLwPn0r8k78cQxhC13DvKltvFtMUoKhBICkLlY=; 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=VmXbjtKKzBZopXEkn3BqA6rxbO0tiHj7c8GEabcslT3/0G5CUDj9kSQIjtEUkHSBu XDB/mfQKLfWohUnS8v7rDRe7An0at8HoA1Ze+ibG4wiXlLuDWDBO++3JXZbbIFtOCO eojw0qqSadBtMwJugHoEN+tOEbsUjUM+t32cbSzM= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 458E06A603 for ; Tue, 21 Apr 2026 12:36:32 -0600 (MDT) 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 J9dBr80_Cyqk for ; Tue, 21 Apr 2026 12:36:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796592; bh=fKW5aMLwPn0r8k78cQxhC13DvKltvFtMUoKhBICkLlY=; 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=VmXbjtKKzBZopXEkn3BqA6rxbO0tiHj7c8GEabcslT3/0G5CUDj9kSQIjtEUkHSBu XDB/mfQKLfWohUnS8v7rDRe7An0at8HoA1Ze+ibG4wiXlLuDWDBO++3JXZbbIFtOCO eojw0qqSadBtMwJugHoEN+tOEbsUjUM+t32cbSzM= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 342E16A604 for ; Tue, 21 Apr 2026 12:36:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796590; bh=tJzL1L5ER/zcOYqXQhbhGv3oNreF4C2olwrmdOXS7wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IpzGfisbB6uixDiZYCvznjxHGbAhdV/QpA0Jxpsv8zHz0UggWIWv0pMqJJDwueCDt jmiZSV58pJKP0fOczwjqJMbTmR6N3LqM6Onv3/Oymes+HYK29lOC18TJTL4DgSA5BS o9ytsf1JIvo3W9ktJl0A7SER9rcpxQgT0+g/9dqo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91D166A603; Tue, 21 Apr 2026 12:36:30 -0600 (MDT) 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 kBUGW8RqQbYw; Tue, 21 Apr 2026 12:36:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796586; bh=HqoBln68fLpCP8hmYR1mUqUgrZ3qI9aZdOZU3KsqfAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6Fi+q2HOTy30r8SgUiexmp6QWP8Rlfb5hSFNHmX8WCKSBF8EVyIQB14yhA/XldRy UEhd3YiNvua18Wm08zpXr/mpOffIXRnoNwHPySoo4CX/YFnqb2UZd61HrJfzvPHaEU UuCPHYgVXwPjMNzdoCLweNo+XhQIrZvV4fPyu2+0= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 397196A601; Tue, 21 Apr 2026 12:36:26 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:53 -0600 Message-ID: <20260421183511.2044469-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GYUV3IIXY2WYVRKZ77TUIOF2RMG6CYHV X-Message-ID-Hash: GYUV3IIXY2WYVRKZ77TUIOF2RMG6CYHV 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/16] scripts: ubuntu-iso-to-uboot: Unlink stale output first 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 xorriso refuses to write into an existing non-empty file when -indev and -outdev differ: it treats the outdev as a session to extend and aborts with xorriso : FAILURE : -indev differs from -outdev and -outdev media holds non-zero data This bites any second run, whether invoked by hand or by the 'qemu-efi-iso' writer method added to labgrid for the new CI role. Unlink the destination so each invocation starts from a clean file. Signed-off-by: Simon Glass --- scripts/ubuntu-iso-to-uboot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py index df38833a4c6..7fc20327f02 100755 --- a/scripts/ubuntu-iso-to-uboot.py +++ b/scripts/ubuntu-iso-to-uboot.py @@ -147,7 +147,13 @@ def repack_iso( -find is tolerant of missing files: if a distribution does not ship one of these binaries, the call is a no-op. + + xorriso refuses to write to an existing non-empty file when -indev + and -outdev differ (it would treat the outdev as a session to + extend), so unlink any stale output first. """ + if out_iso.exists(): + out_iso.unlink() command.run( 'xorriso', '-indev', str(in_iso), From patchwork Tue Apr 21 18:34:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2240 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=1776796596; bh=KZ9o096LjyXpMYfTSM9ybqHnRYrQuId7HhBwBpBgQQU=; 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=NuexWXlXsolYmWBPmhHluhiHNoDQQ8t62xughcywLOxA95RPneYg9nMhZcK19ZV8F 9zQ5buZj8rj7NIDZjtpEHDYfE0KaGu8RPT6YVkfoAGL4B0JfoetXQyngSJWIJ/gjQL CsIj86SP+RFGFU5cfEXGchvIFvhbsFn33viWwbfU= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E337E6A60D for ; Tue, 21 Apr 2026 12:36:36 -0600 (MDT) 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 XTLEzh7ZHYoK for ; Tue, 21 Apr 2026 12:36:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796596; bh=KZ9o096LjyXpMYfTSM9ybqHnRYrQuId7HhBwBpBgQQU=; 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=NuexWXlXsolYmWBPmhHluhiHNoDQQ8t62xughcywLOxA95RPneYg9nMhZcK19ZV8F 9zQ5buZj8rj7NIDZjtpEHDYfE0KaGu8RPT6YVkfoAGL4B0JfoetXQyngSJWIJ/gjQL CsIj86SP+RFGFU5cfEXGchvIFvhbsFn33viWwbfU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2BCE6A603 for ; Tue, 21 Apr 2026 12:36:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796595; bh=PKAczdbW7XF/3wEssM7tia22rRso1IDbv9bxGjlFeds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9BvSBUl4my/et2ZMQmkDG0G51qmJ4wgX1g9bVp1YqbEJMmEiakXs82dGJH7rb+Ci 1p0bQqjnHdVlkVDwUseeclGpC+93NDzlnibf9Ro/UkfFxsuYBa7ja0Dnd6/BWjC0be lFQzgTpzRb3McaTVuF1RI1Y4tuh/DQW9XUXEFhmc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 89B896A603; Tue, 21 Apr 2026 12:36:35 -0600 (MDT) 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 GNzk6qArMWqR; Tue, 21 Apr 2026 12:36:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796591; bh=02drzfIOEPEInZjkkbD/QfQL6KmVykbQcB6EESZaZcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMsjFTQqa3lrO+zrfByYlobTP8xZXxF+dZXTPlFG5iLsHNv9Pcrb2O3FFkLYH3kc7 WORpBFVxmDO5eRPqr29YcvbkqrIh9zE2LpWtQBGBuAxhXKVb/kgEqeIxBE3y0YMlSi bjqw1kZnOTSxuJ01m8McEqy7Gn9Eve7CbhWaLdao= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 271526A601; Tue, 21 Apr 2026 12:36:31 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:54 -0600 Message-ID: <20260421183511.2044469-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: THW3NM5FX4EPDXR36PXLCZC7MJLLYVPE X-Message-ID-Hash: THW3NM5FX4EPDXR36PXLCZC7MJLLYVPE 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/16] scripts: ubuntu-iso-to-uboot: Inherit cmdline from the ISO 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 rewritten ISO should behave the same as the original Ubuntu live image under any boot loader, so the kernel command line it advertises via /loader/entry.conf should match what the source ISO's own grub entry would pass to /casper/vmlinuz. Hard-coding a fresh cmdline changes the user-visible behaviour (e.g. casper flags, plymouth splash) and risks drifting from the upstream ISO as Ubuntu revises it between releases. Parse /boot/grub/grub.cfg out of the input ISO and pick up the arguments after the first 'linux /casper/vmlinuz' line, falling through to that value when the caller does not override with -a. Log the resulting cmdline so the user can see what the rewritten ISO will boot with. Signed-off-by: Simon Glass --- scripts/ubuntu-iso-to-uboot.py | 39 ++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py index 7fc20327f02..d9430cfd006 100755 --- a/scripts/ubuntu-iso-to-uboot.py +++ b/scripts/ubuntu-iso-to-uboot.py @@ -76,7 +76,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'tools')) from u_boot_pylib import command from u_boot_pylib import tout -DEFAULT_CMDLINE = 'console=ttyS0,115200 console=tty0 --- quiet' REQUIRED_TOOLS = ('xorriso', 'mcopy', 'mmd', 'mkfs.vfat') MIB = 1024 * 1024 @@ -90,6 +89,33 @@ def check_tools() -> None: ) +def parse_grub_cmdline(iso: Path) -> str: + """Return the kernel cmdline from the ISO's default grub entry. + + Parses the first `linux /casper/vmlinuz ...` line in /boot/grub/grub.cfg + and strips the kernel path, so the caller can pass the remaining tokens + to the kernel (e.g. '--- quiet splash' on Ubuntu 24.04.1). + """ + with tempfile.TemporaryDirectory(prefix='iso2uboot.grub.') as td: + dst = Path(td) / 'grub.cfg' + command.run( + 'xorriso', '-osirrox', 'on', '-indev', str(iso), + '-extract', '/boot/grub/grub.cfg', str(dst), + ) + cfg = dst.read_text(errors='replace') + + m = re.search( + r'^\s*linux\s+\S*casper/vmlinuz\S*\s*(.*)$', + cfg, re.MULTILINE, + ) + if not m: + tout.fatal( + 'could not find a casper linux entry in /boot/grub/grub.cfg' + ) + # Collapse any run of whitespace to a single space + return ' '.join(m.group(1).split()) + + def parse_boot_report(iso: Path) -> tuple[str, str]: """Return (volume_label, esp_partition_guid) from xorriso's mkisofs report. @@ -181,8 +207,9 @@ def main() -> None: help='kernel path inside the input ISO') p.add_argument('-i', '--initrd', default='casper/initrd', help='initrd path inside the input ISO') - p.add_argument('-a', '--cmdline', default=DEFAULT_CMDLINE, - help='kernel command line written into loader/entry.conf') + p.add_argument('-a', '--cmdline', default=None, + help='kernel command line written into loader/entry.conf ' + '(default: inherit from the ISO\'s grub.cfg)') p.add_argument('-t', '--title', default=None, help='BLS entry title (default: derived from volume label)') p.add_argument('-s', '--esp-size', type=int, default=None, @@ -199,8 +226,12 @@ def main() -> None: # Extract the volume label and ESP partition GUID from xorriso's report vol_id, esp_guid = parse_boot_report(args.iso) title = args.title or f'U-Boot BLS boot ({vol_id})' + cmdline = args.cmdline + if cmdline is None: + cmdline = parse_grub_cmdline(args.iso) print(f' Volume label: {vol_id}') print(f' ESP GUID: {esp_guid}') + print(f' Cmdline: {cmdline}') with tempfile.TemporaryDirectory(prefix='iso2uboot.') as td: work = Path(td) @@ -215,7 +246,7 @@ def main() -> None: f'title {title}\n' f'linux /{args.kernel}\n' f'initrd /{args.initrd}\n' - f'options {args.cmdline}\n' + f'options {cmdline}\n' ) print(f'=> Repacking to {args.out}') From patchwork Tue Apr 21 18:34:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2241 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=1776796602; bh=0mfJhssvko5K9Bh/mKL/5753dGs82KrG6huGUUfAhBg=; 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=dBhowY3EqhgVFrfPDQyDSebvx6rulJlBTlzc6YMBN2IhXpmJl1ZMnHeKD1h4E1kVF yHvPvKkyztOtQwwszAQFOf9FmDCetNB/Vi0xa7wmvKr0KC4HT6QhiZYoFPLxYz0X41 DjtljEt4w439gyMdmh7nY44LFXi/DaBKZOSdLKe0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6EB526A60D for ; Tue, 21 Apr 2026 12:36:42 -0600 (MDT) 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 LgDKcIIKZmQo for ; Tue, 21 Apr 2026 12:36:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796602; bh=0mfJhssvko5K9Bh/mKL/5753dGs82KrG6huGUUfAhBg=; 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=dBhowY3EqhgVFrfPDQyDSebvx6rulJlBTlzc6YMBN2IhXpmJl1ZMnHeKD1h4E1kVF yHvPvKkyztOtQwwszAQFOf9FmDCetNB/Vi0xa7wmvKr0KC4HT6QhiZYoFPLxYz0X41 DjtljEt4w439gyMdmh7nY44LFXi/DaBKZOSdLKe0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5DBC36A608 for ; Tue, 21 Apr 2026 12:36:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796600; bh=jt0MO+LIXh+tayzCfyrRZrxGaY43n68TW2R+2BaRqss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSfWRQEeL+m16ZJ/uKXPmoz6Y2aK50roG7Kg5zsnfGmUAX25PVSVEy+ZwvrWRsfyt WMRV5jZj3aMEoc/+3+2SDlsoIjXmqcH2TBFV6xl8wbgyPXAuAMVNFt9Z1veBlcAn1S c8RhkhBBZsHDoHred1ffr1Pdg8/IL+MhNT1Q39bs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 352726A603; Tue, 21 Apr 2026 12:36:40 -0600 (MDT) 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 NqPPFD359uMg; Tue, 21 Apr 2026 12:36:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796596; bh=dUULm0NbVvyjSiqaXNJgb5eybLLV6jIFYKh/wAtJPoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GQG+SxwXS9rFR5/vxyLQz+oknUEf5cPP5w9NGBY8t1zzOUJliuPlGiqmuxT4iRkL8 2b7kcj2Rqh+hP2AvLchpr7tt/jE/uADEtJ6+0C2Oj52JlJSYWcS/nmpO9kNgkimY1d 23FCzG+iXvytaGpZ1JQ2s9jGImHH31uL+yL0o++Y= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 1F0F86A601; Tue, 21 Apr 2026 12:36:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:55 -0600 Message-ID: <20260421183511.2044469-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QJDXT7APUZWDG4YILI5CZ26T5GAWJOL2 X-Message-ID-Hash: QJDXT7APUZWDG4YILI5CZ26T5GAWJOL2 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/16] scripts: ubuntu-iso-to-uboot: Be quiet by default 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 script prints its own progress markers and passes xorriso's (very chatty) stdout/stderr through unchanged, which makes output from the labgrid 'qemu-efi-iso' writer noisy. Route progress lines through tout.notice() and capture subprocess stdout/stderr by default; on failure u_boot_pylib's CommandExc still carries the captured output so the user sees what xorriso said. Add -v / --verbose to raise tout's verbosity to INFO, which both shows the progress markers and lets the subprocesses' output flow through unchanged for debugging. Signed-off-by: Simon Glass --- scripts/ubuntu-iso-to-uboot.py | 57 +++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py index d9430cfd006..f6326b7eceb 100755 --- a/scripts/ubuntu-iso-to-uboot.py +++ b/scripts/ubuntu-iso-to-uboot.py @@ -80,6 +80,21 @@ REQUIRED_TOOLS = ('xorriso', 'mcopy', 'mmd', 'mkfs.vfat') MIB = 1024 * 1024 +def _quiet() -> bool: + """True when tout is set below INFO (no progress chatter requested).""" + return tout.verbose < tout.INFO + + +def _run(*cmd) -> None: + """Run a command, capturing its output when tout is quiet. + + On failure u_boot_pylib's CommandExc still carries the captured + output, so the user sees what went wrong. + """ + quiet = _quiet() + command.run(*cmd, capture=quiet, capture_stderr=quiet) + + def check_tools() -> None: missing = [t for t in REQUIRED_TOOLS if not shutil.which(t)] if missing: @@ -98,7 +113,7 @@ def parse_grub_cmdline(iso: Path) -> str: """ with tempfile.TemporaryDirectory(prefix='iso2uboot.grub.') as td: dst = Path(td) / 'grub.cfg' - command.run( + _run( 'xorriso', '-osirrox', 'on', '-indev', str(iso), '-extract', '/boot/grub/grub.cfg', str(dst), ) @@ -109,9 +124,7 @@ def parse_grub_cmdline(iso: Path) -> str: cfg, re.MULTILINE, ) if not m: - tout.fatal( - 'could not find a casper linux entry in /boot/grub/grub.cfg' - ) + tout.fatal('could not find a casper linux entry in /boot/grub/grub.cfg') # Collapse any run of whitespace to a single space return ' '.join(m.group(1).split()) @@ -122,9 +135,11 @@ def parse_boot_report(iso: Path) -> tuple[str, str]: Raises SystemExit if the ISO does not have an appended EFI System Partition on slot 2 """ - # xorriso prints the report on stdout; stderr carries progress/status. - report = command.output( + # xorriso prints the report on stdout (which we need to parse) and + # progress/status on stderr (which we swallow unless -v was passed). + report = command.run( 'xorriso', '-indev', str(iso), '-report_el_torito', 'as_mkisofs', + capture=True, capture_stderr=_quiet(), ) m_vol = re.search(r"^-V '([^']*)'", report, re.MULTILINE) @@ -152,10 +167,10 @@ def build_esp(esp_path: Path, size_mib: int, uboot_efi: Path) -> None: with esp_path.open('wb') as f: f.truncate(size_mib * MIB) # FAT12 is enough for the small ESP we emit (just a U-Boot binary). - command.output('mkfs.vfat', '-F12', '-n', 'ESP', str(esp_path)) - command.run('mmd', '-i', str(esp_path), '::EFI', '::EFI/BOOT') - command.run('mcopy', '-i', str(esp_path), str(uboot_efi), - '::EFI/BOOT/BOOTX64.EFI') + _run('mkfs.vfat', '-F12', '-n', 'ESP', str(esp_path)) + _run('mmd', '-i', str(esp_path), '::EFI', '::EFI/BOOT') + _run('mcopy', '-i', str(esp_path), str(uboot_efi), + '::EFI/BOOT/BOOTX64.EFI') def repack_iso( @@ -180,7 +195,7 @@ def repack_iso( """ if out_iso.exists(): out_iso.unlink() - command.run( + _run( 'xorriso', '-indev', str(in_iso), '-outdev', str(out_iso), @@ -214,30 +229,36 @@ def main() -> None: help='BLS entry title (default: derived from volume label)') p.add_argument('-s', '--esp-size', type=int, default=None, help='ESP size in MiB (default: 4 MiB)') + p.add_argument('-v', '--verbose', action='store_true', + help='show progress markers and subprocess output') args = p.parse_args() + # Default verbosity is WARNING (silent); -v raises to INFO so + # tout.notice()/tout.info() print and _run() stops capturing output. + tout.init(tout.INFO if args.verbose else tout.WARNING) + if not args.iso.is_file(): tout.fatal(f'ISO not found: {args.iso}') if not args.uboot.is_file(): tout.fatal(f'EFI app not found: {args.uboot}') check_tools() - print(f'=> Reading boot config from {args.iso}') + tout.notice(f'=> Reading boot config from {args.iso}') # Extract the volume label and ESP partition GUID from xorriso's report vol_id, esp_guid = parse_boot_report(args.iso) title = args.title or f'U-Boot BLS boot ({vol_id})' cmdline = args.cmdline if cmdline is None: cmdline = parse_grub_cmdline(args.iso) - print(f' Volume label: {vol_id}') - print(f' ESP GUID: {esp_guid}') - print(f' Cmdline: {cmdline}') + tout.notice(f' Volume label: {vol_id}') + tout.notice(f' ESP GUID: {esp_guid}') + tout.notice(f' Cmdline: {cmdline}') with tempfile.TemporaryDirectory(prefix='iso2uboot.') as td: work = Path(td) esp_mib = args.esp_size or 4 - print(f'=> Building {esp_mib} MiB ESP') + tout.notice(f'=> Building {esp_mib} MiB ESP') esp = work / 'esp.img' build_esp(esp, esp_mib, args.uboot) @@ -249,11 +270,11 @@ def main() -> None: f'options {cmdline}\n' ) - print(f'=> Repacking to {args.out}') + tout.notice(f'=> Repacking to {args.out}') repack_iso(args.iso, args.out, esp, esp_guid, entry) size_mib = args.out.stat().st_size / MIB - print(f'=> Done: {args.out} ({size_mib:.1f} MiB)') + tout.notice(f'=> Done: {args.out} ({size_mib:.1f} MiB)') if __name__ == '__main__': From patchwork Tue Apr 21 18:34:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2242 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=1776796606; bh=mdnRkjQ9L+LFmBpe0KaYMqlaVqYj6UoqXIsS8GhGHQc=; 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=OJHe2auoMZ5sGmGfT7/JOBs/il9rYeMOd2sGSxETn3MFFRd41DdU6CroNrZ6S64FF MOx/zoiOoTUeFwDgxZ/Wq2akSq6B52eaFnPai1VIsrYRmCI2nLajkXlslTFAbYF5Kw iOqVUcGcmoIp9Rj6RCeDrOUYpFEkH1Nc9sm5/3uw= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DA9366A60D for ; Tue, 21 Apr 2026 12:36:46 -0600 (MDT) 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 NjyO7v6iK62p for ; Tue, 21 Apr 2026 12:36:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796606; bh=mdnRkjQ9L+LFmBpe0KaYMqlaVqYj6UoqXIsS8GhGHQc=; 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=OJHe2auoMZ5sGmGfT7/JOBs/il9rYeMOd2sGSxETn3MFFRd41DdU6CroNrZ6S64FF MOx/zoiOoTUeFwDgxZ/Wq2akSq6B52eaFnPai1VIsrYRmCI2nLajkXlslTFAbYF5Kw iOqVUcGcmoIp9Rj6RCeDrOUYpFEkH1Nc9sm5/3uw= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C85596A608 for ; Tue, 21 Apr 2026 12:36:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796605; bh=ufgbcVbu6IYrOXB5AnOTzeFHXXMPgb+qiBgfnYT5igs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AzlBS61YJmoQjIg+xmaDc8CQuptl4eBAHQbj9NPgPEwgz7Tu83/3WIAtgR0HVPiW0 PXRFNCyVhrlks8pSC0v0idNpL72e/6gvtCuKvw17VP9FGeB+BCEH8og6XU26Iu1Lnc IrEwwmbo7Ws8SyI1E+iJSnaVE/jIOpk8Pbuuo1Ss= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2553A6A603; Tue, 21 Apr 2026 12:36:45 -0600 (MDT) 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 x-sTjzkBbis7; Tue, 21 Apr 2026 12:36:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796601; bh=X0QXKKUXa7ViZJVXOgyn4NoHU6rUB50KHkvQJH5rxIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wi/d+YLZhA56UT01Y/EnjvAqmYtrZhS5baxYa9nO9orTC7iP4OAF9BkE0NdrtCxVo hDIb5OmM6YqaUJwkcOPXrXXec+wBhyoqOm0hQ+5f28rd7lbowd5JKPh1Y4VYESgdSL MNx8VVQRKFygrtmXM6tFmvLUqd0NTGE92g4expXY= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id BDC9B6A601; Tue, 21 Apr 2026 12:36:40 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:56 -0600 Message-ID: <20260421183511.2044469-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZYVTFH5KAAIIWXCIDHP6TFU5BBPJGINO X-Message-ID-Hash: ZYVTFH5KAAIIWXCIDHP6TFU5BBPJGINO 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/16] test: distro: Add end-to-end test for ubuntu-iso-to-uboot 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 Cover the ubuntu-iso-to-uboot.py helper end to end: rewrite an Ubuntu live ISO, boot the result in qemu through U-Boot + BLS, and wait for systemd to start gdm.service on ttyS0. This exercises the script, the isofs streaming read path, XBOOTLDR recognition and the BLS-target scan introduced earlier in the series. The rewrite itself is driven by the labgrid UBootWriterDriver's new 'qemu-efi-iso' method, which runs the script before QEMU is started and caches its output by mtime. The new 'efi-x86_64-uboot-iso' role must be configured with source_disk=ubuntu, disk=ubuntu-uboot and a path to the script; on any other lab the role is absent and the test is deselected by its role marker. Signed-off-by: Simon Glass --- test/py/tests/test_distro.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/py/tests/test_distro.py b/test/py/tests/test_distro.py index 0a0ab8269cc..ed3f6d86249 100644 --- a/test/py/tests/test_distro.py +++ b/test/py/tests/test_distro.py @@ -99,6 +99,39 @@ def test_distro_arm_app_extlinux(ubman): ubman.restart_uboot() +@pytest.mark.boardspec('efi-x86_app64') +@pytest.mark.role('efi-x86_64-uboot-iso') +@pytest.mark.restart +def test_distro_ubuntu_iso_uboot(ubman): + """Boot a rewritten Ubuntu live ISO through U-Boot + BLS. + + The 'efi-x86_64-uboot-iso' role's UBootWriterDriver uses the + 'qemu-efi-iso' method, which runs scripts/ubuntu-iso-to-uboot.py + to rebuild the destination ISO (image slot 'ubuntu-uboot') from + the source (slot 'ubuntu') before QEMU boots. U-Boot's + BOOTMETH_BLS then picks up /loader/entry.conf and loads the + casper kernel/initrd straight off the ISO 9660 partition. + """ + with ubman.log.section('boot'): + # The efi_media_0 phantom bootdev OVMF exposes makes bootflow + # scan iterate through many dead probes before reaching the + # ISO's real partition, so allow a generous timeout for the + # first BLS match. + with ubman.temporary_timeout(120 * 1000): + ubman.run_command('boot', wait_for_prompt=False) + ubman.expect([r"Booting bootflow '[^']+' with bls"]) + + # The ISO's cmdline carries 'quiet splash' so kernel-level info + # messages (including systemd-journald's kmsg output) are dropped; + # what does reach ttyS0 is systemd-pid1's own '[ OK ]' status + # writer. gdm.service is the latest reliable "userspace fully up" + # marker before casper's snap-run race loop fills the console. + with ubman.log.section('Ubuntu'): + with ubman.temporary_timeout(120 * 1000): + ubman.expect([r'Started gdm\.service']) + + ubman.restart_uboot() + @pytest.mark.boardspec('efi-arm_app64') @pytest.mark.role('efi-aarch64') @pytest.mark.restart From patchwork Tue Apr 21 18:34:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2243 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=1776796612; bh=YDy22J8ijrDs6n3iTWhSG9zSbOHzPYhx0uR/0o8ONUg=; 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=Xf92Qd2j+084mUWIadAGnqChzXX7FmEBu//t0D0ZUUSjFL3eTP3hJp5iirIrDYu8s RCEOJVR6rF10sxb1ar5IYGI9v8ca3sfimiVvj5tiFHnjazsWUki2F7CDxUobEaopJM yMVC3nxOZ7dMoKhYXaqYI/1XHGy9Br8idxNYmeUQ= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B51B6A60B for ; Tue, 21 Apr 2026 12:36:52 -0600 (MDT) 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 Tq1vSoXhdZZO for ; Tue, 21 Apr 2026 12:36:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796612; bh=YDy22J8ijrDs6n3iTWhSG9zSbOHzPYhx0uR/0o8ONUg=; 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=Xf92Qd2j+084mUWIadAGnqChzXX7FmEBu//t0D0ZUUSjFL3eTP3hJp5iirIrDYu8s RCEOJVR6rF10sxb1ar5IYGI9v8ca3sfimiVvj5tiFHnjazsWUki2F7CDxUobEaopJM yMVC3nxOZ7dMoKhYXaqYI/1XHGy9Br8idxNYmeUQ= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B4866A603 for ; Tue, 21 Apr 2026 12:36:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796610; bh=T9IhcQ/VKDrzMAQpwykwmWV+Q+0CWHGDh519zt3jWso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1o61iX+sfroJSuAeGL96UzgbjLjRToISiTUTUkt0j8tYl5/KxFT158HtWid3wKpX lPnBoTPxXFh2iTTV6Pjy4CmtWwaS7gjP//iuqzQhmLBBB077WWGdKLWof2YPcPQFki bpcJD3n4oiWzoLLUuAX7aqZsbnegRWjKo/kcO/L0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 291016A603; Tue, 21 Apr 2026 12:36:50 -0600 (MDT) 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 1emPdeoDW5Ey; Tue, 21 Apr 2026 12:36:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796605; bh=Ft8YfR+dcp8A3aCcW4bYvn2LgklAFGlKTdWGFpK0nKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qLb/KsY6LePuwOIpDQ2S9YhT4LuAVf5xR2w945+/rt6E+tYHdd3VZ9/LNVfz8dLQG XAbLU1GwOu83PpIPWsoypVPLiQlG0e98bfzkXYtHUPkXUErRwZl2xNj9mGVeKACzyo GDC9iR0gAtZiakgF4fpsW4dWry5O0Xj6XVftjhPo= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id B2AEA6A601; Tue, 21 Apr 2026 12:36:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:57 -0600 Message-ID: <20260421183511.2044469-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SCQZUDMMHW6KQCQAXLTJIOHAUS6IXZYW X-Message-ID-Hash: SCQZUDMMHW6KQCQAXLTJIOHAUS6IXZYW 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/16] ci: sjg-lab: Add efi-x86_64-uboot-iso role 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 Register the new labgrid role alongside qemu-x86_64 so CI exercises the Ubuntu live ISO + BLS boot path. TEST_PY_TEST_SPEC narrows the run to test_distro_ubuntu_iso_uboot, since that is the only pytest case for which the role is wired up. Signed-off-by: Simon Glass --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2a14fb97ea..81c91a94685 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1046,6 +1046,14 @@ qemu-x86_64: TEST_PY_TEST_SPEC: "and not sleep" <<: *sjg_lab_dfn +# Boots a rewritten Ubuntu live ISO via U-Boot + BLS, exercising the +# qemu-efi-iso labgrid writer and test_distro_ubuntu_iso_uboot. +efi-x86_64-uboot-iso: + variables: + ROLE: efi-x86_64-uboot-iso + TEST_PY_TEST_SPEC: "and test_distro_ubuntu_iso_uboot" + <<: *sjg_lab_dfn + # NVIDIA Jetson TK1 tk1: variables: