From patchwork Mon May 5 10:08:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aristo Chen X-Patchwork-Id: 2081111 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gCOD4J5I; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zrh064TJVz1yNY for ; Mon, 5 May 2025 22:38:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6454E8214F; Mon, 5 May 2025 14:37:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gCOD4J5I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82B5F820E1; Mon, 5 May 2025 12:09:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 24DCA80F03 for ; Mon, 5 May 2025 12:09:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jj251510319013@gmail.com Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-736c1cf75e4so3655944b3a.2 for ; Mon, 05 May 2025 03:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746439742; x=1747044542; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mH+d8R8aWEGoefNMsHGBJI8UfOSAvc1PXAvK5PbQyJE=; b=gCOD4J5Iis+9OuM5D3CH4hWVt8yjarufUoYe/w2JF0rLOX9LO+qulQpBPhpbiSYH9i 82siJKRykmrSCdyN0VytXQ0nP38V5/NQbZv2xk/oLbf7r2HuvPiMyT13b2roy9px+1BE uzJ7oiqcQepGdZhtLOL6aZ+vyM59QyiPVRdA35v1MlTeO+LYyUtH6QLL4TkI5ko0BzAt 2mRpt8zo+nNGEpZFTtAWVFtDIKXYKqfRHcMdGb4KgAEJY//tOpP0CIdW6MnDyfTH0rFz XMpyH12UYjjwDGnNTGwnIQjBrMSEQVAnAuMS2gHDpjIYwg7W9/6HrA1oDhb5jXV5Vk3T sgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746439742; x=1747044542; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mH+d8R8aWEGoefNMsHGBJI8UfOSAvc1PXAvK5PbQyJE=; b=cON6MA0c3HytBoQ6df7SGwLNKKWDQ6gKIYk8759x5VrGqrvWdrDOOjlLpAQnVBFwbM HDHCMCqSR6WI8eI3k6OOKUJLY3fIrK0P2K1rfEmDs4p7v04/41xD/5iEzNTA7WobQrcC mwlvpjH+tG0dkCcRXPBOalmem6sECtjb/rwYrWw4wgnnsBOR0ymMKCFulIFMVJ6RJtcN XhUYOP00vAYJD9IXhwSnmLZxu72TOnDuYidE6+w3e7j5zeyFby3R3PiIg7xJ8ZDFkc5A mDMzXRhLD2ur8yv60LdV5Fag51YYNdTFz64rQ/1gO6HS9Dr+vZKI7UN7lTsy9+XpH+Jc TO1A== X-Gm-Message-State: AOJu0YzUnfn/w+cwIyVQ+QDbJNVJfaNbyX/qGwLgm8gpWAwFBlouQzEk 4ENC7y1FYNNn2k4e6KyglGCuWfQUr+xlbQIbWpKU1+WLiMIyU8PiIDBXO/6Q X-Gm-Gg: ASbGnctEVK90LurDg63JmmvEMFX6x4C5AGUfSOpSyn34bAw0N5QtmQV5t5KIE/LlLY+ kR8K7TCJlZ5nWRZ7CK8ytSPVQByh6isb7574I9zkqhfj0H8MRgIXuBmrzFSYGFsqfBPIquqw/x9 D6cvmKrb1E9Vniznr0lQYkcCDq0bD6O9vz2QD4gBpvPs/bcH6BWyiqa4ZwJrmNnvTdk9NQFhigd thntUfvH8+b/euLzYHfckVWa4XrABPL/iyDUu8wP7ax7/DHgFu2L6nKV5UgpqzH/nRg64CAFiT4 i8zHa4pdxkvwOFwAdl1g4YJ5yJ/xCmdBZPQ7tgFxWsyjkLX1XUpd0RofvmhsQKtyUlekseNfp0O r6oHtfWJ2F7F3m5OVbg== X-Google-Smtp-Source: AGHT+IHh5v3SlXYy0V66xIl/QG3cP2ldHzMzuvjaA7KRsXiyKq0roCykptmGR9fpUokxyab8aX7DZQ== X-Received: by 2002:a17:90b:3851:b0:2fe:b8ba:62e1 with SMTP id 98e67ed59e1d1-30a61a2bdf6mr9825698a91.28.1746439742183; Mon, 05 May 2025 03:09:02 -0700 (PDT) Received: from noble-leuven.lxd (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22e151ea18dsm50873555ad.92.2025.05.05.03.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 May 2025 03:09:01 -0700 (PDT) From: Aristo Chen X-Google-Original-From: Aristo Chen To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, carlos.lopezr4096@gmail.com, aristo.chen@canonical.com Subject: [PATCH 1/1] tools: mkimage: validate image references in FIT configurations Date: Mon, 5 May 2025 10:08:52 +0000 Message-ID: <20250505100852.9364-1-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 05 May 2025 14:37:53 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When parsing a FIT image source (ITS), mkimage does not currently check whether the image names referenced in the /configurations section (e.g. "kernel", "fdt", "ramdisk", "loadables") actually exist in the /images node. This patch introduces a validation step during FIT import that iterates over each configuration and verifies that all referenced image names are defined under /images. If a missing image is detected, an appropriate error is reported and mkimage exits with FDT_ERR_NOTFOUND. This ensures that configuration integrity is validated at build time. Signed-off-by: Aristo Chen --- tools/fit_image.c | 48 +++++++++++++++++++++++++++++++++++++++++++++-- tools/mkimage.c | 7 ++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index caed8d5f901..02b9c9b5855 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -627,6 +627,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) struct stat sbuf; int ret; int images; + int confs; int node; fd = mmap_fdt(params->cmdname, fname, 0, &old_fdt, &sbuf, false, false); @@ -695,6 +696,49 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) } } + confs = fdt_path_offset(fdt, FIT_CONFS_PATH); + + for (node = fdt_first_subnode(fdt, confs); + node >= 0; + node = fdt_next_subnode(fdt, node)) { + static const char * const props[] = { FIT_KERNEL_PROP, + FIT_RAMDISK_PROP, + FIT_FDT_PROP, + FIT_LOADABLE_PROP }; + + for (int i = 0; i < ARRAY_SIZE(props); i++) { + const char *list; + int len = 0; + int offset = 0; + + list = fdt_getprop(fdt, node, props[i], &len); + if (!list) + continue; + + // Some properties (like loadables) are stringlists + while (offset < len) { + const char *img_name = list + offset; + char img_path[256]; + + offset += strlen(img_name) + 1; + snprintf(img_path, sizeof(img_path), "%s/%s", FIT_IMAGES_PATH, + img_name); + + int img = fdt_path_offset(fdt, img_path); + + if (img < 0) { + const char *conf_name = fdt_get_name(fdt, node, NULL); + + fprintf(stderr, + "Error: configuration '%s' references undefined image '%s'\n", + conf_name, img_name); + ret = FDT_ERR_NOTFOUND; + goto err_munmap; + } + } + } + } + munmap(old_fdt, sbuf.st_size); /* Close the old fd so we can re-use it. */ @@ -750,7 +794,7 @@ static int fit_handle_file(struct image_tool_params *params) char bakfile[MKIMAGE_MAX_TMPFILE_LEN + 4] = {0}; char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN]; size_t size_inc; - int ret; + int ret = EXIT_FAILURE; /* Flattened Image Tree (FIT) format handling */ debug ("FIT format handling\n"); @@ -854,7 +898,7 @@ static int fit_handle_file(struct image_tool_params *params) err_system: unlink(tmpfile); unlink(bakfile); - return -1; + return ret; } /** diff --git a/tools/mkimage.c b/tools/mkimage.c index 2954626a283..361711c53b2 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -519,8 +519,13 @@ int main(int argc, char **argv) */ retval = tparams->fflag_handle(¶ms); - if (retval != EXIT_SUCCESS) + if (retval != EXIT_SUCCESS) { + if (retval == FDT_ERR_NOTFOUND) { + // Already printed error, exit cleanly + exit(EXIT_FAILURE); + } usage("Bad parameters for FIT image type"); + } } if (params.lflag || params.fflag) { From patchwork Tue May 20 07:50:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aristo Chen X-Patchwork-Id: 2088128 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hy8KvQjF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4b1v3P6Bl0z1yDK for ; Tue, 20 May 2025 22:28:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2D2482C7F; Tue, 20 May 2025 14:28:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hy8KvQjF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C8A782AB9; Tue, 20 May 2025 09:58:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4165B82A4B for ; Tue, 20 May 2025 09:58:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jj251510319013@gmail.com Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-af51596da56so3902755a12.0 for ; Tue, 20 May 2025 00:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747727906; x=1748332706; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x6dxhKAmGIeE0lS+/61VMNrPTJkQvaeMR2CtTw3YPtQ=; b=hy8KvQjF82ZUVSN9ZncEqLfqYLs26lGOXpOqk6A47VxPxQCANeRMfpQZqbAbPhHt32 MOmOQ4Z0x/alYbkp3l2wKQddOIwM8TV6eflKfyatA+0z/nvnx60IlyGejW5nV+WmJg8N 6xPqmC0d8mIL8JvDmNYXwF2bD+OkywBJvpCHKvU8gPopjrlpp40QH+DZWc3M7wVV7tx+ wEY7Etzg3XhWCmsbQqp4Gl8V9NgmFhR8+FqYRtJuJ5SFkiv9kDFtoab4HoKn3qy9HXBX P4Bw1TvLYEc1D39T2FzUXfbDWaNB9KCF/GId9Poj0EP0ohja8XsqZ8UMX8LwwYZSBRI7 VTDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747727906; x=1748332706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x6dxhKAmGIeE0lS+/61VMNrPTJkQvaeMR2CtTw3YPtQ=; b=eYsppMglUu6X0hF/fa7h3lB0IxKScMbOCryBLow7IJ/OKAvzZU74d6Gowmtg5DTy9L CISJtV6rlrJPFSfZG5Gxh6G8lQTuYs9wzO1cqzyyVBduvR613VvHorrVViJEkPylS/gm lLIqI+WOCGFmGGhDUmmLvxQHgvyeFLXon66LLE3JzYe1Cy8gZkQTdUkaf8Qebzmvv8Wo 99wa23CpHrVFUUZ22w2OB4bBOFMqA9zi5RAcet4ZS9IM43RECrPcXhBZrr52bDX7Fc9s NHzRNvTTW2rJKDmfCd6nk0KyBgCgkHwkUcc24RF7OEmsD4KJcIa2q7pSHThfFyx9V7Gl VKPA== X-Gm-Message-State: AOJu0Yz9Kcq90pcNGSAHyyFySjknpZ+AcBhDWTo2ZPAgH29aGL6m/Hl+ fy01ufGGg4gK3cQBWxxr5OHrZyYPPhwJTaqPIOhGB0wMK0TPvh3ZQf8Yz+Pgd8+2 X-Gm-Gg: ASbGncvEohS0l/ggfnDbB9nEImdAT9Zx4yWUBQ/QjIoAGTwH7hzZi+HNZT08GRy6SSp QQtyNCDpSFeYLmt1MvPBsIlWbRGdt5ZDgM1Z1G3OQkzdQvLlyZQynqcs1UyCPTDqwUgjSIzRw4l UVDma/ml1a/eKKUAOdsA54emK9aekoHUyHzLhtNfQsc3Fuf/MmTgONAHOdaNi7eSFcHrdcgTaO4 PUWJWYYtgETFEYBNCW2iiqsfNw6MIYFtJ/RZeAy+gK/onVQMrVSNLcVUsB5wjF4mAjsKDZTZ69B i4ebDt1jVT7kvGo9R0O5N949/SxaK6Xf9pLYd7X19fZwA8nMEVSVGgdMuG17jn7BEMWKXJs+/GX 4FglLdFd1Yl5Yh1q172y24tc8QVq0V69fU8CSv9o2744WBqc= X-Google-Smtp-Source: AGHT+IH++l9IZerhX1lpAyppUp4HJI8qX+hy+xZeX2pWCI7Avv5OIIXyWW30Um4XppQ7yIX/qot5SA== X-Received: by 2002:a17:903:25c7:b0:231:e331:b7ca with SMTP id d9443c01a7336-231e331bc48mr127477895ad.3.1747727906468; Tue, 20 May 2025 00:58:26 -0700 (PDT) Received: from noble-leuven.tail872496.ts.net (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231d4eba49esm71544795ad.163.2025.05.20.00.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 00:58:26 -0700 (PDT) From: Aristo Chen X-Google-Original-From: Aristo Chen To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, carlos.lopezr4096@gmail.com, aristo.chen@canonical.com, quentin.schulz@cherry.de, ada@thorsis.com Subject: [PATCH v2 2/4] tools: mkimage: validate image references in FIT configurations Date: Tue, 20 May 2025 07:50:04 +0000 Message-ID: <20250520075735.132308-4-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250505100852.9364-1-aristo.chen@canonical.com> References: <20250505100852.9364-1-aristo.chen@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 20 May 2025 14:28:13 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When parsing a FIT image source (ITS), mkimage does not currently check whether the image names referenced in the /configurations section (e.g. "kernel", "fdt", "ramdisk", "loadables") actually exist in the /images node. This patch introduces a validation step during FIT import that iterates over each configuration and verifies that all referenced image names are defined under /images. If a missing image is detected, an appropriate error is reported and mkimage exits with FDT_ERR_NOTFOUND. This ensures that configuration integrity is validated at build time. Signed-off-by: Aristo Chen --- tools/fit_image.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/mkimage.c | 7 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index 3d2fbad3853..bf9a6fc369a 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -627,6 +627,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) struct stat sbuf; int ret; int images; + int confs; int node; fd = mmap_fdt(params->cmdname, fname, 0, &old_fdt, &sbuf, false, false); @@ -695,6 +696,43 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) } } + confs = fdt_path_offset(fdt, FIT_CONFS_PATH); + static const char * const props[] = { FIT_KERNEL_PROP, + FIT_RAMDISK_PROP, + FIT_FDT_PROP, + FIT_LOADABLE_PROP, + FIT_FPGA_PROP, + FIT_FIRMWARE_PROP, + FIT_SCRIPT_PROP}; + + fdt_for_each_subnode(node, fdt, confs) { + const char *conf_name = fdt_get_name(fdt, node, NULL); + + for (int i = 0; i < ARRAY_SIZE(props); i++) { + int count = fdt_stringlist_count(fdt, node, props[i]); + + if (count < 0) + continue; + + for (int j = 0; j < count; j++) { + const char *img_name = + fdt_stringlist_get(fdt, node, props[i], j, NULL); + if (!img_name) + continue; + + int img = fdt_subnode_offset(fdt, images, img_name); + + if (img < 0) { + fprintf(stderr, + "Error: configuration '%s' references undefined image '%s' in property '%s'\n", + conf_name, img_name, props[i]); + ret = FDT_ERR_NOTFOUND; + goto err_munmap; + } + } + } + } + munmap(old_fdt, sbuf.st_size); /* Close the old fd so we can re-use it. */ diff --git a/tools/mkimage.c b/tools/mkimage.c index 2954626a283..361711c53b2 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -519,8 +519,13 @@ int main(int argc, char **argv) */ retval = tparams->fflag_handle(¶ms); - if (retval != EXIT_SUCCESS) + if (retval != EXIT_SUCCESS) { + if (retval == FDT_ERR_NOTFOUND) { + // Already printed error, exit cleanly + exit(EXIT_FAILURE); + } usage("Bad parameters for FIT image type"); + } } if (params.lflag || params.fflag) { From patchwork Tue May 20 07:50:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aristo Chen X-Patchwork-Id: 2088129 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ekai6ORd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4b1v3Z3JTFz1yDK for ; Tue, 20 May 2025 22:28:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FA5382CA2; Tue, 20 May 2025 14:28:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ekai6ORd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 193C582AA7; Tue, 20 May 2025 09:58:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BB08D82A4B for ; Tue, 20 May 2025 09:58:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jj251510319013@gmail.com Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-22fcf9cf3c2so43458025ad.0 for ; Tue, 20 May 2025 00:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747727912; x=1748332712; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UzqhTbGo9uV252TD9Sf80J8NArSZZUjFqxUvP48IFt0=; b=ekai6ORdMadyU9Wuw43a/ChWb8jBkDb85DUuUYo318DrPkOGbC+l2ScAF4NB6siygS Lb0W2LvF+lg4I8jyeIh5fcsz/A2o3xFMpoagyo1I/sZ6TordJerlSkk4CYiTfZouzXJk Tv2VlVtAMB9JIR7UkWPY1WATeDlt8ak7vLYM6VrYEEAiq7ct20M4+Rr7t9a4D2P6s9Zi UF96TS77vPV9kl0kT1c8N47790AxPysklexWUpxGVbEsldyomZyez4gZhGtXlm9aZYMM d3DAA9wcMbW6P8A01J+MopcH3PJwVBJzpQct7rbwEvHpqdstZgb1SeVnoGdGvF4Ew8rr WFCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747727912; x=1748332712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UzqhTbGo9uV252TD9Sf80J8NArSZZUjFqxUvP48IFt0=; b=WzYPPI6jkkNn+PC9umlMtns0yOBZ7zIele84dKS5cAXYR8/0Lj1bpvRXLNMyYQy88b XXCggENXZo8enuKgvVYlPxOPGTaXUcLPnv2MUaiI60OrkrKoasFzATGc5Z7FI+RY0TqA pHVjHS16NDLd89XpCZALHFuqUaeAWhpzeadNTaVQeZ9AmpJNVIZQ/A+5gljMY6a3C7/M oK1zrnHY6BoFHAfAI0CjJMYyzrQ4PCoB5N7Rd1iX9gjAAqf2RZc3fmRZv4vdWkIxpOrQ nmBIEM/32M2ewmPbjG7Ms/9A0EbSj3h2wKBWihkAP5taRhkataX49PWBevFIo4kJU9Ep luWg== X-Gm-Message-State: AOJu0YzhThH4og6KEcAuYyYhMlOFIhND0p1vqq/2wrb8IYZgemtPGM3B GmsHekbPQsppwRhfzVPdQCD70XZC6cz+TkLD5IRrHSko0/yd32I+aJ2GfI5agCR/ X-Gm-Gg: ASbGncu/p0sGHWmO/hMjSznU439Ade/jjh63oIVahM/VbmIttCEmlhlF3XCGeFB8AYv g/oWQ3l0G91W2u1xawBxpnmIU+mldH/CiDKWU2X4NJKSe0qYIcF3UXP3nOkjkXLsMvirXKyFrhE zlAPIDyT/LmiEUa3VFfgoLbezrYKqFP779nIkBIVsmc1FIjDNow7Fo/KrhvShFm+NIt1IfYNY5W MlCWdO4lNiBuvuZwRIHhqvH7FcoEPXKt1TKP1BJI7aM5U+LifjV2Y5W9bpQU95pMdUeIphMAZBZ ITtazvh69MhdFC4oh4isD/GRbY0zSznXcWIgFpz1WuNstsO2j9GhOsfR2CFNd5UaUbB6NvZszpF tvsdbzjWMBqOol3Y4oRX6hPtBS4ltLTV0TTQ0b3Mt8HlHeuw= X-Google-Smtp-Source: AGHT+IEj0y2++/gdXOHHEMY7UYojWM1OO6MHTTdQAF3R549BgMLJOjln+hyStnxyiS4tzVyDJeYVOg== X-Received: by 2002:a17:903:2303:b0:223:52fc:a15a with SMTP id d9443c01a7336-231d452d4ddmr221878915ad.33.1747727912061; Tue, 20 May 2025 00:58:32 -0700 (PDT) Received: from noble-leuven.tail872496.ts.net (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231d4eba49esm71544795ad.163.2025.05.20.00.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 00:58:31 -0700 (PDT) From: Aristo Chen X-Google-Original-From: Aristo Chen To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, carlos.lopezr4096@gmail.com, aristo.chen@canonical.com, quentin.schulz@cherry.de, ada@thorsis.com Subject: [PATCH v2 3/4] binman: test: Ensure all config references exist in /images node Date: Tue, 20 May 2025 07:50:05 +0000 Message-ID: <20250520075735.132308-5-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250505100852.9364-1-aristo.chen@canonical.com> References: <20250505100852.9364-1-aristo.chen@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 20 May 2025 14:28:13 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Several binman FIT test device trees reference image nodes such as atf and uboot in their /configurations sections, but those image nodes were not actually defined in the /images node. This mismatch can lead to validation errors when stricter consistency checks are introduced. This patch adds minimal definitions for atf and uboot under the /images node in all relevant test DTS files. Signed-off-by: Aristo Chen --- tools/binman/test/170_fit_fdt.dts | 14 ++++++++++++++ tools/binman/test/220_fit_subentry_bintool.dts | 2 +- tools/binman/test/223_fit_fdt_oper.dts | 14 ++++++++++++++ tools/binman/test/284_fit_fdt_list.dts | 14 ++++++++++++++ tools/binman/test/333_fit_fdt_dir.dts | 14 ++++++++++++++ tools/binman/test/334_fit_fdt_compat.dts | 14 ++++++++++++++ tools/binman/test/335_fit_fdt_phase.dts | 14 ++++++++++++++ tools/binman/test/345_fit_fdt_name.dts | 14 ++++++++++++++ 8 files changed, 99 insertions(+), 1 deletion(-) diff --git a/tools/binman/test/170_fit_fdt.dts b/tools/binman/test/170_fit_fdt.dts index 0197ffd1597..4b1e9b41ec0 100644 --- a/tools/binman/test/170_fit_fdt.dts +++ b/tools/binman/test/170_fit_fdt.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/220_fit_subentry_bintool.dts b/tools/binman/test/220_fit_subentry_bintool.dts index 6e29d41eeb3..b1d8fb0feae 100644 --- a/tools/binman/test/220_fit_subentry_bintool.dts +++ b/tools/binman/test/220_fit_subentry_bintool.dts @@ -12,7 +12,7 @@ #address-cells = <1>; images { - test { + kernel { description = "Something using a bintool"; type = "kernel"; arch = "arm"; diff --git a/tools/binman/test/223_fit_fdt_oper.dts b/tools/binman/test/223_fit_fdt_oper.dts index e630165acf4..cb3b31e36f6 100644 --- a/tools/binman/test/223_fit_fdt_oper.dts +++ b/tools/binman/test/223_fit_fdt_oper.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/284_fit_fdt_list.dts b/tools/binman/test/284_fit_fdt_list.dts index 8885313f5b8..70cdb326708 100644 --- a/tools/binman/test/284_fit_fdt_list.dts +++ b/tools/binman/test/284_fit_fdt_list.dts @@ -15,6 +15,20 @@ fit,fdt-list-val = "test-fdt1", "test-fdt2"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/333_fit_fdt_dir.dts b/tools/binman/test/333_fit_fdt_dir.dts index aa778451a4b..71971de4232 100644 --- a/tools/binman/test/333_fit_fdt_dir.dts +++ b/tools/binman/test/333_fit_fdt_dir.dts @@ -15,6 +15,20 @@ fit,fdt-list-dir = "fdts"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/334_fit_fdt_compat.dts b/tools/binman/test/334_fit_fdt_compat.dts index 3bf45c710db..bf1b5a4a94a 100644 --- a/tools/binman/test/334_fit_fdt_compat.dts +++ b/tools/binman/test/334_fit_fdt_compat.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/335_fit_fdt_phase.dts b/tools/binman/test/335_fit_fdt_phase.dts index f8d0740a394..c20bcad651a 100644 --- a/tools/binman/test/335_fit_fdt_phase.dts +++ b/tools/binman/test/335_fit_fdt_phase.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/345_fit_fdt_name.dts b/tools/binman/test/345_fit_fdt_name.dts index 631a8e5f59b..0ef2e1934a0 100644 --- a/tools/binman/test/345_fit_fdt_name.dts +++ b/tools/binman/test/345_fit_fdt_name.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; From patchwork Tue May 20 07:50:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aristo Chen X-Patchwork-Id: 2088130 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=er8PfT5A; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4b1v3l5yvdz1yDK for ; Tue, 20 May 2025 22:28:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CF0682CB8; Tue, 20 May 2025 14:28:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="er8PfT5A"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDB4A82AB9; Tue, 20 May 2025 09:58:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A49E382A4B for ; Tue, 20 May 2025 09:58:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jj251510319013@gmail.com Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-232054aa4ebso21570665ad.1 for ; Tue, 20 May 2025 00:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747727915; x=1748332715; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rkJOlwCEYa+tQCPMVKUSgm9ALnwOtk5g9+SfAjqZlrw=; b=er8PfT5A0lvHcplqru0127zoM+8DhLp/h9o87ucBQPsr729yNaxnFA+KKU66Wnyytx AmCdyf9uQ2a5cmOKQQ6L2RPwOXSWVPe9duHOCFhVR/dg1sNMwj7WvcxvKo7wurgAkwA3 WPSOx8uXpP6Apbi4a3qDTVdMV4DTLqtJOmNSCP6KumIK5ZWkpPWPajt2bAuJGkLDQtSD GMsbbj3g59yQnbOKdB/PaJrHFd2/QPZnQiihGIuWQ5dcE4+VnH0WZZ1dBiiqPxPX5rBK trEmfF9AUA8gghDT/NFTsijgh79qI2PikKrOBBXs92Uscwy8xvn5vnmuUnqltfuhfopO SPVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747727915; x=1748332715; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rkJOlwCEYa+tQCPMVKUSgm9ALnwOtk5g9+SfAjqZlrw=; b=gNctQIeKD6H9Pre6YVq1U8vgblyzMyyanWhEKotF7nhn4xBdBjUpfM/qrAwjdy3IGB I2EOFjbQB6is7YqM1LRhMSgMCDlQ2ThC8Kq53ncehgbUeEDb8D3cd2JnRi3HFwDYi0S8 qSf0FGqF70CgTJeOP4K1M8GMmQ3G4cy6FYjzf1ZRHj+jSzTe4bM43g6Hr5zmbvWfa6Jx 3Xa80U3elkjmV8tsrzYXN8pwb7Viz6clbmf2ILTFHJOxdn5gkccmSj5Z41UovojGR/hC Rzou04YiEr4k2ezvFisSmHjmb1Q188sBsiJ8uaYUWSkhW0+i/0nVSdWlgKon2oKCCx5O v0sQ== X-Gm-Message-State: AOJu0YxvB0QldNgdKrmYvymgoZoHOzb49cELldQ+q+gENIBKYirWoT+w 4cFlPg74L2U+fskBuRlEbePM5tGo0F+LAH/vNS/s7yW2rIktA+lRx346i+EptxzB X-Gm-Gg: ASbGncuvnCBEPrDPbryfpQXKi1OWyM6uNrTv+JBigQxGJWXz6nkZdHNLeLTNK6U8OOR Alpdot592zM3V2B02tWH6dAd/sYJ/WN8gftOPf4+hs380lJPaVuVOuiKf7csOPgdeOh6o7M3PL4 H0e1SvkRf1gBPmvzqcHlR9mPTrVTKAZUlPjvxIHZHafB54P8vnVfQ1vjhkUsDuyigc2g7Jm6fn7 XKkKQlxast+dBbdzPE9UCEzT9jRwUbgXalTC5JOUAS7M0w0CVsdTYHz+ajOpH4uPVLTdWNOA7T5 yLVl4ePFct5Q+FDQCrE747m+00shouTNmKdhJzRv9YZyCeWSHWGZ0dLiD8WyV51yJxCDhCaXIaS Dj8qCy6POesQ3VPsiEMV6PrCk1YQ26qJOHEsNT2m17Xb7rS0= X-Google-Smtp-Source: AGHT+IESttnpj49fRl3ZFBSxvTQCGx1wcCjz0z/aZTsE701B1m+8E2sCr7DcpvJgb2gQVvpIwjpW9A== X-Received: by 2002:a17:903:2a8c:b0:221:7e36:b13e with SMTP id d9443c01a7336-231d44d788fmr257862165ad.12.1747727914708; Tue, 20 May 2025 00:58:34 -0700 (PDT) Received: from noble-leuven.tail872496.ts.net (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231d4eba49esm71544795ad.163.2025.05.20.00.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 00:58:34 -0700 (PDT) From: Aristo Chen X-Google-Original-From: Aristo Chen To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, carlos.lopezr4096@gmail.com, aristo.chen@canonical.com, quentin.schulz@cherry.de, ada@thorsis.com Subject: [PATCH v2 4/4] test: py: add mkimage test for undefined image references in FIT configs Date: Tue, 20 May 2025 07:50:06 +0000 Message-ID: <20250520075735.132308-6-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250505100852.9364-1-aristo.chen@canonical.com> References: <20250505100852.9364-1-aristo.chen@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 20 May 2025 14:28:13 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a test case to verify that mkimage correctly rejects a FIT source that references a non-existent image from a configuration node. This test introduces a minimal ITS that defines a valid kernel image but references a missing "fdt" image under the /configurations section. The test asserts that mkimage fails with a clear error message, as introduced in the new validation logic. This helps ensure the validation logic behaves correctly and prevents regressions in future FIT enhancements. Signed-off-by: Aristo Chen --- test/py/tests/test_fit_mkimage_validate.py | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/py/tests/test_fit_mkimage_validate.py diff --git a/test/py/tests/test_fit_mkimage_validate.py b/test/py/tests/test_fit_mkimage_validate.py new file mode 100644 index 00000000000..af56f08ca10 --- /dev/null +++ b/test/py/tests/test_fit_mkimage_validate.py @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2025 +# +# Test that mkimage validates image references in configurations + +import os +import subprocess +import pytest +import fit_util + +@pytest.mark.boardspec('sandbox') +@pytest.mark.requiredtool('dtc') +def test_fit_invalid_image_reference(ubman): + """Test that mkimage fails when configuration references a missing image""" + + its_fname = fit_util.make_fname(ubman, "invalid.its") + itb_fname = fit_util.make_fname(ubman, "invalid.itb") + kernel = fit_util.make_kernel(ubman, 'kernel.bin', 'kernel') + + # Write ITS with an invalid reference to a nonexistent image + its_text = ''' +/dts-v1/; + +/ { + images { + kernel@1 { + description = "Test Kernel"; + data = /incbin/("kernel.bin"); + type = "kernel"; + arch = "sandbox"; + os = "linux"; + compression = "none"; + load = <0x40000>; + entry = <0x40000>; + }; + }; + + configurations { + default = "conf@1"; + conf@1 { + kernel = "kernel@1"; + fdt = "notexist"; + }; + }; +}; +''' + + with open(its_fname, 'w') as f: + f.write(its_text) + + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + cmd = [mkimage, '-f', its_fname, itb_fname] + + result = subprocess.run(cmd, capture_output=True, text=True) + + assert result.returncode != 0, "mkimage should fail due to missing image reference" + assert "references undefined image 'notexist'" in result.stderr +