Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A7E6C433EF for ; Sun, 27 Mar 2022 15:33:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BEB383981; Sun, 27 Mar 2022 17:32:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="S2bzuTa+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED10683994; Sun, 27 Mar 2022 17:32:29 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0914A83953 for ; Sun, 27 Mar 2022 17:32:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x630.google.com with SMTP id qa43so23942932ejc.12 for ; Sun, 27 Mar 2022 08:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bboduJ1hqqAr9DtgnBx25SrAoxJSt+ZGvisMYhebZk4=; b=S2bzuTa+0W+5PcgUMkRhv354UjQM4HzC24t++QPU5/TaGdK+RuBWxGuxYDLxxgo0uy xonlBAhkMUo8BgeSzdXm7PSeznS2Vi0rNSemqEodsz3h+g5pmENk1fpgwTU5QOvngyL4 wF9GzQmw70SPxUgQGrXhrispjpux/TEZyR1TVccOgK54D+v7lQHeB2cqodZizP/02DIC JS0cjAMKm6mGHGbHCdC9Q+nK8wzcqRRRGiznmjKhzNbSkGVfFn2j7QTtMryHgBzT+wox V0j/Gju9depszcEuansB/EfHb+idlInAP0KJF1Qvh12BS8gsqaaf6PaKsgp+N8yAQfjQ vC4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bboduJ1hqqAr9DtgnBx25SrAoxJSt+ZGvisMYhebZk4=; b=TsdLmVhp4sdGAbgE6o53oSGFxAIQmYOLJMWQMkl5P5I2Dw96CALwznugTAJf6gtCeT S2XzmwMckr4LkSG1sJgLMpZlZOkg/zdWvcyvdihO/uteUGXzLrg90SJvHcxjWvqdece4 k2GKJmyLSsCSg5C6edbwLx5HdYSXq8lRTsuUI1qJ8/sdN0SIKCsgUyVlxnGgznABZzSA tcNsoK4WkTihyQLvnpaSYLfQQhFVjmZjgHvzV7vg7vu99L/vpnpZK8L85jvemsoKITI5 4cmMGLZjLp3Pw0Zm0y+UQvPyUFBMmS802plx9rFuCP+Qh0nILgHt8xYcmfKcmDtHjzDH yUUA== X-Gm-Message-State: AOAM531oFt2pKZoragSV+y77oIh9g9xXUqwbOu2ksjdtBfSgFFUYizie aFve0sdeVFcJpE49f+Rg4ZUhMP6//Lw= X-Google-Smtp-Source: ABdhPJzzWmn8Wop1LfZ6e4hkdIqB6bqfXTcmublazBxvRm2LHTcJQt3vMT+o5h0E1LRLJS7En97ywA== X-Received: by 2002:a17:907:7f8d:b0:6db:7227:daea with SMTP id qk13-20020a1709077f8d00b006db7227daeamr22465167ejc.100.1648395141560; Sun, 27 Mar 2022 08:32:21 -0700 (PDT) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id jg22-20020a170907971600b006df9ff416ccsm4639763ejc.137.2022.03.27.08.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 08:32:21 -0700 (PDT) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Thiery , Jan Kiszka , Alper Nebi Yasak Subject: [PATCH 5/7] binman: Create FIT subentries in the FIT section, not its parent Date: Sun, 27 Mar 2022 18:31:48 +0300 Message-Id: <20220327153151.15912-6-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327153151.15912-1-alpernebiyasak@gmail.com> References: <20220327153151.15912-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When reading images from a file, each entry's data is read from its parent section as specified in the Entry.Create() call that created it. The FIT entry type has been creating its subentries under its parent (their grandparent), as creating them under the FIT entry resulted in an error until FIT was converted into a proper section. FIT subentries have their offsets relative to the FIT section, and reading those offsets in the parent section results in wrong data. The subentries rightfully belong under the FIT entries, so create them there. Add tests checking that we can extract the correct data for a FIT entry and its subentries. Signed-off-by: Alper Nebi Yasak --- tools/binman/etype/fit.py | 2 +- tools/binman/ftest.py | 35 +++++++++ tools/binman/test/233_fit_extract_replace.dts | 74 +++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/233_fit_extract_replace.dts diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 035719871e04..12306623af67 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -380,7 +380,7 @@ def _add_entries(base_node, depth, node): # section entries for them here to merge the content subnodes # together and put the merged contents in the subimage node's # 'data' property later. - entry = Entry.Create(self.section, node, etype='section') + entry = Entry.Create(self, node, etype='section') entry.ReadNode() # The hash subnodes here are for mkimage, not binman. entry.SetUpdateHash(False) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 87c072ef9c9c..a31568997f6f 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5568,6 +5568,41 @@ def testReplaceResizeNoRepackSmallerSize(self): self.assertIsNotNone(path) self.assertEqual(expected_fdtmap, fdtmap) + def testExtractFit(self): + """Test extracting a FIT section""" + self._DoReadFileRealDtb('233_fit_extract_replace.dts') + image_fname = tools.get_output_filename('image.bin') + + fit_data = control.ReadEntry(image_fname, 'fit') + fit = fdt.Fdt.FromData(fit_data) + fit.Scan() + + # Check subentry data inside the extracted fit + for node_path, expected in [ + ('/images/kernel', U_BOOT_DATA), + ('/images/fdt-1', U_BOOT_NODTB_DATA), + ('/images/scr-1', COMPRESS_DATA), + ]: + node = fit.GetNode(node_path) + data = fit.GetProps(node)['data'].bytes + self.assertEqual(expected, data) + + def testExtractFitSubentries(self): + """Test extracting FIT section subentries""" + self._DoReadFileRealDtb('233_fit_extract_replace.dts') + image_fname = tools.get_output_filename('image.bin') + + for entry_path, expected in [ + ('fit/kernel', U_BOOT_DATA), + ('fit/kernel/u-boot', U_BOOT_DATA), + ('fit/fdt-1', U_BOOT_NODTB_DATA), + ('fit/fdt-1/u-boot-nodtb', U_BOOT_NODTB_DATA), + ('fit/scr-1', COMPRESS_DATA), + ('fit/scr-1/blob', COMPRESS_DATA), + ]: + data = control.ReadEntry(image_fname, entry_path) + self.assertEqual(expected, data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/233_fit_extract_replace.dts b/tools/binman/test/233_fit_extract_replace.dts new file mode 100644 index 000000000000..b44d05afe1af --- /dev/null +++ b/tools/binman/test/233_fit_extract_replace.dts @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + allow-repack; + + fill { + size = <0x1000>; + fill-byte = [77]; + }; + + fit { + description = "test-desc"; + #address-cells = <1>; + + images { + kernel { + description = "test u-boot"; + type = "kernel"; + arch = "arm64"; + os = "linux"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + + u-boot { + }; + }; + + fdt-1 { + description = "test u-boot-nodtb"; + type = "flat_dt"; + arch = "arm64"; + compression = "none"; + + u-boot-nodtb { + }; + }; + + scr-1 { + description = "test blob"; + type = "script"; + arch = "arm64"; + compression = "none"; + + blob { + filename = "compress"; + }; + }; + }; + + configurations { + default = "conf-1"; + + conf-1 { + description = "Kernel with FDT blob"; + kernel = "kernel"; + fdt = "fdt-1"; + }; + }; + }; + + u-boot-dtb { + }; + + fdtmap { + }; + }; +}; -- 2.35.1