From patchwork Fri Jan 9 23:11:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1426 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=1768000464; bh=V1w+yKVJbAlk2o3hofcCvn7r5qaAjZ6kSIh8UMlgIk8=; 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=am061q6UlOsnuWm2oSlf1eAaAxKJuV9A2Rxt60ZmxbZgJkABj9QZ+Oq4wAB5H3YZq k7IvqZUktQQu1bUHcVi3L8gQCOEH81cAVmMpU1Au8kK8spA4HXmOrdVMYqVEEVF5eG IcufJD8BO5ZwCgUIr/qHO7KdZm6+Ab8nkLRz/exQMokJOvAFYpuGfUQ36sbUvBM0H8 GPzZY+quUow69zLxEFhV3AZ7CzcwtSBg9fCTexmjKZM1ZI6ZMoUBYKZ3wt0Tx1MrnC 1K9kXBPyfXyP51dyaNav5OKAhoBQA/5iYrfBca15dw0yJAcWuVcLZ5YGzlCMzHuEPb 66Ixc7kSRhJcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1F516924E for ; Fri, 9 Jan 2026 16:14:24 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id arxVO635qZ9C for ; Fri, 9 Jan 2026 16:14:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000464; bh=V1w+yKVJbAlk2o3hofcCvn7r5qaAjZ6kSIh8UMlgIk8=; 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=am061q6UlOsnuWm2oSlf1eAaAxKJuV9A2Rxt60ZmxbZgJkABj9QZ+Oq4wAB5H3YZq k7IvqZUktQQu1bUHcVi3L8gQCOEH81cAVmMpU1Au8kK8spA4HXmOrdVMYqVEEVF5eG IcufJD8BO5ZwCgUIr/qHO7KdZm6+Ab8nkLRz/exQMokJOvAFYpuGfUQ36sbUvBM0H8 GPzZY+quUow69zLxEFhV3AZ7CzcwtSBg9fCTexmjKZM1ZI6ZMoUBYKZ3wt0Tx1MrnC 1K9kXBPyfXyP51dyaNav5OKAhoBQA/5iYrfBca15dw0yJAcWuVcLZ5YGzlCMzHuEPb 66Ixc7kSRhJcw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91BD369241 for ; Fri, 9 Jan 2026 16:14:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000463; bh=f44Z8eq3sE72GfLnDRZUy4VK9FZrrqh5Ee07AP3CTwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6mC4EcQdk+/fxxV+zehyden/5cwMGTBzhbqrn6JD/8s8+nIeJxY/rD3V0ZYz7ra7 7sgYHsxn9rHLIYHwd1YLfE3z6Msj4N8eQi5wV/HLM9lOouFpA7OFbnAUUGMCTfVDAA jzyRH5ov5Hiu9Z8kczxGQLbAbx7B6rMr3D7LZi4bFLqlDW5D03cEsybZkqxR3P9npz Sn1FVswEclGEv8Ew12thyDs1JotGYrnvx+aC4ZN4MjuDqE5Q0dogdGb3KngLZ3nlhx 7wNvsmuLO9b1ZLrOoiKpMpxt8xhCz0Ji1Eh42V6TO2IcuLrbv+0ZVV7rgIFVVxPIp6 mnchuvYafll/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B5C869243; Fri, 9 Jan 2026 16:14:23 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 5zIqJuMr0poY; Fri, 9 Jan 2026 16:14:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000458; bh=fER80fgJsRo7S/hYV6IPRg5QXzlLp9C1AdgxO3Bwb20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+FC+/zGnisER3zYHJ14FG/GZyVH2VW43IH81EctkMl3j2HacCDOuScWMo/byyfyo dOKC2WP5kxERvnCDiX7Sngu9QEtSpKiQa3bgzYMkkmp3nCpeh1lXetghH9u5FbVHeM /cnbTXP2ukSK3hUEaXziK4kl2h44PHkTkDBI80pzcOThlXKwzp3lgcYKVP+1BU0YD0 jzFSIWzvmtfOflU2ARQTPj7P6DSu0cViHI9VLwpwelpD87aygFeok9GtMP5u7PW6bs 3FQlDQPhVxMcruGuM4Na/b48n62vwoBaw2ganKFX5Z6u/5lAMYp+KPct4poiEZerKH R9OuKIQ90z7pA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 65AAA69218; Fri, 9 Jan 2026 16:14:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:39 -0700 Message-ID: <20260109231151.4056804-31-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: E3AYWV23YR6KCNEFD5YRSI3IFBM5UNKV X-Message-ID-Hash: E3AYWV23YR6KCNEFD5YRSI3IFBM5UNKV 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: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 30/32] boot: pxe: Add test for FDT overlay loading 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 Extend the PXE parser test to verify that FDT overlays can be loaded. This tests the label_load_fdtoverlays() function by: 1. Creating real DTB and DTBO files in the Python test fixture using dtc 2. Creating dummy kernel/initrd files for loading tests 3. Setting up environment variables for file loading addresses 4. Calling pxe_load_files() to load all files including overlays 5. Verifying overlay addresses are set and sequential Make pxe_load_files() a public function so it can be called from tests to verify file loading without the full boot setup. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 4 ++-- include/pxe_utils.h | 16 ++++++++++++++ test/boot/pxe.c | 36 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 9 ++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e336b125716..8609d832aa6 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -627,8 +627,8 @@ static int generate_localboot(struct pxe_label *label) return 0; } -static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, - char *fdtfile) +int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, + char *fdtfile) { int ret; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index d2062c03997..aa73f5ff7f0 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -445,6 +445,22 @@ int pxe_do_boot(struct pxe_context *ctx); int pxe_select_label(struct pxe_menu *cfg, bool prompt, struct pxe_label **labelp); +/** + * pxe_load_files() - Load kernel/initrd/FDT/overlays for a label + * + * Loads the files specified in the label into memory and saves the + * addresses in @ctx. This does not process the FDT or set up boot + * parameters - use pxe_load_label() for that. + * + * @ctx: PXE context with getfile callback + * @label: Label whose files to load + * @fdtfile: Path to FDT file (may be NULL) + * Return: 0 on success, -ENOENT if no kernel specified, -EIO if file + * retrieval failed + */ +int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, + char *fdtfile); + /** * pxe_load_label() - Load kernel/initrd/FDT for a label * diff --git a/test/boot/pxe.c b/test/boot/pxe.c index df5c106caab..97049e27ab6 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -289,6 +289,42 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str(name, label->name); } + /* + * Test FDT overlay loading + * + * Get the first label (linux) which has fdtoverlays, set up the + * environment, and verify overlay files can be loaded. + */ + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq(2, label->fdtoverlays.count); + + /* Set environment variables for file loading */ + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); + + /* + * Load files via pxe_load_files(). Note: pxe_load_files takes + * ownership of fdtfile and frees it, so we must strdup here. + */ + ret = pxe_load_files(&ctx, label, strdup(label->fdt)); + ut_assertok(ret); + + /* Verify kernel and FDT were loaded */ + ut_asserteq(PXE_KERNEL_ADDR, ctx.kern_addr); + ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); + + /* Verify overlays were loaded to valid addresses */ + ut_assert(alist_get(&label->fdtoverlays, 0, + struct pxe_fdtoverlay)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->fdtoverlays, 1, + struct pxe_fdtoverlay)->addr >= PXE_OVERLAY_ADDR); + + /* Second overlay should be at a higher address than the first */ + ut_assert(alist_get(&label->fdtoverlays, 1, struct pxe_fdtoverlay)->addr > + alist_get(&label->fdtoverlays, 0, struct pxe_fdtoverlay)->addr); + /* Verify no more console output */ ut_assert_console_end(); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index af97568e960..bbcd63d58e2 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -233,6 +233,15 @@ def pxe_image(u_boot_config): cfg_path = create_extlinux_conf(fsh.srcdir, labels, menu_opts) + # Create DTB and overlay files for testing + dtbdir = os.path.join(fsh.srcdir, 'dtb') + os.makedirs(dtbdir, exist_ok=True) + compile_dts(BASE_DTS, os.path.join(dtbdir, 'board.dtb')) + compile_dts(OVERLAY1_DTS, os.path.join(dtbdir, 'overlay1.dtbo'), + is_overlay=True) + compile_dts(OVERLAY2_DTS, os.path.join(dtbdir, 'overlay2.dtbo'), + is_overlay=True) + # Create a chain of 16 nested include files to test MAX_NEST_LEVEL # Level 1 is extlinux.conf, levels 2-16 are extra.conf, nest3.conf, etc. for level in range(2, 17):