From patchwork Thu Nov 20 02:55:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 729 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=1763607397; bh=A6MGdcxZWf5F1IsBb+3QhRVZAttmt6PpxkiRIUtqbc0=; 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=N3umtx//PyK9jb+DiKyXpki8bgjMY6krwH2p7YrtU+XVvXQ9jKmReq3VWR3u9Akgp XF8rO/e9eqwDD59gUQaeu4n+ijlSEejk+Q6tDPgdcZB3vB8Z+uAegTTdPQGmPtSoPz OW7DJrBVX4uJJgt4U0QBnxvbsYcjENWWF0GHCKlmmAE6zgNa8vxs6lI2CF0iSPMPcW IzkOZCKjFtHM2DJl3ijMr6MZ8J4BCC55vIK1W3ljUNn/0ZxKQChnSOSyb2zY8ZmjBg C0FzHN8VtMP4WnXKtnXrW+gRlZIL/n5RO2RaaezFpaQIU1KRAOHR7bwtXzVlO+afe6 B6QYjodLhcFZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B6A17686E1 for ; Wed, 19 Nov 2025 19:56:37 -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 tDprekk56EPt for ; Wed, 19 Nov 2025 19:56:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607395; bh=A6MGdcxZWf5F1IsBb+3QhRVZAttmt6PpxkiRIUtqbc0=; 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=n+8WGjqV8GKAfIuA+iLAhvb4phgYEzTDG5GCJ7Uz508cZava9iJTW9ED8imRppC+F RePsOADQY9rt3hfEgVL28OSVU4G2BN/FFhwgqm9++3IR+RQScP8h28kCq+ROoN7Om9 R16yY0c1QkNyRv87EgxLCXtv/KHvRaB4JuKT/bbAb6SmgPYC3dp3b2xb+abTUKyYhA fBz8DbKspmOF3sOFIRZDqw27jm76seUTmA8Q4fjymgnDFbuDlaxGnT5oZW4h0ROryz zKYX4zEHzqNHUAnacTIPhdFIBbhlr0z5lc3uR1RgIYz71MGNA8XaJ0jj6hCjZBjVsQ UNqP/ci+bWiMQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD30B686C8 for ; Wed, 19 Nov 2025 19:56:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607393; bh=igXPWVlil4UUrf6NbPdoKN8tctYHHYBQGFBh3a0tfaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4MGyVJgaOSWiX673/7zpO+3e8EEsDKDpsMolmFGd0x8ntNoPjug8K6DZKrd5JnG6 NjXgXkVbWnniYSRB0LioTJaA1uQctYhjpvcw6JRpQs3YmmegU8GYzA8M8Xs6vo3zUb 2JoYpvLzkI8kM/xlBCCWZjJVAZSGpGyuBvVO67btx4pLLKg/rxmVI7l30kNzMaXdXV LFVAqg1AcG9AqOLWA30aw1qGDFZB9WvIHq/0glk4fe5Z4zsYTsoetG68+SUcVr1D/A 0nYUUap8nRup8d+66dsLIpfXJDs92+7FsYg6fxccE9Zcvemks84JiV2Hlx9vQopl/R cZEIhIlAaTY9A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3DF3068656; Wed, 19 Nov 2025 19:56:33 -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 zJ0UKmyI9kCs; Wed, 19 Nov 2025 19:56:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607392; bh=MG0wTPGgTZLEvJ2cNS7vRyIJYAwUjzIFKUQ3wQ/SVaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNdyoNU1j45rz6g2AXO4CRrmGL6NRv3Kk+FkvdxQEEupRuK/pzBPfcyyG4HThM4n0 4IEzuKMtZNbP3b+sqnmxS3Qrq4RVmJ4Z1LiMqrclam+fwe2A4688MF45vVw+y+csHM d8GMb7JITRPR8aoJWghyS3KA09oZ7yDziTsTlZA7OR+EzrTQItFRVaCu2qlK7kJyxg qfZw9YcR6htygCntqwBOJoUpMUrif/1vZY9Tyd7m4R6yhsqdPCUyhAcqhDMhvSlYuB 2cf+1v03vDA2UpwNLSwXyO4mOQGrTFLpPqbRLdAPApPI8RFYjdDPmoZQArPp0luRy4 Uua9ezAHJ9snw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 57EA85E7DA; Wed, 19 Nov 2025 19:56:32 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:36 -0700 Message-ID: <20251120025614.2215587-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BMK3XZWMZI5WTUPPJTM5PIKPF2VHZKOE X-Message-ID-Hash: BMK3XZWMZI5WTUPPJTM5PIKPF2VHZKOE 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/30] docs: Merge .claude/README.md into CLAUDE.md 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 Consolidate build and coding documentation into CLAUDE.md and remove the redundant .claude/README.md file. Mention the use of the Co-developed-by tag and how to run tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- .claude/README.md => CLAUDE.md | 3 +++ 1 file changed, 3 insertions(+) rename .claude/README.md => CLAUDE.md (93%) diff --git a/.claude/README.md b/CLAUDE.md similarity index 93% rename from .claude/README.md rename to CLAUDE.md index b84be8d2445..374f24ba1f9 100644 --- a/.claude/README.md +++ b/CLAUDE.md @@ -32,6 +32,7 @@ make sandbox_defconfig O=/tmp/ # Build make -j$(nproc) O=/tmp/ ``` + ## Testing There are aliases in ~/bin/git-alias which you can use. @@ -67,3 +68,5 @@ pyt - This follows U-Boot's established naming convention for output parameters - Keep commit messages concise - focus on the key change and essential details only - Code should be formatted to 80 columns and not have trailing spaces +- Remember to use Co-developed-by in commits +- Remember not to cd into the build directory; run U-Boot directly in the source dir From patchwork Thu Nov 20 02:55:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 730 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=1763607398; bh=/poh6TpL5vErnArOCZh+ujbZuXq+uWNFgZv/rdqdkoY=; 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=mw5njZ8O9kXnmCd1FvOzr5gpvFmxh8Q9MgB/FHa9vMLx9l4z1eGl/Kq3x+0F81K+W rMZauLCKdKh7vkgh7d9dQFRnaqkJyZnWZRNMmxS/VrSpNEX8danlpZaKRyNTHNiSiK XQ4BH+0Ik3U18F8FHneAdVeFiozKJfj6GLFsF83zD/o3+TB19tBUCe8BeV3e9H02Vj 76sRO0mKoroywhs1OtghtZawlpD4BTA/91U2/ztfrQE48JNVBnyHQFtZG43BZpTyUe neEf8gmcJR2Ryusfmc7juB42Kv/i2uuMCdR4pMswmILMZlAbbZdQGYmgfTQswhqylU 6kxtm0u/wpyzA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 11F8F68631 for ; Wed, 19 Nov 2025 19:56:38 -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 jNUUS7oqPyGQ for ; Wed, 19 Nov 2025 19:56:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607396; bh=/poh6TpL5vErnArOCZh+ujbZuXq+uWNFgZv/rdqdkoY=; 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=R+LVdRvnpBLxxHA35ej18gPjv4d2eMm2c3jdpa+1ux+l24Z79GSOFliWP+T11njM4 YVpvrJAN6/oywP4YP2DaPJT1sv9Ts5OZ1ak56iN4TFQnSYXci2UJ4kZGi0Z4BvXsDI pAcuqfEj8yrnoPToVvD1IQ0O1ydo1jqM17NrqMI1sEOo1fwkpEXPX0Sx4Ol7uyBWap xkG9PkXUZwYsusrsZeIq+nHASpQi230qVqGTosWv1JWzE9ro66O64VK8iTp1Vh8OoQ 7Fqx4/4vDtZ4uQLOHuiJBPu472oXqt1JPFTy7wZwVjD8/RAVknj3VqM2TIpfoT3Ll8 JhNbF/SLpL/Pg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9E34D686DC for ; Wed, 19 Nov 2025 19:56:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607394; bh=F4s7NPnnFRXihHiqbgZl9oq1IoMGdgSnVAxFecerUzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sZO4gPOMSDQpvdJWlzSVdOVmKO0E1vAjk2fURwA5cPsaJhDO6Ks9nIHg9XXaopSma nJiwPtSnchRAHWLqecrRSLOTXGQcF+3210lcC7venahJEOQf+k2/GkBRICX+zGeoXM YwAtR8zqguQfzrie6ts4FBzMVdovaze13wovXAXp28Vw31Ry6KKFMn7RTf9GCODtbM yAyYuA7Newt83wOkc1q/A4i3X1EnRy6tBIykVv/lS0ryrg/EKVz9NUv52X4hAcPIpa Yq67ArNUkWlF2prTMn4mzShozErgKjkZizKfmbi5e0FRwOzVJpun+4Qd/lF4CFAu4N X0FrQLdGNOcoQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28D1E68631; Wed, 19 Nov 2025 19:56:34 -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 p-5qUvVSk5Uj; Wed, 19 Nov 2025 19:56:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607393; bh=eWc4WL6sBpp2hy86TGPKReu9ipi5OTsfggsF384x1t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFklFyZIeANsA82pkb/Q/NylQgilqhzoxq1Yl9vRSUMgF8lQuo7Jy0RbaITzHgy5H RPSn9W4CoZ1nA9yFqBf/0yKXDGeaGwl4mRJ6gt1XfzhiaCWzzDb7YMyHBKl7IJzPy+ /p9GEr/XcT2ruHDejvD7DdU9hSiPd0ZoVr9s1lMj3lep49fshVmaMjvBVZ+fUxdCI9 VJFotns+LBDAX41+bZ5U1uhsjLebRG27vMRtj3Vmy6jlQKx4KARMdRihkohBjqyF/2 2CETbAN5fSLnhgwsN9jKGWm77h6fi5S9cMMquRrxTAE1BIUYsAMWs3bapgvSw2+OIg leb2U+Kwg6neg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 82BE85E7DA; Wed, 19 Nov 2025 19:56:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:37 -0700 Message-ID: <20251120025614.2215587-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2VUCJLLR6PS6F5NMXG3HSBIB42DOEO2A X-Message-ID-Hash: 2VUCJLLR6PS6F5NMXG3HSBIB42DOEO2A 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/30] tools: Fix debug() to avoid unused-variable warnings 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 debug() macro in mkimage.h expands to nothing when MKIMAGE_DEBUG is not defined. This causes the compiler to warn about unused variables that are only referenced in debug() statements. Fix this using the same approach as the debug_cond() macro. Co-developed-by: Claude Signed-off-by: Simon Glass --- tools/mkimage.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/mkimage.h b/tools/mkimage.h index 5d6bcc9301a..a356d20c3b1 100644 --- a/tools/mkimage.h +++ b/tools/mkimage.h @@ -25,9 +25,13 @@ #undef MKIMAGE_DEBUG #ifdef MKIMAGE_DEBUG -#define debug(fmt,args...) printf (fmt ,##args) +#define debug(fmt, args...) printf(fmt, ##args) #else -#define debug(fmt,args...) +#define debug(fmt, args...) \ + do { \ + if (0) \ + printf(fmt, ##args); \ + } while (0) #endif /* MKIMAGE_DEBUG */ #define log_debug(fmt, args...) debug(fmt, ##args) From patchwork Thu Nov 20 02:55:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 731 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=1763607402; bh=GghWEHPtRK33qUgaNmF8sXPDS8fkzEhrjzs9iGzTLGw=; 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=REYlpZNJM3b1nnyZok7U0araOlK7EiU1AecRfcLBe24KXszkZJYB3aNWvkxL/y61K tJaOTks4yYPcpksZGCgq5jFL9gQgpNm9G7A3tGTId8FPc+KVRlddXyhxjzo9qIj/PL fpZeKqYW2WbarcTSuHSqsh932Suvz43ipK6f7TCeHMQW3CXlUqMJtYEwESPonkzegF Zcq0y+m/Wx49FUrFaXeWL04boMVKzlYucfj19i24KFvTL0hFL37WNUeoN2Atv14zs/ 3vf1cs7SBCYWnKr6d70wfAnkt93ipFUkwWkLYu6g4bbPjn09tQNPyEpky9AnYeWV5l mqMex2Ol6yQsw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9BABC686C9 for ; Wed, 19 Nov 2025 19:56:42 -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 YeU8lc9ZqYAQ for ; Wed, 19 Nov 2025 19:56:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607402; bh=GghWEHPtRK33qUgaNmF8sXPDS8fkzEhrjzs9iGzTLGw=; 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=REYlpZNJM3b1nnyZok7U0araOlK7EiU1AecRfcLBe24KXszkZJYB3aNWvkxL/y61K tJaOTks4yYPcpksZGCgq5jFL9gQgpNm9G7A3tGTId8FPc+KVRlddXyhxjzo9qIj/PL fpZeKqYW2WbarcTSuHSqsh932Suvz43ipK6f7TCeHMQW3CXlUqMJtYEwESPonkzegF Zcq0y+m/Wx49FUrFaXeWL04boMVKzlYucfj19i24KFvTL0hFL37WNUeoN2Atv14zs/ 3vf1cs7SBCYWnKr6d70wfAnkt93ipFUkwWkLYu6g4bbPjn09tQNPyEpky9AnYeWV5l mqMex2Ol6yQsw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 87207686BB for ; Wed, 19 Nov 2025 19:56:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607400; bh=uuWV8+8iiFr2RZL2hwvLs0NP2HFkmpiljWtndFxa4KE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i500rgnOa97UjsfGlWXlLDGgFII8KHErTzMTm+73kx1Fv0XUw7ASDz71Zjnf1V8S5 4CRBoR6D6XFUjUxRnaDs2vXzUWK7GZG22rjWb6hAgYrVPam5PUsywqttPJlXDmSOC1 AJP+ThK5aXght1U5g3LaCYqXIqpsa2salNpMdAm1Lux52fHOgzWgGz8BhRKO51zLRu b1HYvFbucojVsFGi2a1O09Pldt5e1LlGNMjbsStjZoUgrN2hgJvT1MKgp+IKTIrFUm uKt4hjEI1B0y7OvjPAI86lgYgTUjzdi9iu35VvQ1THuyxt4VgnU1xeFkChQyS+79BH 6IjojDF34Ypaw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B9F468654; Wed, 19 Nov 2025 19:56:40 -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 8sAbFyYc_dwf; Wed, 19 Nov 2025 19:56:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607394; bh=RfJIQYUMAH/gOCRNrqD5Qyni69mgefQLNk1y/SINQL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HYik5h82RCBGJ6onHgrBdswwvCfuo/ecfH36sV2Ws0h4EgjKn9tkbEhbVTVG47NZq hqni71nnYoAqUUUwW4qYaQ8f0HNDgTwFACV7wjgrnc8rmM4rqqoqRSB8fw1E8z2BqQ L2Sv8P4QYnptzr4cxjQdlLkqc5pI9HfxQyCZNSmsztngR2aM4dXu9R4ZBb3tXE5D7T q1cgau2i7avo5/OTaVXGuo31wizkUNVrD6hbDF1MxVVoYeTZGJX1kAzB5EwCoHMTWN +G2G++UxI7kV1xBGypICB3i+lDWQnYwWv+lL4tfAFHpnOJRaIxaa6Ut9DzhNv/FSj2 msPDcVRk+Baqw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6BE9F5E7DA; Wed, 19 Nov 2025 19:56:34 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:38 -0700 Message-ID: <20251120025614.2215587-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: G3O77L7D4GCFSWFHE2C6V4ACPDYEHLMZ X-Message-ID-Hash: G3O77L7D4GCFSWFHE2C6V4ACPDYEHLMZ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/30] test: Increase expect_str/actual_str buffer size 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 These buffers can be exceeded when checking the FIT output with an RSA key. Increase the limit to 1K. Co-developed-by: Claude Signed-off-by: Simon Glass --- include/test/test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index 51609e799b7..f2d956e913c 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -78,8 +78,8 @@ struct unit_test_state { bool force_run; void *old_bloblist; bool soft_fail; - char expect_str[512]; - char actual_str[512]; + char expect_str[1024]; + char actual_str[1024]; }; /* Test flags for each test */ From patchwork Thu Nov 20 02:55:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 732 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=1763607405; bh=e29S6wM+bMw4A6OjaZbGen8m2W9PxcDonFHMN5Xa5p0=; 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=MSToQrWbXXPH0MMyw10lUe9xcNz57i5nhBJ2dMSTFNLgzkPxSWkuAFHBW9WMYqiDA 3wnTDCz/qOHCUlFUt6JezSfMFdgNJ9r8gfYDCHlAlflE/biG6fLi4NzrtGXQTiboNg ZOE/5VDGaCd9oYiMpRZCAdTRwaZFXzYrIhUaHUHq0cO3lPQuO4VuZxq89fxs6F35PE 9nScI63hm1R1rvQXdr6HSVABI3YB/bOJE+zh5XGb9+s4wChV0eS4v3C/6qcaHHFLYd 8PUiurzhfpWdTvVqc/PsoGE9e5CpNmEVRylOrEFx6dvkSG0bx+OqhKItOZeWXoKdGx 73jWWBfrSbpdg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 142CD686EE for ; Wed, 19 Nov 2025 19:56:45 -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 fZYC94Gqcxch for ; Wed, 19 Nov 2025 19:56:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607403; bh=e29S6wM+bMw4A6OjaZbGen8m2W9PxcDonFHMN5Xa5p0=; 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=FpmNvv92S94Xf8ubN/2dTnAOgj/U9R6i7lt5UH7J02hgXujoqv83L/IUtXjoAV4t0 TNVshffPKZHVyR+B26LZus65aTM8aGJ1h7jOFTWn5DXS+4PqHVylcm6Q78I2nZ2VKT hm/hxQrKNinVpNzXTO0WLSzhk2C1tIrasOtdBqpZNTm9bbl1VQl8aY4zw6QBesLWJa UHuSpQAkOWMxOU2xz+lhQlsLk+KlXaDRt1kNTuQ9hGXigwq2BDobwz2R5jPHgUVPIS lFYkXQHNd/rjownJEnAem5zcFA5wqqAjKtzWNVXsGANbRLF2jVckxLp+lUN4gf5v2B XyKenxZ2c/qGQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17A2C68662 for ; Wed, 19 Nov 2025 19:56:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607400; bh=pitqylGrHK9ZYWLbdyC4HiwTQN1lCnd5a5GeJwd+b8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGcZSGAhMscG4l7fyhtnIJuTC+8maiglvlnh3BlOHl6TB5f03UhSfmIVsr7eVMcoP SO8o2zTITSVzofjr9B2+HKy6KM/QDD8mH0PEOm2gPvAxwCBxFW4USXZHcTyc8uJv+o nedUPE/2ps8D79JRCYvZPTym0pOg2LtU5aomEHLKsyNvF9rqMngk6+Plawrg8ta62r Vp2evAE3oonnlAHehPwc4Zi77d2mTwjLu+pY81u7K6/t3Qp56ugMYEAeB67x0Zmol9 eN4j9JkYBxzjx1Fow1gkhro2ZOODUwHfbsrxaWFhE3jsinzy3P54KG/vYIkF3wzmYt bXlQPTACQuFig== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6DBA368662; Wed, 19 Nov 2025 19:56:40 -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 yZw5wT-z2dyR; Wed, 19 Nov 2025 19:56:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607399; bh=FytHpjYqHDCLIu1wLgd4rsw21BPmxlFJSfe1Yx6/a80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJj0ZSq2X0CCzLmxdF9K1HHeqUaR+eKCgpffO+Gf7BSdAReFWAKj+sZqcL4fDWdq/ qMLvK/Br8jHI071ItVtqogfhaS/TvXkME/bkSQ4ejW2bZIoJHf9ZdGf7XUJPWAdRJQ aov2PmWp5iemQQBD5ZF1TL6Cs5zBrZcmfd0zCYQB9YOq+DOunsFVTgvUjXbuIC2b3u DzrZaRDmchlDb1Qs+Iu35OuXstuP1WX1KBJsjmyWUT42K1y7uyznGMV0qJrJdknd7C MhhOkyVZqchBVzIOGHNqD8mPdLh+dySTRQ9MfY9znCza4HeoKe6xLLYokX+eLvnh1e Q+SMGkI+rlBRA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2074C68631; Wed, 19 Nov 2025 19:56:39 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:39 -0700 Message-ID: <20251120025614.2215587-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LV3CM4TG6ITSABZNDDYVR26SI3XJTRUZ X-Message-ID-Hash: LV3CM4TG6ITSABZNDDYVR26SI3XJTRUZ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/30] fit: Remove unused len parameter from fit_get_name() 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 Remove the unused third parameter (len) from fit_get_name(). All uses of this function pass NULL for this parameter. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/image-cipher.c | 2 +- boot/image-fit-sig.c | 24 ++++++++++++------------ boot/image-fit.c | 29 ++++++++++++++--------------- common/spl/spl_fit.c | 12 ++++++------ common/update.c | 4 ++-- drivers/fpga/socfpga_arria10.c | 2 +- include/image.h | 6 +++--- tools/fit_image.c | 2 +- tools/fit_info.c | 2 +- tools/image-host.c | 30 +++++++++++++++--------------- 10 files changed, 56 insertions(+), 57 deletions(-) diff --git a/boot/image-cipher.c b/boot/image-cipher.c index 9d389f26cea..66fae2153cd 100644 --- a/boot/image-cipher.c +++ b/boot/image-cipher.c @@ -76,7 +76,7 @@ static int fit_image_setup_decrypt(struct image_cipher_info *info, char *algo_name; int ret; - node_name = fit_get_name(fit, image_noffset, NULL); + node_name = fit_get_name(fit, image_noffset); if (!node_name) { printf("Can't get node name\n"); return -1; diff --git a/boot/image-fit-sig.c b/boot/image-fit-sig.c index a121de60ae2..8dee5698236 100644 --- a/boot/image-fit-sig.c +++ b/boot/image-fit-sig.c @@ -145,7 +145,7 @@ static int fit_image_verify_sig(const void *fit, int image_noffset, /* Process all hash subnodes of the component image node */ fdt_for_each_subnode(noffset, fit, image_noffset) { - const char *name = fit_get_name(fit, noffset, NULL); + const char *name = fit_get_name(fit, noffset); /* * We don't support this since libfdt considers names with the @@ -178,8 +178,8 @@ static int fit_image_verify_sig(const void *fit, int image_noffset, error: printf(" error!\n%s for '%s' hash node in '%s' image node\n", - err_msg, fit_get_name(fit, noffset, NULL), - fit_get_name(fit, image_noffset, NULL)); + err_msg, fit_get_name(fit, noffset), + fit_get_name(fit, image_noffset)); return -1; } @@ -212,7 +212,7 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset, key_blob, noffset); if (ret) { printf("Failed to verify required signature '%s'\n", - fit_get_name(key_blob, noffset, NULL)); + fit_get_name(key_blob, noffset)); return ret; } verify_count++; @@ -277,10 +277,10 @@ static int fit_config_check_sig(const void *fit, int noffset, int conf_noffset, char path[200]; int count; - config_name = fit_get_name(fit, conf_noffset, NULL); + config_name = fit_get_name(fit, conf_noffset); debug("%s: fdt=%p, conf='%s', sig='%s'\n", __func__, key_blob, - fit_get_name(fit, noffset, NULL), - fit_get_name(key_blob, required_keynode, NULL)); + fit_get_name(fit, noffset), + fit_get_name(key_blob, required_keynode)); *err_msgp = NULL; if (fit_image_setup_verify(&info, fit, noffset, key_blob, required_keynode, err_msgp)) @@ -421,7 +421,7 @@ static int fit_config_verify_key(const void *fit, int conf_noffset, /* Process all hash subnodes of the component conf node */ fdt_for_each_subnode(noffset, fit, conf_noffset) { - const char *name = fit_get_name(fit, noffset, NULL); + const char *name = fit_get_name(fit, noffset); if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) { @@ -448,8 +448,8 @@ static int fit_config_verify_key(const void *fit, int conf_noffset, error: printf(" error!\n%s for '%s' hash node in '%s' config node\n", - err_msg, fit_get_name(fit, noffset, NULL), - fit_get_name(fit, conf_noffset, NULL)); + err_msg, fit_get_name(fit, noffset), + fit_get_name(fit, conf_noffset)); return -EPERM; } @@ -469,7 +469,7 @@ error: static int fit_config_verify_required_keys(const void *fit, int conf_noffset, const void *key_blob) { - const char *name = fit_get_name(fit, conf_noffset, NULL); + const char *name = fit_get_name(fit, conf_noffset); int noffset; int key_node; int verified = 0; @@ -525,7 +525,7 @@ static int fit_config_verify_required_keys(const void *fit, int conf_noffset, if (ret) { if (reqd_policy_all) { printf("Failed to verify required signature '%s'\n", - fit_get_name(key_blob, noffset, NULL)); + fit_get_name(key_blob, noffset)); return ret; } } else { diff --git a/boot/image-fit.c b/boot/image-fit.c index 7bcdb97985a..eb47c00cc01 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -148,7 +148,7 @@ static void fit_get_debug(const void *fit, int noffset, char *prop_name, int err) { debug("Can't get '%s' property from FIT 0x%08lx, node: offset %d, name %s (%s)\n", - prop_name, (ulong)fit, noffset, fit_get_name(fit, noffset, NULL), + prop_name, (ulong)fit, noffset, fit_get_name(fit, noffset), fdt_strerror(err)); } @@ -205,8 +205,7 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p, bool required; int ret, i; - debug("%s %s node: '%s'\n", p, type, - fit_get_name(fit, noffset, NULL)); + debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); printf("%s %s algo: ", p, type); if (fit_image_hash_get_algo(fit, noffset, &algo)) { printf("invalid/unsupported\n"); @@ -271,7 +270,7 @@ static void fit_image_print_verification_data(const void *fit, int noffset, * Multiple hash/signature nodes require unique unit node * names, e.g. hash-1, hash-2, signature-1, signature-2, etc. */ - name = fit_get_name(fit, noffset, NULL); + name = fit_get_name(fit, noffset); if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) { fit_image_print_data(fit, noffset, p, "Hash"); } else if (!strncmp(name, FIT_SIG_NODENAME, @@ -436,7 +435,7 @@ void fit_print_contents(const void *fit) * i.e. component image node. */ printf("%s Image %u (%s)\n", p, count++, - fit_get_name(fit, noffset, NULL)); + fit_get_name(fit, noffset)); fit_image_print(fit, noffset, p); } @@ -466,7 +465,7 @@ void fit_print_contents(const void *fit) * i.e. configuration node. */ printf("%s Configuration %u (%s)\n", p, count++, - fit_get_name(fit, noffset, NULL)); + fit_get_name(fit, noffset)); fit_conf_print(fit, noffset, p); } @@ -1215,7 +1214,7 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) sizeof(uint32_t)); if (ret) { debug("Can't set '%s' property for '%s' node (%s)\n", - FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL), + FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset), fdt_strerror(ret)); return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1; } @@ -1352,7 +1351,7 @@ int fit_image_verify_with_data(const void *fit, int image_noffset, /* Process all hash subnodes of the component image node */ fdt_for_each_subnode(noffset, fit, image_noffset) { - const char *name = fit_get_name(fit, noffset, NULL); + const char *name = fit_get_name(fit, noffset); /* * Check subnode name, must be equal to "hash". @@ -1393,8 +1392,8 @@ int fit_image_verify_with_data(const void *fit, int image_noffset, error: printf(" error!\n%s for '%s' hash node in '%s' image node\n", - err_msg, fit_get_name(fit, noffset, NULL), - fit_get_name(fit, image_noffset, NULL)); + err_msg, fit_get_name(fit, noffset), + fit_get_name(fit, image_noffset)); return 0; } @@ -1413,7 +1412,7 @@ error: */ int fit_image_verify(const void *fit, int image_noffset) { - const char *name = fit_get_name(fit, image_noffset, NULL); + const char *name = fit_get_name(fit, image_noffset); const void *data; size_t size; char *err_msg = ""; @@ -1437,7 +1436,7 @@ int fit_image_verify(const void *fit, int image_noffset) err: printf("error!\n%s in '%s' image node\n", err_msg, - fit_get_name(fit, image_noffset, NULL)); + fit_get_name(fit, image_noffset)); return 0; } @@ -1480,7 +1479,7 @@ int fit_all_image_verify(const void *fit) * i.e. component image node. */ printf(" Hash(es) for Image %u (%s): ", count, - fit_get_name(fit, noffset, NULL)); + fit_get_name(fit, noffset)); count++; if (!fit_image_verify(fit, noffset)) @@ -2127,7 +2126,7 @@ static int select_from_config(const void *fit, struct bootm_headers *images, return -ENOPKG; } - *fit_unamep = fit_get_name(fit, noffset, NULL); + *fit_unamep = fit_get_name(fit, noffset); return noffset; } @@ -2639,7 +2638,7 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr, if (i < count) { noffset = fit_conf_get_prop_node_index(fit, cfg_noffset, FIT_FDT_PROP, i); - uname = fit_get_name(fit, noffset, NULL); + uname = fit_get_name(fit, noffset); uconfig = NULL; } else { if (!next_config) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 49b4df60560..b4049e41c2c 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -255,7 +255,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, if (fit_image_get_load(fit, node, &load_addr)) { if (!image_info->load_addr) { printf("Can't load %s: No load address and no buffer\n", - fit_get_name(fit, node, NULL)); + fit_get_name(fit, node)); return -ENOBUFS; } load_addr = image_info->load_addr; @@ -281,7 +281,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, /* Dont bother to copy 0 byte data, but warn, though */ if (!len) { log_warning("%s: Skip load '%s': image size is 0!\n", - __func__, fit_get_name(fit, node, NULL)); + __func__, fit_get_name(fit, node)); return 0; } @@ -318,7 +318,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) { printf("## Checking hash(es) for Image %s ... ", - fit_get_name(fit, node, NULL)); + fit_get_name(fit, node)); if (!fit_image_verify_with_data(fit, node, gd_fdt_blob(), src, length)) return -EPERM; @@ -489,12 +489,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, (void *)image_info.load_addr); if (ret) { pr_err("failed to apply DT overlay %s\n", - fit_get_name(ctx->fit, node, NULL)); + fit_get_name(ctx->fit, node)); break; } debug("%s: DT overlay %s applied\n", __func__, - fit_get_name(ctx->fit, node, NULL)); + fit_get_name(ctx->fit, node)); } free(tmpbuffer); if (ret) @@ -720,7 +720,7 @@ static int spl_simple_fit_parse(struct spl_fit_info *ctx) if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) { printf("## Checking hash(es) for config %s ... ", - fit_get_name(ctx->fit, ctx->conf_node, NULL)); + fit_get_name(ctx->fit, ctx->conf_node)); if (fit_config_verify(ctx->fit, ctx->conf_node)) return -EPERM; puts("OK\n"); diff --git a/common/update.c b/common/update.c index 6801b49479d..8f44a64592a 100644 --- a/common/update.c +++ b/common/update.c @@ -278,7 +278,7 @@ got_update_file: if (ndepth != 1) goto next_node; - fit_image_name = (char *)fit_get_name(fit, noffset, NULL); + fit_image_name = (char *)fit_get_name(fit, noffset); printf("Processing update '%s' :", fit_image_name); if (!fit_image_verify(fit, noffset)) { @@ -354,7 +354,7 @@ int fit_update(const void *fit) if (ndepth != 1) goto next_node; - fit_image_name = (char *)fit_get_name(fit, noffset, NULL); + fit_image_name = (char *)fit_get_name(fit, noffset); printf("Processing update '%s' :", fit_image_name); if (!fit_image_verify(fit, noffset)) { diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c index e9822b2bb0e..317bb261bc8 100644 --- a/drivers/fpga/socfpga_arria10.c +++ b/drivers/fpga/socfpga_arria10.c @@ -613,7 +613,7 @@ static int first_loading_rbf_to_buffer(struct udevice *dev, images_noffset = fit_conf_get_prop_node_index(buffer_p, confs_noffset, FIT_FPGA_PROP, i); - uname = fit_get_name(buffer_p, images_noffset, NULL); + uname = fit_get_name(buffer_p, images_noffset); if (uname) { debug("FPGA: %s\n", uname); diff --git a/include/image.h b/include/image.h index a972e3f6921..33eb5d71e79 100644 --- a/include/image.h +++ b/include/image.h @@ -1225,15 +1225,15 @@ ulong fit_get_end(const void *fit); /** * fit_get_name - get FIT node name * @fit: pointer to the FIT format image header + * @noffset: node offset * * returns: * NULL, on error * pointer to node name, on success */ -static inline const char *fit_get_name(const void *fit_hdr, - int noffset, int *len) +static inline const char *fit_get_name(const void *fit_hdr, int noffset) { - return fdt_get_name(fit_hdr, noffset, len); + return fdt_get_name(fit_hdr, noffset, NULL); } /** diff --git a/tools/fit_image.c b/tools/fit_image.c index 013242cd204..80f9020d29d 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -972,7 +972,7 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) */ if (itl->pflag == count) { printf("Extracted:\n%s Image %u (%s)\n", p, - count, fit_get_name(fit, noffset, NULL)); + count, fit_get_name(fit, noffset)); fit_image_print(fit, noffset, p); diff --git a/tools/fit_info.c b/tools/fit_info.c index b2642ec5b76..3c049a7f7e1 100644 --- a/tools/fit_info.c +++ b/tools/fit_info.c @@ -98,7 +98,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset, NULL)); + printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset)); printf("LEN: %d\n", len); printf("OFF: %d\n", (int)(nodep - fit_blob)); (void) munmap((void *)fit_blob, fsbuf.st_size); diff --git a/tools/image-host.c b/tools/image-host.c index a9b86902763..99594f89de0 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -46,7 +46,7 @@ static int fit_set_hash_value(void *fit, int noffset, uint8_t *value, ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len); if (ret) { fprintf(stderr, "Can't set hash '%s' property for '%s' node(%s)\n", - FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL), + FIT_VALUE_PROP, fit_get_name(fit, noffset), fdt_strerror(ret)); return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO; } @@ -76,7 +76,7 @@ static int fit_image_process_hash(void *fit, const char *image_name, const char *algo; int ret; - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); if (fit_image_hash_get_algo(fit, noffset, &algo)) { fprintf(stderr, @@ -176,7 +176,7 @@ static int fit_image_setup_sig(struct image_sign_info *info, const char *node_name; const char *padding_name; - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); if (!algo_name) { if (fit_image_hash_get_algo(fit, noffset, &algo_name)) { fprintf(stderr, @@ -247,7 +247,7 @@ static int fit_image_process_sig(const char *keydir, const char *keyfile, engine_id, algo_name)) return -1; - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); region.data = data; region.size = size; ret = info.crypto->sign(&info, ®ion, 1, &value, &value_len); @@ -585,7 +585,7 @@ int fit_image_cipher_data(const char *keydir, void *keydest, int cipher_node_offset, len; /* Get image name */ - image_name = fit_get_name(fit, image_noffset, NULL); + image_name = fit_get_name(fit, image_noffset); if (!image_name) { fprintf(stderr, "Can't get image name\n"); return -1; @@ -677,7 +677,7 @@ int fit_image_add_verification_data(const char *keydir, const char *keyfile, return -1; } - image_name = fit_get_name(fit, image_noffset, NULL); + image_name = fit_get_name(fit, image_noffset); /* Process all hash subnodes of the component image node */ for (noffset = fdt_first_subnode(fit, image_noffset); @@ -691,7 +691,7 @@ int fit_image_add_verification_data(const char *keydir, const char *keyfile, * Multiple hash nodes require unique unit node * names, e.g. hash-1, hash-2, signature-1, etc. */ - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); if (!strncmp(node_name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) { ret = fit_image_process_hash(fit, image_name, noffset, @@ -809,7 +809,7 @@ static int fit_config_add_hash(const void *fit, int image_noffset, for (noffset = fdt_first_subnode(fit, image_noffset); noffset >= 0; noffset = fdt_next_subnode(fit, noffset)) { - const char *name = fit_get_name(fit, noffset, NULL); + const char *name = fit_get_name(fit, noffset); if (strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) @@ -884,8 +884,8 @@ static int fit_config_get_hash_list(const void *fit, int conf_noffset, int image_count; int ret, len; - conf_name = fit_get_name(fit, conf_noffset, NULL); - sig_name = fit_get_name(fit, sig_offset, NULL); + conf_name = fit_get_name(fit, conf_noffset); + sig_name = fit_get_name(fit, sig_offset); /* * Build a list of nodes we need to hash. We always need the root @@ -991,8 +991,8 @@ static int fit_config_get_regions(const void *fit, int conf_noffset, char *region_prop; int ret, len; - conf_name = fit_get_name(fit, conf_noffset, NULL); - sig_name = fit_get_name(fit, sig_offset, NULL); + conf_name = fit_get_name(fit, conf_noffset); + sig_name = fit_get_name(fit, sig_offset); debug("%s: conf='%s', sig='%s'\n", __func__, conf_name, sig_name); /* Get a list of nodes we want to hash */ @@ -1084,7 +1084,7 @@ static int fit_config_process_sig(const char *keydir, const char *keyfile, uint value_len; int ret; - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); if (fit_config_get_regions(fit, conf_noffset, noffset, ®ion, ®ion_count, ®ion_prop, ®ion_proplen)) @@ -1148,7 +1148,7 @@ static int fit_config_add_verification_data(const char *keydir, const char *conf_name; int noffset; - conf_name = fit_get_name(fit, conf_noffset, NULL); + conf_name = fit_get_name(fit, conf_noffset); /* Process all hash subnodes of the configuration node */ for (noffset = fdt_first_subnode(fit, conf_noffset); @@ -1157,7 +1157,7 @@ static int fit_config_add_verification_data(const char *keydir, const char *node_name; int ret = 0; - node_name = fit_get_name(fit, noffset, NULL); + node_name = fit_get_name(fit, noffset); if (!strncmp(node_name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) { ret = fit_config_process_sig(keydir, keyfile, keydest, From patchwork Thu Nov 20 02:55:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 733 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=1763607405; bh=1O3+p872ws/0govTvOqzlqqUlVUcATL82rXwMdAMlKc=; 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=XFNi/kC/mFsU4sZk4HgBcFOgDjFdfjj4x56yh/w+xl2KcuSBEXM2pcnPjvxjumpqj giD8GLx8Ct5kZPNTrJgKcuSIaJBBwWHd2AhNPzTcrKEvqFaeZPXyxYEcTxQxU994GQ GljESL5ZuhkjzYI6cnIK7759EBnFbWngcHvAWoqUddSPCzxnEtKPh+UqFmgZT7gK+3 nzh9ZDULxz0pCBIrSQp3JzjqyO3E/WBfLTatXD6hqRFis1XwNX0P9uNuygpMFad67j 8ZXpg0eNKe0jTxU4bKOM3JEu8btF+tWPupiOmPMnK1sFY0UOGJxJSuZ4ngxYySI29v wJtsE69ldLc+g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 75C96686C9 for ; Wed, 19 Nov 2025 19:56:45 -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 w2vZU9P2XHAo for ; Wed, 19 Nov 2025 19:56:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607403; bh=1O3+p872ws/0govTvOqzlqqUlVUcATL82rXwMdAMlKc=; 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=Mf0KsmvNvl8mwlFKurg4mkqXdNBbl2YmxH81VHOn+BXriwGtFKTfW2pS4EcHYO1yi tP2M10XYLKSlJ1NAuqP7rCGP2TP8ifm2tI2mmMpYM+n7Cy65iD00Q0xbeAiR6oQDFL bP/ziUHKvxKZ70dNEtX6k727jENo5WSaq6YoVYDEJb1MttEVN3LDnWnEbgdQDwB7d8 U8kChDAxxkJwAdXGN09JPjoIEP/9xskou0NfHvyL7Q37wuV5NfC2N+mOC/W3DZGSak NhWfagSd7bOPH1WUpA4ehsxkAevhWk6CoMm17bx+Nmb1Ec5c2p+n8eP7VfhmfAPQIu qWL/6h05i4Srw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C8823686DF for ; Wed, 19 Nov 2025 19:56:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607401; bh=/JszXojwMAVMkZI49rPulBGtXH4anMxI0x6B1Uxum/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3Fa/qQBWPCJQWnHXvq3gRVn4KZtWoStF99V8zbSDw/JlRxv9jaI8pyj133FgbdC8 Emj2gZmxyzLnC8bucyM4gSezEudafg/DQOrLFsG9oPeNctsIrxWgVSff5wj786/bqz BoOY0rNCsT5fE5jUTLyiPCWVgNk3MSFnqbXTgOIibXN9yx4aPLLDmft51xI1FUt/SU 1EFFV4YzKVzufi1zMu8O67iZZt+RohEo6t83mUGc+FPTIEjDCUbmrres9bAVsvieGL G/ZMN/pV8uuS/LOM2W0mg+LI6if1o3pia99RzoimyJ4eZnPCq84lIsh5lWkYhwvdQS AFvb6vSTxYFEQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 670FA68631; Wed, 19 Nov 2025 19:56:41 -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 CDzro0QFbPsg; Wed, 19 Nov 2025 19:56:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607400; bh=nI9ToTo9pI/qELJUfk9w6tRf8x1GFghGMsQh+e8vPyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MP0YueAxN2ZPogU5oyOJucUEmL1Q2A8jXoXM2e3WZUKdZ8dWdwRclMO8pS0WrbOk9 MCjq8NOaCHqtxtoXrKyetIxasA2HQUiPgT8Ot73LRR40qonDWurFuegvewMBYench0 hxXFfIzWlXLvkLS/nWbdvB8Ab6dobzQuHtHyMd1u47ZB+3MjSYyISwzLvHHljN6Dlb tQfgY8wyoc3BWN0ZWyF6ODOQTSri4Mu/jRiSa6PDXLsIaiWxfcrB6D+ZSleYiHGA/w BqFQnySP30vaCzb6CaS+JHa90ZEHPh4/EZr+ajH0jGYmru8mZkhiXL+QRd/DL18VGP BDFwdkY7kP4XQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7A6215E7DA; Wed, 19 Nov 2025 19:56:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:40 -0700 Message-ID: <20251120025614.2215587-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZTKMNGG7U234WPLQ22WD4A3LKW5WBBYS X-Message-ID-Hash: ZTKMNGG7U234WPLQ22WD4A3LKW5WBBYS 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/30] test: Add a test for FIT image printing 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 code for printing FITs is quite messy, with lots of separate printf() calls, an indentation string, etc. It also has no tests. In preparation for refactoring this code, add a test. Use Python code to create the test image and C code to test it. The test covers FIT description, image details (type, architecture, OS, addresses), and configuration details. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/Makefile | 1 + test/boot/fit_print.c | 93 +++++++++++++++++++++++++ test/py/tests/test_fit_print.py | 120 ++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 test/boot/fit_print.c create mode 100644 test/py/tests/test_fit_print.py diff --git a/test/boot/Makefile b/test/boot/Makefile index 71c482f8d24..70e15bf63fa 100644 --- a/test/boot/Makefile +++ b/test/boot/Makefile @@ -5,6 +5,7 @@ ifdef CONFIG_UT_BOOTSTD obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o obj-$(CONFIG_FIT) += image.o +obj-$(CONFIG_$(PHASE_)FIT_PRINT) += fit_print.o obj-$(CONFIG_BLK_LUKS) += luks.o obj-$(CONFIG_EXPO) += expo.o expo_common.o diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c new file mode 100644 index 00000000000..ef1e86800ee --- /dev/null +++ b/test/boot/fit_print.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for FIT image printing + * + * Copyright 2025 Canonical Ltd + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include "bootstd_common.h" + +/* Test fit_print_contents() output */ +static int test_fit_print_norun(struct unit_test_state *uts) +{ + char fname[256]; + void *fit; + void *buf; + ulong addr; + int size; + + /* Load the FIT created by the Python test */ + ut_assertok(os_persistent_file(fname, sizeof(fname), "test-fit.fit")); + ut_assertok(os_read_file(fname, &buf, &size)); + + /* Copy to address 0x10000 and print from there */ + addr = 0x10000; + fit = map_sysmem(addr, size); + memcpy(fit, buf, size); + + /* Print it and check output line by line */ + console_record_reset_enable(); + fit_print_contents(fit); + + /* Check every line of output */ + ut_assert_nextline(" FIT description: Test FIT image for printing"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Image 0 (kernel)"); + ut_assert_nextline(" Description: Test kernel"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Kernel Image"); + ut_assert_nextline(" Compression: gzip compressed"); + ut_assert_nextline(" Data Start: 0x000100c4"); + ut_assert_nextline(" Data Size: 327 Bytes = 327 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Linux"); + ut_assert_nextline(" Load Address: 0x01000000"); + ut_assert_nextline(" Entry Point: 0x01000000"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee"); + ut_assert_nextline(" Image 1 (ramdisk)"); + ut_assert_nextline(" Description: Test ramdisk"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: RAMDisk Image"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x00010304"); + ut_assert_nextline(" Data Size: 301 Bytes = 301 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Linux"); + ut_assert_nextline(" Load Address: 0x02000000"); + ut_assert_nextline(" Entry Point: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655"); + ut_assert_nextline(" Image 2 (fdt)"); + ut_assert_nextline(" Description: Test FDT"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Flat Device Tree"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x00010514"); + ut_assert_nextline(" Data Size: 157 Bytes = 157 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 51918524b06745cae06331047c7e566909431bf71338e5f703dffba1823274f4"); + ut_assert_nextline(" Default Configuration: 'conf-1'"); + ut_assert_nextline(" Configuration 0 (conf-1)"); + ut_assert_nextline(" Description: Test configuration"); + ut_assert_nextline(" Kernel: kernel"); + ut_assert_nextline(" Init Ramdisk: ramdisk"); + ut_assert_nextline(" FDT: fdt"); + ut_assert_nextline(" Configuration 1 (conf-2)"); + ut_assert_nextline(" Description: Alternate configuration"); + ut_assert_nextline(" Kernel: kernel"); + ut_assert_nextline(" FDT: fdt"); + ut_assert_console_end(); + + os_free(buf); + + return 0; +} +BOOTSTD_TEST(test_fit_print_norun, UTF_CONSOLE | UTF_MANUAL); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py new file mode 100644 index 00000000000..4960ce503b4 --- /dev/null +++ b/test/py/tests/test_fit_print.py @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Canonical Ltd +# Written by Simon Glass + +"""Test for FIT image printing""" + +import os + +import pytest + +import fit_util +import utils + +# ITS for testing FIT printing with hashes, ramdisk, and multiple configs +PRINT_ITS = ''' +/dts-v1/; + +/ { + description = "Test FIT image for printing"; + #address-cells = <1>; + + images { + kernel { + description = "Test kernel"; + data = /incbin/("%(kernel)s"); + type = "kernel"; + arch = "sandbox"; + os = "linux"; + compression = "gzip"; + load = <0x1000000>; + entry = <0x1000000>; + hash-1 { + algo = "sha256"; + }; + }; + ramdisk { + description = "Test ramdisk"; + data = /incbin/("%(ramdisk)s"); + type = "ramdisk"; + arch = "sandbox"; + os = "linux"; + compression = "none"; + load = <0x2000000>; + hash-1 { + algo = "sha256"; + }; + }; + fdt { + description = "Test FDT"; + data = /incbin/("%(fdt)s"); + type = "flat_dt"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + }; + configurations { + default = "conf-1"; + conf-1 { + description = "Test configuration"; + kernel = "kernel"; + fdt = "fdt"; + ramdisk = "ramdisk"; + }; + conf-2 { + description = "Alternate configuration"; + kernel = "kernel"; + fdt = "fdt"; + }; + }; +}; +''' + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +def test_fit_print(ubman): + """Test fit_print_contents() via C unit test""" + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + + # Create test files (make kernel ~6.3K) + kernel = fit_util.make_kernel(ubman, 'test-kernel.bin', + 'kernel with some extra test data') + + # Compress the kernel (with -n to avoid timestamps for reproducibility) + kernel_gz = kernel + '.gz' + utils.run_and_log(ubman, ['gzip', '-f', '-n', '-k', kernel]) + + fdt = fit_util.make_dtb(ubman, ''' +/dts-v1/; +/ { + #address-cells = <1>; + #size-cells = <0>; + model = "Test"; +}; +''', 'test-fdt') + ramdisk = fit_util.make_kernel(ubman, 'test-ramdisk.bin', 'ramdisk') + + # Compress the ramdisk (with -n to avoid timestamps for reproducibility) + ramdisk_gz = ramdisk + '.gz' + utils.run_and_log(ubman, ['gzip', '-f', '-n', '-k', ramdisk]) + + # Create FIT image with fixed timestamp for reproducible output + params = { + 'kernel': kernel_gz, + 'fdt': fdt, + 'ramdisk': ramdisk_gz, + } + env = os.environ.copy() + env['SOURCE_DATE_EPOCH'] = '1234567890' # 2009-02-13 23:31:30 UTC + fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit.fit') + its = fit_util.make_its(ubman, PRINT_ITS, params) + utils.run_and_log(ubman, [mkimage, '-f', its, fit], env=env) + + # Run the C test which will load and verify this FIT + ubman.run_command('ut -f bootstd test_fit_print_norun') + result = ubman.run_command('echo $?') + assert '0' == result From patchwork Thu Nov 20 02:55:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 734 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=1763607405; bh=j2xV7ALzH9YZSLa5o2nR97IyAayNwp0OMe4PWCXEKP0=; 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=hKBkSmOplxAGtOfitbXayjZtbtjdxbNtaVoiw713CUthCnEDotVH21rDiCKrBaXEd DnVkgCklqwEMqRsJMQ380Oif+cWHHx60AeJJa7D0uyfIekRXkq9MW4ytmgUbpbAPav Z1msbM4CYGueTkoQNtfgNhXjo9yrtOoAYGJu0sLoeRa2bfEg/G4Hql2hOKlb/3wegP LJWPbte43BMCKPeVgmr+33lNmwgkRREc4gwfnKaaAYDFasVmjR2Jy+5Pwnc3GXQorB j9uAlZJY7qlTSDBDG1TyxWByUyE53pEDGqu9SOkfl403aC18AZYy8/fNrGc/IzM2oO /4vVRytZY88SA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F38A8686CB for ; Wed, 19 Nov 2025 19:56:45 -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 CeWM15VbpFzc for ; Wed, 19 Nov 2025 19:56:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607404; bh=j2xV7ALzH9YZSLa5o2nR97IyAayNwp0OMe4PWCXEKP0=; 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=UNsI0mOzSIMUdEBv84XfKdREpg1NtEFY5c+SJf+sk6163W/dY1ObiwwPo/2m0KEf5 MXUWbU2HF2QG2ObBED0StEePljwJQrdPr8m72blBl9pNIPSGBSjk9l4BtwLwGYV8ff rcllmK1iUoqN4jQkyDUFnXUnAfFr0HtLDnXemhKZqb7oyJVkwkZvpNs5cIr+5+WI53 fFIfiDMxPXEjbmAvmr9dVAF0sNtYfy2zHmbdYxcxkX61SYcm/1z0ONBG0hi/nlMUfG T8b03uCbcdWJGJpdBxWVpLQaX6ckeZvlXZ4sajoQBk8yvaXG+oSIt4PtkTDpYrHf51 //rWJWPcTtZlQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3612C686E7 for ; Wed, 19 Nov 2025 19:56:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607402; bh=moeNuFF0hdgXB1pijsZCwZaJ7ppBgyWFjc8BONqPF7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUJjRQmPwvr7fZJSThyatBMbSQ0IqTUKX0M/GnJH12p4kOFHmjgY+t/73QWvF6iAn nTRQDsYu0TCeEdQo35mvt3UWBZBOMGCTiDiqbR2Iun88lbQKqSVuxrECT12RkxZCNu V6U1WEnkV9wytsaGTa8Jh2HvWj3XHY4bGntvLzSCVpSeNqtz3HCbpC0WcfAQPGpvr3 DPBc4M1uAGH4JQJk9X556Mb2MkHaVL2vMWhZ7o1noMsFeh7AKWhftNJw1VKFtRvvgG qo0ddkekdOO3h1Y+qbQkYhJrV4RM89tarniJ+LDXi9gsk6w3zg024CONJvvUrXe1jz fMG8COMS2JfWQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 937F768654; Wed, 19 Nov 2025 19:56:42 -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 mgjzzIihuHDz; Wed, 19 Nov 2025 19:56:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607402; bh=a/CSxm6YD+PR7caZJyP+P9NFHucZvLfjnfEl6sp8v1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhgABh/crCg06sywFKgKjc8Ty5eij7AXQHJyq1AnC464LaUzOUQQfS2in40aSOL+K 2aQP7jW4hMzHuHwj1z1eI7xKf5XgEQrDSNrYzR4c9p0oiS0Y/zweXO0f57ulwLzDXn 3Vw9nMmhULL7vlJPro95xYjb8TjxdhiMpEEEMzsQ7h8tnzxIlEQxn7h2VoOqfNx4j4 qEHLjlhOPiYNiYNrbSqXrD+WGYY2lJLUg0tWB9Q8FaIH57enQ+5uVzKkBJLLekjr7R dgUq3AlUvORAjz95qjLyte/RpCLWHDNtGic+NwUWc8IYckDnUq4DKfHy4gJJt6T5nt hGkkb4saocCIQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ACAAD5E7DA; Wed, 19 Nov 2025 19:56:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:41 -0700 Message-ID: <20251120025614.2215587-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: W2QYHDDZL2DES2LXIFU5TXKCPR2NY2F3 X-Message-ID-Hash: W2QYHDDZL2DES2LXIFU5TXKCPR2NY2F3 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/30] test: Add signature-testing to the FIT-printing test 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 Add a signature node to the FIT configuration in the ITS template, using a fixed RSA-2048 private key for reproducible signatures. Use the default 'pkcs-1.5' padding. Use mkimage to sign it. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 4 +++ test/py/tests/test_fit_print.py | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index ef1e86800ee..8aa1de3a6c4 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -80,6 +80,10 @@ static int test_fit_print_norun(struct unit_test_state *uts) ut_assert_nextline(" Kernel: kernel"); ut_assert_nextline(" Init Ramdisk: ramdisk"); ut_assert_nextline(" FDT: fdt"); + ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); + ut_assert_nextline(" Sign padding: pkcs-1.5"); + ut_assert_nextlinen(" Sign value: 9ed5738204714c0ecf46"); + ut_assert_nextline(" Timestamp: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Configuration 1 (conf-2)"); ut_assert_nextline(" Description: Alternate configuration"); ut_assert_nextline(" Kernel: kernel"); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 4960ce503b4..de52bbb61a4 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -63,6 +63,12 @@ PRINT_ITS = ''' kernel = "kernel"; fdt = "fdt"; ramdisk = "ramdisk"; + signature { + algo = "sha256,rsa2048"; + padding = "pkcs-1.5"; + key-name-hint = "test-key"; + sign-images = "fdt", "kernel", "ramdisk"; + }; }; conf-2 { description = "Alternate configuration"; @@ -76,6 +82,7 @@ PRINT_ITS = ''' @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('fit_print') @pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') def test_fit_print(ubman): """Test fit_print_contents() via C unit test""" mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') @@ -114,6 +121,56 @@ def test_fit_print(ubman): its = fit_util.make_its(ubman, PRINT_ITS, params) utils.run_and_log(ubman, [mkimage, '-f', its, fit], env=env) + # Use a fixed RSA key pair for reproducible signatures + tmpdir = ubman.config.result_dir + '/' + + # Fixed 2048-bit RSA private key for testing (for reproducible signatures) + key_pem = '''-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDU18AB+xpQw+GX +mywzH4nsEIECgLVnBTNaAnE4XSIqbiviZetumBP6Ib2W+0OIOn8/hIh3UnzzyWIP +aRus94CVfFQPqwhi6/M9ptL7N7lCXq9DwQ0EY55GquwoO9jZnnDsCSU76jgKg+Nc +dsbvprfFDxBjkrLBfdEgzJtNUaJnUCd58RG8sII7EOP4JTGnXn2wVTsKYcTmr8y6 +bOZTUQfsYj9BGFTbskkLYj1RJ6Dpzk4yBqyUn4fUYhfqsAHwlJs/64Byx2m7J7Ia +rfp49NkqgOFlTvDzKnecxGt4pmgEA+4MtRxUFDliZ/bG3TvG/xNlXvWaHp9DG05u +4h9jy2NPAgMBAAECggEAAMZKOheeWGXmF8WmSwdV2qiSt54dSuMvdSfmHpTkL3BY +M4o4aZ4fEH138ak3bTL9TI9gacLAlqiIdVLmGWKLMsARlD8EmEuQhoxpXyWsRGwQ +yjfVIst0A4DSvDC/kMctVQaRfp7TFmK1fJwoDC44o/xyjFI32VFqZeqotAbUhvi3 +gIYvP5Q4Kvbaq9aZNURqazJHuEVD9LpwbnroUd4cBrcorstJzaDmTIyb5swLX+IX +FjMOVtHtBDKOG9Ce1wlEOXZtSsoZtAEgkd1IQYBCTBUDkxPdx+ZKPdfT4aKWX3S4 +WQ65lDEGAnplMmetFRV+k9NNJvEia9JoX/SJqhUWGQKBgQD1/rffQZnFWqGM2dD1 +CEkXpCN23xAEaZjQtuIhPMBWEWufAPZhyZSbq3eLjcqSS5mzU8B+n1c9Zxw6r0qM +BXlcUftreFPKvEXeyp1YWh7loxHiVVuasp2lEDx4arwUrI61XtAaixUb9Opxxj/x +UDrY5cj7BIRhrkDZtnor/EbRaQKBgQDdf9pymbbxRmHHFGERSzo6/gbr1GRK9fUA +ZNrzfBM5Sdvmm2aKgYd7hIKhOgeKIkS858gEOsRw75x6nvlrjZvFZGIfetXXxaN9 +c6Uqq/f6rTRUTB9/SqvMgKZMuJ2SFms8I1nbxSE/PMD0T6TRbhjaFoZwZP42HVsM +wAN2Oiq/9wKBgQC7sQHyYkdFgYVJxtfcXdoHI8G7bS73buqeNSwMWCIYiWooA7/5 +lKjCre2kmSc6wFwhq4FwG3ug6g9r51tlwrd6bUL8GO81/LkC6G1tgDWa2PVIUAB4 +5FfMHbtF1Ypz68VnNVRrLDuK/S/0Z2NaZ/C+lXTnseaf8Sih9Mz6yp3uIQKBgBc4 +61cuhH6hSWkM2uxsPaunrGQXPXiadthWupnifUV5V+PCkSqeT+0ERInQwq+Zzikc +B91hp+zLQlWcyzuaeiVk0+DHCRp5Lx3c/QkPRI10kVLxNDAtTPvA1S6gAG0rioyg +jDA9Z7Hwla5Hl1kZuONMj0XDYN+djkk07Gf9yzObAoGAbiS3mRID0pLFhWR1L64h +NlRJpZjsHNRPd0WFVxXnJRzZxkStoTwL2BhPtG3Xx1ReIkNVCxlu1Dk0rLLKl1nj +4B/X9Qu6aejXnOsbqp1/JBXYxD8l5B2yg5//wz18um/SOSagpAPeH4i/V3NxOup5 +S0n8gbs0Ht/ZckLk8mPclbk= +-----END PRIVATE KEY-----''' + + with open(tmpdir + 'test-key.key', 'w', encoding='utf-8') as f: + f.write(key_pem) + + utils.run_and_log(ubman, + f'openssl req -batch -new -x509 -key {tmpdir}test-key.key ' + f'-out {tmpdir}test-key.crt') + + # Create a dummy DTB for the public key + dtb = fit_util.make_fname(ubman, 'test-key.dtb') + utils.run_and_log(ubman, ['dtc', '-I', 'dts', '-O', 'dtb', '-o', dtb], + stdin=b'/dts-v1/; / { };') + + # Sign the FIT configuration (use env for reproducible timestamp) + utils.run_and_log(ubman, [mkimage, '-F', '-k', tmpdir, '-K', dtb, + '-r', fit, '-c', 'Configuration signing'], + env=env) + # Run the C test which will load and verify this FIT ubman.run_command('ut -f bootstd test_fit_print_norun') result = ubman.run_command('echo $?') From patchwork Thu Nov 20 02:55:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 735 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=1763607410; bh=Eub/NpHiAUp/74V66bMz+PLY0PGa0E9dQW5kLmbeYM8=; 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=WTYO9madaov5CkU7XNwx1cVyK5ZUkvr9d4thiMJ02E9NEqG1R/Hb02VScdABbijWC 2B0p59u87rNJfvjkU5tHZonhtW7otyM3/u/cFE2hQ9BbBBd6Dn49v0SmE37pphQHnN mrXTOe9CYxV8HZ2INetOf9uaVWafjhRJl8RGSKtZsRusCPlmCjt9dClccwcetVRvl3 NCPEzqK5yvRByJMbRE7Ljn8U9zVK1FdCgKYnMn20dBazb/X4Jey72v2LXVXkUjbF6J XB1CCnjp1P35W9PaUZDgks6Bi6g3EcxU2jharIiz7ybAoXo+/LA3OiPQglerl+FBop VS1mbzc5o4qeA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ADF09686BB for ; Wed, 19 Nov 2025 19:56:50 -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 ZAdGA3WGrdkt for ; Wed, 19 Nov 2025 19:56:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607410; bh=Eub/NpHiAUp/74V66bMz+PLY0PGa0E9dQW5kLmbeYM8=; 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=WTYO9madaov5CkU7XNwx1cVyK5ZUkvr9d4thiMJ02E9NEqG1R/Hb02VScdABbijWC 2B0p59u87rNJfvjkU5tHZonhtW7otyM3/u/cFE2hQ9BbBBd6Dn49v0SmE37pphQHnN mrXTOe9CYxV8HZ2INetOf9uaVWafjhRJl8RGSKtZsRusCPlmCjt9dClccwcetVRvl3 NCPEzqK5yvRByJMbRE7Ljn8U9zVK1FdCgKYnMn20dBazb/X4Jey72v2LXVXkUjbF6J XB1CCnjp1P35W9PaUZDgks6Bi6g3EcxU2jharIiz7ybAoXo+/LA3OiPQglerl+FBop VS1mbzc5o4qeA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9C03A68654 for ; Wed, 19 Nov 2025 19:56:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607408; bh=GBhlKJSPc9rzM5CCaIJAVHYEwu2AHkDr+KlbZTO9JUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRopjnvfiI++en904G9xuOpqTafHs72XbRCJSVY+nw81X9qoiX3roItYEUG1uDHxd PDXlqxWGioXRg7BkQCBArMJtr7RVAJ6X64w3s8Nbn9EXWPynimKLIhqU0esU4yatqQ KZBh2dAloX8KtyeRIuvwVWWO6nrLUiR/xJU8T88bvrYaJktmvX4S/oCHp1ZMhKHFpv /VLq+moTT6AKUBquPiM3bsAFcEY9/MRQPjtOY0RsPrm1ATPe/9WIFBV2n+lcsxqZHI 7yKo66RkDz6Pa0H5jbszjTjfqvhHfGn87wtyRR7ntWDrOB2a8S3KTmm17H3pZgsRdz iFzz+akrBpiRg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D74A68631; Wed, 19 Nov 2025 19:56:48 -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 4qBWpaw211eh; Wed, 19 Nov 2025 19:56:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607403; bh=RDePBcXFY7sX0i0kjHceoXmmdek21QVbvpW9X1RYmQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNlZRt+Q8tdhr5E6bo5fsWAjh7W67ofObdcOia72+lYg5rJoRDq6b24J0+gqDZUU0 omfIuAErL22oqxmRULB7b7h9vIkBYe81dpZ5eQNjWaw3Vnsa2XY4XkZELjoJcGHh6t Bw8SPKdgQuBAv6vsgJIA/2sqJ8dfZTIolbODCGD6wCAdvbwHV+hnBA+7qGM5nB2/KV mvpOgPrYhs8oMCGSXepxpo1rhocokMEU0ddUIZ/bbHTj2PBss8yXCAJMuHG8iwwlsJ 9wSK7LDzNwR1mDq5ovnn1ixpZzGVsNaZbFN34fG7gVFHWCbcwmprDxVS5aRmQAd89X Fj65n1YqEP0qg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D787F5E7DA; Wed, 19 Nov 2025 19:56:42 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:42 -0700 Message-ID: <20251120025614.2215587-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RCP4C7FGN75WNON6Y45QQW5HXM7SD64L X-Message-ID-Hash: RCP4C7FGN75WNON6Y45QQW5HXM7SD64L 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/30] test: fit: Test printing a FIT with multiple FDTs 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 Update the FDT fdt to include two separate FDT images, referenced by the two configurations. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 27 ++++++++++++++++------- test/py/tests/test_fit_print.py | 39 ++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 8aa1de3a6c4..69ab2ecf081 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -64,30 +64,41 @@ static int test_fit_print_norun(struct unit_test_state *uts) ut_assert_nextline(" Entry Point: unavailable"); ut_assert_nextline(" Hash algo: sha256"); ut_assert_nextline(" Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655"); - ut_assert_nextline(" Image 2 (fdt)"); - ut_assert_nextline(" Description: Test FDT"); + ut_assert_nextline(" Image 2 (fdt-1)"); + ut_assert_nextline(" Description: Test FDT 1"); ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Type: Flat Device Tree"); ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x00010514"); - ut_assert_nextline(" Data Size: 157 Bytes = 157 Bytes"); + ut_assert_nextline(" Data Start: 0x00010518"); + ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); ut_assert_nextline(" Architecture: Sandbox"); ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 51918524b06745cae06331047c7e566909431bf71338e5f703dffba1823274f4"); + ut_assert_nextline(" Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb"); + ut_assert_nextline(" Image 3 (fdt-2)"); + ut_assert_nextline(" Description: Test FDT 2"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Flat Device Tree"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x0001067c"); + ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4"); ut_assert_nextline(" Default Configuration: 'conf-1'"); ut_assert_nextline(" Configuration 0 (conf-1)"); ut_assert_nextline(" Description: Test configuration"); ut_assert_nextline(" Kernel: kernel"); ut_assert_nextline(" Init Ramdisk: ramdisk"); - ut_assert_nextline(" FDT: fdt"); + ut_assert_nextline(" FDT: fdt-1"); ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); ut_assert_nextline(" Sign padding: pkcs-1.5"); - ut_assert_nextlinen(" Sign value: 9ed5738204714c0ecf46"); + ut_assert_nextlinen(" Sign value: 6b1cc88f8b3b7f2f148d"); ut_assert_nextline(" Timestamp: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Configuration 1 (conf-2)"); ut_assert_nextline(" Description: Alternate configuration"); ut_assert_nextline(" Kernel: kernel"); - ut_assert_nextline(" FDT: fdt"); + ut_assert_nextline(" FDT: fdt-1"); + ut_assert_nextline(" fdt-2"); ut_assert_console_end(); os_free(buf); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index de52bbb61a4..5127fc6f8f0 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -45,9 +45,19 @@ PRINT_ITS = ''' algo = "sha256"; }; }; - fdt { - description = "Test FDT"; - data = /incbin/("%(fdt)s"); + fdt-1 { + description = "Test FDT 1"; + data = /incbin/("%(fdt1)s"); + type = "flat_dt"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + fdt-2 { + description = "Test FDT 2"; + data = /incbin/("%(fdt2)s"); type = "flat_dt"; arch = "sandbox"; compression = "none"; @@ -61,19 +71,19 @@ PRINT_ITS = ''' conf-1 { description = "Test configuration"; kernel = "kernel"; - fdt = "fdt"; + fdt = "fdt-1"; ramdisk = "ramdisk"; signature { algo = "sha256,rsa2048"; padding = "pkcs-1.5"; key-name-hint = "test-key"; - sign-images = "fdt", "kernel", "ramdisk"; + sign-images = "fdt-1", "kernel", "ramdisk"; }; }; conf-2 { description = "Alternate configuration"; kernel = "kernel"; - fdt = "fdt"; + fdt = "fdt-1", "fdt-2"; }; }; }; @@ -95,14 +105,22 @@ def test_fit_print(ubman): kernel_gz = kernel + '.gz' utils.run_and_log(ubman, ['gzip', '-f', '-n', '-k', kernel]) - fdt = fit_util.make_dtb(ubman, ''' + fdt1 = fit_util.make_dtb(ubman, ''' +/dts-v1/; +/ { + #address-cells = <1>; + #size-cells = <0>; + model = "Test FDT 1"; +}; +''', 'test-fdt-1') + fdt2 = fit_util.make_dtb(ubman, ''' /dts-v1/; / { #address-cells = <1>; #size-cells = <0>; - model = "Test"; + model = "Test FDT 2"; }; -''', 'test-fdt') +''', 'test-fdt-2') ramdisk = fit_util.make_kernel(ubman, 'test-ramdisk.bin', 'ramdisk') # Compress the ramdisk (with -n to avoid timestamps for reproducibility) @@ -112,7 +130,8 @@ def test_fit_print(ubman): # Create FIT image with fixed timestamp for reproducible output params = { 'kernel': kernel_gz, - 'fdt': fdt, + 'fdt1': fdt1, + 'fdt2': fdt2, 'ramdisk': ramdisk_gz, } env = os.environ.copy() From patchwork Thu Nov 20 02:55:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 736 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=1763607412; bh=hQw2z5uKIvVcnaJsMIkrvrQQL9lHype5T1jLHmjj0uo=; 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=FqnVZ21uF7Tazh/u7m+kAFRfFIy+gQHNxziRrr6bGPnP0wUQ6fmYZQxTyB+alxf54 jsgsTXl7QFzvlRxoj2dgbQt3gFzc0GG1vrtHvLbrw3QrHrdxdyYVP82/RugdLdnIxH dthN/sZlNrVF4NAZZ4mNgTbVJCePBkSCLq33lgSlmi+UrOt0jCHFZK/2T8QOuMwve2 xP+o5OiyKQd22yC6yv/bG118gJpMw4CeeXD4ze9U1o6in/fV/LcoAfD5rGWwmfM4tQ ocEkO5cTe/5plEo0obDfLa2xMthJzM0hEJLykzoDV2eAoOHjAshHwMZQHGnU/bapML wrl8jrL+GUQIg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B93968654 for ; Wed, 19 Nov 2025 19:56:52 -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 Op6ihxtcIzGR for ; Wed, 19 Nov 2025 19:56:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607411; bh=hQw2z5uKIvVcnaJsMIkrvrQQL9lHype5T1jLHmjj0uo=; 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=YsgPF9mrHLcEvzy++TP3JxtuR/XQx+4E2IGBftUAAAQ4SzSs/v7IEnKefM2iyvpK7 wMUzJm+bVdRdVw3z2LZMEuEijEFPPEsr9SwsFstoaZwOTbhWAlQyePbBPO4eXCh/Ve hO/wtnjbCLB5an2DG0BZZTrfPCG278xM4azbHS/uukfBjihppRaMjmz7vrzwjflJf6 lZqO+jjvz9S/kWwEz0s8B02UyJDLV5PSRhJQYnsp2p/m3EhTwCtByK8mBeWGYH19tF 2ptzhA4fUSLfWhrJ0iasAT/PxlEMD/oN17QHgbWeqqp0aQ7QvlRSTdklB60Wk9YAT2 mblPL/BjiCx8w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8456968631 for ; Wed, 19 Nov 2025 19:56:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607408; bh=dzkOXE6cZhMxqlS9xyLvgQh+teBLGmEMLER5BEn/fdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRQFW5cS1nWqElHMKbbsobgjx1Ah6b79YKeX9K32admwCRAfIx4Vq2FzhMPfuR1kI 1SrbI2Cl0G5U7/57X8tAhL9Y2B/5wPhvhxQMu0oemYOXhTrls5szjtZieujSWyQ2fO 0s4ycJe6eltnpiW4HrPzvafL3+6cKYmkAlcqF8YVP5FyHvR3iVcxAg6jsrnDNjAw7k fDCktxdf7yRFuy7YCnlloZ1rqF/QGyuCGx+msVNEcUtlId54lBXyyONVC30Y4BwqHp Si0GCJUZnp0n0tQWnd2fRlJQm4t6SVNvHAUtNLKeS97TR4mMbWHqX7fQcD9qsZtDkj ZdMi6jpDLOHaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2FA68654; Wed, 19 Nov 2025 19:56:48 -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 3koqBm0JVoes; Wed, 19 Nov 2025 19:56:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607404; bh=Dh/2PVg0ZNG8dCRWWBA/VPHYqS3RJ6MXzD78qt926fU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtsJ4O3AAmFVAHDBJyHMlkEq0wfmO02LOT0331z7gEI8VXqQ2ebHc7FTbktJDhzHw mSfq/grwif/JJVIdDhFpZ9tDcUJnkEct4/vo+hsKvWHULiAL3zc+y7S17hyeUBld22 GzbpdFLRxaoMPLsf7Py/aG56tDdy98CtHMNJctYKbCtR7XIN4Onkc3KzzUkGvONPrt QRdnBaBF1K/hL7kEzrAjW2iw7JSWeQl0BTMGlBIgxmNQcXhgjs+bwLv/KVoG/puwbB RiR4xVaZyW5ezqXrjyk1BLZmHDqitWXmgPRoNXdpgLn3m4+P3Wj7b3qqWy4iRE1gA2 TADq5Ag2sUN9g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E71C0686E3; Wed, 19 Nov 2025 19:56:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:43 -0700 Message-ID: <20251120025614.2215587-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 36DFQROEC26BR64WBW4YXALBG6FM2KON X-Message-ID-Hash: 36DFQROEC26BR64WBW4YXALBG6FM2KON 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/30] test: fit: Test the remaining features and edge cases 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 Add support for testing the loadables, fpga, compatible properties and unavailable/error conditions in FIT configurations. With this, most of the FIT-printing code is covered by tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 54 ++++++++++++++++++++++++++++++- test/py/tests/test_fit_print.py | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 69ab2ecf081..856cbfc6613 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -84,21 +84,73 @@ static int test_fit_print_norun(struct unit_test_state *uts) ut_assert_nextline(" Architecture: Sandbox"); ut_assert_nextline(" Hash algo: sha256"); ut_assert_nextline(" Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4"); + ut_assert_nextline(" Image 4 (firmware-1)"); + ut_assert_nextline(" Description: Test Firmware 1"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000107e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414"); + ut_assert_nextline(" Image 5 (firmware-2)"); + ut_assert_nextline(" Description: Test Firmware 2"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000117e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1"); + ut_assert_nextline(" Image 6 (fpga)"); + ut_assert_nextline(" Description: Test FPGA"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: FPGA Image"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000127e0"); + ut_assert_nextline(" Data Size: 4291 Bytes = 4.2 KiB"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622"); + ut_assert_nextline(" Image 7 (script)"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Script"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x0001394c"); + ut_assert_nextline(" Data Size: 3791 Bytes = 3.7 KiB"); + ut_assert_nextline(" Hash algo: invalid/unsupported"); ut_assert_nextline(" Default Configuration: 'conf-1'"); ut_assert_nextline(" Configuration 0 (conf-1)"); ut_assert_nextline(" Description: Test configuration"); ut_assert_nextline(" Kernel: kernel"); ut_assert_nextline(" Init Ramdisk: ramdisk"); ut_assert_nextline(" FDT: fdt-1"); + ut_assert_nextline(" Compatible: vendor,board-1.0"); + ut_assert_nextline(" vendor,board"); ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); ut_assert_nextline(" Sign padding: pkcs-1.5"); - ut_assert_nextlinen(" Sign value: 6b1cc88f8b3b7f2f148d"); + ut_assert_nextlinen(" Sign value: c20f64d9bf79ddb0b1a6"); ut_assert_nextline(" Timestamp: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Configuration 1 (conf-2)"); ut_assert_nextline(" Description: Alternate configuration"); ut_assert_nextline(" Kernel: kernel"); ut_assert_nextline(" FDT: fdt-1"); ut_assert_nextline(" fdt-2"); + ut_assert_nextline(" FPGA: fpga"); + ut_assert_nextline(" Loadables: firmware-1"); + ut_assert_nextline(" firmware-2"); + ut_assert_nextline(" Compatible: vendor,board-2.0"); + ut_assert_nextline(" Configuration 2 (conf-3)"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Kernel: unavailable"); + ut_assert_nextline(" Loadables: script"); ut_assert_console_end(); os_free(buf); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 5127fc6f8f0..25fada7d468 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -65,6 +65,44 @@ PRINT_ITS = ''' algo = "sha256"; }; }; + firmware-1 { + description = "Test Firmware 1"; + data = /incbin/("%(firmware1)s"); + type = "firmware"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + firmware-2 { + description = "Test Firmware 2"; + data = /incbin/("%(firmware2)s"); + type = "firmware"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + fpga { + description = "Test FPGA"; + data = /incbin/("%(fpga)s"); + type = "fpga"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + script { + data = /incbin/("%(script)s"); + type = "script"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; }; configurations { default = "conf-1"; @@ -73,6 +111,7 @@ PRINT_ITS = ''' kernel = "kernel"; fdt = "fdt-1"; ramdisk = "ramdisk"; + compatible = "vendor,board-1.0", "vendor,board"; signature { algo = "sha256,rsa2048"; padding = "pkcs-1.5"; @@ -84,6 +123,12 @@ PRINT_ITS = ''' description = "Alternate configuration"; kernel = "kernel"; fdt = "fdt-1", "fdt-2"; + fpga = "fpga"; + loadables = "firmware-1", "firmware-2"; + compatible = "vendor,board-2.0"; + }; + conf-3 { + loadables = "script"; }; }; }; @@ -121,7 +166,11 @@ def test_fit_print(ubman): model = "Test FDT 2"; }; ''', 'test-fdt-2') + firmware1 = fit_util.make_kernel(ubman, 'test-firmware-1.bin', 'firmware 1') + firmware2 = fit_util.make_kernel(ubman, 'test-firmware-2.bin', 'firmware 2') + fpga = fit_util.make_kernel(ubman, 'test-fpga.bin', 'fpga bitstream') ramdisk = fit_util.make_kernel(ubman, 'test-ramdisk.bin', 'ramdisk') + script = fit_util.make_kernel(ubman, 'test-script.bin', 'echo test') # Compress the ramdisk (with -n to avoid timestamps for reproducibility) ramdisk_gz = ramdisk + '.gz' @@ -132,7 +181,11 @@ def test_fit_print(ubman): 'kernel': kernel_gz, 'fdt1': fdt1, 'fdt2': fdt2, + 'firmware1': firmware1, + 'firmware2': firmware2, + 'fpga': fpga, 'ramdisk': ramdisk_gz, + 'script': script, } env = os.environ.copy() env['SOURCE_DATE_EPOCH'] = '1234567890' # 2009-02-13 23:31:30 UTC @@ -190,6 +243,10 @@ S0n8gbs0Ht/ZckLk8mPclbk= '-r', fit, '-c', 'Configuration signing'], env=env) + # Delete the algo property from the hash-1 node to test invalid/unsupported + utils.run_and_log(ubman, ['fdtput', '-d', fit, '/images/script/hash-1', + 'algo']) + # Run the C test which will load and verify this FIT ubman.run_command('ut -f bootstd test_fit_print_norun') result = ubman.run_command('echo $?') From patchwork Thu Nov 20 02:55:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 737 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=1763607412; bh=o1OnQ8rYZbzIsUogn+8z6xdQjtfpa6twBtrAYsO5DFs=; 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=g8S4kpiSeYOnPAkBfHW0GnX2BnBgQj5E/6S0tNNsK2gARG0MztNVWt+fh5CTS/CNd kBq1jshqm6ywf8SLIE8Uc7Ebl3EzpHlgyTkgfM4hlmjqrcf6QmvIhbFnEaNp+qtz44 aINSWCyz9V/iM3vczvi5Y5Ri429and2CcjNHQo5RuVPa1qeSWw/4c8DRCrRZLUxLKE 7nJ6rATgwhJXwmJNI5ZkEAI1+NYonXk1AlFeWLQ3BXHAqn3x0VgC2Xmsrvo8JZYywm bKJ5nNox6puEgVXgYpILNW9vAKU5wKJelYRuM/1fIs7FQ5Zzk/lTnXlTh99ci/coGx 06oQcLd+fvzKQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7B86D686DF for ; Wed, 19 Nov 2025 19:56:52 -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 gx0gEQq6mN2P for ; Wed, 19 Nov 2025 19:56:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607412; bh=o1OnQ8rYZbzIsUogn+8z6xdQjtfpa6twBtrAYsO5DFs=; 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=g8S4kpiSeYOnPAkBfHW0GnX2BnBgQj5E/6S0tNNsK2gARG0MztNVWt+fh5CTS/CNd kBq1jshqm6ywf8SLIE8Uc7Ebl3EzpHlgyTkgfM4hlmjqrcf6QmvIhbFnEaNp+qtz44 aINSWCyz9V/iM3vczvi5Y5Ri429and2CcjNHQo5RuVPa1qeSWw/4c8DRCrRZLUxLKE 7nJ6rATgwhJXwmJNI5ZkEAI1+NYonXk1AlFeWLQ3BXHAqn3x0VgC2Xmsrvo8JZYywm bKJ5nNox6puEgVXgYpILNW9vAKU5wKJelYRuM/1fIs7FQ5Zzk/lTnXlTh99ci/coGx 06oQcLd+fvzKQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C5F568668 for ; Wed, 19 Nov 2025 19:56:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607409; bh=gFXrV3iz/vPfPa4JyFtXm/UoVHk7oIgZiFSXrqBSDEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwLjhSmsC55LP9UtII8e9Gpk7WclrfkYbS2BOKTdRakdwKsL5QT6xSwONZuuTZUMP 39JQusShZWbtG379grs8siH7rsGejdlv8MXq+8wB0P1h9MncNHtFRHF+z/nGpOXVeL FcBEB6KB1wfnPbD41aBfpoGnX9zv9kvG30nDiqBI7GScWSpuN+gbj0YbTfsGP3ee4k ZYRnu7aXjZaMyAk0ZtoEgcWkzLy2DlD80Dnx9LUWlfTHoLuYFCSDWEeoeavlcsukvv toWYbhGKLtTacS8kmFjMGIKMmWoDjFZa+r+FT8bJOPFTJSvaoipMwMtIiTwDzEMKVf rpi78NPBiKBPg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 35AE05E7DA; Wed, 19 Nov 2025 19:56:49 -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 XIW2u9DSs9n2; Wed, 19 Nov 2025 19:56:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607405; bh=Wx+rczd1+iTToggcXFxl9f7mDrGUEkb947IvmXkCAHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgImhq6hePR/RW8pa5VdcJdgyQE9E31V4k9Vw9QZEdQlGObdt+O2EzmD7y0Yxz75r PLfoZkH5SgU/AyJgJ9wgPinWh6HeHjpBhRfKx/SoUN1CLoaK7ELKxDoHlj1Bk7COn4 CrMr8v2vo43OLdslR+gT6Gst3U2eZa9/+qrrQ4WL38RV7aU/xObbQGduPW9P9ivYS+ snY9nVgoiZtzbezjEBDpPlBHHM4YbYJEiVLMgHnI6QxsYTpq72M93b5eoFUoPMnuti vifosEyerboh1zL3XaR+uF2yNVzQyj7oVXDmH1AJb+wvttahOKbkYe2e4WKIb8acEF ZV5xLdFlCgBpg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EB6A1686EC; Wed, 19 Nov 2025 19:56:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:44 -0700 Message-ID: <20251120025614.2215587-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NZJREG272RGUV3YGIWJ37GO5ALDDFMDZ X-Message-ID-Hash: NZJREG272RGUV3YGIWJ37GO5ALDDFMDZ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/30] test: fit: Add test for missing FIT description 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 Add a test to verify that fit_print_contents() correctly handles a FIT image with a missing description property. To handle this a new FIT created with the description removed after mkimage has processed it, since mkimage will fail if the description is missing. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 32 ++++++++++++++++++++++++ test/py/tests/test_fit_print.py | 43 +++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 856cbfc6613..8e8d81e7f6b 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -158,3 +158,35 @@ static int test_fit_print_norun(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(test_fit_print_norun, UTF_CONSOLE | UTF_MANUAL); + +/* Test fit_print_contents() with missing FIT description */ +static int test_fit_print_no_desc_norun(struct unit_test_state *uts) +{ + char fname[256]; + void *fit; + void *buf; + ulong addr; + int size; + + /* Load the FIT created by the Python test (with deleted description) */ + ut_assertok(os_persistent_file(fname, sizeof(fname), + "test-fit-nodesc.fit")); + ut_assertok(os_read_file(fname, &buf, &size)); + + /* Copy to address 0x10000 and print from there */ + addr = 0x10000; + fit = map_sysmem(addr, size); + memcpy(fit, buf, size); + + /* Print it and check just the first line */ + console_record_reset_enable(); + fit_print_contents(fit); + + /* Check the first line shows unavailable */ + ut_assert_nextline(" FIT description: unavailable"); + + os_free(buf); + + return 0; +} +BOOTSTD_TEST(test_fit_print_no_desc_norun, UTF_CONSOLE | UTF_MANUAL); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 25fada7d468..0ab8c0d4769 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -134,12 +134,14 @@ PRINT_ITS = ''' }; ''' -@pytest.mark.boardspec('sandbox') -@pytest.mark.buildconfigspec('fit_print') -@pytest.mark.requiredtool('dtc') -@pytest.mark.requiredtool('openssl') -def test_fit_print(ubman): - """Test fit_print_contents() via C unit test""" +def build_test_fit(ubman, fit): + """Build a test FIT image with all components + + Args: + ubman (ConsoleBase): U-Boot manager object + fit (str): Path where the FIT file should be created + """ + # pylint: disable=too-many-locals mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') # Create test files (make kernel ~6.3K) @@ -189,7 +191,6 @@ def test_fit_print(ubman): } env = os.environ.copy() env['SOURCE_DATE_EPOCH'] = '1234567890' # 2009-02-13 23:31:30 UTC - fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit.fit') its = fit_util.make_its(ubman, PRINT_ITS, params) utils.run_and_log(ubman, [mkimage, '-f', its, fit], env=env) @@ -247,7 +248,35 @@ S0n8gbs0Ht/ZckLk8mPclbk= utils.run_and_log(ubman, ['fdtput', '-d', fit, '/images/script/hash-1', 'algo']) + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print(ubman): + """Test fit_print_contents() via C unit test""" + fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit.fit') + build_test_fit(ubman, fit) + # Run the C test which will load and verify this FIT ubman.run_command('ut -f bootstd test_fit_print_norun') result = ubman.run_command('echo $?') assert '0' == result + + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print_no_desc(ubman): + """Test fit_print_contents() with missing FIT description""" + fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit-nodesc.fit') + build_test_fit(ubman, fit) + + # Delete the description property + utils.run_and_log(ubman, ['fdtput', '-d', fit, '/', 'description']) + + # Run the C test to check the missing description + ubman.run_command('ut -f bootstd test_fit_print_no_desc_norun') + result = ubman.run_command('echo $?') + assert '0' == result From patchwork Thu Nov 20 02:55:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 738 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=1763607416; bh=50oLvQH5NhIT35zs7l0UQpSM19RRs+ojN9fsQmwz78g=; 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=IoA2iYtepaDCnFsVfQL75f1flydK1Cf1BTSf8N4hwuP3KcaSAYAmDmFIFxOJaxS/l Ux21zVU0AdYdZXaF8onLJK0yFSyBbJ3qi3MplCYJxSy0mmEFLnjRnbG1At8NK4DbiM P4IobOwdnRbdg95CftPuG2jTdPQ3tTl4hq34xOvv+hdMhqGWeAXGMZujjoYsdtmIfK RILh6eyAJOUAjuB+mH2hi7WUB9059mn2/rdybR/eHhIVMxG5KyrfBoITQkD2tlDKZL jWP/GqBg+NlesLJwPmLI67lWwB59WAgMKEd1F9OsFkl0mYGXZsHwyxRyYiSzqHSyeF cUDgLOXtfKhUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E932268631 for ; Wed, 19 Nov 2025 19:56:56 -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 p_83h_Ew2W0l for ; Wed, 19 Nov 2025 19:56:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607416; bh=50oLvQH5NhIT35zs7l0UQpSM19RRs+ojN9fsQmwz78g=; 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=IoA2iYtepaDCnFsVfQL75f1flydK1Cf1BTSf8N4hwuP3KcaSAYAmDmFIFxOJaxS/l Ux21zVU0AdYdZXaF8onLJK0yFSyBbJ3qi3MplCYJxSy0mmEFLnjRnbG1At8NK4DbiM P4IobOwdnRbdg95CftPuG2jTdPQ3tTl4hq34xOvv+hdMhqGWeAXGMZujjoYsdtmIfK RILh6eyAJOUAjuB+mH2hi7WUB9059mn2/rdybR/eHhIVMxG5KyrfBoITQkD2tlDKZL jWP/GqBg+NlesLJwPmLI67lWwB59WAgMKEd1F9OsFkl0mYGXZsHwyxRyYiSzqHSyeF cUDgLOXtfKhUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D664D68662 for ; Wed, 19 Nov 2025 19:56:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607414; bh=zoyK20CpY1f9+vP92YIim36oiArxif/d5V+Hs89Cw6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmfL2FPpKVDsP4CyI2/U12QSbQW6VjKU8aSrzzn05TwtSfE952VC+tdywGb9poimx 4/nPmsWCnys1W5XYMDjnrlzQh7YuZOSBg5sqOsnnCeq1TeiNvgRjZAA309fnv7vU6g nva3bICuolUiNQzw30ukt3521Z+8uY0T8ERhlBY8RXIrnWEKPkxWD8fvcthUBXIk5l eX0/JeXH4Ggl2OXzUEsA1rafm3IWEZ0Z7oqahHej/0Ev8DTrZvUZrV0dvXglwb0lDL 7PhnNHEn7F4M4j84zbQ9RRI/ONAGJxhb8cDuoWIx4yiKUJhpCJtRPuqM4sGziYPnIq WPBVikYbqI2UQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DBD9968631; Wed, 19 Nov 2025 19:56:54 -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 7Pi3eT8WLZ39; Wed, 19 Nov 2025 19:56:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607409; bh=DJTgUufkbd07bCzNZe+6UgJScwaT2V32G6YfbmVVzHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spXtcAWY6EBC5ayvc6BoOtr9jmRCLmXymRUG3jCSgixrq6tfFb6yHATi1KoRTg7eV f99P86IuRDZypfCNwzLWETO+PXyg7AlqHLbSIr8La51j8r7MRyMNbfNUw7+4sXeSad 3bic0rZ05ymdlaXocwFgrljkScCbcpA3+hkeXk8zObaabvrFp0KqesBtd7IOBlys4Z 3IvFqP6StEAyfhr+vEuZGpUkNcQW1XvuFtgX9+shCkMFsC2eeJAE+srcw0Ux+kEXus GOQs+iCcd+lzBLobvkQajEh7U0dZX/SdHwc/QsLudJeRh1pVfZcDMfALlLaKQWv/kc U8UD1krA3xV8A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7AD7468662; Wed, 19 Nov 2025 19:56:49 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:45 -0700 Message-ID: <20251120025614.2215587-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4AHIIQGUAAUZQ2YXC2BU5NULQ7YP47AI X-Message-ID-Hash: 4AHIIQGUAAUZQ2YXC2BU5NULQ7YP47AI 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/30] test: fit: Add pytest for mkimage output 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 Add a new pytest to check the output of 'mkimage -l' on the test FIT. Only check the first 80 chars as the signature lines can be very long. The timestamps are quite annoying, since we need the test to pass on whatever CI machine is used. Obtain the first timestamp and use that to check the rest, after some sanity checks. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/py/tests/test_fit_print.py | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 0ab8c0d4769..180467fba72 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -5,6 +5,8 @@ """Test for FIT image printing""" import os +import re +import time import pytest @@ -280,3 +282,150 @@ def test_fit_print_no_desc(ubman): ubman.run_command('ut -f bootstd test_fit_print_no_desc_norun') result = ubman.run_command('echo $?') assert '0' == result + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print_mkimage(ubman): + """Test 'mkimage -l' output on FIT image""" + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + fit = fit_util.make_fname(ubman, 'test-fit-mkimage.fit') + build_test_fit(ubman, fit) + + # Run mkimage -l and capture output + output = utils.run_and_log(ubman, [mkimage, '-l', fit]) + + # Extract the actual timestamp from mkimage output to avoid timezone issues + # mkimage uses localtime() which can vary based on system timezone + match = re.search(r'Created:\s+(.+)', output) + if not match: + raise ValueError("Could not find Created: line in mkimage output") + timestamp_str = match.group(1).strip() + + expected_timestamp = 1234567890 + # Validate timestamp is reasonable (SOURCE_DATE_EPOCH) + parsed_time = time.strptime(timestamp_str, '%a %b %d %H:%M:%S %Y') + parsed_timestamp = time.mktime(parsed_time) + time_diff = abs(parsed_timestamp - expected_timestamp) + + # Check it is within 24 hours (86400 seconds) + assert time_diff < 86400, \ + f"Timestamp {timestamp_str} is more than 24 hours from expected" + + # Expected output (complete output from mkimage -l) + expected = f''' +FIT description: Test FIT image for printing +Created: {timestamp_str} + Image 0 (kernel) + Description: Test kernel + Created: {timestamp_str} + Type: Kernel Image + Compression: gzip compressed + Data Size: 327 Bytes = 0.32 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x01000000 + Entry Point: 0x01000000 + Hash algo: sha256 + Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee + Image 1 (ramdisk) + Description: Test ramdisk + Created: {timestamp_str} + Type: RAMDisk Image + Compression: uncompressed + Data Size: 301 Bytes = 0.29 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x02000000 + Entry Point: unavailable + Hash algo: sha256 + Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655 + Image 2 (fdt-1) + Description: Test FDT 1 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb + Image 3 (fdt-2) + Description: Test FDT 2 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4 + Image 4 (firmware-1) + Description: Test Firmware 1 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414 + Image 5 (firmware-2) + Description: Test Firmware 2 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1 + Image 6 (fpga) + Description: Test FPGA + Created: {timestamp_str} + Type: FPGA Image + Compression: uncompressed + Data Size: 4291 Bytes = 4.19 KiB = 0.00 MiB + Load Address: unavailable + Hash algo: sha256 + Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622 + Image 7 (script) + Description: unavailable + Created: {timestamp_str} + Type: Script + Compression: uncompressed + Data Size: 3791 Bytes = 3.70 KiB = 0.00 MiB + Hash algo: invalid/unsupported + Default Configuration: 'conf-1' + Configuration 0 (conf-1) + Description: Test configuration + Kernel: kernel + Init Ramdisk: ramdisk + FDT: fdt-1 + Compatible: vendor,board-1.0 + vendor,board + Sign algo: sha256,rsa2048:test-key + Sign padding: pkcs-1.5 + Sign value: c20f64d9bf79ddb0b1a69293b2375ad88e70536684705a9577f2156e6da4df6d + Timestamp: {timestamp_str} + Configuration 1 (conf-2) + Description: Alternate configuration + Kernel: kernel + FDT: fdt-1 + fdt-2 + FPGA: fpga + Loadables: firmware-1 + firmware-2 + Compatible: vendor,board-2.0 + Configuration 2 (conf-3) + Description: unavailable + Kernel: unavailable + Loadables: script +'''.strip().split('\n') + + lines = output.split('\n') + for seq, (expected, line) in enumerate(zip(expected, lines)): + exp = expected[:80] + act = line[:80] + assert exp == act, f"line {seq + 1}: expect '{exp}' got '{act}'" From patchwork Thu Nov 20 02:55:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 739 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=1763607420; bh=blSPgfo1kq4EMj8Fpbx9dQvd0EK1fC3MQFzMWHs276U=; 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=G0jDywZoewPnUPHpe7ZcGvOqMFBz6tU7U03JBjP9GKQSjK3oaJi+9B1SRtlMnTakk pppIlotdnrn7TOErd7LoWE7tI8PKe64DeV7pyqfEEqNzeNHBCeb9/+RSa/YGZn142W ggvMzCRHPsaTSh3nfsdgQdRnn6p9dzKVgBDjYVQ4KTMUFNFDgGqJ1hoAftBYLNL5EX QpdxdRa5JwHN76k13/UWmKb82EycVfk8O+iJWGKQ/53XP8Zwe4nZgW1EnzvmMajxoQ fnYmtXlUDtgRqWr3fDB3gX7AqoBELSzxu7AtoRRCy7mdT2ZKH6aGTaJkkni/ZvmfEo r4DsLq5oDzOMA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AD6C8686C8 for ; Wed, 19 Nov 2025 19:57:00 -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 wCC9EZtTl0NN for ; Wed, 19 Nov 2025 19:57:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607420; bh=blSPgfo1kq4EMj8Fpbx9dQvd0EK1fC3MQFzMWHs276U=; 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=G0jDywZoewPnUPHpe7ZcGvOqMFBz6tU7U03JBjP9GKQSjK3oaJi+9B1SRtlMnTakk pppIlotdnrn7TOErd7LoWE7tI8PKe64DeV7pyqfEEqNzeNHBCeb9/+RSa/YGZn142W ggvMzCRHPsaTSh3nfsdgQdRnn6p9dzKVgBDjYVQ4KTMUFNFDgGqJ1hoAftBYLNL5EX QpdxdRa5JwHN76k13/UWmKb82EycVfk8O+iJWGKQ/53XP8Zwe4nZgW1EnzvmMajxoQ fnYmtXlUDtgRqWr3fDB3gX7AqoBELSzxu7AtoRRCy7mdT2ZKH6aGTaJkkni/ZvmfEo r4DsLq5oDzOMA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A3B768668 for ; Wed, 19 Nov 2025 19:57:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607418; bh=GOWNx/sJa8UqXtA/3wR6P5grI5SxAp7wedGWpK0hhMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQX54Y8K2T4jbq2ZesaKZ/7PkixJ5bZBKXrSTcVVENOs3Gl/RBk6VfE5TCflA7E/i zSXri1PjisAw0feepgPxmdxVISdV4Ss+ITge0SJnVCt2Wdv2XsE1HrbLczUhpOmt1r K5QIVV61Mer8eyGSwrGr0Y5t+3dfPnM5JhVmu/VHtGYFz+hDYp33GpXAQ0MvMjWkCl fqDWa/FGXYAuoxIinybNMo6FBDWEoJwvrmOy3t9W3CpENFerVkcoaHOtklLunsfOij IqI8W118Qecwlx0FlbwbHd0c4zM/vQSqDC7p2ShQPBMh6BwkJfwf011lFMKFTFS7bl 7tmdGr0TGOBPQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9209C68631; Wed, 19 Nov 2025 19:56:58 -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 DOBqHM_9WyxJ; Wed, 19 Nov 2025 19:56:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607414; bh=YeyZO2c2/J9Kq7SDLAv+DWrRuhDEfTpiY0Yod8p/WdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uVQhu7nFxkrnEXGWTSb0VICVoGo4vAHJClBJrpv9vL6Fy8Zbpk3gTnZOOXnydG/3r yGXChD5A1KG+nl8jC40OCtxP38wuzYZ2Mqun6n5U6Cl4wIDmihfZWbIRZlaEmwp5wm e4p2uwB6jfsQ8hSVv5g6W8EreJ69Q1zZJjhl8wmIA+sPpQskQLKUwG5zT1wZBQ7e8t qn1AQ5gnIVPRm81FIbGCUo8Mh5L74fc44pDej+q5RZ11eekS65T4+JTIqwOUQEKlvR xvD6cfDTo46HAnQnddmpl3DuSEEOLt0GcxdlWapAwLwG8pXTbE/WqP4zZ/LLQIjppO SzoJXwX3Noq5w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3951C68614; Wed, 19 Nov 2025 19:56:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:46 -0700 Message-ID: <20251120025614.2215587-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GGZGQXFTEEAFXLO33I6RRA7B7UKZQIKD X-Message-ID-Hash: GGZGQXFTEEAFXLO33I6RRA7B7UKZQIKD 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/30] fit: Refactor fit_print_contents() to use new fit_print() 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 Create a new fit_print() function containing the logic from fit_print_contents(), and make fit_print_contents() call it. This allows future callers to use fit_print() directly as we add more features. Tidy up the function comments so that they are in the header. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/image-fit.c | 34 ++++++---------------------------- include/image.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/boot/image-fit.c b/boot/image-fit.c index eb47c00cc01..9103016bd08 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -368,19 +368,7 @@ static void fit_conf_print(const void *fit, int noffset, const char *p) } } -/** - * fit_print_contents - prints out the contents of the FIT format image - * @fit: pointer to the FIT format image header - * @p: pointer to prefix string - * - * fit_print_contents() formats a multi line FIT image contents description. - * The routine prints out FIT image properties (root node level) followed by - * the details of each component image. - * - * returns: - * no returned results - */ -void fit_print_contents(const void *fit) +void fit_print(const void *fit) { const char *desc; char *uname; @@ -472,21 +460,11 @@ void fit_print_contents(const void *fit) } } -/** - * fit_image_print - prints out the FIT component image details - * @fit: pointer to the FIT format image header - * @image_noffset: offset of the component image node - * @p: pointer to prefix string - * - * fit_image_print() lists all mandatory properties for the processed component - * image. If present, hash nodes are printed out as well. Load - * address for images of type firmware is also printed out. Since the load - * address is not mandatory for firmware images, it will be output as - * "unavailable" when not present. - * - * returns: - * no returned results - */ +void fit_print_contents(const void *fit) +{ + fit_print(fit); +} + void fit_image_print(const void *fit, int image_noffset, const char *p) { uint8_t type, arch, os, comp = IH_COMP_NONE; diff --git a/include/image.h b/include/image.h index 33eb5d71e79..2f9469e2709 100644 --- a/include/image.h +++ b/include/image.h @@ -1198,9 +1198,52 @@ int fit_parse_subimage(const char *spec, ulong addr_curr, ulong *addr, const char **image_name); int fit_get_subimage_count(const void *fit, int images_noffset); -void fit_print_contents(const void *fit); + +/** + * fit_print() - prints out the contents of the FIT format image + * @fit: pointer to the FIT format image header + * @p: pointer to prefix string + * + * This formats a multi line FIT image contents description. + * The routine prints out FIT image properties (root node level) followed by + * the details of each component image. + * + * returns: + * no returned results + */ +void fit_print(const void *fit); + +/** + * fit_image_print - prints out the FIT component image details + * @fit: pointer to the FIT format image header + * @image_noffset: offset of the component image node + * @p: pointer to prefix string + * + * fit_image_print() lists all mandatory properties for the processed component + * image. If present, hash nodes are printed out as well. Load + * address for images of type firmware is also printed out. Since the load + * address is not mandatory for firmware images, it will be output as + * "unavailable" when not present. + * + * returns: + * no returned results + */ void fit_image_print(const void *fit, int noffset, const char *p); +/** + * fit_print_contents() - prints out the contents of the FIT format image + * @fit: pointer to the FIT format image header + * @p: pointer to prefix string + * + * This formats a multi line FIT image contents description. + * The routine prints out FIT image properties (root node level) followed by + * the details of each component image. + * + * returns: + * no returned results + */ +void fit_print_contents(const void *fit); + /** * fit_get_end - get FIT image size * @fit: pointer to the FIT format image header From patchwork Thu Nov 20 02:55:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 740 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=1763607422; bh=6a7CXk15t94oWzhFwLrfvZ6ZN1zSW12uhCKk1WPtp2g=; 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=eEknic49kQcE1pbgjwUOGxvInaLp4qC+rTr5FDcYWbQH8Xt2u1kY4Zvc6ez8fPq2Y JPvL7/UHHkoxr4tY/Asy7dIanDu1CQBVEj8Kvt4yDqy96rAK4Auk5qZ544KOjYfc7q yNYb6wvRBVSxrimtypRF7KCOTpiK0mhkKpDFk1/85izNNQM6HAZNVlqbhk9SvbSD1m eBCoN/KNg4eMLxHNygowgf7i/HBW/MdN7tcGlkhwPUhu2LZKskqgg4976xOuxy7n6g D2bDzolqiRaGMp/hetgUdoEd3pgUzzo0oLNngYluEpXldP/HqOJYRtQ2w21GfYOO85 E1FPEB7lMBv7A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68C7268631 for ; Wed, 19 Nov 2025 19:57:02 -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 M1tcGLb4ttHU for ; Wed, 19 Nov 2025 19:57:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607422; bh=6a7CXk15t94oWzhFwLrfvZ6ZN1zSW12uhCKk1WPtp2g=; 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=eEknic49kQcE1pbgjwUOGxvInaLp4qC+rTr5FDcYWbQH8Xt2u1kY4Zvc6ez8fPq2Y JPvL7/UHHkoxr4tY/Asy7dIanDu1CQBVEj8Kvt4yDqy96rAK4Auk5qZ544KOjYfc7q yNYb6wvRBVSxrimtypRF7KCOTpiK0mhkKpDFk1/85izNNQM6HAZNVlqbhk9SvbSD1m eBCoN/KNg4eMLxHNygowgf7i/HBW/MdN7tcGlkhwPUhu2LZKskqgg4976xOuxy7n6g D2bDzolqiRaGMp/hetgUdoEd3pgUzzo0oLNngYluEpXldP/HqOJYRtQ2w21GfYOO85 E1FPEB7lMBv7A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 22B14686BB for ; Wed, 19 Nov 2025 19:57:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607420; bh=GV/z7+ehpFg7xi50fP2ufW/vV1OEl9h3mVsWtWYykr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iReBAVibJEAhmpO13xQY0oaQBExSyfEAHZ7ECoUfjk8j2BKaJFfHFm9o3U5dSwRW1 HB79q1lGALe1VM6zxR3gr/zQnPoDVTvCMkSx1lR4a0ncSvrj6NYNTdttsbKvYy8Cyq RetDEQ5p7JZdjG3EJP6oDE68Pig3gcjadql5nAKdMaL1ZdymcRVCX5mjfV/g2xPiV+ WbLpH3ScQMOBOjH01XHjvmbDAyBHvxzvSxqeuM7vEXo2Sx0o/6rvs9VB/oeIsDgMul WLc34tWE2hvdj9XG910DCP7usfQE586VubsNRfSJnS4qsaNWh6NBPYyOxzf3Z7FElf trS1rkT5u6+SQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E1985E7DA; Wed, 19 Nov 2025 19:57:00 -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 MvN-HkB-68Cc; Wed, 19 Nov 2025 19:57:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607419; bh=EK5JsydyYif9mMWqZ9udapaEGRqz8iJ6ckoeGuOWb6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dG5TxYAE84u/d3egdb2rZM9tJEzZJHBTMfk7509rbHr5MAfXfY12OVODu3jHvvYpj LkBmANBlsLWU04f/9HqVEstqN/t256OwmoPF1uFOUKLwADYFeC5ScJ8nlt4gJC3wdi Udwl3KCNo/sPepj7SelllB6k6t1ecUId2umjIp0yKXlSaywEaSqKO0CumLUheIGqc7 QWOzMifajay5jlBBG8xufg9IsjQZq9q9bKE5eUrCRkIt+Wb/oLOvheG2IqFIbmUjR/ IPqNbzYvnBDWmXykGgH5tRdg+wXBGYJiZMG8I7Sh3VEew4hxC3Q9ghQ+j8Stom+3wH jUc/jb/jf3GDA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D686968614; Wed, 19 Nov 2025 19:56:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:47 -0700 Message-ID: <20251120025614.2215587-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WNJNBAJ7ZA4OBZTYC3KLXURQ6QEZMOPM X-Message-ID-Hash: WNJNBAJ7ZA4OBZTYC3KLXURQ6QEZMOPM 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/30] fit: Move printing code to its own file 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 There is enough code here that it makes sense to put it in its own file. Create a new fit_print.c file, before undertaking future refactoring. Printing is only included in the main build if CONFIG_FIT_PRINT is enabled, although it is always included in the tools build. Add static inlines for existing callers. Make a few small code-style adjustments, including fixing checkpatch warnings about over-use of brackets. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/Makefile | 1 + boot/fit_print.c | 411 +++++++++++++++++++++++++++++++++++++++++++++++ boot/image-fit.c | 394 --------------------------------------------- include/image.h | 12 ++ tools/Makefile | 1 + 5 files changed, 425 insertions(+), 394 deletions(-) create mode 100644 boot/fit_print.c diff --git a/boot/Makefile b/boot/Makefile index cfa5a0a98e9..725af083e66 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_$(PHASE_)UPL_WRITE) += upl_write.o obj-$(CONFIG_$(PHASE_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(PHASE_)FIT_SIGNATURE) += fdt_region.o obj-$(CONFIG_$(PHASE_)FIT) += image-fit.o +obj-$(CONFIG_$(PHASE_)FIT_PRINT) += fit_print.o obj-$(CONFIG_$(PHASE_)MULTI_DTB_FIT) += boot_fit.o common_fit.o obj-$(CONFIG_$(PHASE_)IMAGE_PRE_LOAD) += image-pre-load.o obj-$(CONFIG_$(PHASE_)IMAGE_SIGN_INFO) += image-sig.o diff --git a/boot/fit_print.c b/boot/fit_print.c new file mode 100644 index 00000000000..134625396bd --- /dev/null +++ b/boot/fit_print.c @@ -0,0 +1,411 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2013, Google Inc. + * + * (C) Copyright 2008 Semihalf + * + * (C) Copyright 2000-2006 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#define LOG_CATEGORY LOGC_BOOT + +#ifdef USE_HOSTCC +#include "mkimage.h" +#include +#include +#else +#include +#include +#include +#include +#endif + +#include +#include + +/** + * fit_image_print_data() - prints out the hash node details + * @fit: pointer to the FIT format image header + * @noffset: offset of the hash node + * @p: pointer to prefix string + * @type: Type of information to print ("hash" or "sign") + * + * fit_image_print_data() lists properties for the processed hash node + * + * This function avoid using puts() since it prints a newline on the host + * but does not in U-Boot. + * + * returns: + * no returned results + */ +static void fit_image_print_data(const void *fit, int noffset, const char *p, + const char *type) +{ + const char *keyname, *padding, *algo; + int value_len, ret, i; + uint8_t *value; + bool required; + + debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); + printf("%s %s algo: ", p, type); + if (fit_image_hash_get_algo(fit, noffset, &algo)) { + printf("invalid/unsupported\n"); + return; + } + printf("%s", algo); + keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL); + required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL); + if (keyname) + printf(":%s", keyname); + if (required) + printf(" (required)"); + printf("\n"); + + padding = fdt_getprop(fit, noffset, "padding", NULL); + if (padding) + printf("%s %s padding: %s\n", p, type, padding); + + ret = fit_image_hash_get_value(fit, noffset, &value, &value_len); + printf("%s %s value: ", p, type); + if (ret) { + printf("unavailable\n"); + } else { + for (i = 0; i < value_len; i++) + printf("%02x", value[i]); + printf("\n"); + } + + debug("%s %s len: %d\n", p, type, value_len); + + /* Signatures have a time stamp */ + if (IMAGE_ENABLE_TIMESTAMP && keyname) { + time_t timestamp; + + printf("%s Timestamp: ", p); + if (fit_get_timestamp(fit, noffset, ×tamp)) + printf("unavailable\n"); + else + genimg_print_time(timestamp); + } +} + +/** + * fit_image_print_verification_data() - prints out the hash/signature details + * @fit: pointer to the FIT format image header + * @noffset: offset of the hash or signature node + * @p: pointer to prefix string + * + * This lists properties for the processed hash node + * + * returns: + * no returned results + */ +static void fit_image_print_verification_data(const void *fit, int noffset, + const char *p) +{ + const char *name; + + /* + * Check subnode name, must be equal to "hash" or "signature". + * Multiple hash/signature nodes require unique unit node + * names, e.g. hash-1, hash-2, signature-1, signature-2, etc. + */ + name = fit_get_name(fit, noffset); + if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) + fit_image_print_data(fit, noffset, p, "Hash"); + else if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) + fit_image_print_data(fit, noffset, p, "Sign"); +} + +void fit_image_print(const void *fit, int image_noffset, const char *p) +{ + uint8_t type, arch, os, comp = IH_COMP_NONE; + const char *desc; + size_t size; + ulong load, entry; + const void *data; + int noffset; + int ndepth; + int ret; + + if (!CONFIG_IS_ENABLED(FIT_PRINT)) + return; + + /* Mandatory properties */ + ret = fit_get_desc(fit, image_noffset, &desc); + printf("%s Description: ", p); + if (ret) + printf("unavailable\n"); + else + printf("%s\n", desc); + + if (IMAGE_ENABLE_TIMESTAMP) { + time_t timestamp; + + ret = fit_get_timestamp(fit, 0, ×tamp); + printf("%s Created: ", p); + if (ret) + printf("unavailable\n"); + else + genimg_print_time(timestamp); + } + + fit_image_get_type(fit, image_noffset, &type); + printf("%s Type: %s\n", p, genimg_get_type_name(type)); + + fit_image_get_comp(fit, image_noffset, &comp); + printf("%s Compression: %s\n", p, genimg_get_comp_name(comp)); + + ret = fit_image_get_data(fit, image_noffset, &data, &size); + + if (!tools_build()) { + printf("%s Data Start: ", p); + if (ret) { + printf("unavailable\n"); + } else { + void *vdata = (void *)data; + + printf("0x%08lx\n", (ulong)map_to_sysmem(vdata)); + } + } + + printf("%s Data Size: ", p); + if (ret) + printf("unavailable\n"); + else + genimg_print_size(size); + + /* Remaining, type dependent properties */ + if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || + type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE || + type == IH_TYPE_FLATDT) { + fit_image_get_arch(fit, image_noffset, &arch); + printf("%s Architecture: %s\n", p, genimg_get_arch_name(arch)); + } + + if (type == IH_TYPE_KERNEL || type == IH_TYPE_RAMDISK || + type == IH_TYPE_FIRMWARE) { + fit_image_get_os(fit, image_noffset, &os); + printf("%s OS: %s\n", p, genimg_get_os_name(os)); + } + + if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || + type == IH_TYPE_FIRMWARE || type == IH_TYPE_RAMDISK || + type == IH_TYPE_FPGA) { + ret = fit_image_get_load(fit, image_noffset, &load); + printf("%s Load Address: ", p); + if (ret) + printf("unavailable\n"); + else + printf("0x%08lx\n", load); + } + + /* optional load address for FDT */ + if (type == IH_TYPE_FLATDT && + !fit_image_get_load(fit, image_noffset, &load)) + printf("%s Load Address: 0x%08lx\n", p, load); + + if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || + type == IH_TYPE_RAMDISK) { + ret = fit_image_get_entry(fit, image_noffset, &entry); + printf("%s Entry Point: ", p); + if (ret) + printf("unavailable\n"); + else + printf("0x%08lx\n", entry); + } + + /* Process all hash subnodes of the component image node */ + for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* Direct child node of the component image node */ + fit_image_print_verification_data(fit, noffset, p); + } + } +} + +/** + * fit_conf_print - prints out the FIT configuration details + * @fit: pointer to the FIT format image header + * @noffset: offset of the configuration node + * @p: pointer to prefix string + * + * fit_conf_print() lists all mandatory properties for the processed + * configuration node. + * + * returns: + * no returned results + */ +static void fit_conf_print(const void *fit, int noffset, const char *p) +{ + const char *uname, *desc; + int ret, ndepth, i; + + /* Mandatory properties */ + ret = fit_get_desc(fit, noffset, &desc); + printf("%s Description: ", p); + if (ret) + printf("unavailable\n"); + else + printf("%s\n", desc); + + uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); + printf("%s Kernel: ", p); + if (!uname) + printf("unavailable\n"); + else + printf("%s\n", uname); + + /* Optional properties */ + uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); + if (uname) + printf("%s Init Ramdisk: %s\n", p, uname); + + uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); + if (uname) + printf("%s Firmware: %s\n", p, uname); + + for (i = 0; + uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, + i, NULL), uname; + i++) { + if (!i) + printf("%s FDT: ", p); + else + printf("%s ", p); + printf("%s\n", uname); + } + + uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); + if (uname) + printf("%s FPGA: %s\n", p, uname); + + /* Print out all of the specified loadables */ + for (i = 0; + uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, + i, NULL), uname; + i++) { + if (!i) + printf("%s Loadables: ", p); + else + printf("%s ", p); + printf("%s\n", uname); + } + + /* Show the list of compatible strings */ + for (i = 0; uname = fdt_stringlist_get(fit, noffset, + FIT_COMPATIBLE_PROP, i, NULL), uname; i++) { + if (!i) + printf("%s Compatible: ", p); + else + printf("%s ", p); + printf("%s\n", uname); + } + + /* Process all hash subnodes of the component configuration node */ + for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* Direct child node of the component config node */ + fit_image_print_verification_data(fit, noffset, p); + } + } +} + +void fit_print(const void *fit) +{ + const char *desc; + char *uname; + int images_noffset; + int confs_noffset; + int noffset; + int ndepth; + int count = 0; + int ret; + const char *p; + time_t timestamp; + + /* Indent string is defined in header image.h */ + p = IMAGE_INDENT_STRING; + + /* Root node properties */ + ret = fit_get_desc(fit, 0, &desc); + printf("%sFIT description: ", p); + if (ret) + printf("unavailable\n"); + else + printf("%s\n", desc); + + if (IMAGE_ENABLE_TIMESTAMP) { + ret = fit_get_timestamp(fit, 0, ×tamp); + printf("%sCreated: ", p); + if (ret) + printf("unavailable\n"); + else + genimg_print_time(timestamp); + } + + /* Find images parent node offset */ + images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); + if (images_noffset < 0) { + printf("Can't find images parent node '%s' (%s)\n", + FIT_IMAGES_PATH, fdt_strerror(images_noffset)); + return; + } + + /* Process its subnodes, print out component images details */ + for (ndepth = 0, count = 0, + noffset = fdt_next_node(fit, images_noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* + * Direct child node of the images parent node, + * i.e. component image node. + */ + printf("%s Image %u (%s)\n", p, count++, + fit_get_name(fit, noffset)); + + fit_image_print(fit, noffset, p); + } + } + + /* Find configurations parent node offset */ + confs_noffset = fdt_path_offset(fit, FIT_CONFS_PATH); + if (confs_noffset < 0) { + debug("Can't get configurations parent node '%s' (%s)\n", + FIT_CONFS_PATH, fdt_strerror(confs_noffset)); + return; + } + + /* get default configuration unit name from default property */ + uname = (char *)fdt_getprop(fit, noffset, FIT_DEFAULT_PROP, NULL); + if (uname) + printf("%s Default Configuration: '%s'\n", p, uname); + + /* Process its subnodes, print out configurations details */ + for (ndepth = 0, count = 0, + noffset = fdt_next_node(fit, confs_noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* + * Direct child node of the configurations parent node, + * i.e. configuration node. + */ + printf("%s Configuration %u (%s)\n", p, count++, + fit_get_name(fit, noffset)); + + fit_conf_print(fit, noffset, p); + } + } +} + +void fit_print_contents(const void *fit) +{ + fit_print(fit); +} diff --git a/boot/image-fit.c b/boot/image-fit.c index 9103016bd08..5eef9479781 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -179,400 +179,6 @@ int fit_get_subimage_count(const void *fit, int images_noffset) return count; } -/** - * fit_image_print_data() - prints out the hash node details - * @fit: pointer to the FIT format image header - * @noffset: offset of the hash node - * @p: pointer to prefix string - * @type: Type of information to print ("hash" or "sign") - * - * fit_image_print_data() lists properties for the processed hash node - * - * This function avoid using puts() since it prints a newline on the host - * but does not in U-Boot. - * - * returns: - * no returned results - */ -static void fit_image_print_data(const void *fit, int noffset, const char *p, - const char *type) -{ - const char *keyname; - uint8_t *value; - int value_len; - const char *algo; - const char *padding; - bool required; - int ret, i; - - debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); - printf("%s %s algo: ", p, type); - if (fit_image_hash_get_algo(fit, noffset, &algo)) { - printf("invalid/unsupported\n"); - return; - } - printf("%s", algo); - keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL); - required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL) != NULL; - if (keyname) - printf(":%s", keyname); - if (required) - printf(" (required)"); - printf("\n"); - - padding = fdt_getprop(fit, noffset, "padding", NULL); - if (padding) - printf("%s %s padding: %s\n", p, type, padding); - - ret = fit_image_hash_get_value(fit, noffset, &value, - &value_len); - printf("%s %s value: ", p, type); - if (ret) { - printf("unavailable\n"); - } else { - for (i = 0; i < value_len; i++) - printf("%02x", value[i]); - printf("\n"); - } - - debug("%s %s len: %d\n", p, type, value_len); - - /* Signatures have a time stamp */ - if (IMAGE_ENABLE_TIMESTAMP && keyname) { - time_t timestamp; - - printf("%s Timestamp: ", p); - if (fit_get_timestamp(fit, noffset, ×tamp)) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } -} - -/** - * fit_image_print_verification_data() - prints out the hash/signature details - * @fit: pointer to the FIT format image header - * @noffset: offset of the hash or signature node - * @p: pointer to prefix string - * - * This lists properties for the processed hash node - * - * returns: - * no returned results - */ -static void fit_image_print_verification_data(const void *fit, int noffset, - const char *p) -{ - const char *name; - - /* - * Check subnode name, must be equal to "hash" or "signature". - * Multiple hash/signature nodes require unique unit node - * names, e.g. hash-1, hash-2, signature-1, signature-2, etc. - */ - name = fit_get_name(fit, noffset); - if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) { - fit_image_print_data(fit, noffset, p, "Hash"); - } else if (!strncmp(name, FIT_SIG_NODENAME, - strlen(FIT_SIG_NODENAME))) { - fit_image_print_data(fit, noffset, p, "Sign"); - } -} - -/** - * fit_conf_print - prints out the FIT configuration details - * @fit: pointer to the FIT format image header - * @noffset: offset of the configuration node - * @p: pointer to prefix string - * - * fit_conf_print() lists all mandatory properties for the processed - * configuration node. - * - * returns: - * no returned results - */ -static void fit_conf_print(const void *fit, int noffset, const char *p) -{ - const char *uname, *desc; - int ret, ndepth, i; - - /* Mandatory properties */ - ret = fit_get_desc(fit, noffset, &desc); - printf("%s Description: ", p); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); - - uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); - printf("%s Kernel: ", p); - if (!uname) - printf("unavailable\n"); - else - printf("%s\n", uname); - - /* Optional properties */ - uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) - printf("%s Init Ramdisk: %s\n", p, uname); - - uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) - printf("%s Firmware: %s\n", p, uname); - - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, - i, NULL), uname; - i++) { - if (!i) - printf("%s FDT: ", p); - else - printf("%s ", p); - printf("%s\n", uname); - } - - uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) - printf("%s FPGA: %s\n", p, uname); - - /* Print out all of the specified loadables */ - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, - i, NULL), uname; - i++) { - if (!i) - printf("%s Loadables: ", p); - else - printf("%s ", p); - printf("%s\n", uname); - } - - /* Show the list of compatible strings */ - for (i = 0; uname = fdt_stringlist_get(fit, noffset, - FIT_COMPATIBLE_PROP, i, NULL), uname; i++) { - if (!i) - printf("%s Compatible: ", p); - else - printf("%s ", p); - printf("%s\n", uname); - } - - /* Process all hash subnodes of the component configuration node */ - for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* Direct child node of the component configuration node */ - fit_image_print_verification_data(fit, noffset, p); - } - } -} - -void fit_print(const void *fit) -{ - const char *desc; - char *uname; - int images_noffset; - int confs_noffset; - int noffset; - int ndepth; - int count = 0; - int ret; - const char *p; - time_t timestamp; - - if (!CONFIG_IS_ENABLED(FIT_PRINT)) - return; - - /* Indent string is defined in header image.h */ - p = IMAGE_INDENT_STRING; - - /* Root node properties */ - ret = fit_get_desc(fit, 0, &desc); - printf("%sFIT description: ", p); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); - - if (IMAGE_ENABLE_TIMESTAMP) { - ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%sCreated: ", p); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } - - /* Find images parent node offset */ - images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); - if (images_noffset < 0) { - printf("Can't find images parent node '%s' (%s)\n", - FIT_IMAGES_PATH, fdt_strerror(images_noffset)); - return; - } - - /* Process its subnodes, print out component images details */ - for (ndepth = 0, count = 0, - noffset = fdt_next_node(fit, images_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* - * Direct child node of the images parent node, - * i.e. component image node. - */ - printf("%s Image %u (%s)\n", p, count++, - fit_get_name(fit, noffset)); - - fit_image_print(fit, noffset, p); - } - } - - /* Find configurations parent node offset */ - confs_noffset = fdt_path_offset(fit, FIT_CONFS_PATH); - if (confs_noffset < 0) { - debug("Can't get configurations parent node '%s' (%s)\n", - FIT_CONFS_PATH, fdt_strerror(confs_noffset)); - return; - } - - /* get default configuration unit name from default property */ - uname = (char *)fdt_getprop(fit, noffset, FIT_DEFAULT_PROP, NULL); - if (uname) - printf("%s Default Configuration: '%s'\n", p, uname); - - /* Process its subnodes, print out configurations details */ - for (ndepth = 0, count = 0, - noffset = fdt_next_node(fit, confs_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* - * Direct child node of the configurations parent node, - * i.e. configuration node. - */ - printf("%s Configuration %u (%s)\n", p, count++, - fit_get_name(fit, noffset)); - - fit_conf_print(fit, noffset, p); - } - } -} - -void fit_print_contents(const void *fit) -{ - fit_print(fit); -} - -void fit_image_print(const void *fit, int image_noffset, const char *p) -{ - uint8_t type, arch, os, comp = IH_COMP_NONE; - const char *desc; - size_t size; - ulong load, entry; - const void *data; - int noffset; - int ndepth; - int ret; - - if (!CONFIG_IS_ENABLED(FIT_PRINT)) - return; - - /* Mandatory properties */ - ret = fit_get_desc(fit, image_noffset, &desc); - printf("%s Description: ", p); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); - - if (IMAGE_ENABLE_TIMESTAMP) { - time_t timestamp; - - ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%s Created: ", p); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } - - fit_image_get_type(fit, image_noffset, &type); - printf("%s Type: %s\n", p, genimg_get_type_name(type)); - - fit_image_get_comp(fit, image_noffset, &comp); - printf("%s Compression: %s\n", p, genimg_get_comp_name(comp)); - - ret = fit_image_get_data(fit, image_noffset, &data, &size); - - if (!tools_build()) { - printf("%s Data Start: ", p); - if (ret) { - printf("unavailable\n"); - } else { - void *vdata = (void *)data; - - printf("0x%08lx\n", (ulong)map_to_sysmem(vdata)); - } - } - - printf("%s Data Size: ", p); - if (ret) - printf("unavailable\n"); - else - genimg_print_size(size); - - /* Remaining, type dependent properties */ - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) || - (type == IH_TYPE_RAMDISK) || (type == IH_TYPE_FIRMWARE) || - (type == IH_TYPE_FLATDT)) { - fit_image_get_arch(fit, image_noffset, &arch); - printf("%s Architecture: %s\n", p, genimg_get_arch_name(arch)); - } - - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_RAMDISK) || - (type == IH_TYPE_FIRMWARE)) { - fit_image_get_os(fit, image_noffset, &os); - printf("%s OS: %s\n", p, genimg_get_os_name(os)); - } - - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) || - (type == IH_TYPE_FIRMWARE) || (type == IH_TYPE_RAMDISK) || - (type == IH_TYPE_FPGA)) { - ret = fit_image_get_load(fit, image_noffset, &load); - printf("%s Load Address: ", p); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", load); - } - - /* optional load address for FDT */ - if (type == IH_TYPE_FLATDT && !fit_image_get_load(fit, image_noffset, &load)) - printf("%s Load Address: 0x%08lx\n", p, load); - - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) || - (type == IH_TYPE_RAMDISK)) { - ret = fit_image_get_entry(fit, image_noffset, &entry); - printf("%s Entry Point: ", p); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", entry); - } - - /* Process all hash subnodes of the component image node */ - for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* Direct child node of the component image node */ - fit_image_print_verification_data(fit, noffset, p); - } - } -} - int fit_get_desc(const void *fit, int noffset, const char **descp) { const char *desc; diff --git a/include/image.h b/include/image.h index 2f9469e2709..17dd68e7048 100644 --- a/include/image.h +++ b/include/image.h @@ -1199,6 +1199,8 @@ int fit_parse_subimage(const char *spec, ulong addr_curr, int fit_get_subimage_count(const void *fit, int images_noffset); +#if CONFIG_IS_ENABLED(FIT_PRINT) + /** * fit_print() - prints out the contents of the FIT format image * @fit: pointer to the FIT format image header @@ -1244,6 +1246,16 @@ void fit_image_print(const void *fit, int noffset, const char *p); */ void fit_print_contents(const void *fit); +#else /* !FIT_PRINT */ + +static inline void fit_print(const void *fit) {} +static inline void fit_image_print(const void *fit, int noffset, const char *p) +{ +} +static inline void fit_print_contents(const void *fit) {} + +#endif + /** * fit_get_end - get FIT image size * @fit: pointer to the FIT format image header diff --git a/tools/Makefile b/tools/Makefile index 97ce1dbb17e..995350b5f5f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -72,6 +72,7 @@ hostprogs-y += file2include endif FIT_OBJS-y := fit_common.o fit_image.o image-host.o generated/boot/image-fit.o +FIT_OBJS-y += generated/boot/fit_print.o FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o generated/boot/image-fit-sig.o FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := generated/boot/image-cipher.o From patchwork Thu Nov 20 02:55:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 741 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=1763607424; bh=dRqro6Enb3h85C04rrm3fTS418dz2F+PTK1CEEpikhg=; 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=bo5R+XJV09nlBlucJoitqrEzvSw+nmniu9O3ndYIV1Hlyzl3gTHaYvGp1xBGMvSr0 CJOR/msFAp3xuu7emKNyfb6DE8V+wa9nZ/Q4A/e03PRRtDe3DMsTKUcNOv9h1V4+0q I/7qGjRK5P91NJ+n2WDk9AKfaYFngwLzUFmDqio9lkQe9xqApFnyTmRNYXkP2KgrR4 jvESPO/oGhYY4hv8PbUgeqvpPu2X2pWAsbcTyQQSoCjMeoqvoZfiUGg+keDeOeaNTG VRzXKuJQozVCEwbV6fKA3kLhWPRKWWR2HO1Ll/I09mgNB6fxns1k3KdlcRrJO1b5Zu LG5GHxuuf2hfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD42C686C9 for ; Wed, 19 Nov 2025 19:57:04 -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 wHD6XEbeOXVE for ; Wed, 19 Nov 2025 19:57:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607424; bh=dRqro6Enb3h85C04rrm3fTS418dz2F+PTK1CEEpikhg=; 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=bo5R+XJV09nlBlucJoitqrEzvSw+nmniu9O3ndYIV1Hlyzl3gTHaYvGp1xBGMvSr0 CJOR/msFAp3xuu7emKNyfb6DE8V+wa9nZ/Q4A/e03PRRtDe3DMsTKUcNOv9h1V4+0q I/7qGjRK5P91NJ+n2WDk9AKfaYFngwLzUFmDqio9lkQe9xqApFnyTmRNYXkP2KgrR4 jvESPO/oGhYY4hv8PbUgeqvpPu2X2pWAsbcTyQQSoCjMeoqvoZfiUGg+keDeOeaNTG VRzXKuJQozVCEwbV6fKA3kLhWPRKWWR2HO1Ll/I09mgNB6fxns1k3KdlcRrJO1b5Zu LG5GHxuuf2hfw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AA21C686BB for ; Wed, 19 Nov 2025 19:57:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607422; bh=Slaplod5HaF8KBVlw5oG39RooXALjWRzm+uT8Z6lByI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=riO1fIy5Z45E9w4WENpsJg+ry+2IoM1zAl85M7xHg/jK1kbYKMsUT5+l07exswSCf Ml4wtpqdDvOwsVyZ+kevrElaZpdfpj4/dXraDwnMYfkaxinYwwV0SyR596tXGFhnGK qwvW6jBV30SRnZpYe5W8sejBflWGUWMqG2bE9tuiVNpX5bv07N1zQI42L21rNnzSuG vpbFkYZnWsl55ZWWTXpoHCJki6poVWXSOoc171BgAsy9vn+cd85HkRgKNfVojnLjQq YkRpXfsY/ZXMZJCRzF/zUfaRImebaFu4hMHRIBXNKgMGC5ZTxrIt3x5eNOSeFYRaKZ YVNEBqOyPUE5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 23C06686C8; Wed, 19 Nov 2025 19:57:02 -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 1oAPiwAF91su; Wed, 19 Nov 2025 19:57:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607420; bh=TzCFS0i8H01rawM5xlY+4bHpjzvYoHM+4t/Adqbitd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fu/2gmXw9WYCphnp5JJUKpMnxrrLvxTlBtia+xYcOkLGFa6Q39k1Fo6Gpj6rmIFg+ C9AsRhxXO2t2OyhPA3ezvphk02ycvjyEMf1jfahTtfnuve0lAEbX2ZACelDfQsYwr+ BYx+XUDwcOzpeZjZ+VUyzL1L321s+hDBda6qlbEZgzB0rzfcaTbrJoBpAkZUIfVQNl jymwypM2LhzJItax6LsbIcSIaruECvkkHp2Nqf9VBP/fGASx8bqG3Y7Qh5MCcGpV/F I0fLN99PM2eHmpvV9mmjY9N8MpkrI94oFjlNuj6caPW3+WKriwzavFdA87mBzba+h/ jCXMBLu59ALeA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 60BB168614; Wed, 19 Nov 2025 19:57:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:48 -0700 Message-ID: <20251120025614.2215587-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: C4DMKO37IBX7PNI7J5DZ4UEHNVICVQ6T X-Message-ID-Hash: C4DMKO37IBX7PNI7J5DZ4UEHNVICVQ6T 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/30] fit: Drop showing an unused 'required' property 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 This is actually not defined by the spec. The 'required' property is for use by the verifying code. Having it in the FIT does not help size an attacker could potentially remove it. Signed-off-by: Simon Glass --- boot/fit_print.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 134625396bd..bea2e176f17 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -45,7 +45,6 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p, const char *keyname, *padding, *algo; int value_len, ret, i; uint8_t *value; - bool required; debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); printf("%s %s algo: ", p, type); @@ -55,11 +54,8 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p, } printf("%s", algo); keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL); - required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL); if (keyname) printf(":%s", keyname); - if (required) - printf(" (required)"); printf("\n"); padding = fdt_getprop(fit, noffset, "padding", NULL); From patchwork Thu Nov 20 02:55:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 742 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=1763607427; bh=veB1xuhh6x1ImT+Ug6auPeYGWfHrNwCdtlnnfJtBgOk=; 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=SiaX0ZhEgn4IOFyXLM1b7mszVGFa5d9w8Na08dmI4CwTSvwpo5AwPrmKI4SjppRtm mREEWBxyMRYz1VJiegVKYUICKRqpxr7JjxbYn1eI36Bw1lY0bFMPKXyhWrEW81Z1pm ooUca0s8tG2ApBzvuueEkeg+d+gjAs+styLhN9RiEKNZhNNDI6xmT16oouWFI53si/ ikLt8tNWu71pYwBro91pgs60CN+JaNjT+kIfMqWNu5SpkKzZI/OmWu1SfWHA+yBFjD SDRUE5kKxzjOMsG1h3gWXp3kY2TPne8C7OJbkr9hCZxpvHB1n97Mi1yd9ITWHj2PDy ZavosENe9V+dA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28AFF68631 for ; Wed, 19 Nov 2025 19:57:07 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id hTjvjFqKAj6C for ; Wed, 19 Nov 2025 19:57:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607425; bh=veB1xuhh6x1ImT+Ug6auPeYGWfHrNwCdtlnnfJtBgOk=; 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=DwwUSK0/Lp1oug0cuK8z9xqXpomxqE4nyMKIKSkrECgqgIUPDiY/wU3xQOmhd0MP9 P4VlrCa7uU0vJ1Kx9YMgIiveIGzpNE787g5J9rW3wvb+No78Ld80oY4QWtAkrphbI0 SJBu5L7rO4j0wsLx2mDUJO3akbkrWQPrI9Q76fStfl9uZsH89TxCRad0CUr8i9G/e/ QB4QmEvLmChNU5XXv3iJuvWT1w0Ggon972VticxsjO2AcUPkzQC+rpvoltm0vTPCqv 4Qgk9bfr3c2fjqPpHxibquCnANOCfVaIWjs82diypwmCccNL+4d9XXz/wqA9OeUO+L Dh2Lx3kmCKIyg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 39455686C8 for ; Wed, 19 Nov 2025 19:57:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607422; bh=HPpPwMJVYDH7l54agyFrvRubTZOl+ncs/5yw/Vb12xI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vG6N7Jz0e1J/2D5Du2eTv0jSq72s/D6V3baA26QEXt8iyZpsu1Er/qjdr/W8jT/mh wna/FpCxkuWFIKQMA3FkGVv9ZvrEWIZod46JU2ITPby2DqGXzE1nBugcIpJw/Sy+fa iTN47yuAI2r/aU1oGcX3VVseIPL1brdmjwBCMuxd847qzI9B/J0cGm69Xk7XKkuS+R rlG7NaVqY+R+zhVN1sabaGMthzaUeziqwfXOfqdT95RBsvaD3ONEl/1bnIFpjOI6Ig ay5UO7k/wBSZZ7uDz42d3/4rLQbXKmXiUuxVNhVq/lhJv9LwUkXVq73mZAKstn/7l2 c4JVLesEXcQMA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54BAE686E2; Wed, 19 Nov 2025 19:57:02 -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 DT388UoSaQU2; Wed, 19 Nov 2025 19:57:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607421; bh=5c5XE+friOPkH3hEAc3wfi5PhrMpDjOXiQRl76yN4PI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GdV5QDlGEQ0qwyrZCv/mYbgkoFcu0BZXqFKDRFYxFpVvNwLmPyXUQDtjTCmF7S+My G6X7QEpNxOycF23i032d5M/RfEDZl2gfcpB4TAwgh1lBDVsxd6GQf259MYI1ZM2z4A O0HmFbXuswKVhW14rDqNCAjf3NosBhQS2GvwH/wBr51QCthrVGUVxsMWcyiqBXpXtx eH//vJ9NUXbjUGN7OF79v5bpJATvXVpkpilmxi0RBQduxxN2tmFzkABopHERN2vaYU pmdMyv8W/Hofty2pPL7ekoVlGvA73liia1mQ4LVxa/hBq8cq52OWOIxrHrHIVEqqI4 mtn05s9xz37sA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7092468668; Wed, 19 Nov 2025 19:57:01 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:49 -0700 Message-ID: <20251120025614.2215587-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VL5FHAJNLUDNKIYTCKCZV5BECQHUJPLL X-Message-ID-Hash: VL5FHAJNLUDNKIYTCKCZV5BECQHUJPLL 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/30] fit: Add a context struct for FIT-printing 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 Create a struct fit_print_ctx to hold the FIT pointer and pass it to all printing functions instead of passing the FIT pointer directly. This provides a foundation for adding additional context in the future. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 58 +++++++++++++++++++++++++++++++---------------- boot/image-fit.c | 5 +++- include/image.h | 30 ++++++++++++++++++------ tools/fit_image.c | 5 +++- 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index bea2e176f17..bb6dc140e34 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -25,8 +25,20 @@ #include /** - * fit_image_print_data() - prints out the hash node details + * fit_print_init() - initialize FIT print context + * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header + * + * This initializes a fit_print_ctx structure with the given FIT image. + */ +void fit_print_init(struct fit_print_ctx *ctx, const void *fit) +{ + ctx->fit = fit; +} + +/** + * fit_image_print_data() - prints out the hash node details + * @ctx: pointer to FIT print context * @noffset: offset of the hash node * @p: pointer to prefix string * @type: Type of information to print ("hash" or "sign") @@ -39,10 +51,11 @@ * returns: * no returned results */ -static void fit_image_print_data(const void *fit, int noffset, const char *p, - const char *type) +static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, + const char *p, const char *type) { const char *keyname, *padding, *algo; + const void *fit = ctx->fit; int value_len, ret, i; uint8_t *value; @@ -88,7 +101,7 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p, /** * fit_image_print_verification_data() - prints out the hash/signature details - * @fit: pointer to the FIT format image header + * @ctx: pointer to FIT print context * @noffset: offset of the hash or signature node * @p: pointer to prefix string * @@ -97,9 +110,10 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p, * returns: * no returned results */ -static void fit_image_print_verification_data(const void *fit, int noffset, - const char *p) +static void fit_image_print_verification_data(struct fit_print_ctx *ctx, + int noffset, const char *p) { + const void *fit = ctx->fit; const char *name; /* @@ -109,13 +123,14 @@ static void fit_image_print_verification_data(const void *fit, int noffset, */ name = fit_get_name(fit, noffset); if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) - fit_image_print_data(fit, noffset, p, "Hash"); + fit_image_print_data(ctx, noffset, p, "Hash"); else if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) - fit_image_print_data(fit, noffset, p, "Sign"); + fit_image_print_data(ctx, noffset, p, "Sign"); } -void fit_image_print(const void *fit, int image_noffset, const char *p) +void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p) { + const void *fit = ctx->fit; uint8_t type, arch, os, comp = IH_COMP_NONE; const char *desc; size_t size; @@ -125,9 +140,6 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) int ndepth; int ret; - if (!CONFIG_IS_ENABLED(FIT_PRINT)) - return; - /* Mandatory properties */ ret = fit_get_desc(fit, image_noffset, &desc); printf("%s Description: ", p); @@ -218,14 +230,14 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component image node */ - fit_image_print_verification_data(fit, noffset, p); + fit_image_print_verification_data(ctx, noffset, p); } } } /** * fit_conf_print - prints out the FIT configuration details - * @fit: pointer to the FIT format image header + * @ctx: pointer to FIT print context * @noffset: offset of the configuration node * @p: pointer to prefix string * @@ -235,8 +247,10 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) * returns: * no returned results */ -static void fit_conf_print(const void *fit, int noffset, const char *p) +static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, + const char *p) { + const void *fit = ctx->fit; const char *uname, *desc; int ret, ndepth, i; @@ -307,13 +321,14 @@ static void fit_conf_print(const void *fit, int noffset, const char *p) noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component config node */ - fit_image_print_verification_data(fit, noffset, p); + fit_image_print_verification_data(ctx, noffset, p); } } } -void fit_print(const void *fit) +void fit_print(struct fit_print_ctx *ctx) { + const void *fit = ctx->fit; const char *desc; char *uname; int images_noffset; @@ -366,7 +381,7 @@ void fit_print(const void *fit) printf("%s Image %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_image_print(fit, noffset, p); + fit_image_print(ctx, noffset, p); } } @@ -396,12 +411,15 @@ void fit_print(const void *fit) printf("%s Configuration %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_conf_print(fit, noffset, p); + fit_conf_print(ctx, noffset, p); } } } void fit_print_contents(const void *fit) { - fit_print(fit); + struct fit_print_ctx ctx; + + fit_print_init(&ctx, fit); + fit_print(&ctx); } diff --git a/boot/image-fit.c b/boot/image-fit.c index 5eef9479781..ed77a5e09c5 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -1555,7 +1555,10 @@ int fit_get_data_conf_prop(const void *fit, const char *prop_name, static int print_and_verify(const void *fit, int rd_noffset, int verify) { - fit_image_print(fit, rd_noffset, " "); + struct fit_print_ctx ctx; + + fit_print_init(&ctx, fit); + fit_image_print(&ctx, rd_noffset, " "); if (verify) { puts(" Verifying Hash Integrity ... "); diff --git a/include/image.h b/include/image.h index 17dd68e7048..9b5a1815df9 100644 --- a/include/image.h +++ b/include/image.h @@ -1199,26 +1199,41 @@ int fit_parse_subimage(const char *spec, ulong addr_curr, int fit_get_subimage_count(const void *fit, int images_noffset); +/** + * struct fit_print_ctx - context for FIT printing + * @fit: pointer to the FIT format image header + */ +struct fit_print_ctx { + const void *fit; +}; + #if CONFIG_IS_ENABLED(FIT_PRINT) /** - * fit_print() - prints out the contents of the FIT format image + * fit_print_init() - initialize FIT print context + * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header - * @p: pointer to prefix string * - * This formats a multi line FIT image contents description. + * This inits a fit_print_ctx structure with the given FIT image. + */ +void fit_print_init(struct fit_print_ctx *ctx, const void *fit); + +/** + * fit_print() - prints out the contents of the FIT format image + * @ctx: pointer to FIT print context + * * The routine prints out FIT image properties (root node level) followed by * the details of each component image. * * returns: * no returned results */ -void fit_print(const void *fit); +void fit_print(struct fit_print_ctx *ctx); /** * fit_image_print - prints out the FIT component image details - * @fit: pointer to the FIT format image header - * @image_noffset: offset of the component image node + * @ctx: pointer to FIT print context + * @noffset: offset of the component image node * @p: pointer to prefix string * * fit_image_print() lists all mandatory properties for the processed component @@ -1230,7 +1245,7 @@ void fit_print(const void *fit); * returns: * no returned results */ -void fit_image_print(const void *fit, int noffset, const char *p); +void fit_image_print(struct fit_print_ctx *ctx, int noffset, const char *p); /** * fit_print_contents() - prints out the contents of the FIT format image @@ -1248,6 +1263,7 @@ void fit_print_contents(const void *fit); #else /* !FIT_PRINT */ +static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit) {} static inline void fit_print(const void *fit) {} static inline void fit_image_print(const void *fit, int noffset, const char *p) { diff --git a/tools/fit_image.c b/tools/fit_image.c index 80f9020d29d..017a2d212e9 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -971,10 +971,13 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) * i.e. component image node. */ if (itl->pflag == count) { + struct fit_print_ctx ctx; + printf("Extracted:\n%s Image %u (%s)\n", p, count, fit_get_name(fit, noffset)); - fit_image_print(fit, noffset, p); + fit_print_init(&ctx, fit); + fit_image_print(&ctx, noffset, p); return fit_image_extract(fit, noffset, itl->outfile); From patchwork Thu Nov 20 02:55:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 744 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=1763607433; bh=2RucJaTVPL+rlo+QUVp/nnDSkWcMVkXPjFQD+5YV+NM=; 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=avIr0oMT69agfqzKMoZ30dj+h9qPkee97bkz8A24FxTrxbkZJgToPe3QyEcmRks+X fudBY9i5y0XR7saI4S9XfeRNaHb1JBI5K2S4W2j9L3D5fleml46VZfjsTCrjHmQeQJ +MWmvvXwwTyIAptgQG+SbCLanM3v2DpJlkiqdkX+rPHKipw8WnqO0XCYK551pWqfpS zeIbGh6Z7801NKh/PYrWIE0jbF0E77lh6pjuhk2fW6hoX3vKWhCKdS+/txNmvrxB9u 0GMBOAcHkUBb81ECinC0IegoM89GPdi81WQwsVQ/SktGYYmlKLVTI+WlBv3FVH6v/m B8MPAZT8sDuZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C1AD686DF for ; Wed, 19 Nov 2025 19:57:13 -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 P2PuejtrBd0u for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607433; bh=2RucJaTVPL+rlo+QUVp/nnDSkWcMVkXPjFQD+5YV+NM=; 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=avIr0oMT69agfqzKMoZ30dj+h9qPkee97bkz8A24FxTrxbkZJgToPe3QyEcmRks+X fudBY9i5y0XR7saI4S9XfeRNaHb1JBI5K2S4W2j9L3D5fleml46VZfjsTCrjHmQeQJ +MWmvvXwwTyIAptgQG+SbCLanM3v2DpJlkiqdkX+rPHKipw8WnqO0XCYK551pWqfpS zeIbGh6Z7801NKh/PYrWIE0jbF0E77lh6pjuhk2fW6hoX3vKWhCKdS+/txNmvrxB9u 0GMBOAcHkUBb81ECinC0IegoM89GPdi81WQwsVQ/SktGYYmlKLVTI+WlBv3FVH6v/m B8MPAZT8sDuZA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4443F68657 for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=Q8CTifE/x8EPaC32lHk17Mxh4dbL+mZTQGYno9B7Iyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1fxhp0l9H1N9MTd6NknEZh0fJhewMVaQG9+7aPXEbfc9B1GdWvGgfFI029gvyE+Q 9DmplDVhZ4GoPZsuLDeSxJb6p/ygemi6M1RP9kNLSNhs4CpYciEZjS7EQNj2L94qsI GH6lRGE52Jv/uPDWksKf8wVXc0I3pcTYGIJlMHzyM4jTMUKhvvQVVnXMNplfbwoNP5 CIuyM2T6prFjN/JfZPWbFJvw/fVkeTIMuhFBInp7EQXVNx4l+MtznRvIujsTIRQzfp EeA0ZhiwoBBBUCqlgae4Qu0noMj1UI7QdFfPuG0g89/asFbMI9eO9Y8u1s3TW4Vbrx 62hLQ/ml7EHYw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 669F7686C9; Wed, 19 Nov 2025 19:57:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id U1CwdoSQ0n-L; Wed, 19 Nov 2025 19:57:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607422; bh=OzEV0O7CLWp+bBVgxetbJU1eIct5QGqEvLDMou5/FkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqirsP+/FlVifLr68+1+ynhSXjGiF578DzPchVILkicZ5E2WJI6LqZhCFADvBeAu4 bFu9Cc6/VUy5U2FPCs5KvPPPNPvTrJQSLdWeXFmD3Ob+M2jAFm6ieE3YGyD9/xNW9e E4qpTgZgp+gTfP3N74fmhEdC6rIAdKQ3pJhYWrP1S0mVjMUBMLkantt/OelOgHtJiO Vq1nZs8UvcIpjo0z0v96TeDn7Ad4RIKMHfmLLWuFWJ1A6RkLZ8n/Blmey0bcDYQ3L3 F/AUkdabVDBFxiDuX4sj/8ObUPLarh3zfIn/wdyFq8P99kmpA3AjQJMm24Kk0Vsq7W 7RXg8TpsoPhJw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 83A245E7DA; Wed, 19 Nov 2025 19:57:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:50 -0700 Message-ID: <20251120025614.2215587-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KABQOQSWWPTCFPSKXAFXXXHNIRERTX6B X-Message-ID-Hash: KABQOQSWWPTCFPSKXAFXXXHNIRERTX6B 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/30] fit: Put the indent string into print context 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 Move the indent string into struct fit_print_ctx so it is available to the printing functions. This avoids having to pass it as a separate parameter. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 54 +++++++++++++++++++++++++++++------------------ boot/image-fit.c | 4 ++-- include/image.h | 18 ++++++++++------ tools/fit_image.c | 4 ++-- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index bb6dc140e34..07454dcf5cf 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -28,19 +28,21 @@ * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header + * @indent: indentation string for printing * * This initializes a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit) +void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent) { ctx->fit = fit; + ctx->indent = indent; } /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context * @noffset: offset of the hash node - * @p: pointer to prefix string * @type: Type of information to print ("hash" or "sign") * * fit_image_print_data() lists properties for the processed hash node @@ -52,9 +54,10 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit) * no returned results */ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, - const char *p, const char *type) + const char *type) { const char *keyname, *padding, *algo; + const char *p = ctx->indent; const void *fit = ctx->fit; int value_len, ret, i; uint8_t *value; @@ -103,7 +106,6 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, * fit_image_print_verification_data() - prints out the hash/signature details * @ctx: pointer to FIT print context * @noffset: offset of the hash or signature node - * @p: pointer to prefix string * * This lists properties for the processed hash node * @@ -111,7 +113,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, * no returned results */ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, - int noffset, const char *p) + int noffset) { const void *fit = ctx->fit; const char *name; @@ -123,14 +125,30 @@ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, */ name = fit_get_name(fit, noffset); if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) - fit_image_print_data(ctx, noffset, p, "Hash"); + fit_image_print_data(ctx, noffset, "Hash"); else if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) - fit_image_print_data(ctx, noffset, p, "Sign"); + fit_image_print_data(ctx, noffset, "Sign"); } -void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p) +/** + * fit_image_print - prints out the FIT component image details + * @ctx: pointer to FIT print context + * @image_noffset: offset of the component image node + * @p: pointer to prefix string + * + * fit_image_print() lists all mandatory properties for the processed component + * image. If present, hash nodes are printed out as well. Load + * address for images of type firmware is also printed out. Since the load + * address is not mandatory for firmware images, it will be output as + * "unavailable" when not present. + * + * returns: + * no returned results + */ +void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) { const void *fit = ctx->fit; + const char *p = ctx->indent; uint8_t type, arch, os, comp = IH_COMP_NONE; const char *desc; size_t size; @@ -230,7 +248,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component image node */ - fit_image_print_verification_data(ctx, noffset, p); + fit_image_print_verification_data(ctx, noffset); } } } @@ -239,7 +257,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p * fit_conf_print - prints out the FIT configuration details * @ctx: pointer to FIT print context * @noffset: offset of the configuration node - * @p: pointer to prefix string * * fit_conf_print() lists all mandatory properties for the processed * configuration node. @@ -247,10 +264,10 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p * returns: * no returned results */ -static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, - const char *p) +static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; + const char *p = ctx->indent; const char *uname, *desc; int ret, ndepth, i; @@ -321,7 +338,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component config node */ - fit_image_print_verification_data(ctx, noffset, p); + fit_image_print_verification_data(ctx, noffset); } } } @@ -329,6 +346,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, void fit_print(struct fit_print_ctx *ctx) { const void *fit = ctx->fit; + const char *p = ctx->indent; const char *desc; char *uname; int images_noffset; @@ -337,12 +355,8 @@ void fit_print(struct fit_print_ctx *ctx) int ndepth; int count = 0; int ret; - const char *p; time_t timestamp; - /* Indent string is defined in header image.h */ - p = IMAGE_INDENT_STRING; - /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); printf("%sFIT description: ", p); @@ -381,7 +395,7 @@ void fit_print(struct fit_print_ctx *ctx) printf("%s Image %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_image_print(ctx, noffset, p); + fit_image_print(ctx, noffset); } } @@ -411,7 +425,7 @@ void fit_print(struct fit_print_ctx *ctx) printf("%s Configuration %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_conf_print(ctx, noffset, p); + fit_conf_print(ctx, noffset); } } } @@ -420,6 +434,6 @@ void fit_print_contents(const void *fit) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit); + fit_print_init(&ctx, fit, IMAGE_INDENT_STRING); fit_print(&ctx); } diff --git a/boot/image-fit.c b/boot/image-fit.c index ed77a5e09c5..bb8a96fe39e 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -1557,8 +1557,8 @@ static int print_and_verify(const void *fit, int rd_noffset, int verify) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit); - fit_image_print(&ctx, rd_noffset, " "); + fit_print_init(&ctx, fit, " "); + fit_image_print(&ctx, rd_noffset); if (verify) { puts(" Verifying Hash Integrity ... "); diff --git a/include/image.h b/include/image.h index 9b5a1815df9..7a5ad29a3ec 100644 --- a/include/image.h +++ b/include/image.h @@ -1202,9 +1202,11 @@ int fit_get_subimage_count(const void *fit, int images_noffset); /** * struct fit_print_ctx - context for FIT printing * @fit: pointer to the FIT format image header + * @indent: indentation string for printing */ struct fit_print_ctx { const void *fit; + const char *indent; }; #if CONFIG_IS_ENABLED(FIT_PRINT) @@ -1213,10 +1215,12 @@ struct fit_print_ctx { * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header + * @indent: indentation string for printing * * This inits a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit); +void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent); /** * fit_print() - prints out the contents of the FIT format image @@ -1231,10 +1235,9 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit); void fit_print(struct fit_print_ctx *ctx); /** - * fit_image_print - prints out the FIT component image details + * fit_image_print() - prints out the FIT component image details * @ctx: pointer to FIT print context * @noffset: offset of the component image node - * @p: pointer to prefix string * * fit_image_print() lists all mandatory properties for the processed component * image. If present, hash nodes are printed out as well. Load @@ -1245,7 +1248,7 @@ void fit_print(struct fit_print_ctx *ctx); * returns: * no returned results */ -void fit_image_print(struct fit_print_ctx *ctx, int noffset, const char *p); +void fit_image_print(struct fit_print_ctx *ctx, int noffset); /** * fit_print_contents() - prints out the contents of the FIT format image @@ -1263,11 +1266,12 @@ void fit_print_contents(const void *fit); #else /* !FIT_PRINT */ -static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit) {} -static inline void fit_print(const void *fit) {} -static inline void fit_image_print(const void *fit, int noffset, const char *p) +static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent) { } +static inline void fit_print(const void *fit) {} +static inline void fit_image_print(const void *fit, int noffset) {} static inline void fit_print_contents(const void *fit) {} #endif diff --git a/tools/fit_image.c b/tools/fit_image.c index 017a2d212e9..10815e8f4d3 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -976,8 +976,8 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) printf("Extracted:\n%s Image %u (%s)\n", p, count, fit_get_name(fit, noffset)); - fit_print_init(&ctx, fit); - fit_image_print(&ctx, noffset, p); + fit_print_init(&ctx, fit, p); + fit_image_print(&ctx, noffset); return fit_image_extract(fit, noffset, itl->outfile); From patchwork Thu Nov 20 02:55:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 743 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=1763607431; bh=WSmJ4sUFJR0vwsyHyFgJWMwSYXGFDvztAPnd09wdLOg=; 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=Z3BpbqNoxLPVVIH+mp/zyjpSSGI6JQ5vNLw8poEDkSHN2Og2hUzvH2wMgNOXvXasA yaI565vlolxw3/Oj+WL41iRGbSYu6Jo0/uhA5Xm19McgqEJR7bWyRa+xsb1ipyAClG YICS2g1MluBoDBBx0f0dMegnMC5AMs263LpTRzGuQHLE6+Noq3Vr0Bx3/2GBdMPMEH NPaMd0ISgNBpCGvB0uH0ERZb2IItmdEcmhG3kGJWC6lHjZ+B4PSQRToiv/xYPHbj47 H1B2KsAkAWV9GO0iFgkwPFoQYQb2xRGlDUIX9SieCGFHlJ8r5otI+rCb/Rr8TCZ7oC q1ZQZlmNJCX5w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F2A7B68657 for ; Wed, 19 Nov 2025 19:57:11 -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 hPe0DY3I498R for ; Wed, 19 Nov 2025 19:57:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607431; bh=WSmJ4sUFJR0vwsyHyFgJWMwSYXGFDvztAPnd09wdLOg=; 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=Z3BpbqNoxLPVVIH+mp/zyjpSSGI6JQ5vNLw8poEDkSHN2Og2hUzvH2wMgNOXvXasA yaI565vlolxw3/Oj+WL41iRGbSYu6Jo0/uhA5Xm19McgqEJR7bWyRa+xsb1ipyAClG YICS2g1MluBoDBBx0f0dMegnMC5AMs263LpTRzGuQHLE6+Noq3Vr0Bx3/2GBdMPMEH NPaMd0ISgNBpCGvB0uH0ERZb2IItmdEcmhG3kGJWC6lHjZ+B4PSQRToiv/xYPHbj47 H1B2KsAkAWV9GO0iFgkwPFoQYQb2xRGlDUIX9SieCGFHlJ8r5otI+rCb/Rr8TCZ7oC q1ZQZlmNJCX5w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E02DD5E7DA for ; Wed, 19 Nov 2025 19:57:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=YNjs6Sh16FYqNxOCSBkBDglkAfa9NuRdrPajLMYqDc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TjpB9oDyvE8qNEiw7fUr9f9M2H8tFNr+2SH/OT+x7k++Ren2EJb4+qsf+9/jO3OcQ MYZrXE6ZnCseN1Su3ZSWrHFMbkYY7EfKqwwYeo3XEw4FuiWI9Uo2OA9gZDzun+3Cxw lzZEyyQvLlBJrWUJ96vuOD29d8XmxaTPkgEl1sOlnJTMkc14zltHXxO6eyr50WAPPI V1EMuXlN3R34tIN3brV2oGbUYuoqmtHHElBdvNLpIHvr+m6bTg1AEtBg7/nvXPNU32 0uENWH8pQDozQoZln4ETnqnXvtxYsdoJx+J0nubFC+lCAQM7a25WsYOp/BjfEW8Ab2 lFfNUVrr7ehAg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 665F068657; Wed, 19 Nov 2025 19:57:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 3FZjSWg5Ncez; Wed, 19 Nov 2025 19:57:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607427; bh=3F+7/6J6+L4jF0IkkA+5rutEsYigWc3pN+y1zYnQalw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qp6MODIOt7c1M9428nX1IeHYQ/shJE/IEVY8p007uXzsn3hW/cDsDBJw99TVsxlFD fD9E8Z9+y1Qk8V9j3meB2CDbrcBSs8t7/NRjkWXw3rLTUUic+sF9DFgD7F/WN5A8Mz kmTa+dUX84x86CZPWlVr/Y4DRGVczB1oicoa8j0808CaSncn7MZNwHbqbV+lM5gSu3 LCzvBM0sk0uELJUS+0ZWWT5VnjftMKmHNgOrSiJCb8vojteSQLya6WjWJ+HM8WhzAS e4M6Yq/EmP5A7AJt1kDkGcP0ApWUEvbR1CTc7AbN0VXbli2+YwckHIEruvU+J2M1Ny get4cZrSnQxuw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3AA40686C8; Wed, 19 Nov 2025 19:57:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:51 -0700 Message-ID: <20251120025614.2215587-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J53CYNSLWWYITEX6PKDPVLYTBJ2YTJBU X-Message-ID-Hash: J53CYNSLWWYITEX6PKDPVLYTBJ2YTJBU 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/30] fit: Create some helpers for printing 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 current code is quite fiddly with manually spaced labels. Add helper functions for printing labels (with or without a type prefix) with a cofigurable tab width for the value that folows. Signed-off-by: Simon Glass --- boot/fit_print.c | 42 +++++++++++++++++++++++++++++++++++++++--- include/image.h | 2 ++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 07454dcf5cf..b87526023b4 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -37,6 +37,42 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit, { ctx->fit = fit; ctx->indent = indent; + ctx->tab = 16 + strlen(indent); +} + +/** + * emit_type() - print a label with indentation and padding + * @ctx: pointer to FIT print context + * @type: type prefix (e.g., "Hash" or "Sign") + * @label: label suffix (e.g., "algo" or "value") + * + * Prints the indentation from the context, followed by two spaces, the type, + * a space, the label, a colon, and padding to align values to ctx->tab. + */ +static void emit_type(struct fit_print_ctx *ctx, const char *type, + const char *label) +{ + int len; + + len = printf("%s %s %s:", ctx->indent, type, label); + printf("%*s", ctx->tab - len, ""); +} + +/** + * emit_label() - print a label with indentation and padding + * @ctx: pointer to FIT print context + * @type: type prefix (e.g., "Hash" or "Sign") + * @label: label suffix (e.g., "algo" or "value") + * + * Prints the indentation from the context, followed by two spaces, a space, + * the label, a colon, and padding to align values to ctx->tab. + */ +static void emit_label(struct fit_print_ctx *ctx, const char *label) +{ + int len; + + len = printf("%s %s:", ctx->indent, label); + printf("%*s", ctx->tab - len, ""); } /** @@ -63,7 +99,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, uint8_t *value; debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); - printf("%s %s algo: ", p, type); + emit_type(ctx, type, "algo"); if (fit_image_hash_get_algo(fit, noffset, &algo)) { printf("invalid/unsupported\n"); return; @@ -79,7 +115,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, printf("%s %s padding: %s\n", p, type, padding); ret = fit_image_hash_get_value(fit, noffset, &value, &value_len); - printf("%s %s value: ", p, type); + emit_type(ctx, type, "value"); if (ret) { printf("unavailable\n"); } else { @@ -94,7 +130,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, if (IMAGE_ENABLE_TIMESTAMP && keyname) { time_t timestamp; - printf("%s Timestamp: ", p); + emit_label(ctx, "Timestamp"); if (fit_get_timestamp(fit, noffset, ×tamp)) printf("unavailable\n"); else diff --git a/include/image.h b/include/image.h index 7a5ad29a3ec..d5c3cc03de5 100644 --- a/include/image.h +++ b/include/image.h @@ -1203,10 +1203,12 @@ int fit_get_subimage_count(const void *fit, int images_noffset); * struct fit_print_ctx - context for FIT printing * @fit: pointer to the FIT format image header * @indent: indentation string for printing + * @tab: amount of space to tab out for the label */ struct fit_print_ctx { const void *fit; const char *indent; + int tab; }; #if CONFIG_IS_ENABLED(FIT_PRINT) From patchwork Thu Nov 20 02:55:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 745 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=1763607435; bh=izSKvO2ys9a1RZjxFrslbHfqy6rq8UlULHppaqGGHss=; 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=msNcQXbC5HWQxhtcORys6gY+ELKdStgsMkIhcPkY5pmDYSpGTD5A1LBid+eICnGp5 Kh8UFT/wHpU4WGW+zi4q8lBl20KkJrazXQcK6z3ME8mtZVLoqDt2PmRECOqDogNBcI kORXmMxP2+RrPAi5LTktY7Lp2o58vpxKZnWnbnhCV9jQOLQTPt3ter1SMPdgWwkKMR JD23BIHQHAQy/6Cz52jOrOxAX5WCTXpgef3t6ZxH3slMnQSnnzOMUGv4OWLv4H5500 xe+kI0xr1gxpk0sOGAWtuDRM+LaDoreGHO0g5R+ZNndfrTq61LbqsCT0pvu6BiX0mD HWaA4yXcoWxZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C1C53686C9 for ; Wed, 19 Nov 2025 19:57:15 -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 czYLKDWh6CUC for ; Wed, 19 Nov 2025 19:57:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607433; bh=izSKvO2ys9a1RZjxFrslbHfqy6rq8UlULHppaqGGHss=; 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=SiOMNrL2gTvceHqSz97ZqQRYZfjcXRM21AX5FOYo3LPQVT/J6T22rOL8s1W4Axd6r UocB2OjMy6oXSEPW5Gakdf2orPi0N5iEzh4Vbs334TyVQzyK/vXn3kZ0r2e5thMCym fgFIOs55VwzsApW1lljUZ1yVo9rVJkBu+1G3fNmVheCanEiReEMrbnQrut8Qm8ysJz ENHgnvDGTGBq3bowsbDjZl71kiIMSl2Cm5aR63LvDstsQmvOxQyRwZahL7xvB/OSv3 VVN/cibHslcEyA0Zi5RYpGD3+jNi/mNy991eXTbeoaT5qZVkQ0UDitLju1mUNyOUYy Yt14ce+1cD5ew== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BF23768631 for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=CrfWacoUzTkXu2koLVufn2U0V0cYhT+wW0lmmoX7wW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lf1MBKsf9uMErGXhy1jHHazziuIfW00tkiOl1KAWSgRCyYERAnLLYXvcz7AMD7+Cf AIocge91BnEvHjT9xKLBKnUGrqt74cr7UaL0OG/9edYKisPVk5rJ8Tm0dg02ILgjhF 8zzPIzfvk0uSxDun4uPvBvppiNjzKNiV759trPWo5K46oS32R79bgSLsHCnVGzYfhk hBhHc8vll4KGqfAVZVGqNHxJpzcTUqCU2xTJQYfc74jP5BKTtloM0wPdPcyWRiMWkD 3P/oYktPONZv3QaCuqTb8gxC1EWKpglA+R/1LlZhHzlzQXItoaMAoO+//xERiVHnTo tXwj2zvolWFkg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79DAC5E7DA; Wed, 19 Nov 2025 19:57:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bzk1AWAlB3vY; Wed, 19 Nov 2025 19:57:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607428; bh=cYJXQBHp7t2VvSAhiI8iGGIGhqo5OvGNwyGMkGuea0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rhHeBmRvsX95nNiPVN8m9KL77ZUU/MrP2ydZ78jisx/HsblYdlFHze1jdm+DhhACY W4gpAnQZNHA7EUYKauUTF79Mq09yHYG/bRYJQZL6i9Mz4WNfOAsBWt7EtxOEm7ZGLR 9LtR7MCiispThvUpeyjLkNhhbL24uvY/OoRR7dnq+17lUv0jFGKe3VACqpVPQezRr3 IPYDt7D/2jwtibvy2fZhMVaWEn//5n4y9jFdwXjxvS3YgV8IGRW3TJzCLIGvcuTi8X DLejlutQuNiORdLSMz272y4T+ZjowjgkokCZltqHqGWIsnrdvZZIFaQnjxST3LtmHz rvejqtSyYVz3A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3522468654; Wed, 19 Nov 2025 19:57:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:52 -0700 Message-ID: <20251120025614.2215587-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PCNVE7F2FKV7EBLFNEDVL5KIVRXQJE6M X-Message-ID-Hash: PCNVE7F2FKV7EBLFNEDVL5KIVRXQJE6M 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/30] fit: Use emit_label() helper in fit_image_print() 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 Update fit_image_print() to use the emit_label() helper function for printing labels. This avoids various manual printf() calls and spacing logic. Set ctx->tab to 19 to align values at the correct column position. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index b87526023b4..69139c46931 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -184,7 +184,6 @@ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) { const void *fit = ctx->fit; - const char *p = ctx->indent; uint8_t type, arch, os, comp = IH_COMP_NONE; const char *desc; size_t size; @@ -196,7 +195,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) /* Mandatory properties */ ret = fit_get_desc(fit, image_noffset, &desc); - printf("%s Description: ", p); + emit_label(ctx, "Description"); if (ret) printf("unavailable\n"); else @@ -206,7 +205,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) time_t timestamp; ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%s Created: ", p); + emit_label(ctx, "Created"); if (ret) printf("unavailable\n"); else @@ -214,15 +213,17 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) } fit_image_get_type(fit, image_noffset, &type); - printf("%s Type: %s\n", p, genimg_get_type_name(type)); + emit_label(ctx, "Type"); + printf("%s\n", genimg_get_type_name(type)); fit_image_get_comp(fit, image_noffset, &comp); - printf("%s Compression: %s\n", p, genimg_get_comp_name(comp)); + emit_label(ctx, "Compression"); + printf("%s\n", genimg_get_comp_name(comp)); ret = fit_image_get_data(fit, image_noffset, &data, &size); if (!tools_build()) { - printf("%s Data Start: ", p); + emit_label(ctx, "Data Start"); if (ret) { printf("unavailable\n"); } else { @@ -232,7 +233,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) } } - printf("%s Data Size: ", p); + emit_label(ctx, "Data Size"); if (ret) printf("unavailable\n"); else @@ -243,20 +244,22 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE || type == IH_TYPE_FLATDT) { fit_image_get_arch(fit, image_noffset, &arch); - printf("%s Architecture: %s\n", p, genimg_get_arch_name(arch)); + emit_label(ctx, "Architecture"); + printf("%s\n", genimg_get_arch_name(arch)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE) { fit_image_get_os(fit, image_noffset, &os); - printf("%s OS: %s\n", p, genimg_get_os_name(os)); + emit_label(ctx, "OS"); + printf("%s\n", genimg_get_os_name(os)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_FIRMWARE || type == IH_TYPE_RAMDISK || type == IH_TYPE_FPGA) { ret = fit_image_get_load(fit, image_noffset, &load); - printf("%s Load Address: ", p); + emit_label(ctx, "Load Address"); if (ret) printf("unavailable\n"); else @@ -265,13 +268,15 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) /* optional load address for FDT */ if (type == IH_TYPE_FLATDT && - !fit_image_get_load(fit, image_noffset, &load)) - printf("%s Load Address: 0x%08lx\n", p, load); + !fit_image_get_load(fit, image_noffset, &load)) { + emit_label(ctx, "Load Address"); + printf("0x%08lx\n", load); + } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_RAMDISK) { ret = fit_image_get_entry(fit, image_noffset, &entry); - printf("%s Entry Point: ", p); + emit_label(ctx, "Entry Point"); if (ret) printf("unavailable\n"); else From patchwork Thu Nov 20 02:55:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 746 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=1763607436; bh=GKAs2QfWy7YgcuLiX3hJskYzkYEt/8l2S0CyDm7eQ/I=; 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=O6CUk32B5JOQf8LgXyf1ens+f/lVjcz+fbAjGn0PgsZ9GFKBJnsbj6T2Kdu8onull WpT21ty21/AYVnXjnbJB/8ym4hoD3NhsHl1x5YCQi0oBu6ZbcVAqV2SyqKHmMnMWVX 5Hr3+aMtXzvF40BiEsZczVLemvCOVJaL5kp5p41H5DsUpbUPOldNLBxTCVyepzinwX TIBgg4QqrxI/t5jmzJRP3PJ5h5apzXOdE/na/WphOxOhTOVehMTMzxHBhHi6f9BgKO FgvdavmD05YGIWAZR2QyLUAwGXc3hlRcPKG4kyVdx5GGjPXhEbuebv99LI9PsDHKrE Ynp/YXW3ZUzng== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12D2E686DF for ; Wed, 19 Nov 2025 19:57:16 -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 m-3Txev4jwUu for ; Wed, 19 Nov 2025 19:57:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607434; bh=GKAs2QfWy7YgcuLiX3hJskYzkYEt/8l2S0CyDm7eQ/I=; 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=bVVl4VyOKA5wyL4EAFN9WplwIYEUSItGBIlo750LDGmlhYfPOhaBb4v0ZOmFsYgok +MKanZT85eW8ScGDQDf+5VVLO7m9HpSnBLwYOA7OCCH7fiei2urnhIyQQt5aW28mb2 WW2k/FZF53zUV3R5pfjhW7cxXB33BKaFX9MH1RjaQnXYFjg9XM+up73dgNw7Vt9YtA UOvh7rvcc6Quq0Sw8ONtbASde8hl0V7umaNgyvGEYk/TkmRR2jQsgYFl9WhWdkgk+N YsE1RaJn6UYi870aAmLoMEc17QIwg3y7+luK+LeUQiQLUk2peISNB8R16kt8EKD0Fy nvQWr0KtMrgXw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32147686EE for ; Wed, 19 Nov 2025 19:57:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=cR9T6o848dnPTznc1waeoALBuSoQUvR8lE9yjWdkAG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VBAATZFVqm/B0Whx/+7xy1QvPZySBET69FRm0NBEAoYb5epIVKBTxsfYyr8zts/AG rNrp23xpvqaX9TtJjJHvWpRMNuwmJv+5x1U1I7fYpDywGTEZLd4zMOjV0hRKSXfzld F+Qc1/OJyoNT+J5U25bmGsdE3idalnUZHPCIAJS2UDyHtRhqvU6xuqIpbZUJXbD2HC dV2YG48gl9cH5y6xp8S1dPpodnlU6fQ8A86IppZJz+rGOEACXh+lXbrXZosgaH6Vha b0jLcByIhLhXHIdN17JWe8o0BvWT2O45NUkm86/F6FoiacWAlkfUr+1vXFMtODwEr1 zpe9BkRChLrEQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AFDBC68654; Wed, 19 Nov 2025 19:57:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id LKYkDgTtXphS; Wed, 19 Nov 2025 19:57:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=UTR5L8uq7PlKCdOTxj3zi6TQ8RqEMk2Z7RpHxWTYVbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R7bxeY5vrYFSmiRxvX1UXU634JsU5zW79mDaZv8XsC7Jfhyn7BB5DwRoByvKnVbQ/ 1sQc+vSNlklbwxF99Ue2gNqVJP+XJPGmEQTdoX0YxClLtkOyNJh/q2sLQ8Efs9f6bH PEtAcaWHslpffYWhSlL5FDpVucXrO8pFCGJfbboY6ynqjAzJlS2Y53IN7pbzzkioWr TyD572Sgu3qtU784eOUdHlf+XHuteFscTcZI/+dZnoG5ckbCjrgY5SczEbQckzaYOs TEWGOnso3I1lyb8JCMFOdCnUIkxQnSmNL4E8dH/DGEMJQjA3wcG4fI+3N5KDfDxrHp OSBCA5u0JhYlg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1FC0568614; Wed, 19 Nov 2025 19:57:09 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:53 -0700 Message-ID: <20251120025614.2215587-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AYFTZIJDH7JDF2P5KZ6NO5B4MUOUENWJ X-Message-ID-Hash: AYFTZIJDH7JDF2P5KZ6NO5B4MUOUENWJ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 18/30] fit: Use emit_label() helper in fit_conf_print() 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 Update fit_conf_print() to use the emit_label() helper function for printing labels. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 69139c46931..97dab4b2490 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -312,16 +312,18 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) const char *uname, *desc; int ret, ndepth, i; + ctx->tab = 19; + /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); - printf("%s Description: ", p); + emit_label(ctx, "Description"); if (ret) printf("unavailable\n"); else printf("%s\n", desc); uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); - printf("%s Kernel: ", p); + emit_label(ctx, "Kernel"); if (!uname) printf("unavailable\n"); else @@ -329,27 +331,33 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) /* Optional properties */ uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) - printf("%s Init Ramdisk: %s\n", p, uname); + if (uname) { + emit_label(ctx, "Init Ramdisk"); + printf("%s\n", uname); + } uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) - printf("%s Firmware: %s\n", p, uname); + if (uname) { + emit_label(ctx, "Firmware"); + printf("%s\n", uname); + } for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, i, NULL), uname; i++) { if (!i) - printf("%s FDT: ", p); + emit_label(ctx, "FDT"); else printf("%s ", p); printf("%s\n", uname); } uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) - printf("%s FPGA: %s\n", p, uname); + if (uname) { + emit_label(ctx, "FPGA"); + printf("%s\n", uname); + } /* Print out all of the specified loadables */ for (i = 0; @@ -357,7 +365,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) i, NULL), uname; i++) { if (!i) - printf("%s Loadables: ", p); + emit_label(ctx, "Loadables"); else printf("%s ", p); printf("%s\n", uname); @@ -367,7 +375,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_COMPATIBLE_PROP, i, NULL), uname; i++) { if (!i) - printf("%s Compatible: ", p); + emit_label(ctx, "Compatible"); else printf("%s ", p); printf("%s\n", uname); From patchwork Thu Nov 20 02:55:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 747 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=1763607439; bh=UAQCex6b3rxyXY1CGzYHrixn9M26O0RIy84JOmgkwD0=; 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=TM3+s/e7mKhYr4VZVg/ow7p6S4sNqoIHIbmAHHcMVT8aTklbdBO2k0JGn0tx5pzQC FxSe0pwjxU0U/xvsCk/2fVb84RoK9EOtlflRp8pNRlTmNyOiAPm5koB0lauyKH2B4y u1tgxgboq1skuCisboTvrK3O1orlpA7T7kaOSwD1R3zcR4WTNBaM0hiYevFK0ms3eR Njm2jgHQXZtwHp1xuCz0CRliCZbrF62NEeUlRiK1oVAm7Sfl3R9GTIlc2EVHir0dYA l9hvHBByhO9whVdjzSBMd1A9/PN+h1QijOupq03IIhqKVJfFoCVOZRWFQhWbozHxDg A5vFsUBxDk/FA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE0C168657 for ; Wed, 19 Nov 2025 19:57:19 -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 IIi49QU1kNWv for ; Wed, 19 Nov 2025 19:57:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607439; bh=UAQCex6b3rxyXY1CGzYHrixn9M26O0RIy84JOmgkwD0=; 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=TM3+s/e7mKhYr4VZVg/ow7p6S4sNqoIHIbmAHHcMVT8aTklbdBO2k0JGn0tx5pzQC FxSe0pwjxU0U/xvsCk/2fVb84RoK9EOtlflRp8pNRlTmNyOiAPm5koB0lauyKH2B4y u1tgxgboq1skuCisboTvrK3O1orlpA7T7kaOSwD1R3zcR4WTNBaM0hiYevFK0ms3eR Njm2jgHQXZtwHp1xuCz0CRliCZbrF62NEeUlRiK1oVAm7Sfl3R9GTIlc2EVHir0dYA l9hvHBByhO9whVdjzSBMd1A9/PN+h1QijOupq03IIhqKVJfFoCVOZRWFQhWbozHxDg A5vFsUBxDk/FA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BC066686BB for ; Wed, 19 Nov 2025 19:57:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607438; bh=qEtBrCjDBPg+WrCC6yer/P7eyv9uGWN8A/xBLDc/suc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wlheN6UO++VLvh6MZYyH+ko4z4HvC8GCpeI8YJfWVlvgsxaAkActozEZuZOLM6RP/ Pq3Jr0GWBxDMLC8JEurC4qRc8/yxUWMpzbxOs09zKa5yxefL7nkfq9wfHDe5Hsf39v phknljssLctP5Focbx+wPkyFN8hILOX2+Uce8qmOHDkA0slsa6q+cUM6ETnh6UIZkm 9PAPFLDC9kxT+21sKCi3WR8THtUu45NbmWdsNogt41pDLD9q6BywGXNiH/wHS5NWO4 yHkbblUOavAl1QLRBWcLNz7HHiQHmvOlQqU86HhCFZeiB036RuzrqvU4rqeAm9U8LH xXtMeD4sVLLpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D2FA68631; Wed, 19 Nov 2025 19:57:18 -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 gZHwT50XsUwa; Wed, 19 Nov 2025 19:57:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607430; bh=nTY5s2M+zAhX7ejQT77vkSxrP5hfx1G0qxZsTWRt1Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WsBhc1YCm2fWIOuxgERGqjMjIEWBTeIwZgIeC8wvWLphe/nLGKJWsfDSVkTxO3bSK GEbc79unnL+hcaB0kvl6TB+/GA0C68iDri9do7yJZqelhjVv5da5yxg5mUaxxPBrlI 7SvVxS3PuqPm94CJYjD7NrfbJ9euywiBDIny7A4w9e9wOQgdWw7Oe1FiC2eUoAtVx9 rNHcywk7j4+MUWzOcPQfwz+BzosVV5nP1oinjm7DdA/XaWPiyLV0cXEAyuLuN6Aaux rdjrtnMndR95N4vhr17W0decisGC/F0gEJEaSSA6xAmxp/3j8Qf+e9LrOhoatjxrsz VTeT9Bo/y7JLg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F114268614; Wed, 19 Nov 2025 19:57:09 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:54 -0700 Message-ID: <20251120025614.2215587-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MBZWSMJYK5WXK23UXUXK5Q4TXEUIZRLN X-Message-ID-Hash: MBZWSMJYK5WXK23UXUXK5Q4TXEUIZRLN 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/30] fit: Add a a function to print labels with values 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 Add a new emit_label_val() helper function that combines emit_label() and printf() for simple label-value pairs. Make use of it where appropriate. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 65 ++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 97dab4b2490..3ff53fceded 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -75,6 +75,23 @@ static void emit_label(struct fit_print_ctx *ctx, const char *label) printf("%*s", ctx->tab - len, ""); } +/** + * emit_label_val() - print a label with value + * @ctx: pointer to FIT print context + * @label: label string (e.g., "Type" or "OS") + * @val: value string to print after the label + * + * Prints the indentation, label with padding to ctx->tab, and the value + * followed by a newline. This is a convenience function that combines + * emit_label() and printf() for simple label-value pairs. + */ +static void emit_label_val(struct fit_print_ctx *ctx, const char *label, + const char *val) +{ + emit_label(ctx, label); + printf("%s\n", val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -195,11 +212,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) /* Mandatory properties */ ret = fit_get_desc(fit, image_noffset, &desc); - emit_label(ctx, "Description"); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "Description", ret ? "unavailable" : desc); if (IMAGE_ENABLE_TIMESTAMP) { time_t timestamp; @@ -213,12 +226,10 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) } fit_image_get_type(fit, image_noffset, &type); - emit_label(ctx, "Type"); - printf("%s\n", genimg_get_type_name(type)); + emit_label_val(ctx, "Type", genimg_get_type_name(type)); fit_image_get_comp(fit, image_noffset, &comp); - emit_label(ctx, "Compression"); - printf("%s\n", genimg_get_comp_name(comp)); + emit_label_val(ctx, "Compression", genimg_get_comp_name(comp)); ret = fit_image_get_data(fit, image_noffset, &data, &size); @@ -244,15 +255,13 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE || type == IH_TYPE_FLATDT) { fit_image_get_arch(fit, image_noffset, &arch); - emit_label(ctx, "Architecture"); - printf("%s\n", genimg_get_arch_name(arch)); + emit_label_val(ctx, "Architecture", genimg_get_arch_name(arch)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE) { fit_image_get_os(fit, image_noffset, &os); - emit_label(ctx, "OS"); - printf("%s\n", genimg_get_os_name(os)); + emit_label_val(ctx, "OS", genimg_get_os_name(os)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || @@ -316,31 +325,19 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); - emit_label(ctx, "Description"); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "Description", ret ? "unavailable" : desc); uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); - emit_label(ctx, "Kernel"); - if (!uname) - printf("unavailable\n"); - else - printf("%s\n", uname); + emit_label_val(ctx, "Kernel", uname ?: "unavailable"); /* Optional properties */ uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) { - emit_label(ctx, "Init Ramdisk"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "Init Ramdisk", uname); uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) { - emit_label(ctx, "Firmware"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "Firmware", uname); for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, @@ -354,10 +351,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) } uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) { - emit_label(ctx, "FPGA"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "FPGA", uname); /* Print out all of the specified loadables */ for (i = 0; From patchwork Thu Nov 20 02:55:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 748 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=1763607440; bh=owBDPjczblDlYYPTsrhuA8J11dDOuzsl6CWxe1kt4mI=; 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=oNgeKsOF5F3Tgr/8bK+AOATQ9NKT7rEmDEIMhV+FdYSRecU9uZqBGct1EO16GAnKH EV0ZUhoE9aVEDcwoXaVzun1f3QE0KyZtLsKm0E0vKllrqkX/XPVxOKnWJcOuI3PCW4 0KbMjX1O2OTtmIBabpF2KuZlohczEzYRQJpgWfbEp2eQe8MF5oKqP8xFKBKFzgM96M qL1Ea+yM6IAUUKF/i3rrC3J14Xlp2cPzLzJgCopKlo+/9kReAz4UXMQtGwagB/s2Pj zjIn+/JlVw2URxHEbBRggLLhfVm47HXr+CNopEt0vQA3EKCV7T5Qgc9GmWHtzSxx2m hdHIKasEgB26w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3F9A68657 for ; Wed, 19 Nov 2025 19:57:20 -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 CZUtZ95higb0 for ; Wed, 19 Nov 2025 19:57:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607440; bh=owBDPjczblDlYYPTsrhuA8J11dDOuzsl6CWxe1kt4mI=; 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=oNgeKsOF5F3Tgr/8bK+AOATQ9NKT7rEmDEIMhV+FdYSRecU9uZqBGct1EO16GAnKH EV0ZUhoE9aVEDcwoXaVzun1f3QE0KyZtLsKm0E0vKllrqkX/XPVxOKnWJcOuI3PCW4 0KbMjX1O2OTtmIBabpF2KuZlohczEzYRQJpgWfbEp2eQe8MF5oKqP8xFKBKFzgM96M qL1Ea+yM6IAUUKF/i3rrC3J14Xlp2cPzLzJgCopKlo+/9kReAz4UXMQtGwagB/s2Pj zjIn+/JlVw2URxHEbBRggLLhfVm47HXr+CNopEt0vQA3EKCV7T5Qgc9GmWHtzSxx2m hdHIKasEgB26w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A93F68631 for ; Wed, 19 Nov 2025 19:57:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607439; bh=Q26+RSZyA5DRCKs/aQtvTirUZfMOvYoqpBIKRXiETF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmZVF95zOobFEjpwunejq2jjedZaRMfUMsNBT+E1N1FjYrh/ITy6cX6Dq1aVv/fbo m9+6OslMBy6nCWRfSuYF616KogM5h4BRKTMqzaP7yTr/PE/LriApnmCGoT1UUQnC8o QWJU1KC+4WY1KLsmtD7ZcOrIDsrooB/jYsMfZ1yBWJl7+pB4p9jmNl+tgNn+Gyk0zy MdVQquDJKGTMbh5QGuXBCFaZPddM50Uf+UlfwJHcZLgnCSrDED+NCfsSqsOEqWhMys UidhumGb6r3TwkAk7023EcJpGNQ0atdkhboCJWuDteUJJ6qbNsRL1vLUzzyZ9wrJ+V N0spDDX9R0/bw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1634668614; Wed, 19 Nov 2025 19:57:19 -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 ozvC84CynALT; Wed, 19 Nov 2025 19:57:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607435; bh=kQJ1bPkI8A+og0VJ0gWuUMlTx5Ofbxd/JZJQZST86Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Leo4WmdNnzlqHKIyOBAzkXW7mhsH77KoRU2aXmJj+kK+pbt+STIst/S7/SeZFRno0 mZ5fv7sN7AomgV/HAoegYHADBjfKqh4Jd7LrMT/HFwkCXKUWD7s2IqS3ZZsmmPJQJo rfbT3qrqMz46QJsuBa503j7KkX5NurCy1kzr5GaY1L9uSEWYlW78IwBN3+ssBgNV6R QDgaFWF5j5lR6HIPYu3R+uE01sDA2hsz9w1hVF861gLHL4+vK8QW6DuEm4ok4C/XAr Mlgd0EREI/MJVDMh6J7rwvy/oBzyprJOv/xFQDqY63eYpUZw2W083lZfy1Jb8zrXxY elpyzupE6rnCg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A52A9686BB; Wed, 19 Nov 2025 19:57:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:55 -0700 Message-ID: <20251120025614.2215587-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JUBKO6AQDOUB7O644DTLQPIT2UX7Q4WW X-Message-ID-Hash: JUBKO6AQDOUB7O644DTLQPIT2UX7Q4WW 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 20/30] fit: Change indent from string to int 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 Change the indent field in fit_print_ctx from a string pointer to an int number of spaces to indent. Set the initial indent value to 3 to match IMAGE_INDENT_STRING Drop indentation from the debug() calls since these are not visible to users. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 47 +++++++++++++++++++++++------------------------ boot/image-fit.c | 2 +- include/image.h | 13 ++++++------- tools/fit_image.c | 10 +++++----- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 3ff53fceded..a361ec21b5e 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -28,16 +28,14 @@ * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header - * @indent: indentation string for printing * * This initializes a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit, - const char *indent) +void fit_print_init(struct fit_print_ctx *ctx, const void *fit) { ctx->fit = fit; - ctx->indent = indent; - ctx->tab = 16 + strlen(indent); + ctx->indent = IMAGE_INDENT; + ctx->tab = 16 + IMAGE_INDENT; } /** @@ -54,7 +52,7 @@ static void emit_type(struct fit_print_ctx *ctx, const char *type, { int len; - len = printf("%s %s %s:", ctx->indent, type, label); + len = printf("%*s%s %s:", ctx->indent, "", type, label); printf("%*s", ctx->tab - len, ""); } @@ -71,7 +69,7 @@ static void emit_label(struct fit_print_ctx *ctx, const char *label) { int len; - len = printf("%s %s:", ctx->indent, label); + len = printf("%*s%s:", ctx->indent, "", label); printf("%*s", ctx->tab - len, ""); } @@ -110,12 +108,11 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, const char *type) { const char *keyname, *padding, *algo; - const char *p = ctx->indent; + int p = ctx->indent; const void *fit = ctx->fit; int value_len, ret, i; uint8_t *value; - debug("%s %s node: '%s'\n", p, type, fit_get_name(fit, noffset)); emit_type(ctx, type, "algo"); if (fit_image_hash_get_algo(fit, noffset, &algo)) { printf("invalid/unsupported\n"); @@ -129,7 +126,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, padding = fdt_getprop(fit, noffset, "padding", NULL); if (padding) - printf("%s %s padding: %s\n", p, type, padding); + printf("%*s%s padding: %s\n", p, "", type, padding); ret = fit_image_hash_get_value(fit, noffset, &value, &value_len); emit_type(ctx, type, "value"); @@ -141,7 +138,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, printf("\n"); } - debug("%s %s len: %d\n", p, type, value_len); + debug("%s len: %d\n", type, value_len); /* Signatures have a time stamp */ if (IMAGE_ENABLE_TIMESTAMP && keyname) { @@ -317,12 +314,10 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; - const char *p = ctx->indent; + int p = ctx->indent; const char *uname, *desc; int ret, ndepth, i; - ctx->tab = 19; - /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); emit_label_val(ctx, "Description", ret ? "unavailable" : desc); @@ -346,7 +341,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "FDT"); else - printf("%s ", p); + printf("%*s ", p, ""); printf("%s\n", uname); } @@ -362,7 +357,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "Loadables"); else - printf("%s ", p); + printf("%*s ", p, ""); printf("%s\n", uname); } @@ -372,7 +367,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "Compatible"); else - printf("%s ", p); + printf("%*s ", p, ""); printf("%s\n", uname); } @@ -390,7 +385,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) void fit_print(struct fit_print_ctx *ctx) { const void *fit = ctx->fit; - const char *p = ctx->indent; + int p = ctx->indent; const char *desc; char *uname; int images_noffset; @@ -403,7 +398,7 @@ void fit_print(struct fit_print_ctx *ctx) /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); - printf("%sFIT description: ", p); + printf("%*sFIT description: ", p, ""); if (ret) printf("unavailable\n"); else @@ -411,7 +406,7 @@ void fit_print(struct fit_print_ctx *ctx) if (IMAGE_ENABLE_TIMESTAMP) { ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%sCreated: ", p); + printf("%*sCreated: ", p, ""); if (ret) printf("unavailable\n"); else @@ -436,10 +431,12 @@ void fit_print(struct fit_print_ctx *ctx) * Direct child node of the images parent node, * i.e. component image node. */ - printf("%s Image %u (%s)\n", p, count++, + printf("%*s Image %u (%s)\n", p, "", count++, fit_get_name(fit, noffset)); + ctx->indent += 2; fit_image_print(ctx, noffset); + ctx->indent -= 2; } } @@ -454,7 +451,7 @@ void fit_print(struct fit_print_ctx *ctx) /* get default configuration unit name from default property */ uname = (char *)fdt_getprop(fit, noffset, FIT_DEFAULT_PROP, NULL); if (uname) - printf("%s Default Configuration: '%s'\n", p, uname); + printf("%*s Default Configuration: '%s'\n", p, "", uname); /* Process its subnodes, print out configurations details */ for (ndepth = 0, count = 0, @@ -466,10 +463,12 @@ void fit_print(struct fit_print_ctx *ctx) * Direct child node of the configurations parent node, * i.e. configuration node. */ - printf("%s Configuration %u (%s)\n", p, count++, + printf("%*s Configuration %u (%s)\n", p, "", count++, fit_get_name(fit, noffset)); + ctx->indent += 2; fit_conf_print(ctx, noffset); + ctx->indent -= 2; } } } @@ -478,6 +477,6 @@ void fit_print_contents(const void *fit) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit, IMAGE_INDENT_STRING); + fit_print_init(&ctx, fit); fit_print(&ctx); } diff --git a/boot/image-fit.c b/boot/image-fit.c index bb8a96fe39e..defe45b1df0 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -1557,7 +1557,7 @@ static int print_and_verify(const void *fit, int rd_noffset, int verify) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit, " "); + fit_print_init(&ctx, fit); fit_image_print(&ctx, rd_noffset); if (verify) { diff --git a/include/image.h b/include/image.h index d5c3cc03de5..476f35128f4 100644 --- a/include/image.h +++ b/include/image.h @@ -26,6 +26,7 @@ struct fdt_region; #include #include +#define IMAGE_INDENT 0 #define IMAGE_INDENT_STRING "" #define BIT(nr) (1UL << (nr)) @@ -37,6 +38,7 @@ struct fdt_region; #include #include +#define IMAGE_INDENT 3 #define IMAGE_INDENT_STRING " " #endif /* USE_HOSTCC */ @@ -1202,12 +1204,12 @@ int fit_get_subimage_count(const void *fit, int images_noffset); /** * struct fit_print_ctx - context for FIT printing * @fit: pointer to the FIT format image header - * @indent: indentation string for printing + * @indent: indentation level for printing * @tab: amount of space to tab out for the label */ struct fit_print_ctx { const void *fit; - const char *indent; + int indent; int tab; }; @@ -1217,12 +1219,10 @@ struct fit_print_ctx { * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header - * @indent: indentation string for printing * * This inits a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit, - const char *indent); +void fit_print_init(struct fit_print_ctx *ctx, const void *fit); /** * fit_print() - prints out the contents of the FIT format image @@ -1268,8 +1268,7 @@ void fit_print_contents(const void *fit); #else /* !FIT_PRINT */ -static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit, - const char *indent) +static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit) { } static inline void fit_print(const void *fit) {} diff --git a/tools/fit_image.c b/tools/fit_image.c index 10815e8f4d3..2e08b68d479 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -940,10 +940,10 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) int ndepth; const void *fit = ptr; int count = 0; - const char *p; + int p; - /* Indent string is defined in header image.h */ - p = IMAGE_INDENT_STRING; + /* Indent value is defined in header image.h */ + p = 5; /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); @@ -973,10 +973,10 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) if (itl->pflag == count) { struct fit_print_ctx ctx; - printf("Extracted:\n%s Image %u (%s)\n", p, + printf("Extracted:\n%*s Image %u (%s)\n", p, "", count, fit_get_name(fit, noffset)); - fit_print_init(&ctx, fit, p); + fit_print_init(&ctx, fit); fit_image_print(&ctx, noffset); return fit_image_extract(fit, noffset, From patchwork Thu Nov 20 02:55:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 749 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=1763607442; bh=CAb3amw03lzCaAhHZz+sI3r8HLM6iBLhpykCoytKNQQ=; 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=WYqS8F7ptYXznEEZk8GQuFfvwBdlQY2GAPPEt8XvgFOToPvKt0Hsv2Qdae02D6phn EBRLxVIoBtDQ002K9lZ1+vG/GKlOnvwZ+r+dDU0c1GGgp3rhOl6xZWMcJg3YKd/Jmy Mtb0xgcg+9HBu6kEeWgHlWeA2Td+PBdPyjKDdf2MjrwzwPoNxpsua9DqT9XGXZN5tf MjGbEyY/AQCtGgyp+aSX04TPnb7P+YhxTAM4zdolMQSohN2jLgtkUP8JqkSbINLKSp 7NeBHsYuWVdcxNH8Bg0xqr0p8TKxvtEjpWVCGuuq+S+Ueq9XAiArcTLhFMBylHB4tL 5WaSjae3tSpdw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 38968686D8 for ; Wed, 19 Nov 2025 19:57:22 -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 yjJ8pEQX7fIG for ; Wed, 19 Nov 2025 19:57:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607442; bh=CAb3amw03lzCaAhHZz+sI3r8HLM6iBLhpykCoytKNQQ=; 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=WYqS8F7ptYXznEEZk8GQuFfvwBdlQY2GAPPEt8XvgFOToPvKt0Hsv2Qdae02D6phn EBRLxVIoBtDQ002K9lZ1+vG/GKlOnvwZ+r+dDU0c1GGgp3rhOl6xZWMcJg3YKd/Jmy Mtb0xgcg+9HBu6kEeWgHlWeA2Td+PBdPyjKDdf2MjrwzwPoNxpsua9DqT9XGXZN5tf MjGbEyY/AQCtGgyp+aSX04TPnb7P+YhxTAM4zdolMQSohN2jLgtkUP8JqkSbINLKSp 7NeBHsYuWVdcxNH8Bg0xqr0p8TKxvtEjpWVCGuuq+S+Ueq9XAiArcTLhFMBylHB4tL 5WaSjae3tSpdw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17C8368654 for ; Wed, 19 Nov 2025 19:57:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607440; bh=9ev/LZ956IGYym5uV7ZM5l8yrPhUYUdzH35xXWwnVOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+A4+keFLfrWjF0QmoZQapqx4fALRhuUX22k3qorJGPqHykFMF3yIE0oducxGQT2Y 9DwG9SFW3QwXIOIPg+8oQP6BYO1OS/b0/HbXvIWRRWHqp4lQ150VhJ4msZbYRcesEZ a1qaOj4Kv5fVeuw84dTvcvlpqcJI84wJCUmdO6N6Qy/EPYL7mlZfkRtz94YjSb0Jdp YI9DrxlAyuEw8eU6VkZqbFZx3LL97B/xTDwTS+fS/i6vf+66z8Le4nGxkrqi4g9cz/ TO9f55TtJ0H53PP3SoMe+C0cSXFa8zvlnKkO1u+Pd9S4G2dF/7bq2iuRawFfKuDVwo 6O33jecUvUdMA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC0EB686E6; Wed, 19 Nov 2025 19:57:20 -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 3WY2dAe7DFAZ; Wed, 19 Nov 2025 19:57:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607439; bh=1PshieXYdY/nGqjwoxATQ3x5ABYDa48LAbQUfA4lteI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l6aHVQi833HHYMG/ep/eIbIBFHpNnQl5TDspacmPhtcMCe00egcjTs4Tu/zS4UhNT WwYzJPFwDZcgKYQMkzh3veqyf57DPrzR6QVNzDrQBr10QZhN9AxyoCxfKxJ7qRa2Y0 zOGzhil06wUX+9PUUQv25pVKHTEHr1S0vKZ8sscAu8bZfefqVWK/pIesEh+som1/iC D7qa8GbnaXKH8EYInWGGI+si1gwfR7rFH7MUUMxMy/YRKF3alln/Sl2GIQDTQN+a2o qqN1HIG25tQ59YLB4MBN3aHj8Q/NfWISt3UzqAbkQnEqEiW4K8khVmSYKNtbAGXe0t AcwtzrSTR7Ihg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5574368654; Wed, 19 Nov 2025 19:57:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:56 -0700 Message-ID: <20251120025614.2215587-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DM6RO3V2HKYAEJC3VOTES3AHFA2O2UOB X-Message-ID-Hash: DM6RO3V2HKYAEJC3VOTES3AHFA2O2UOB 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 21/30] fit: Move values one column to the right 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 Line up the values witht the FIT Description and Created items at the top. This looks a little nicer. Signed-off-by: Simon Glass --- boot/fit_print.c | 11 +- test/boot/fit_print.c | 202 ++++++++++++++++---------------- test/py/tests/test_fit_print.py | 186 ++++++++++++++--------------- 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index a361ec21b5e..e26f2294229 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -35,7 +35,7 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit) { ctx->fit = fit; ctx->indent = IMAGE_INDENT; - ctx->tab = 16 + IMAGE_INDENT; + ctx->tab = 17 + IMAGE_INDENT; } /** @@ -113,6 +113,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, int value_len, ret, i; uint8_t *value; + debug("%s node: '%s'\n", type, fit_get_name(fit, noffset)); emit_type(ctx, type, "algo"); if (fit_image_hash_get_algo(fit, noffset, &algo)) { printf("invalid/unsupported\n"); @@ -126,7 +127,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, padding = fdt_getprop(fit, noffset, "padding", NULL); if (padding) - printf("%*s%s padding: %s\n", p, "", type, padding); + printf("%*s%s padding: %s\n", p, "", type, padding); ret = fit_image_hash_get_value(fit, noffset, &value, &value_len); emit_type(ctx, type, "value"); @@ -341,7 +342,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "FDT"); else - printf("%*s ", p, ""); + printf("%*s ", p, ""); printf("%s\n", uname); } @@ -357,7 +358,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "Loadables"); else - printf("%*s ", p, ""); + printf("%*s ", p, ""); printf("%s\n", uname); } @@ -367,7 +368,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) if (!i) emit_label(ctx, "Compatible"); else - printf("%*s ", p, ""); + printf("%*s ", p, ""); printf("%s\n", uname); } diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 8e8d81e7f6b..3b105045667 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -39,118 +39,118 @@ static int test_fit_print_norun(struct unit_test_state *uts) ut_assert_nextline(" FIT description: Test FIT image for printing"); ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Image 0 (kernel)"); - ut_assert_nextline(" Description: Test kernel"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Kernel Image"); - ut_assert_nextline(" Compression: gzip compressed"); - ut_assert_nextline(" Data Start: 0x000100c4"); - ut_assert_nextline(" Data Size: 327 Bytes = 327 Bytes"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" OS: Linux"); - ut_assert_nextline(" Load Address: 0x01000000"); - ut_assert_nextline(" Entry Point: 0x01000000"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee"); + ut_assert_nextline(" Description: Test kernel"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Kernel Image"); + ut_assert_nextline(" Compression: gzip compressed"); + ut_assert_nextline(" Data Start: 0x000100c4"); + ut_assert_nextline(" Data Size: 327 Bytes = 327 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Linux"); + ut_assert_nextline(" Load Address: 0x01000000"); + ut_assert_nextline(" Entry Point: 0x01000000"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee"); ut_assert_nextline(" Image 1 (ramdisk)"); - ut_assert_nextline(" Description: Test ramdisk"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: RAMDisk Image"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x00010304"); - ut_assert_nextline(" Data Size: 301 Bytes = 301 Bytes"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" OS: Linux"); - ut_assert_nextline(" Load Address: 0x02000000"); - ut_assert_nextline(" Entry Point: unavailable"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655"); + ut_assert_nextline(" Description: Test ramdisk"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: RAMDisk Image"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x00010304"); + ut_assert_nextline(" Data Size: 301 Bytes = 301 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Linux"); + ut_assert_nextline(" Load Address: 0x02000000"); + ut_assert_nextline(" Entry Point: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655"); ut_assert_nextline(" Image 2 (fdt-1)"); - ut_assert_nextline(" Description: Test FDT 1"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Flat Device Tree"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x00010518"); - ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb"); + ut_assert_nextline(" Description: Test FDT 1"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Flat Device Tree"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x00010518"); + ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb"); ut_assert_nextline(" Image 3 (fdt-2)"); - ut_assert_nextline(" Description: Test FDT 2"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Flat Device Tree"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x0001067c"); - ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4"); + ut_assert_nextline(" Description: Test FDT 2"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Flat Device Tree"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x0001067c"); + ut_assert_nextline(" Data Size: 161 Bytes = 161 Bytes"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4"); ut_assert_nextline(" Image 4 (firmware-1)"); - ut_assert_nextline(" Description: Test Firmware 1"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Firmware"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x000107e8"); - ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" OS: Unknown OS"); - ut_assert_nextline(" Load Address: unavailable"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414"); + ut_assert_nextline(" Description: Test Firmware 1"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000107e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414"); ut_assert_nextline(" Image 5 (firmware-2)"); - ut_assert_nextline(" Description: Test Firmware 2"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Firmware"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x000117e8"); - ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); - ut_assert_nextline(" Architecture: Sandbox"); - ut_assert_nextline(" OS: Unknown OS"); - ut_assert_nextline(" Load Address: unavailable"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1"); + ut_assert_nextline(" Description: Test Firmware 2"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000117e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1"); ut_assert_nextline(" Image 6 (fpga)"); - ut_assert_nextline(" Description: Test FPGA"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: FPGA Image"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x000127e0"); - ut_assert_nextline(" Data Size: 4291 Bytes = 4.2 KiB"); - ut_assert_nextline(" Load Address: unavailable"); - ut_assert_nextline(" Hash algo: sha256"); - ut_assert_nextline(" Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622"); + ut_assert_nextline(" Description: Test FPGA"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: FPGA Image"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000127e0"); + ut_assert_nextline(" Data Size: 4291 Bytes = 4.2 KiB"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622"); ut_assert_nextline(" Image 7 (script)"); - ut_assert_nextline(" Description: unavailable"); - ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); - ut_assert_nextline(" Type: Script"); - ut_assert_nextline(" Compression: uncompressed"); - ut_assert_nextline(" Data Start: 0x0001394c"); - ut_assert_nextline(" Data Size: 3791 Bytes = 3.7 KiB"); - ut_assert_nextline(" Hash algo: invalid/unsupported"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Script"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x0001394c"); + ut_assert_nextline(" Data Size: 3791 Bytes = 3.7 KiB"); + ut_assert_nextline(" Hash algo: invalid/unsupported"); ut_assert_nextline(" Default Configuration: 'conf-1'"); ut_assert_nextline(" Configuration 0 (conf-1)"); - ut_assert_nextline(" Description: Test configuration"); - ut_assert_nextline(" Kernel: kernel"); - ut_assert_nextline(" Init Ramdisk: ramdisk"); - ut_assert_nextline(" FDT: fdt-1"); - ut_assert_nextline(" Compatible: vendor,board-1.0"); - ut_assert_nextline(" vendor,board"); - ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); - ut_assert_nextline(" Sign padding: pkcs-1.5"); - ut_assert_nextlinen(" Sign value: c20f64d9bf79ddb0b1a6"); - ut_assert_nextline(" Timestamp: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Description: Test configuration"); + ut_assert_nextline(" Kernel: kernel"); + ut_assert_nextline(" Init Ramdisk: ramdisk"); + ut_assert_nextline(" FDT: fdt-1"); + ut_assert_nextline(" Compatible: vendor,board-1.0"); + ut_assert_nextline(" vendor,board"); + ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); + ut_assert_nextline(" Sign padding: pkcs-1.5"); + ut_assert_nextlinen(" Sign value: c20f64d9bf79ddb0b1a6"); + ut_assert_nextline(" Timestamp: 2009-02-13 23:31:30 UTC"); ut_assert_nextline(" Configuration 1 (conf-2)"); - ut_assert_nextline(" Description: Alternate configuration"); - ut_assert_nextline(" Kernel: kernel"); - ut_assert_nextline(" FDT: fdt-1"); - ut_assert_nextline(" fdt-2"); - ut_assert_nextline(" FPGA: fpga"); - ut_assert_nextline(" Loadables: firmware-1"); - ut_assert_nextline(" firmware-2"); - ut_assert_nextline(" Compatible: vendor,board-2.0"); + ut_assert_nextline(" Description: Alternate configuration"); + ut_assert_nextline(" Kernel: kernel"); + ut_assert_nextline(" FDT: fdt-1"); + ut_assert_nextline(" fdt-2"); + ut_assert_nextline(" FPGA: fpga"); + ut_assert_nextline(" Loadables: firmware-1"); + ut_assert_nextline(" firmware-2"); + ut_assert_nextline(" Compatible: vendor,board-2.0"); ut_assert_nextline(" Configuration 2 (conf-3)"); - ut_assert_nextline(" Description: unavailable"); - ut_assert_nextline(" Kernel: unavailable"); - ut_assert_nextline(" Loadables: script"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Kernel: unavailable"); + ut_assert_nextline(" Loadables: script"); ut_assert_console_end(); os_free(buf); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 180467fba72..d8b034e9ce9 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -318,110 +318,110 @@ def test_fit_print_mkimage(ubman): FIT description: Test FIT image for printing Created: {timestamp_str} Image 0 (kernel) - Description: Test kernel - Created: {timestamp_str} - Type: Kernel Image - Compression: gzip compressed - Data Size: 327 Bytes = 0.32 KiB = 0.00 MiB - Architecture: Sandbox - OS: Linux - Load Address: 0x01000000 - Entry Point: 0x01000000 - Hash algo: sha256 - Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee + Description: Test kernel + Created: {timestamp_str} + Type: Kernel Image + Compression: gzip compressed + Data Size: 327 Bytes = 0.32 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x01000000 + Entry Point: 0x01000000 + Hash algo: sha256 + Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee Image 1 (ramdisk) - Description: Test ramdisk - Created: {timestamp_str} - Type: RAMDisk Image - Compression: uncompressed - Data Size: 301 Bytes = 0.29 KiB = 0.00 MiB - Architecture: Sandbox - OS: Linux - Load Address: 0x02000000 - Entry Point: unavailable - Hash algo: sha256 - Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655 + Description: Test ramdisk + Created: {timestamp_str} + Type: RAMDisk Image + Compression: uncompressed + Data Size: 301 Bytes = 0.29 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x02000000 + Entry Point: unavailable + Hash algo: sha256 + Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655 Image 2 (fdt-1) - Description: Test FDT 1 - Created: {timestamp_str} - Type: Flat Device Tree - Compression: uncompressed - Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB - Architecture: Sandbox - Hash algo: sha256 - Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb + Description: Test FDT 1 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb Image 3 (fdt-2) - Description: Test FDT 2 - Created: {timestamp_str} - Type: Flat Device Tree - Compression: uncompressed - Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB - Architecture: Sandbox - Hash algo: sha256 - Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4 + Description: Test FDT 2 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4 Image 4 (firmware-1) - Description: Test Firmware 1 - Created: {timestamp_str} - Type: Firmware - Compression: uncompressed - Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB - Architecture: Sandbox - OS: Unknown OS - Load Address: unavailable - Hash algo: sha256 - Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414 + Description: Test Firmware 1 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414 Image 5 (firmware-2) - Description: Test Firmware 2 - Created: {timestamp_str} - Type: Firmware - Compression: uncompressed - Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB - Architecture: Sandbox - OS: Unknown OS - Load Address: unavailable - Hash algo: sha256 - Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1 + Description: Test Firmware 2 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1 Image 6 (fpga) - Description: Test FPGA - Created: {timestamp_str} - Type: FPGA Image - Compression: uncompressed - Data Size: 4291 Bytes = 4.19 KiB = 0.00 MiB - Load Address: unavailable - Hash algo: sha256 - Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622 + Description: Test FPGA + Created: {timestamp_str} + Type: FPGA Image + Compression: uncompressed + Data Size: 4291 Bytes = 4.19 KiB = 0.00 MiB + Load Address: unavailable + Hash algo: sha256 + Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622 Image 7 (script) - Description: unavailable - Created: {timestamp_str} - Type: Script - Compression: uncompressed - Data Size: 3791 Bytes = 3.70 KiB = 0.00 MiB - Hash algo: invalid/unsupported + Description: unavailable + Created: {timestamp_str} + Type: Script + Compression: uncompressed + Data Size: 3791 Bytes = 3.70 KiB = 0.00 MiB + Hash algo: invalid/unsupported Default Configuration: 'conf-1' Configuration 0 (conf-1) - Description: Test configuration - Kernel: kernel - Init Ramdisk: ramdisk - FDT: fdt-1 - Compatible: vendor,board-1.0 - vendor,board - Sign algo: sha256,rsa2048:test-key - Sign padding: pkcs-1.5 - Sign value: c20f64d9bf79ddb0b1a69293b2375ad88e70536684705a9577f2156e6da4df6d - Timestamp: {timestamp_str} + Description: Test configuration + Kernel: kernel + Init Ramdisk: ramdisk + FDT: fdt-1 + Compatible: vendor,board-1.0 + vendor,board + Sign algo: sha256,rsa2048:test-key + Sign padding: pkcs-1.5 + Sign value: c20f64d9bf79ddb0b1a69293b2375ad88e70536684705a9577f2156e6da4df6d + Timestamp: {timestamp_str} Configuration 1 (conf-2) - Description: Alternate configuration - Kernel: kernel - FDT: fdt-1 - fdt-2 - FPGA: fpga - Loadables: firmware-1 - firmware-2 - Compatible: vendor,board-2.0 + Description: Alternate configuration + Kernel: kernel + FDT: fdt-1 + fdt-2 + FPGA: fpga + Loadables: firmware-1 + firmware-2 + Compatible: vendor,board-2.0 Configuration 2 (conf-3) - Description: unavailable - Kernel: unavailable - Loadables: script + Description: unavailable + Kernel: unavailable + Loadables: script '''.strip().split('\n') lines = output.split('\n') From patchwork Thu Nov 20 02:55:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 750 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=1763607447; bh=/lIM/w1o/LZ4WJq7NuRq1sZp4LWh1G7oOXgtNjvwUcY=; 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=JaeQR1uxMIFnb51vE9R70D7ve/SCMGlCSPjV9wHAO00tDLHOwGnknmxH0LbUITBbW 0lSehhHO64ymLFUFKVB4KaGS2RDT+UntR7EjZ9PSzY/NdoYk6uS4i2CY8gpWEP0m+5 si9eAhm5aOgUObnkXyU1B/pWqkMSTFPjVqm6b8ctZQUJicNmvFkEIrSYzXxwy9kZcj POhWtuMmwrC3Hb/6ktVdXR9t96C67a9BN3IVATbZ00+BjN76bAimW8roJbWNpq02VT Ut/2wMY/s5khAAeAFysT8Wtk/xJJBTGC0DF3MWkwj5w7MBx+nhPt44c8ydNLtkxu6d o494TdE/gvMrg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FE4F686C9 for ; Wed, 19 Nov 2025 19:57:27 -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 Bae-8yfB-YkG for ; Wed, 19 Nov 2025 19:57:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607447; bh=/lIM/w1o/LZ4WJq7NuRq1sZp4LWh1G7oOXgtNjvwUcY=; 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=JaeQR1uxMIFnb51vE9R70D7ve/SCMGlCSPjV9wHAO00tDLHOwGnknmxH0LbUITBbW 0lSehhHO64ymLFUFKVB4KaGS2RDT+UntR7EjZ9PSzY/NdoYk6uS4i2CY8gpWEP0m+5 si9eAhm5aOgUObnkXyU1B/pWqkMSTFPjVqm6b8ctZQUJicNmvFkEIrSYzXxwy9kZcj POhWtuMmwrC3Hb/6ktVdXR9t96C67a9BN3IVATbZ00+BjN76bAimW8roJbWNpq02VT Ut/2wMY/s5khAAeAFysT8Wtk/xJJBTGC0DF3MWkwj5w7MBx+nhPt44c8ydNLtkxu6d o494TdE/gvMrg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7FDF4686B2 for ; Wed, 19 Nov 2025 19:57:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607445; bh=Vi6Ckc2O0bNhBckO63BI6IXyG1bHC1qDYclgpugt68o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nTVtUedRvUMM7N1cZt7d8ZIrJYWV0wv+OWX3LhcdFA+HCW87aZe3mhKOGP5ILLNjS /m9/Re9q6iXfgrYlC6qWDmctF9su+AD1R2KaZUCacP6tU7qZSiANUewtEftGYu/box M172Twm4e6RlQydhPfWgm8zqGoeiMqkloL7fAjmKWG6vtn7ndTr14aO5a9+P9Kd7bP 2oRq0VaSOjPTlrZAH5JSc8xrNW5E4PI8ypJVLOjlU/1FJgWDkMmv7sg8kkqFQ/56LA E5h482xQ3LobhEq/l2iYOCxghuUi+gmyqUT7XSlrzeGA1+bpkNwZqRz129s9Ip+YaN isZuZZXxoVf5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51F295E7DA; Wed, 19 Nov 2025 19:57:25 -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 bW9dhICQM0tG; Wed, 19 Nov 2025 19:57:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607441; bh=dtgTJ5M7oSFsRUtB9DXf4LJDI9Chrxo98XPEzzlHr0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WARuvuN2GsbT/+iwHt5q+B95qT6YSamC2Yr0yU3aW78y4g/XsY4AovP07lqW0FdOQ RaBjlWB723VjEmnkDlEbCyQQEdXwBUXH9QHKtP39Axl/J1HJmR3D6BbwM8hLjemAPX +M6H60S3XPWcPnqy/zpBg999hVm1iK9RUh6vVW92JeVsMeEvsIGGHjr8jI3zXYCv5e uFRTgZgNGrRLRHlxayhRjQo5rT4ASlOVPj0truQVSdg6vrAC7tYgP34VtHXuvsRRSU aQQjX2ChIBzLKrpLiEG4fLZHAKVKQJfuUUOEypr6vXMHj5JBcGrqluMHrOizzxrX5p 7xee5B+5P9/SA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EFF59686ED; Wed, 19 Nov 2025 19:57:20 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:57 -0700 Message-ID: <20251120025614.2215587-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WI2OXR6OYQCYUM2RCJYFDYP3MEWJFOZU X-Message-ID-Hash: WI2OXR6OYQCYUM2RCJYFDYP3MEWJFOZU 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 22/30] fit: Use emit_label_val() where possible 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 Refactor the printing of multi-line properties to use the emit_label_val() helper function instead of custom formatting. Update emit_label() to deal with an empty label and not show a colon in that case. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index e26f2294229..628d6108bea 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -69,7 +69,7 @@ static void emit_label(struct fit_print_ctx *ctx, const char *label) { int len; - len = printf("%*s%s:", ctx->indent, "", label); + len = printf("%*s%s%c", ctx->indent, "", label, *label ? ':' : ' '); printf("%*s", ctx->tab - len, ""); } @@ -315,7 +315,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; - int p = ctx->indent; const char *uname, *desc; int ret, ndepth, i; @@ -338,13 +337,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, i, NULL), uname; - i++) { - if (!i) - emit_label(ctx, "FDT"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + i++) + emit_label_val(ctx, i ? "" : "FDT", uname); uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); if (uname) @@ -354,23 +348,13 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, i, NULL), uname; - i++) { - if (!i) - emit_label(ctx, "Loadables"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + i++) + emit_label_val(ctx, i ? "" : "Loadables", uname); /* Show the list of compatible strings */ for (i = 0; uname = fdt_stringlist_get(fit, noffset, - FIT_COMPATIBLE_PROP, i, NULL), uname; i++) { - if (!i) - emit_label(ctx, "Compatible"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + FIT_COMPATIBLE_PROP, i, NULL), uname; i++) + emit_label_val(ctx, i ? "" : "Compatible", uname); /* Process all hash subnodes of the component configuration node */ for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); @@ -399,11 +383,7 @@ void fit_print(struct fit_print_ctx *ctx) /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); - printf("%*sFIT description: ", p, ""); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); if (IMAGE_ENABLE_TIMESTAMP) { ret = fit_get_timestamp(fit, 0, ×tamp); From patchwork Thu Nov 20 02:55:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 751 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=1763607449; bh=0zCXeSet7Qd3ezMEUnS13HpIb4rvtzrNDpKEOALNj2Y=; 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=a0cNvU3oCkw/7w6z1esT+LFmH2Kkp+1tgbvSy6UqLk6BkgQxc99P+FatbkUte2S3m lifeUX2/9K3vHUgMqRhk3YEsLd5A2oTfqBWSVsA1Lae5NjL5hVuHL8hKG6FxetU1sj BMOrVOQ0QZsXU0AMXG63WwS1SgYcK+XT0uoYWU+45mb54QcPSV4FCCBhga+Q9fhbGU GbvUh57QIaQxkJ5Ud48GuKc1Z7Xa52bBgdC0JMLDuzV1VPGV2qBfX3vUNs+1vFA8Zm LRvuYZXRS/yIlcsrV7TdOrbnOprFECFU01pMZELDFhqeERTfA55Dowef8hpUvVOeRS 1ss2b79sek3FQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F2E2F686F0 for ; Wed, 19 Nov 2025 19:57:29 -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 wICDm6mI2I0c for ; Wed, 19 Nov 2025 19:57:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607448; bh=0zCXeSet7Qd3ezMEUnS13HpIb4rvtzrNDpKEOALNj2Y=; 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=vS5Og3s8uxFn2/QzZl85CUVxJs0uiJ6eo7seAMYYWWFKnuWnt3UYtXWi7jrMAU1nb VFwys237wc4s3Yw8+t1FNIE0BHdwz25G9gtoE98gYivz2jCpv6D+AEIjCqrxxflpt3 64lnER6q9GEzQNgQfw/DhBt9wZ87QjmhmXEffXggA9JMc9WC7kTtPPGYRFIRrXpeSp 34LBK3ir4zcpRE+x/H36mk+N/GWS3HWhFL1yx2lG3LVe0iK7la/ydb9f6UKSoJTc0i dPUYcAtER1K06sYCAoT1DxYB7o2EiUuJGCJPvZddXrCmEgx47XMtdgROPhZ2y0CpBK E26DKts/EvHoA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED532686B2 for ; Wed, 19 Nov 2025 19:57:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=ogUyJYDWjFTRHfZ6ncxYUucQp05RLJ1F/yFL08EEJ+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7e7dRCqswVvI6zeMvm+5oSSlyT0WflIuiyBBs8G83oVlh1DKdq5o6iWZwEyLcUnP QRYJlBAtKpenJroScgrDM0H+GmRAm4hsxoTm6bnZn+y3sWwmUszvY4urNtiT1IFGc4 1bCT7r73w+lmWg8cxETxFh76zI207PXp0sxxDN/qwkqv9C6lilsghSi2rZ2FXcuYzI DHvrQIaeQcG9sL/XVNzH7AY3JGIM5EMIE/7dGFUNQKB57OzZ3LN2QPG+Fpsz0BmKF5 EPPlIrBatlQcCvAi1ZoepfwbIHvFDcGMyV8Yj5YJblA+Liz8CVBXEuKbouTR8sFMB8 5U1y8tUWEcv4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C43B68668; Wed, 19 Nov 2025 19:57:26 -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 pjivDWzwyNsg; Wed, 19 Nov 2025 19:57:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=FWAcEd6obvuFeFbtISbIMov3azs2Sx95gkwJHl1ZTdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Am1nrTE26zvRcnv6kzy905WD3iTK4J2J20pPWrZi76XjVnwT0nFkz0XKjVX5+UMAt DFCURVoqKyP4BSYrhnm0ml1x5qqJUnh9Pnbzvx5KDvks+0mdjtVZBiwPY17FYi6K25 Wu/zXfP7TJI7gCCJOBOpEVd39t6ipghAfn0V2Ey3VWuvYBE1BVtjJo7/D4xEXC0Odl gXI0q16/bR1qO5rsx/UV1R9BgiROI6coTa6fiCsEm6mr03OPnagia/X0z3YYbbkvQI p3nVYKL5ak/hJHqlTEAdXB0CkH42eZqQgHqS5+Qe4dtws43ZHjftrwSKpWXExPjyXB AXWB08rzpsgfQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 97EE768657; Wed, 19 Nov 2025 19:57:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:58 -0700 Message-ID: <20251120025614.2215587-24-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HNV3QMLAUEIKEXWAMQVIJNQOK2E4FS7O X-Message-ID-Hash: HNV3QMLAUEIKEXWAMQVIJNQOK2E4FS7O 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 23/30] fit: Add a helper to output optional properties 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 Add a new emit_prop() helper function to simplify printing optional properties in FIT configurations. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 628d6108bea..84836a71090 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -90,6 +90,27 @@ static void emit_label_val(struct fit_print_ctx *ctx, const char *label, printf("%s\n", val); } +/** + * emit_prop() - print a property if it exists + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the property + * @prop: property name to get and print + * @label: label string to use when printing + * + * Gets a property from the specified node and prints it with the given label + * only if the property exists. This is a convenience function for optional + * properties that should only be printed when present. + */ +static void emit_prop(struct fit_print_ctx *ctx, int noffset, + const char *prop, const char *label) +{ + const char *val; + + val = fdt_getprop(ctx->fit, noffset, prop, NULL); + if (val) + emit_label_val(ctx, label, val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -326,13 +347,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) emit_label_val(ctx, "Kernel", uname ?: "unavailable"); /* Optional properties */ - uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) - emit_label_val(ctx, "Init Ramdisk", uname); - - uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) - emit_label_val(ctx, "Firmware", uname); + emit_prop(ctx, noffset, FIT_RAMDISK_PROP, "Init Ramdisk"); + emit_prop(ctx, noffset, FIT_FIRMWARE_PROP, "Firmware"); for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, @@ -340,9 +356,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) i++) emit_label_val(ctx, i ? "" : "FDT", uname); - uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) - emit_label_val(ctx, "FPGA", uname); + emit_prop(ctx, noffset, FIT_FPGA_PROP, "FPGA"); /* Print out all of the specified loadables */ for (i = 0; From patchwork Thu Nov 20 02:55:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 752 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=1763607454; bh=Mbww3pawum5hS5B17a6hy8rMd0uLbm251XmHW+CUcBQ=; 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=SPkutXWDYSX/q5LhN28eNhBborK9ObaFAsbWDD7epHm2ZQINPq4zAqsSpvEKzwVp6 wKQDx1zv6VhQaIVVnS/G5Jhi9PMMZtSRsMI8E7S1IWt7HO3Agskpy1L9HirtGuQpD8 ugKu6tpD4X7D2oYsSk6kkVXWG7VuYCncIItaRNPnPRGfiJ4rpBWJE5YW6jUqDoGhmJ EmoP7Q24iG7rOnp/QXG9SBJiPtSzrekv7NyrtN5flAB0cdFB0xbEvgm3n/iTQz7qFM Slc5k33Mz+nA4M/w9jBA2O4PiBPKtLLpmiV5n5qY8cLGGlY5kICIa8frOkni4G2zom f45CDCci52I5Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6365E68657 for ; Wed, 19 Nov 2025 19:57:34 -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 Z9UpaUXGwKZY for ; Wed, 19 Nov 2025 19:57:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607454; bh=Mbww3pawum5hS5B17a6hy8rMd0uLbm251XmHW+CUcBQ=; 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=SPkutXWDYSX/q5LhN28eNhBborK9ObaFAsbWDD7epHm2ZQINPq4zAqsSpvEKzwVp6 wKQDx1zv6VhQaIVVnS/G5Jhi9PMMZtSRsMI8E7S1IWt7HO3Agskpy1L9HirtGuQpD8 ugKu6tpD4X7D2oYsSk6kkVXWG7VuYCncIItaRNPnPRGfiJ4rpBWJE5YW6jUqDoGhmJ EmoP7Q24iG7rOnp/QXG9SBJiPtSzrekv7NyrtN5flAB0cdFB0xbEvgm3n/iTQz7qFM Slc5k33Mz+nA4M/w9jBA2O4PiBPKtLLpmiV5n5qY8cLGGlY5kICIa8frOkni4G2zom f45CDCci52I5Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5286E686B2 for ; Wed, 19 Nov 2025 19:57:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607452; bh=b20tkDSc3eQ8hIYEAmPK6bXL4FxIzn0JDFpSkb1Q0TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQ51MA1Zu3YC14jzzCp111FFtyOIiotece7AkI3L6M30qwIICmtTl0ZcDqRDr2jAv WyDwTjeTYQUIkDQpvXw/BT9FKZX67qqYLq7owJafnKIyIwZihzvZ8b6+xv1VW+Jn9k bzN3NxXZu+ZEigXvhAhcl3G4xfQRaSNLUlEzgMlaXn3GcAnW1sN3omRCCOMESQj4pi BmJyUWt9koogE9OdVRw6H/IZufdZDjk/wkqKgTEdBHJrYMxR/yY6/5IpwL3iNF9soQ UtZmTtxuAstBKLa9qAJBLNc3uPrcboYLMOrTx8BGW+K54R7zqgb5gczFFan4z6jxYf jn7V9CvVVaUMw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4AB05686B2; Wed, 19 Nov 2025 19:57:32 -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 ec0I-z7-HgDY; Wed, 19 Nov 2025 19:57:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=STqXynH1GGBnnCK4RYb5zr0zeHam284cUqXyFryUI9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKpOY810LmaPXGNFqHYtuoHUsE9ovG3JMLOrs8byD6ILIOk4skBhs8xtknGAHwl8V 71b6UZAo/OEfZK2qFl+zouLiF3+BXKetjJLKP0t7t4FJigcBOL9Jc5VqispDYNp5wH rynkAffglCXtqgg6MY6lcCgZVgvD39/cLwhO7YNvte0oNM9A+6Qgcp5H7cOSOWVg4U P7PE8u146ldZHMlsdlqJdbYjde3uoeVYIeNSrm7DXedX1JbDfzeCEKWDJggcYctUQl ILWElc9yAJ7UDKbNcG5/OgfEBZE6FFrgXZNYhG42L0alRxXWqVAdaA/tyQ3zBgIqxF NTYiJLjoZdt4g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7F73068657; Wed, 19 Nov 2025 19:57:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:59 -0700 Message-ID: <20251120025614.2215587-25-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SRCFCOOQYCABYLZIND3AM5EAPUYH7JCU X-Message-ID-Hash: SRCFCOOQYCABYLZIND3AM5EAPUYH7JCU 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 24/30] fit: Add a helper for timestamp printing 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 Add a new emit_timestamp() helper function to handle printing timestamps in FITs. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 84836a71090..9696679762d 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -111,6 +111,28 @@ static void emit_prop(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, label, val); } +/** + * emit_timestamp() - print a timestamp + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the timestamp + * @label: label string to use when printing + * + * Gets the timestamp from the specified node and prints it with the given + * label. If the timestamp is not available, prints "unavailable" instead. + * This is a convenience function for printing FIT timestamps. + */ +static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, + const char *label) +{ + time_t timestamp; + + emit_label(ctx, label); + if (fit_get_timestamp(ctx->fit, noffset, ×tamp)) + printf("unavailable\n"); + else + genimg_print_time(timestamp); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -163,15 +185,8 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, debug("%s len: %d\n", type, value_len); /* Signatures have a time stamp */ - if (IMAGE_ENABLE_TIMESTAMP && keyname) { - time_t timestamp; - - emit_label(ctx, "Timestamp"); - if (fit_get_timestamp(fit, noffset, ×tamp)) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP && keyname) + emit_timestamp(ctx, noffset, "Timestamp"); } /** @@ -233,16 +248,8 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) ret = fit_get_desc(fit, image_noffset, &desc); emit_label_val(ctx, "Description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) { - time_t timestamp; - - ret = fit_get_timestamp(fit, 0, ×tamp); - emit_label(ctx, "Created"); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP) + emit_timestamp(ctx, 0, "Created"); fit_image_get_type(fit, image_noffset, &type); emit_label_val(ctx, "Type", genimg_get_type_name(type)); @@ -393,20 +400,13 @@ void fit_print(struct fit_print_ctx *ctx) int ndepth; int count = 0; int ret; - time_t timestamp; /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) { - ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%*sCreated: ", p, ""); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP) + emit_timestamp(ctx, 0, "Created"); /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); From patchwork Thu Nov 20 02:56:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 753 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=1763607459; bh=gMVLLPGHFCqZOzgab3hCQAgK0SGswSi13YrL8cE7Inw=; 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=Z/8+bOE/h2reOLW0TyIGunKUt7YAftBSp9eQNKcG1v0zPrj8qwHjw6BA+GJA/U0Lb N9glLqFdLYGOLdmmLfLHZnZqze8+x9hcDue422NcEJs9icWBDF5JXo1FeMiRpojKez NCiVEmKQUFjEFkoL8O51joWUrzhC9uQk3zflzD18EoGC7Qo6q4rRlC7yjHAlIHwCax +PZl96Vo1ui+hswEza6cbqlyUJut3eMEzxAErAImH0TPxC1x1gNdubFil4CUXJrWUY uM5yeucbJdp8OLO9iiNNZJi045+YTiQb5NhC9ydoUapr5M+Qg1kJ+pz8k59Fq7LQum LopUA5JeiAVCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 319785E7DA for ; Wed, 19 Nov 2025 19:57:39 -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 PK04A0zHOlNP for ; Wed, 19 Nov 2025 19:57:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607459; bh=gMVLLPGHFCqZOzgab3hCQAgK0SGswSi13YrL8cE7Inw=; 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=Z/8+bOE/h2reOLW0TyIGunKUt7YAftBSp9eQNKcG1v0zPrj8qwHjw6BA+GJA/U0Lb N9glLqFdLYGOLdmmLfLHZnZqze8+x9hcDue422NcEJs9icWBDF5JXo1FeMiRpojKez NCiVEmKQUFjEFkoL8O51joWUrzhC9uQk3zflzD18EoGC7Qo6q4rRlC7yjHAlIHwCax +PZl96Vo1ui+hswEza6cbqlyUJut3eMEzxAErAImH0TPxC1x1gNdubFil4CUXJrWUY uM5yeucbJdp8OLO9iiNNZJi045+YTiQb5NhC9ydoUapr5M+Qg1kJ+pz8k59Fq7LQum LopUA5JeiAVCw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E9AA68631 for ; Wed, 19 Nov 2025 19:57:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607456; bh=pRsND2GqD4siVSe8io4n7rr9tj7S0KQefS483OVUj20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bo6hIPB18TpLufd7DIj9vxqF20NMfu8Qj+YCoWemt/NVFG5Lpj4hlWJ8eHTC8/pPo 5g0bfthdkUD3FxZWbC50Fwk3He8voEBaIB1vEkjTTD7Hyc0V8yAu0aW6k7LA5Q+qsu Lqa/kfoK1W4g9QmKo/vAtHF1yN5tAZ4N1ENXenDHDBePKZSs3b2AVpja39hyqDLBT7 Hofgw3xzPbyHGiUuDANe2lc+5rB1rYK2wQ77LFy4whwQiHoNfnb464o7lQw7YJs9oi UwaN/nlbGyj9vfk0cw2wsOwRwNrD/kfJerfjqvcZ/tJfraAJ/9JuKUb6rm7xVR6Iny 7m4+4VM7Ln6Kg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B29B7686E6; Wed, 19 Nov 2025 19:57:36 -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 CnJc-rmoHdMy; Wed, 19 Nov 2025 19:57:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607451; bh=Aaz1GLFqrtUSdXf1kgrlZ2BJuD6c6aznYoNIUuZdvyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UUjoCgqm0HuWkAUevHag7uZtFQNwpvwyxgG2yBw6g6kHMMbHGFT2ivVtqO+OLgQY7 owD/mzNftzfZ4gyeSts71XIp176g1rLB1tP4XnF8LwXOFlBy84MXKmUYqweg7N20qh rixeR7Pr2pEpaUgoEutjla+DwnESVQSyiSXgX9TI5+aCKI1mStdtgU4NAgOGxenISD giMsCY3KiFAzsDpWO/Vwvp7KoZW7ij+b0K435hu1Ru6PJyfHT6F+dO6ZoxwJ/0UmHO ceBmzqAmWR6rpupNOukQthLKh4oZ0oDb6RbpLc4ZGLYKsxSnUjcAQ1hFnBNeTCmC6N phuhyZTZpRmOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2684D68614; Wed, 19 Nov 2025 19:57:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:00 -0700 Message-ID: <20251120025614.2215587-26-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IH2FTV6W5AUQQZP5NZ2JEUR4IDNPOWF2 X-Message-ID-Hash: IH2FTV6W5AUQQZP5NZ2JEUR4IDNPOWF2 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 25/30] fit: Add a helper for stringlist properties 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 Add a emit_stringlist() helper function to simplify printing stringlist properties in FIT configurations. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 56 +++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 9696679762d..8781d5a7da7 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -126,6 +126,8 @@ static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, { time_t timestamp; + if (!IMAGE_ENABLE_TIMESTAMP) + return; emit_label(ctx, label); if (fit_get_timestamp(ctx->fit, noffset, ×tamp)) printf("unavailable\n"); @@ -133,6 +135,30 @@ static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, genimg_print_time(timestamp); } +/** + * emit_stringlist() - print a stringlist property + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the property + * @prop: property name to get and print + * @label: label string to use when printing + * + * Gets a stringlist property from the specified node and prints each string + * with the given label. The first string shows the label, subsequent strings + * are indented to align with the first value. If the property doesn't exist, + * nothing is printed. + */ +static void emit_stringlist(struct fit_print_ctx *ctx, int noffset, + const char *prop, const char *label) +{ + const char *val; + int i; + + for (i = 0; + val = fdt_stringlist_get(ctx->fit, noffset, prop, i, NULL), val; + i++) + emit_label_val(ctx, i ? "" : label, val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -248,8 +274,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) ret = fit_get_desc(fit, image_noffset, &desc); emit_label_val(ctx, "Description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) - emit_timestamp(ctx, 0, "Created"); + emit_timestamp(ctx, 0, "Created"); fit_image_get_type(fit, image_noffset, &type); emit_label_val(ctx, "Type", genimg_get_type_name(type)); @@ -344,7 +369,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; const char *uname, *desc; - int ret, ndepth, i; + int ret, ndepth; /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); @@ -356,26 +381,10 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) /* Optional properties */ emit_prop(ctx, noffset, FIT_RAMDISK_PROP, "Init Ramdisk"); emit_prop(ctx, noffset, FIT_FIRMWARE_PROP, "Firmware"); - - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, - i, NULL), uname; - i++) - emit_label_val(ctx, i ? "" : "FDT", uname); - + emit_stringlist(ctx, noffset, FIT_FDT_PROP, "FDT"); emit_prop(ctx, noffset, FIT_FPGA_PROP, "FPGA"); - - /* Print out all of the specified loadables */ - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, - i, NULL), uname; - i++) - emit_label_val(ctx, i ? "" : "Loadables", uname); - - /* Show the list of compatible strings */ - for (i = 0; uname = fdt_stringlist_get(fit, noffset, - FIT_COMPATIBLE_PROP, i, NULL), uname; i++) - emit_label_val(ctx, i ? "" : "Compatible", uname); + emit_stringlist(ctx, noffset, FIT_LOADABLE_PROP, "Loadables"); + emit_stringlist(ctx, noffset, FIT_COMPATIBLE_PROP, "Compatible"); /* Process all hash subnodes of the component configuration node */ for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); @@ -405,8 +414,7 @@ void fit_print(struct fit_print_ctx *ctx) ret = fit_get_desc(fit, 0, &desc); emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) - emit_timestamp(ctx, 0, "Created"); + emit_timestamp(ctx, 0, "Created"); /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); From patchwork Thu Nov 20 02:56:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 754 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=1763607463; bh=MQD80w2rPNBq3L8UK5qFf5TrjTIFR22HhKBgeBe2A7E=; 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=dOCpK8i1eAyecC3mqlbgxOoEpzEXiWgAm73gQpUGngktnUMkz2ZX5gIRNja3fqQXC SSXbN0/lX7i68MIqPatjwhHOxxYH1lzYa5ZmENiUXl/CShMOBqwL6+nbDUcdRQpdfu 5air95FAtGHymydt2ftUBR6N5ET7UQxmP+71cpDDevUfADRV2q6z3yr9JCM3zTwulW cdhzUksRxrBPc4W6aCEQFSiKA6W8NJY/EaJDW4HSqMLy/QrzN8NyHY4ySBiKlCu3xs pefpPNUu9Yu5FRwfqKqSLO7IfYmXOaA6M4x/frxXERp0YLRFV0LXKb7ddPRMD5PLwH 0GBIPjE9KKVJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE7FB686D8 for ; Wed, 19 Nov 2025 19:57:43 -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 cgtJR91Xum4F for ; Wed, 19 Nov 2025 19:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607463; bh=MQD80w2rPNBq3L8UK5qFf5TrjTIFR22HhKBgeBe2A7E=; 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=dOCpK8i1eAyecC3mqlbgxOoEpzEXiWgAm73gQpUGngktnUMkz2ZX5gIRNja3fqQXC SSXbN0/lX7i68MIqPatjwhHOxxYH1lzYa5ZmENiUXl/CShMOBqwL6+nbDUcdRQpdfu 5air95FAtGHymydt2ftUBR6N5ET7UQxmP+71cpDDevUfADRV2q6z3yr9JCM3zTwulW cdhzUksRxrBPc4W6aCEQFSiKA6W8NJY/EaJDW4HSqMLy/QrzN8NyHY4ySBiKlCu3xs pefpPNUu9Yu5FRwfqKqSLO7IfYmXOaA6M4x/frxXERp0YLRFV0LXKb7ddPRMD5PLwH 0GBIPjE9KKVJA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9DAFB68657 for ; Wed, 19 Nov 2025 19:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607461; bh=0jllZ0zGeIWHvJI8UOpX6HMZfzbABlNOs2lNihStdMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExH7KJds1pXYYsUv1dp73V98EiSIxWJvULyB/kv8dDF4PUX4YgDEt8zzUwxtU8QvN OpO68y9F2i8FZreE+SuoBaeWZwBmMLkbrATeZG2qIroEUJcwgKHiqcKxFPvhJAu8uY aLO7VnoB2nHIwrZFm547OvsyQHt/vH3pSRn2HAktYo4ArpFe44zPfBSZ9fe4xK6Yxg t7bpx0zmul0Ft2zfyM3rg2mG3syqHDHY45ypshrA7jXv130JBM1DBLyCSx2KBvGLCg emA0n5Bvi9zAn66cG0lpfk8l9cpoM1N/zISW2FzXY8DhQ095QZV/MiLYk5zYn15CfC QeNDTt/Ch06wA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D616686D8; Wed, 19 Nov 2025 19:57:41 -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 QF3hfmbah1LU; Wed, 19 Nov 2025 19:57:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607456; bh=XQUqp/c7SgJFlWVJO4XHj8UUqTcBREsO7OktQvGAmf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DkrnWm7XpcOCd1Ect/03Cn6Jrem01VuBTIkqOLbCDHFvh9gZYlnJzuLzsYu0kLkxz n8WIIqn2Zwj6PKECHuekiPuWkMAnTvdTaS1oOMnMSeoiPDpWZ2T6DihER7MFviG+VX 5X0hjdi+Ki9CEeDURfylROHXQIRbNAhv1kiD5JM9fPJVQ14ULoD4PkZElX8s2UJ93i YK+2kqdMGLeO3nbuxTPJrq+gCEe54yPDXOR2t1WesNqViXWkAWVdOdkwpmQ/3MESEO LnkykJ3ZQERevmJKnWbJRhbTv21Y+0FVEqN/Et8eizff4klO228ixlANOvKJZet7oy AZ3SfqSjj4ATw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C4DC268657; Wed, 19 Nov 2025 19:57:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:01 -0700 Message-ID: <20251120025614.2215587-27-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DGBXTD6QW6QUQDVS7MITYZ6AZAO22K56 X-Message-ID-Hash: DGBXTD6QW6QUQDVS7MITYZ6AZAO22K56 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 26/30] fit: Add a helper for printing descriptions 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 Add emit_desc() which handles getting and printing descriptions from FIT nodes. Handle the "unavailable" case when a description is missing. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 8781d5a7da7..069afbe8567 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -159,6 +159,26 @@ static void emit_stringlist(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, i ? "" : label, val); } +/** + * emit_desc() - print a description + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the description + * @label: label string to use when printing + * + * Gets the description from the specified node and prints it with the given + * label. If the description is not available, prints "unavailable" instead. + * This is a convenience function for printing FIT descriptions. + */ +static void emit_desc(struct fit_print_ctx *ctx, int noffset, + const char *label) +{ + const char *desc; + int ret; + + ret = fit_get_desc(ctx->fit, noffset, &desc); + emit_label_val(ctx, label, ret ? "unavailable" : desc); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -262,7 +282,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) { const void *fit = ctx->fit; uint8_t type, arch, os, comp = IH_COMP_NONE; - const char *desc; size_t size; ulong load, entry; const void *data; @@ -271,8 +290,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) int ret; /* Mandatory properties */ - ret = fit_get_desc(fit, image_noffset, &desc); - emit_label_val(ctx, "Description", ret ? "unavailable" : desc); + emit_desc(ctx, image_noffset, "Description"); emit_timestamp(ctx, 0, "Created"); @@ -368,12 +386,11 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; - const char *uname, *desc; - int ret, ndepth; + const char *uname; + int ndepth; /* Mandatory properties */ - ret = fit_get_desc(fit, noffset, &desc); - emit_label_val(ctx, "Description", ret ? "unavailable" : desc); + emit_desc(ctx, noffset, "Description"); uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); emit_label_val(ctx, "Kernel", uname ?: "unavailable"); @@ -401,18 +418,15 @@ void fit_print(struct fit_print_ctx *ctx) { const void *fit = ctx->fit; int p = ctx->indent; - const char *desc; char *uname; int images_noffset; int confs_noffset; int noffset; int ndepth; int count = 0; - int ret; /* Root node properties */ - ret = fit_get_desc(fit, 0, &desc); - emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); + emit_desc(ctx, 0, "FIT description"); emit_timestamp(ctx, 0, "Created"); From patchwork Thu Nov 20 02:56:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 755 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=1763607465; bh=X4jJlm0O7YYfwerj4S8zblH3zZvYerqqFNvScf6nCtA=; 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=wtYmbTBziiVkr/cfqhp4+jQ4jBa0NbxGJqwLXvsjwJ7D6CveaQNCfIw1DEpDJ90lM UBvOtQ+/rImO8kJHsPAwzPv/HG3zEGgTOjRT7N5ERIfxdL/ve/2dm0rxbdPY4hbub3 4SaF1KI9K6LhI4iETzTmzTlyrNNz+Zo/uuScm5RJ+UGvysIHY0462NolBdmBx9VqDl AWUVsIS2XZUIlVskapuQVI7nTUHHUUcL9QQI3K4v4SVsDal/4B3ogGpte460UUcGxW MmraCfuKHDQr3/BAIDdn6OTU3nY3gkCVvR4FXH27NHwqnYbIRsJKtvxV9pd7SNGaPw KFlUZu/5GhH7Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2FDED686F2 for ; Wed, 19 Nov 2025 19:57:45 -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 9-pcU1mB3tfv for ; Wed, 19 Nov 2025 19:57:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607464; bh=X4jJlm0O7YYfwerj4S8zblH3zZvYerqqFNvScf6nCtA=; 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=ZlGB2FMrhpTtRKmA0Mq9Ux48oiZBx+3l/1c3wTthX9xnorX1+JvAN/RL8iONXBFof AEKl0S3JLxrAyRh2S5jU1MJzAtHbvxDzPVqE0Co9ZYU/f6GGQcf6s2uL4iam/TEHCu HlpHV3xEyOXUKVeIoVkjnMo6Cb1lv3iKO7O6ve2elgINQADyPHmN7R4QLgvabRVw5L yfl4wQ5zjq0SGZn8LTtgoEHXIWm8NLLOKMwQNumjm212YyX4IgvQYXr0HP5X5xlIfX 3b21392U6WqWbsTtvIaIW8wiyfaNlpXcw915Fh2bhDoKcksAL1icxwEiRWbWn/2CMo St5UPPYUcbk9A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D6A068614 for ; Wed, 19 Nov 2025 19:57:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607461; bh=0e4imx59AEox48R/xQuKidpjZWZTK3ywqNwNUhZ71yI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRtnJ3jF6zvcqErC6nxbjhsf5QOa4Ki7EY/FhCpquwtwEZjNQ4OALg5MbFaVVjjcA Xnk1axD98dFvBQHoY7VlQ2cn8sQpZVwd5Cs2r+taF5sy3eTrRWRfCasCRzhNUQhfuK FFU5hOF2fk5XcvpjJ9OBtuiQdB8cwKFY7M7gTR0CBc/rCJoUZ2ENshpUjmZxnloxfJ Va4tyEMA01warV900P4dfsyd0C0VjF6ctz/rTw+rynqhKIvA2cWu9YGpAe2S2lMr3M ihUPCsn63kGvLQKMBwQ/mT8b4oqLHozB2dsFmnlmmAbJb/digumsU5y8uiv2GG7MFd ECGfuNMptAxIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F72B68657; Wed, 19 Nov 2025 19:57:41 -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 UWoEcLmAh1Nk; Wed, 19 Nov 2025 19:57:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607460; bh=pb7ADZKP8Wp7GlRVjp7nbVioL5HvUNmBoznwf4L/Mv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyIayzIgynqXSUPGCKKDCP0VQ7bHjULRZH+T/HM2JWmzCcvm5ffnedV34yUXll8n7 ZR25Jitd+tOw1sPNo6KvQUZ6771pbO43bzYa0a0tWLtjyOwSHYpYnO7fnpldnsvm+l yDF3qtUH6rnESlKWDNAP/e+1ZDxLoh/SWYcyOmpspuv6h/gAv0Y5nS32Wkt+Q8lC0O SG+xhrXZdzyiMBAOxv/adZ5tPDW6iU0aw69ZPbV1nqy0xH7OHxwe9Q7nAsxK7wgoE9 XkVxjapep08hJGXAim/imFiJTsP1JCmu8pNSoJBauTop8UKXRB42qOT0Isvb/jUF46 SnGa9Vt/fNJsg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6EFE35E7DA; Wed, 19 Nov 2025 19:57:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:02 -0700 Message-ID: <20251120025614.2215587-28-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QYYAHQTDR75FY5MDCSEAIXO2X5UHQQHM X-Message-ID-Hash: QYYAHQTDR75FY5MDCSEAIXO2X5UHQQHM 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 27/30] fit: Add a helper for address printing 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 Add emit_addr() to handle printing load an entry addresses. The helper takes a 'valid' boolean parameter to determine whether to print the address value or 'unavailable'. Combine the two separate if() blocks for the load address. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 069afbe8567..70199a34c18 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -179,6 +179,26 @@ static void emit_desc(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, label, ret ? "unavailable" : desc); } +/** + * emit_addr() - print an address property + * @ctx: pointer to FIT print context + * @label: label string to use when printing + * @addr: address value to print + * @valid: true if the address is valid, false to print "unavailable" + * + * Prints an address with the given label. If valid is false, prints + * "unavailable" instead of the address value. + */ +static void emit_addr(struct fit_print_ctx *ctx, const char *label, ulong addr, + bool valid) +{ + emit_label(ctx, label); + if (valid) + printf("0x%08lx\n", addr); + else + printf("unavailable\n"); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -335,30 +355,16 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_FIRMWARE || type == IH_TYPE_RAMDISK || - type == IH_TYPE_FPGA) { + type == IH_TYPE_FPGA || type == IH_TYPE_FLATDT) { ret = fit_image_get_load(fit, image_noffset, &load); - emit_label(ctx, "Load Address"); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", load); - } - - /* optional load address for FDT */ - if (type == IH_TYPE_FLATDT && - !fit_image_get_load(fit, image_noffset, &load)) { - emit_label(ctx, "Load Address"); - printf("0x%08lx\n", load); + if ((type != IH_TYPE_FLATDT) || !ret) + emit_addr(ctx, "Load Address", load, !ret); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_RAMDISK) { ret = fit_image_get_entry(fit, image_noffset, &entry); - emit_label(ctx, "Entry Point"); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", entry); + emit_addr(ctx, "Entry Point", entry, !ret); } /* Process all hash subnodes of the component image node */ From patchwork Thu Nov 20 02:56:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 757 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=1763607472; bh=dSIA/k4Y7W/nTCTCJ2IXMrtEn4IzdJSR+wOK9h3Kvmg=; 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=PNvtHngZzS0gBEdT7wqZbYriwB96oRjlIjnbDZdIoULASYUQopGfcihzdqJcEW7AP MpHxPEgHJi60vMNp+nbfmKJNWo0kAXz6HaPyZQW47X+Al2UsLIJPMvQqGI4LDCqtcZ VEDLu3tgeZbOtRrdVRFyR37gspwheam12zijurcukiOfZ0UaN4lmZ4SU4G7CZ/UUrx T1USoi9DGv94+1+Eb7bqGnypvrinQhMQkx3h+QXom09edp65EmJPdhGiLzjF8smSSh DjcW6n4Zga/Q9N/P8aAGFS7EgL25K+pqLUSBdjwGes1ZEuQSOdjgpoZLc3sImuGRLc BYAQXxqcQg2Zw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A92C6686BB for ; Wed, 19 Nov 2025 19:57:52 -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 P5inVadZOv7C for ; Wed, 19 Nov 2025 19:57:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607470; bh=dSIA/k4Y7W/nTCTCJ2IXMrtEn4IzdJSR+wOK9h3Kvmg=; 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=OskJLe5rVYlK1qa8di8IBtGauehsA1PUVZiAsFidEcxTgk8+dppFmpTyDM9guSQhF HM+3flHC+IUrQl61KrvAg+mB1r4J1/u2Y6raKlNmv5weuRTvFU4hciqRqrN3TfTCZu fXvMcsAOJ6/ZF9GNWJrRtDbwgoDavmyWkWjGNUcfOR0/tC6kXwgprbnL/KKLQUZkVU YQrqYcbNh/LsutxHDr/PnVTRb2N6xEj3ayxjgQZHDoh/A+M8/0RAb2M1ZOr/mIR40e jlNZY+FbswW3OYm3It8b0ejrFoa5VdKtwhRYx2Xz7v7EmNOgUhxQ6IZzCH8p1cFBqY 2xTF6JeCNHU+Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A97DA68657 for ; Wed, 19 Nov 2025 19:57:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607467; bh=QumgkZaLs9OfJuwwt8bchxvRSjMnOndViomJyQPrGSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2d81bnGEGqCEADQPaigk0aJwBtuO2O2xcLkKv6iT277o05gSMQ6fYbO371H1fUUG peiGHUkFNQS5nv4Ij+cx/HwTQcKiKSwH2vZ8en8KSXJsMoy4y7moakbWuF8NAy/daT ASQUJk5wuR9x6GzrYJo2pQusewmRWHzHyZ007SG2y+d4zHTICU2KabIAA1PV+KPLMn v9229u3t2Lml807AbEh79g89P6M4hxy8LNpa9GtjRF/cWGuOeO7SrelgD+NgHJSZPL EK9XHOlkjOnvozlLepjjguGCnIuXFjdxB/3TAfgJG55bATF0JoHlnLRWKr0YAYJXT3 sm1n1mvGqV9rQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CF4E686BB; Wed, 19 Nov 2025 19:57:47 -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 8byjM2CDtMjd; Wed, 19 Nov 2025 19:57:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607461; bh=Vn4XhpSSBToXuc7cbtTYO57MnRP2hUUfwL4GLaDI6ME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHIXkkMgFM+Ujmvk121Lf8vY8kmdQ1nzYtj92dH9V7xKgHUrBnz1M+9hKpbQmi47T 8NVDCjI9vQ4vunAIoTnJ6yHEWLgHePRraXkngTwLm6QeJo1pXt/Cy3EFJv1B4FUe20 94gfqMzaMIUGEhnmrvfbIiCu/64dFCw7WK87YIo8B4n/urv4WpEZGo7nDeawCuB0E3 o66PU84t2REK9Uy3zl61i7NzZ+4kLIf/9ljZwZxgXxReHJLe5lypJTVg0aaf/o2Iz9 hu+IoENVGtp/s01UHcpVGiOV3taqKfSPhhlSpis5gf3vVeqKijcxr14uzrfVa/yVUH 47DUxmgkbBuxQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 67EC368631; Wed, 19 Nov 2025 19:57:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:03 -0700 Message-ID: <20251120025614.2215587-29-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PRLXAKNCMVPCUXOF7ZKT4TOYP2TM6UHY X-Message-ID-Hash: PRLXAKNCMVPCUXOF7ZKT4TOYP2TM6UHY 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 28/30] fit: Use a boolean to simplify type checks 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 Add a boolean variable 'loadable' that combines the common type check for kernel, standalone, and ramdisk images. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 70199a34c18..6772460a151 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -340,29 +340,27 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) genimg_print_size(size); /* Remaining, type dependent properties */ - if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || - type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE || - type == IH_TYPE_FLATDT) { + bool loadable = type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || + type == IH_TYPE_RAMDISK; + + if (loadable || type == IH_TYPE_FIRMWARE || type == IH_TYPE_FLATDT) { fit_image_get_arch(fit, image_noffset, &arch); emit_label_val(ctx, "Architecture", genimg_get_arch_name(arch)); } - if (type == IH_TYPE_KERNEL || type == IH_TYPE_RAMDISK || - type == IH_TYPE_FIRMWARE) { + if (loadable || type == IH_TYPE_FIRMWARE) { fit_image_get_os(fit, image_noffset, &os); emit_label_val(ctx, "OS", genimg_get_os_name(os)); } - if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || - type == IH_TYPE_FIRMWARE || type == IH_TYPE_RAMDISK || - type == IH_TYPE_FPGA || type == IH_TYPE_FLATDT) { + if (loadable || type == IH_TYPE_FIRMWARE || type == IH_TYPE_FPGA || + type == IH_TYPE_FLATDT) { ret = fit_image_get_load(fit, image_noffset, &load); - if ((type != IH_TYPE_FLATDT) || !ret) + if (type != IH_TYPE_FLATDT || !ret) emit_addr(ctx, "Load Address", load, !ret); } - if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || - type == IH_TYPE_RAMDISK) { + if (loadable) { ret = fit_image_get_entry(fit, image_noffset, &entry); emit_addr(ctx, "Entry Point", entry, !ret); } From patchwork Thu Nov 20 02:56:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 756 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=1763607470; bh=mNftQVvVogv3l9jyRZepWWgK4vxgUM5KxLRd7sOOtd4=; 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=N8gYCILRwjKkfkHgl83NA85htwFPCbs3nzmOy7lUxEEyIcJBQxUgGBEz1PWIRCxYl /4CA3jaFxcZRgwT6/4iPaFva1XwntgKJvW4F4Azp3mXubpfxKxwEBiDAIqnHvzoMml fI3KwBP5YG39QwcvZuDgOrK84Pd0BgFRTZ07YvIaJxZGsL+W11JklnWArK2GfPRVaa SG/h6BD4A3CNmZRPZx9whAPo/rRMTnrP5jp2FONJZQDrFbXKoVVcbfLPk4JwmzjiHE C1C2k2+iQlNw5cxQv1KRrcCgZD24uTNnQjINWAs7ardUerj/FUPzzPdO86J0qN5hEZ bzRq7kTOWTLXg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C1AB686BB for ; Wed, 19 Nov 2025 19:57:50 -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 vSPcq64sz5K2 for ; Wed, 19 Nov 2025 19:57:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607470; bh=mNftQVvVogv3l9jyRZepWWgK4vxgUM5KxLRd7sOOtd4=; 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=N8gYCILRwjKkfkHgl83NA85htwFPCbs3nzmOy7lUxEEyIcJBQxUgGBEz1PWIRCxYl /4CA3jaFxcZRgwT6/4iPaFva1XwntgKJvW4F4Azp3mXubpfxKxwEBiDAIqnHvzoMml fI3KwBP5YG39QwcvZuDgOrK84Pd0BgFRTZ07YvIaJxZGsL+W11JklnWArK2GfPRVaa SG/h6BD4A3CNmZRPZx9whAPo/rRMTnrP5jp2FONJZQDrFbXKoVVcbfLPk4JwmzjiHE C1C2k2+iQlNw5cxQv1KRrcCgZD24uTNnQjINWAs7ardUerj/FUPzzPdO86J0qN5hEZ bzRq7kTOWTLXg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B02E68657 for ; Wed, 19 Nov 2025 19:57:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607467; bh=OWinCuv1DiJEpMJsFFM+8E+sglN06mM7979Md9hYOxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdSKIg8pgGDV41gRJmJTQMGCQFDi5zjv2G43gvv3gRIhzy0klGaEnjtpDC0xUHbL+ x6EZ+pbVjBqafpUgEeH2C3elD91kGMJU6A1qji61vWd34Xgp7992qWvAMwNA1RAjqm tXkamna7woMmvBO8bsFGBhvGZFpJz29OllH+Sh2Byzq0/Bz7GtcCQiKHxG42DSvpb4 QpezOavvohUp7aXGazN7rZ61JGerkZ7SgI8FvEKFgWiq7Ou/uGBKRyBvKJqdfyuNA6 ycS+nOtdyyFvyQ47PWD3mCTV8tr4IYNUe8ZtRL7fKk7oZofUOZRHp7IUf+2W4Y6g+s XWvk5SDAUONqA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CF4268657; Wed, 19 Nov 2025 19:57:47 -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 PcEqDrmJEX_w; Wed, 19 Nov 2025 19:57:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607466; bh=jHyW5mPRiUhxSITiGT1O2EXB/b15PrTjbYo3ktYiL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFBz39LZ5JIWHC5vfr/9dzVKHFIUFjCQ3JeC/HwGp0gyYZEdx6xI1DDM8i2WAibRt H4c8RBnJ7xAax8QFBilFwqDd/EX8aiLaQDqBOlDN4cZqWrVohmAJBLP0ITcjqJL0lm RtkbyP+tALI3GZY66bxFtPVIn0bJDcQhJIpFt0FIA15qfPlZomc/Cijo/Oe3ty6mmt do6g757lxBFfTwPoSp502A9yrW878KxWx4ZBwf8GL6dKH48oIrpCK/3FLh390AVu8A MBWLmT2T37YwgqHDMvRIWq4LXAkRFU9MDIMV+DGNhjvFrSxRTijXz7GQ6b+SyjpWj5 gNzF7KECxK0zQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 109F0686B2; Wed, 19 Nov 2025 19:57:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:04 -0700 Message-ID: <20251120025614.2215587-30-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5TROJ5UC5BX7GIB62HQOSTYUW4PYT3MM X-Message-ID-Hash: 5TROJ5UC5BX7GIB62HQOSTYUW4PYT3MM 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 29/30] fit: Add a helper to iterate through hash/signature nodes 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 pattern for iterating through and processing hash/signature subnodes is repeated in two places. Add a new process_subnodes() helper to reduce code duplication. Drop the now-unused ndepth and noffset local variables. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 6772460a151..638f66942e9 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -283,6 +283,28 @@ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, fit_image_print_data(ctx, noffset, "Sign"); } +/** + * process_subnodes() - process and print verification data for all subnodes + * @ctx: pointer to FIT print context + * @parent: parent node offset + * + * Iterates through all direct child nodes of the parent and prints their + * verification data (hash/signature information). + */ +static void process_subnodes(struct fit_print_ctx *ctx, int parent) +{ + const void *fit = ctx->fit; + int noffset; + int ndepth; + + for (ndepth = 0, noffset = fdt_next_node(fit, parent, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) + fit_image_print_verification_data(ctx, noffset); + } +} + /** * fit_image_print - prints out the FIT component image details * @ctx: pointer to FIT print context @@ -305,8 +327,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) size_t size; ulong load, entry; const void *data; - int noffset; - int ndepth; int ret; /* Mandatory properties */ @@ -366,14 +386,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) } /* Process all hash subnodes of the component image node */ - for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* Direct child node of the component image node */ - fit_image_print_verification_data(ctx, noffset); - } - } + process_subnodes(ctx, image_noffset); } /** @@ -391,7 +404,6 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; const char *uname; - int ndepth; /* Mandatory properties */ emit_desc(ctx, noffset, "Description"); @@ -408,14 +420,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) emit_stringlist(ctx, noffset, FIT_COMPATIBLE_PROP, "Compatible"); /* Process all hash subnodes of the component configuration node */ - for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* Direct child node of the component config node */ - fit_image_print_verification_data(ctx, noffset); - } - } + process_subnodes(ctx, noffset); } void fit_print(struct fit_print_ctx *ctx) From patchwork Thu Nov 20 02:56:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 758 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=1763607477; bh=KzK9MITGL/DGetnLNaIz2ULVxUMXMfsJrIjL6KRUcEo=; 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=K7meiveRmaFpJ0ATbsl1DUWdrtl9e72V8Vn9egMSdnm+lAV9/5RYSuHfu5Mts0O9d do/zCxBtAH33MeZ13FjGC2m7CvbXVRQu6nw/DVZ0lOP0/nqeawFQJ4de+kkhAYQL3A XLKqQuQQ6KtaL9jRe69Ihm4f3hRTcbHilCwhWdzE9mgydRnZZIySbp9J8BrOmqBmny o7BzNSVl9Htpf0chxzarIJuKQA1VInWYtY/nvmlJCWebXbCZlP+7HAQ/OJgr7NCKDJ RjNUd12RrjMXdrR62mY2A6GjSaOjNUpK+BduE7EStByu0M3H8Cm7ZETTEl7lISUzCA DmkfHgXYBYtuQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2F9FB5E7DA for ; Wed, 19 Nov 2025 19:57:57 -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 BNJoO5yCTIy9 for ; Wed, 19 Nov 2025 19:57:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607477; bh=KzK9MITGL/DGetnLNaIz2ULVxUMXMfsJrIjL6KRUcEo=; 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=K7meiveRmaFpJ0ATbsl1DUWdrtl9e72V8Vn9egMSdnm+lAV9/5RYSuHfu5Mts0O9d do/zCxBtAH33MeZ13FjGC2m7CvbXVRQu6nw/DVZ0lOP0/nqeawFQJ4de+kkhAYQL3A XLKqQuQQ6KtaL9jRe69Ihm4f3hRTcbHilCwhWdzE9mgydRnZZIySbp9J8BrOmqBmny o7BzNSVl9Htpf0chxzarIJuKQA1VInWYtY/nvmlJCWebXbCZlP+7HAQ/OJgr7NCKDJ RjNUd12RrjMXdrR62mY2A6GjSaOjNUpK+BduE7EStByu0M3H8Cm7ZETTEl7lISUzCA DmkfHgXYBYtuQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F36C68614 for ; Wed, 19 Nov 2025 19:57:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607474; bh=fPjCfmtJCqP+fyt/pSu+N9uM12NRSo+4dWQbjkA6yU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AALLbLxQtKeGYWyOfHAACE4o5BvhraO4f9BkCYXy8xYDpV2jUGhZCzPNeLyx7iFQ2 noelmFeuAndubKlko3Foow99BzCqFXmlJNl8YaEAo4sqrY8P2GRmaSsZsZn1LAI0nk Q6Jap2KjqAb2bvNyyqja1WSsUcL/xUJC4lnQ13I9fsDjKqO/114rrQG8DPu15Jkr9A 4DTkr2oA/iFAOpcpAXoIg47N5MM1ydZMAuEVfsftBJHBFtpW+diN5TYT23MEi3lkQV CunBStfDvwteCvkLbFPhJLhCGl05nuaR+zZAejtyXb7kZFLS3dOBvnXsqqFD5uKr0c 1GislwVoxDSxA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F34DA68614; Wed, 19 Nov 2025 19:57:54 -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 gAC0nDk9Q10L; Wed, 19 Nov 2025 19:57:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607467; bh=0rSD14OvZmrbT+qKaMFO3EMgIjcB+rybqIUKNKZ4M28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXAKRy5PosdsS1mz3LnyBUQ3Cw9ExB2UYbV/7LIARRQjNfYL3GG22U+fYwqOf5N/l 6k+3PZQXqpfn78eR7sXOfQnJqYhKO0IisipNe31jFWt6PBfE7PmdR4D8igFX4YWTXn qULO65+15xvpZjy1twJnnDHdfFV8fivZ+6dQLyhHdUOAG96llZw4PiWEu2eW/DNz9C ql7KDVzz6OuCgHMOfpxRIP+4Gt6emVG9CWMNOllIsuQvT9+FLkex8Tptpb3qFQvV9U AodWQ7cxnIDFVwZcTiFYwOTuZUy0di8awCAnWFX4RhlcojX1cKODefrBMGUY6K5khN zeq7mrAi9UF8Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E67EE5E7DA; Wed, 19 Nov 2025 19:57:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:05 -0700 Message-ID: <20251120025614.2215587-31-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TIDBAW623VTMN2S2JRTFQ453LJZ5P45W X-Message-ID-Hash: TIDBAW623VTMN2S2JRTFQ453LJZ5P45W 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 30/30] fit: Use the libfdt subnode iterator 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 Replace fdt_next_node() with depth tracking with fdt_for_each_subnode() which has been available for some time. This also fixes a latent bug where the default configuration was being read from the wrong node offset. It happened to work before because noffset ended up at the right value after the images loop. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 70 +++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 638f66942e9..f4428d020e5 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -295,14 +295,9 @@ static void process_subnodes(struct fit_print_ctx *ctx, int parent) { const void *fit = ctx->fit; int noffset; - int ndepth; - for (ndepth = 0, noffset = fdt_next_node(fit, parent, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) - fit_image_print_verification_data(ctx, noffset); - } + fdt_for_each_subnode(noffset, fit, parent) + fit_image_print_verification_data(ctx, noffset); } /** @@ -431,8 +426,7 @@ void fit_print(struct fit_print_ctx *ctx) int images_noffset; int confs_noffset; int noffset; - int ndepth; - int count = 0; + int count; /* Root node properties */ emit_desc(ctx, 0, "FIT description"); @@ -448,22 +442,18 @@ void fit_print(struct fit_print_ctx *ctx) } /* Process its subnodes, print out component images details */ - for (ndepth = 0, count = 0, - noffset = fdt_next_node(fit, images_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* - * Direct child node of the images parent node, - * i.e. component image node. - */ - printf("%*s Image %u (%s)\n", p, "", count++, - fit_get_name(fit, noffset)); - - ctx->indent += 2; - fit_image_print(ctx, noffset); - ctx->indent -= 2; - } + count = 0; + fdt_for_each_subnode(noffset, fit, images_noffset) { + /* + * Direct child node of the images parent node, + * i.e. component image node. + */ + printf("%*s Image %u (%s)\n", p, "", count++, + fit_get_name(fit, noffset)); + + ctx->indent += 2; + fit_image_print(ctx, noffset); + ctx->indent -= 2; } /* Find configurations parent node offset */ @@ -475,27 +465,23 @@ void fit_print(struct fit_print_ctx *ctx) } /* get default configuration unit name from default property */ - uname = (char *)fdt_getprop(fit, noffset, FIT_DEFAULT_PROP, NULL); + uname = (char *)fdt_getprop(fit, confs_noffset, FIT_DEFAULT_PROP, NULL); if (uname) printf("%*s Default Configuration: '%s'\n", p, "", uname); /* Process its subnodes, print out configurations details */ - for (ndepth = 0, count = 0, - noffset = fdt_next_node(fit, confs_noffset, &ndepth); - (noffset >= 0) && (ndepth > 0); - noffset = fdt_next_node(fit, noffset, &ndepth)) { - if (ndepth == 1) { - /* - * Direct child node of the configurations parent node, - * i.e. configuration node. - */ - printf("%*s Configuration %u (%s)\n", p, "", count++, - fit_get_name(fit, noffset)); - - ctx->indent += 2; - fit_conf_print(ctx, noffset); - ctx->indent -= 2; - } + count = 0; + fdt_for_each_subnode(noffset, fit, confs_noffset) { + /* + * Direct child node of the configurations parent node, + * i.e. configuration node. + */ + printf("%*s Configuration %u (%s)\n", p, "", count++, + fit_get_name(fit, noffset)); + + ctx->indent += 2; + fit_conf_print(ctx, noffset); + ctx->indent -= 2; } }