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 7D06FEB64DC for ; Tue, 11 Jul 2023 15:01:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED074868CB; Tue, 11 Jul 2023 17:00:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="kL9QFevT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 71878868B7; Tue, 11 Jul 2023 16:59:59 +0200 (CEST) Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 5AE908689D for ; Tue, 11 Jul 2023 16:59:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-345d3c10bdfso19919125ab.2 for ; Tue, 11 Jul 2023 07:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689087592; x=1691679592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W4AfIkQjb/up2mOVPev0QDiT6gLRbGWfzzjQ+cZ4MeA=; b=kL9QFevTBYrdzNM4NFG7LCf4JfBzhubV1jfQcJNBSBGJdDXT5S0mZ65ITqqT6aWPvW n8NeTVXVgBblgLrt3Jocr8dl3XKN7dKEeJykEvXKcOEAq2Eohy/MUnyoaULslR0iwjD+ gVHWDUiydwpfkdo1YnPMqrGR3CzUr91StvXvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689087592; x=1691679592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W4AfIkQjb/up2mOVPev0QDiT6gLRbGWfzzjQ+cZ4MeA=; b=EemVlxuNa487enJvfZCXx+650E0QFxlbHRaYRYiR7D2I8Sf74uRcC998bNPxmeXk9L dAvwNK8oaM8nFxtd05Ec34alvDBuq6qtOWAw7l5qSsqEH8N9/0Qnh7LzoPXKnj3fAlFT wm90ZyixTzL8Xdd2R5K1GBrWdmu22We4wdkriPa9GxlFLdoVjB6DZObEcDYWfhDOtgFy WvIcEnxosgEUt0hhL66P/IQpKCnJPhxsdgCO2LuVmbqTVsVU5MxgIP919t3PcYSSNtis gj3FV/IzF0CRRlW1IDHCeUXxPr351TdqrnmLGA0Yq04NiPEzzsRqXgcpU7zr4GZ0Ub1A gznw== X-Gm-Message-State: ABy/qLZNrjReVFgNesUyRWd6YO/vrYE9rQUZZYgAMCZoeWyXH1UE+/UY 9rw9yfC0UrJoXFt0MBUsTbHDcT7VuFxQkN2z9jk= X-Google-Smtp-Source: APBJJlFCJLn9+9rPegyB70cXEsbtWBkbOnp61QuXrcg2WylG0ozSyyVuPnyMA21lgiLswgrYDf5+kQ== X-Received: by 2002:a92:c647:0:b0:346:49bd:7b72 with SMTP id 7-20020a92c647000000b0034649bd7b72mr10742717ill.14.1689087591911; Tue, 11 Jul 2023 07:59:51 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id v6-20020a92cd46000000b00338a1272ce1sm658881ilq.52.2023.07.11.07.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 07:59:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Jan Kiszka , Simon Glass , Alper Nebi Yasak , Neha Malcom Francis , Peng Fan , Philippe Reynes , Stefan Herbrechtsmeier Subject: [PATCH v4 08/20] binman: Add more detail on how ObtainContents() works Date: Tue, 11 Jul 2023 08:59:10 -0600 Message-ID: <20230711145935.2289816-9-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog In-Reply-To: <20230711145935.2289816-1-sjg@chromium.org> References: <20230711145935.2289816-1-sjg@chromium.org> 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.8 at phobos.denx.de X-Virus-Status: Clean This area of binman can be a bit confusing. Add some more comments to help. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Add new patch with more detail on how ObtainContents() works tools/binman/entry.py | 3 +++ tools/binman/etype/section.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 328b5bc568a9..f20f32213a9b 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -474,6 +474,9 @@ class Entry(object): def ObtainContents(self, skip_entry=None, fake_size=0): """Figure out the contents of an entry. + For missing blobs (where allow-missing is enabled), the contents are set + to b'' and self.missing is set to True. + Args: skip_entry (Entry): Entry to skip when obtaining section contents fake_size (int): Size of fake file to create if needed diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index d56cc11d1023..d9b9e428024a 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -316,12 +316,15 @@ class Entry_section(Entry): This should be overridden by subclasses which want to build their own data structure for the section. + Missing entries will have be given empty (or fake) data, so are + processed normally here. + Args: required: True if the data must be present, False if it is OK to return None Returns: - Contents of the section (bytes) + Contents of the section (bytes), None if not available """ section_data = bytearray() @@ -711,6 +714,33 @@ class Entry_section(Entry): def GetEntryContents(self, skip_entry=None): """Call ObtainContents() for each entry in the section + The overall goal of this function is to read in any available data in + this entry and any subentries. This includes reading in blobs, setting + up objects which have predefined contents, etc. + + Since entry types which contain entries call ObtainContents() on all + those entries too, the result is that ObtainContents() is called + recursively for the whole tree below this one. + + Entries with subentries are generally not *themselves& processed here, + i.e. their ObtainContents() implementation simply obtains contents of + their subentries, skipping their own contents. For example, the + implementation here (for entry_Section) does not attempt to pack the + entries into a final result. That is handled later. + + Generally, calling this results in SetContents() being called for each + entry, so that the 'data' and 'contents_size; properties are set, and + subsequent calls to GetData() will return value data. + + Where 'allow_missing' is set, this can result in the 'missing' property + being set to True if there is no data. This is handled by setting the + data to b''. This function will still return success. Future calls to + GetData() for this entry will return b'', or in the case where the data + is faked, GetData() will return that fake data. + + Args: + skip_entry: (single) Entry to skip, or None to process all entries + Note that this may set entry.absent to True if the entry is not actually needed """ -- 2.41.0.390.g38632f3daf-goog