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 B3AF4EB64DC for ; Mon, 10 Jul 2023 02:42:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9DEF5865DA; Mon, 10 Jul 2023 04:41:50 +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="hD5OZ74H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0001F86093; Mon, 10 Jul 2023 04:41:41 +0200 (CEST) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 70912865D0 for ; Mon, 10 Jul 2023 04:41:37 +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-io1-xd29.google.com with SMTP id ca18e2360f4ac-78362f57500so206642039f.3 for ; Sun, 09 Jul 2023 19:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1688956896; x=1691548896; 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=phei8KQRv9yYEZMPKKin5s+HLbjc3Gkei03I43fFQyI=; b=hD5OZ74HP/UtZuv5z5bTMmy4Bln6vlZqA7taZ+musTlHhIStNxjNcRSDg6iAGwxhZ0 l5r6iX63VClsQKlDkqoACPaF63c+x8X3zQOpPgJhFLVlUWDAAfYzF56KMiEQheRvFr44 CkS52Vn0hjTy6tw9M2hrtYrmEqR2wOYAKxJnw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688956896; x=1691548896; 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=phei8KQRv9yYEZMPKKin5s+HLbjc3Gkei03I43fFQyI=; b=LsFumX9fpI35crOUeyYxhR6jUBPRuUYpjFpd3pKFp7cZGcTckRkKKMlC80/yLGs7Ye wHcxDCgdbK/gPkdb3QA273ZiWyPPYbt7kHBfF+pTM6X1A/ppdX4PX4lXmfRLoGttHbNU l6P+VtQr9yjX3HXTU27FWeiqKV/ZlSKTXEMr/8HhLiMSczBIlFtQVvkXgf7pEu8Y3f1U BvPsDcWgniGiXTnp5A0AbKfPVmcBDxd4R3KO5W5DbTIhRPE9JIoT8Gsxyg9U8qp16NpY HZiQA7KfiWvtUgA+j7VKChl5HVI8+nAuPfq9hDKfiTfO0WCRZ/7YCOJvf1ahMArjghkn U7hA== X-Gm-Message-State: ABy/qLaKE/LS5HWg8J7UIt8pnRshPUJafewImOVEmjKKMZc1rcxxK7GA yeUwUbfvy3TieMuDPklmnjgf8dPeDKo6sXNWaOo= X-Google-Smtp-Source: APBJJlEwIlSLRp0h4HdF9ZPkOfTrTEzxr7gfjW8cpbjskKKZYq+fvgL6VuHa7XyyTz3po1kXc0o//g== X-Received: by 2002:a5d:9f0f:0:b0:783:60f7:ade9 with SMTP id q15-20020a5d9f0f000000b0078360f7ade9mr13052040iot.5.1688956895971; Sun, 09 Jul 2023 19:41:35 -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 v22-20020a5ec116000000b00783581fd200sm3354025iol.20.2023.07.09.19.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 19:41:35 -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 v3 08/19] binman: Add more detail on how ObtainContents() works Date: Sun, 9 Jul 2023 20:41:06 -0600 Message-ID: <20230710024123.2078645-9-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog In-Reply-To: <20230710024123.2078645-1-sjg@chromium.org> References: <20230710024123.2078645-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 --- 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