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 578D6C433EF for ; Sun, 6 Feb 2022 21:03:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D83283C01; Sun, 6 Feb 2022 22:03:22 +0100 (CET) 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="bhJ6DMhU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DAD483C01; Sun, 6 Feb 2022 22:03:20 +0100 (CET) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 952F08319C for ; Sun, 6 Feb 2022 22:03:15 +0100 (CET) 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-ed1-x530.google.com with SMTP id cn6so3150537edb.5 for ; Sun, 06 Feb 2022 13:03:15 -0800 (PST) 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=15PbZTsvlmvXeOZ1gxPvCnYKSIqTQr7dG5JKsSu0vto=; b=bhJ6DMhUqtVsO1bKjk4vPJ+KgCufIDeg99WKxO4CZpf4G3ICzEOWlgbEcKnUeOFLs6 syA+P/DmTSVGGss+0FZlhlbQY2bZ+gmUcNl8jSXky06Au9BOuTSBmny7/bh+/0wxSIEC glsrpofueY7NT7IZ8s7/dJ0XFxt8s4gNA+aRtzi5e/CLPYrXMIVo5Z+bqbXW0Fmgfpa+ EK505UeTW9DDdBbmgLibIJAZ9qiUBPJyxPRI5B3HXT4+X7HGePMbLtsTcbTw+NxycSqI D6rdwag9WcWCqqIvapgnxe7jdGC7NmfU+ENyjA5PhwU+QQ9RRX9kpASI1wRsswp1dOCk buEQ== 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=15PbZTsvlmvXeOZ1gxPvCnYKSIqTQr7dG5JKsSu0vto=; b=YoSc579wNhjjN8jPuamdNsAsjL6tfeucwZS2eoFXKjCj7zYoby6cGnk2kYc8jkEE2L QBHBGZfF8feJcC5xh64PYJcG2n+bx0qO23KfkoHGLTWpaFTCc9zd8KhD9EWDPxtjIiBY c2iuNBwvdtHQF7lBCWlHVhEVLTL4VXZaWJ3HhtYDs7+AJ+/8WqRS01KzPnlDjKdjs1h3 N/3j9xvYULG3x6jzTxA9kDMSUj7h8HmHcvtBGOif2ynA1TeuOi9Lzk4IwI42dcvyYcpY Yv9HdjTtit5MKlQcjGpoQgYey2z7vEbHthKOhmu3AzT1phl3IO4yX9W7Vpd4gZzKZt1o Y8iQ== X-Gm-Message-State: AOAM530gaWsh/lDgUvEBIlUStg5cMaVgdWYlWDV9Nb/8MWXdKIifOz26 1b7btunh4NYiIyNo+/eJEc5LWyIMNiI= X-Google-Smtp-Source: ABdhPJwN8/Yu1XtkNlOyPQ0wgds8MjSu0BDSAMBi/rqNy761qLJAcnXaT30N5Dr5CNR9lxPXbW1acQ== X-Received: by 2002:a05:6402:190d:: with SMTP id e13mr10849574edz.38.1644181395167; Sun, 06 Feb 2022 13:03:15 -0800 (PST) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id u4sm2168405ejn.216.2022.02.06.13.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 13:03:14 -0800 (PST) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Simon Glass , Jan Kiszka , Heiko Thiery , Alper Nebi Yasak Subject: [PATCH 4/5] binman: Convert FIT entry type to a subclass of Section entry type Date: Mon, 7 Feb 2022 00:02:48 +0300 Message-Id: <20220206210250.90406-5-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220206210250.90406-1-alpernebiyasak@gmail.com> References: <20220206210250.90406-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 The binman FIT entry type shares some code with the Section entry type. This shared code is bound to grow, since FIT entries are conceptually a variation of Section entries. Make FIT entry type a subclass of Section entry type, simplifying it a bit and providing us the features that Section implements. Also fix the subentry alignment test which now attempts to write symbols to a nonexistent SPL ELF test file by creating it first. Signed-off-by: Alper Nebi Yasak --- tools/binman/etype/fit.py | 70 +++++++++++---------------------------- tools/binman/ftest.py | 1 + 2 files changed, 20 insertions(+), 51 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 9dffcd5adbd6..0f8c88a9720e 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -9,11 +9,12 @@ import libfdt from binman.entry import Entry, EntryArg +from binman.etype.section import Entry_section from dtoc import fdt_util from dtoc.fdt import Fdt from patman import tools -class Entry_fit(Entry): +class Entry_fit(Entry_section): """Flat Image Tree (FIT) This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the @@ -112,15 +113,15 @@ def __init__(self, section, etype, node): """ Members: _fit: FIT file being built - _fit_sections: dict: + _entries: dict from Entry_section: key: relative path to entry Node (from the base of the FIT) value: Entry_section object comprising the contents of this node """ super().__init__(section, etype, node) self._fit = None - self._fit_sections = {} self._fit_props = {} + for pname, prop in self._node.props.items(): if pname.startswith('fit,'): self._fit_props[pname] = prop @@ -185,7 +186,7 @@ def _AddNode(base_node, depth, node): # 'data' property later. entry = Entry.Create(self.section, node, etype='section') entry.ReadNode() - self._fit_sections[rel_path] = entry + self._entries[rel_path] = entry for subnode in node.subnodes: if has_images and not (subnode.name.startswith('hash') or @@ -237,18 +238,19 @@ def _AddNode(base_node, depth, node): self._fdt = Fdt.FromData(fdt.as_bytearray()) self._fdt.Scan() - def ExpandEntries(self): - super().ExpandEntries() - for section in self._fit_sections.values(): - section.ExpandEntries() - - def ObtainContents(self): - """Obtain the contents of the FIT + def BuildSectionData(self, required): + """Build FIT entry contents This adds the 'data' properties to the input ITB (Image-tree Binary) then runs mkimage to process it. + + Args: + required: True if the data must be present, False if it is OK to + return None + + Returns: + Contents of the section (bytes) """ - # self._BuildInput() either returns bytes or raises an exception. data = self._BuildInput(self._fdt) uniq = self.GetUniqueName() input_fname = tools.GetOutputFilename('%s.itb' % uniq) @@ -264,14 +266,12 @@ def ObtainContents(self): 'pad': fdt_util.fdt32_to_cpu(ext_offset.value) } if self.mkimage.run(reset_timestamp=True, output_fname=output_fname, - **args) is not None: - self.SetContents(tools.ReadFile(output_fname)) - else: + **args) is None: # Bintool is missing; just use empty data as the output self.record_missing_bintool(self.mkimage) - self.SetContents(tools.GetBytes(0, 1024)) + return tools.GetBytes(0, 1024) - return True + return tools.ReadFile(output_fname) def _BuildInput(self, fdt): """Finish the FIT by adding the 'data' properties to it @@ -282,12 +282,8 @@ def _BuildInput(self, fdt): Returns: New fdt contents (bytes) """ - for path, section in self._fit_sections.items(): + for path, section in self._entries.items(): node = fdt.GetNode(path) - # Entry_section.ObtainContents() either returns True or - # raises an exception. - section.ObtainContents() - section.Pack(0) data = section.GetData() node.AddData('data', data) @@ -295,34 +291,6 @@ def _BuildInput(self, fdt): data = fdt.GetContents() return data - def CheckMissing(self, missing_list): - """Check if any entries in this FIT have missing external blobs - - If there are missing blobs, the entries are added to the list - - Args: - missing_list: List of Entry objects to be added to - """ - for path, section in self._fit_sections.items(): - section.CheckMissing(missing_list) - - def SetAllowMissing(self, allow_missing): - for section in self._fit_sections.values(): - section.SetAllowMissing(allow_missing) - def AddBintools(self, tools): - for section in self._fit_sections.values(): - section.AddBintools(tools) + super().AddBintools(tools) self.mkimage = self.AddBintool(tools, 'mkimage') - - def check_missing_bintools(self, missing_list): - """Check if any entries in this section have missing bintools - - If there are missing bintools, these are added to the list - - Args: - missing_list: List of Bintool objects to be added to - """ - super().check_missing_bintools(missing_list) - for entry in self._fit_sections.values(): - entry.check_missing_bintools(missing_list) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index ce0dcf7c3e02..785f64a0c98b 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3880,6 +3880,7 @@ def testPadInSections(self): def testFitImageSubentryAlignment(self): """Test relative alignability of FIT image subentries""" + self._SetupSplElf() entry_args = { 'test-id': TEXT_DATA, } -- 2.34.1