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 24336EB64DD for ; Fri, 21 Jul 2023 16:08:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92060867F4; Fri, 21 Jul 2023 18:07:48 +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="LAjcsnxT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 120ED867C8; Fri, 21 Jul 2023 18:07:37 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 1C1D082A2C for ; Fri, 21 Jul 2023 18:07:34 +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-xd32.google.com with SMTP id ca18e2360f4ac-78372625badso91297639f.3 for ; Fri, 21 Jul 2023 09:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689955652; x=1690560452; 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=3veVr/vi+qN8ImZrC5pSVDzNlvOSnIpc3TKhXrXOqro=; b=LAjcsnxT2aVkwZGhpNhYc7cEJ+ml9VdEXGhjmrwkE2yKcr3JG9zWNohA6loGV29DYe EzHc5JIXSO67frmtucJjO0KK9AbWdsE6kC4acO+GwMhhRCvOH8zTpFZoCDX8H5ZgafP1 wlPRYo5Wqmlk1OM2UTxNuWbU2JSkL3H8BGUEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689955652; x=1690560452; 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=3veVr/vi+qN8ImZrC5pSVDzNlvOSnIpc3TKhXrXOqro=; b=ecL90VczlX5/v+nXOb3NWXqZ2NSzx5cdms+xwLYnELhO7iMFel1Va6yjgKA3jO9RC7 0ixiEs0PTOsM8a7YF4J1NGuWrHW4ft2t7wzY4Pe5WQV1oEci6HktJ5xqqF70KWm1f6Qa vm5HTonSJ2Vy3Pi/YTsWRL+AWaKNb2qrLv94MSIJfHL6jr62e0njrTzZQn4YJvVtZCbG /eK9HRgJK4bTIQIJJkckk0awzkKOviVJlAxBA7ajsJmghGbAo5ViJb5YwdEQvi4KKRJj 7uIjdznE90EqsxXJE4DQhMULg9hutd3AMvconktVch0GQ2Y6rRZ7OtuerI3Ucga9R5vI CeTw== X-Gm-Message-State: ABy/qLZgq1i9XEghCfTdnylspM5DWgK0he7Wws0tWVtKwnSw/OldajT7 kS8pgOTVvYrOvmfgiNbGIpd6/aqB+2Prqn3mWGY= X-Google-Smtp-Source: APBJJlHRaFeVCgE+jORx1TkeoHRUCattMIEsdjJNIEjl8w2rbROhPUibrej8uJQmKaTGa3LcU8lVzg== X-Received: by 2002:a6b:d817:0:b0:786:fff8:13c2 with SMTP id y23-20020a6bd817000000b00786fff813c2mr407100iob.11.1689955652608; Fri, 21 Jul 2023 09:07:32 -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 r17-20020a6bd911000000b0078680780694sm1158685ioc.34.2023.07.21.09.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 09:07:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Neha Malcom Francis , Stefan Herbrechtsmeier , Philippe Reynes , Peng Fan , Simon Glass Subject: [PATCH 6/6] WIP: binman: Support templates containing phandles Date: Fri, 21 Jul 2023 10:07:06 -0600 Message-ID: <20230721160710.968748-7-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230721160710.968748-1-sjg@chromium.org> References: <20230721160710.968748-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 provides support for phandles to be copied over from templates. This is not quite safe, since if the template is instantiated twice (i.e. in two different nodes), then duplicate phandles will be found. This patch is provided for some initial experimentation. Signed-off-by: Simon Glass --- tools/binman/control.py | 4 ++ tools/binman/ftest.py | 15 +++++++ tools/binman/test/291_template_phandle.dts | 51 ++++++++++++++++++++++ tools/dtoc/fdt.py | 1 + 4 files changed, 71 insertions(+) create mode 100644 tools/binman/test/291_template_phandle.dts diff --git a/tools/binman/control.py b/tools/binman/control.py index 3857f50e6436..6a6d247e6969 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -567,6 +567,10 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): _RemoveTemplates(node) dtb.Sync(True) + + # Rescan the dtb to pick up the new phandles + dtb.Scan() + node = _FindBinmanNode(dtb) fname = tools.get_output_filename('u-boot.dtb.tmpl2') tools.write_file(fname, dtb.GetContents()) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 7ea4797ad6ac..5f3f56e07736 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6900,6 +6900,21 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Move to next spl_data = content[:0x18] + def testTemplatePhandle(self): + """Test using a template in a node containing a phandle""" + entry_args = { + 'atf-bl31-path': 'bl31.elf', + } + data = self._DoReadFileDtb('291_template_phandle.dts', + entry_args=entry_args) + fname = tools.get_output_filename('image.bin') + out = tools.run('dumpimage', '-l', fname) + + # We should see the FIT description and one for each of the two images + lines = out.splitlines() + descs = [line.split()[-1] for line in lines if 'escription' in line] + self.assertEqual(['test-desc', 'atf', 'fdt'], descs) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/291_template_phandle.dts b/tools/binman/test/291_template_phandle.dts new file mode 100644 index 000000000000..c4ec1dd41bed --- /dev/null +++ b/tools/binman/test/291_template_phandle.dts @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + multiple-images; + + ti_spl_template: template-1 { + fit { + description = "test-desc"; + #address-cells = <1>; + images { + atf { + description = "atf"; + ti-secure { + type = "collection"; + content = <&atf>; + keyfile = "key.pem"; + }; + atf: atf-bl31 { + description = "atf"; + }; + }; + }; + }; + }; + + image { + insert-template = <&ti_spl_template>; + fit { + images { + fdt-0 { + description = "fdt"; + ti-secure { + type = "collection"; + content = <&foo_dtb>; + keyfile = "key.pem"; + }; + foo_dtb: blob-ext { + filename = "vga.bin"; + }; + }; + }; + }; + }; + }; +}; diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 917088041cc4..216c068c5fb5 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -835,6 +835,7 @@ class Fdt: TODO(sjg@chromium.org): Implement the 'root' parameter """ + self.phandle_to_node = {} self._cached_offsets = True self._root = self.Node(self, None, 0, '/', '/') self._root.Scan() -- 2.41.0.487.g6d72f3e995-goog