From patchwork Tue Feb 8 18:49:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590032 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=WgkYq8iQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXC82TsDz9s0B for ; Wed, 9 Feb 2022 05:50:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85E8583D8C; Tue, 8 Feb 2022 19:50:33 +0100 (CET) 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="WgkYq8iQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BAD8E83DA2; Tue, 8 Feb 2022 19:50:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 23C0A83D8A for ; Tue, 8 Feb 2022 19:50:27 +0100 (CET) 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-xd33.google.com with SMTP id q204so208639iod.8 for ; Tue, 08 Feb 2022 10:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LLKLgQPzMw4qmuNGCxI61akaSuT550GEthTbVZdpoCc=; b=WgkYq8iQG4tJ12QkvL8qxUdUfHWK5igxhZvUrw/kXtvvw4gkIB78j+K62rc/+uaNuL 1lqBbs4ffhlzb+I7BPPjjD9nWVWXrAm3O02gAco6sVrO4/qp5IGz5hutYMk+WB8jHERR 2Y0Diu7iB7AHjis3Sv5n0XB6DMbLKnpF0nu74= 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=LLKLgQPzMw4qmuNGCxI61akaSuT550GEthTbVZdpoCc=; b=7nke6htS+qRCckrP7nD7x0yTzuZPotssmNfZ4C8pG4H//VAGjO+gnyNFc6qW8R2zRH YwmUj1N7AxsApxUfdqvkI8wc3wE9BOMRsvxJj7MHlTOBLZhyQ0GLGvEckKjjLwZEv7WK 6pwSKrJL2W3fQGMUrCdF47HVakWLaw2+oEOh59nBzdKDYGCpLz9QyzgTLscAnnHoeoLV 9TVx7MCTxWAPwySfb98TBf2QMEsPYzuglpF8vQ93kwG2O8ljw1BhGofkuJyOMjaAx7G1 7oyytqz76KL3M6e3vxcliQEKKmI3OXLq02RjdXtBhaTqoRZgLDmQ7ZDYQ7ZF6M9labKO yOgQ== X-Gm-Message-State: AOAM5317OeAggv0dMhO+kfVSY2W656pwHEyZod8rxV61XpxyctfZ522B 1eJAv15H+LZQotxwGKmuFB88aN6N1eIf9A== X-Google-Smtp-Source: ABdhPJz5fBI/tSoRKZcRLYeipkFCbjKSRO+II9um0YpalWHF3pzibpJnhSd8lvJHUPo/BDzuBO+5zA== X-Received: by 2002:a5e:da47:: with SMTP id o7mr2659070iop.91.1644346225796; Tue, 08 Feb 2022 10:50:25 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Heinrich Schuchardt , Trevor Woerner Subject: [PATCH 01/24] moveconfig: Show the config name rather than the defconfig Date: Tue, 8 Feb 2022 11:49:45 -0700 Message-Id: <20220208114935.1.I28b16953dd8c39096a959acf715a423090fa5750@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 _defconfig suffix is unnecessary when showing matching boards. Drop it. Signed-off-by: Simon Glass --- tools/moveconfig.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 1bcf58caf1..5ef5a95eb6 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -91,7 +91,20 @@ SIZES = { 'SZ_4G': 0x100000000 } +RE_REMOVE_DEFCONFIG = re.compile(r'(.*)_defconfig') + ### helper functions ### +def remove_defconfig(defc): + """Drop the _defconfig suffix on a string + + Args: + defc (str): String to convert + + Returns: + str: string with the '_defconfig' suffix removed + """ + return RE_REMOVE_DEFCONFIG.match(defc)[1] + def check_top_directory(): """Exit if we are not at the top of source directory.""" for fname in 'README', 'Licenses': @@ -1638,7 +1651,7 @@ def do_find_config(config_list): print(f"Error: Not in Kconfig: %s" % ' '.join(adhoc)) else: print(f'{len(out)} matches') - print(' '.join(out)) + print(' '.join([remove_defconfig(item) for item in out])) def prefix_config(cfg): From patchwork Tue Feb 8 18:49:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590033 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jcum69DZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXCF21Y8z9s0B for ; Wed, 9 Feb 2022 05:50:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 481A283D9E; Tue, 8 Feb 2022 19:50:37 +0100 (CET) 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="jcum69DZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FACC83D89; Tue, 8 Feb 2022 19:50:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 25CAF83D91 for ; Tue, 8 Feb 2022 19:50:28 +0100 (CET) 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-xd2e.google.com with SMTP id w7so232329ioj.5 for ; Tue, 08 Feb 2022 10:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DtJIlZFbE3YhdDcvU6ezwOpN+8gpj67mHURhm1u+Mjw=; b=jcum69DZv6634Lu3mPXW4m4w0RuoeChuBjIqC8+VesLuhp5KKacogoVVIjcclSOFBI D8s4nHHz6QrAH36HXKHI5OfeJ4dnPT43zms+JkK3/kGWtCEpLziurOdXWj1ctKBeTvn8 t5pyW0pYax06Znr+jNHbaldAelkxV7nuT8YJc= 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=DtJIlZFbE3YhdDcvU6ezwOpN+8gpj67mHURhm1u+Mjw=; b=m2yQ44eXyYm+Iefjr4dqxAADtOYDB1Pm6WSeANAaNYnxWw3gg86w7UMSWoV5QIOBQS dcM/UMn34kV7JVFSASwj5w8V+SWxdC8kArUhKUC1hlL9NYjSF11+F8EIcYROeQjM5qkp 4MVpy7k4qTiSgxrHBuAjhee6C9VrECtLq2MRdKWH89tm+K8JdOiZcxCzuAnvkGRIKu5s zPXVhkiHcYpDLBh1hsk40OfcGKhxqYvYYXDto69MPIMYsPcMvwC7Tsbwj8XmdHFIOkqb NKICeOQnvWFCzjAjqO/2Rz8z4gXocVjaAo3rZrSGLk5z2+CTL6VlckjOaNxosv+4kUI8 IfIQ== X-Gm-Message-State: AOAM5334eE5U/mh6FfLaTRs/E8+dXK2E9DDikTZGNC+XMJ8DeR5gr/G+ qIXqC8rw8A1E905K5IAzvwaLKlv3L1XqZw== X-Google-Smtp-Source: ABdhPJy4jwLSDd4NyJRxlX0rr0f6raartWD/nm14w4RsKSeBzF6TY9uPL/9VLH9xI4aWIplb4u4Ocg== X-Received: by 2002:a05:6638:2608:: with SMTP id m8mr2867149jat.298.1644346226747; Tue, 08 Feb 2022 10:50:26 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Heinrich Schuchardt , Trevor Woerner Subject: [PATCH 02/24] moveconfig: Allow regex matches when finding combinations Date: Tue, 8 Feb 2022 11:49:46 -0700 Message-Id: <20220208114935.2.I061931956016352181753039d4df732997a7ab15@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 It is useful to be able to search for CONFIG options that match a regex, such as this, which lists boards which define SPL_FIT_GENERATOR and anything not starting with ROCKCHIP: ./tools/moveconfig.py -f SPL_FIT_GENERATOR ~ROCKCHIP.* Add support for this. Signed-off-by: Simon Glass --- tools/moveconfig.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 5ef5a95eb6..cff1e30658 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1606,12 +1606,31 @@ def do_imply_config(config_list, add_imply, imply_flags, skip_added, for linenum in sorted(linenums, reverse=True): add_imply_rule(config[CONFIG_LEN:], fname, linenum) +def defconfig_matches(configs, re_match): + """Check if any CONFIG option matches a regex + + The match must be complete, i.e. from the start to end of the CONFIG option. + + Args: + configs (dict): Dict of CONFIG options: + key: CONFIG option + value: Value of option + re_match (re.Pattern): Match to check + + Returns: + bool: True if any CONFIG matches the regex + """ + for cfg in configs: + m_cfg = re_match.match(cfg) + if m_cfg and m_cfg.span()[1] == len(cfg): + return True + return False def do_find_config(config_list): """Find boards with a given combination of CONFIGs Params: - config_list: List of CONFIG options to check (each a string consisting + config_list: List of CONFIG options to check (each a regex consisting of a config option, with or without a CONFIG_ prefix. If an option is preceded by a tilde (~) then it must be false, otherwise it must be true) @@ -1643,8 +1662,9 @@ def do_find_config(config_list): # running for the next stage in_list = out out = set() + re_match = re.compile(cfg) for defc in in_list: - has_cfg = cfg in config_db[defc] + has_cfg = defconfig_matches(config_db[defc], re_match) if has_cfg == want: out.add(defc) if adhoc: From patchwork Tue Feb 8 18:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590034 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=m2MXWNb1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXCW5ptYz9s0B for ; Wed, 9 Feb 2022 05:51:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68C1D83DB2; Tue, 8 Feb 2022 19:50:39 +0100 (CET) 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="m2MXWNb1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5C1C83DA9; Tue, 8 Feb 2022 19:50:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 459F283D95 for ; Tue, 8 Feb 2022 19:50:29 +0100 (CET) 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-xd34.google.com with SMTP id s18so175958ioa.12 for ; Tue, 08 Feb 2022 10:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xdxz4adpeabBtXjC1mRxxJJ6QW/6O3zpE15YEsvvzwE=; b=m2MXWNb1L7lc8lhyryP9gYPhvsCc8UDYDh0//+mrE4+IE5uXo4zMGZOSdgdaXQiys3 byHk8bYQ00tb2gbPKY3uD7v/66vnviOn2DfpNvYg8ZYNpJ3W7GJaz+Ix1bqGKqG8f1I6 wcDmGOMAsrr4e8JCDIIyyvCmifhoItfZlovck= 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=xdxz4adpeabBtXjC1mRxxJJ6QW/6O3zpE15YEsvvzwE=; b=X8in7/JI18vEuhgzZfNTfqM00PMucOxbP6A8+DzgEcG9eTgKbigPNmXIl48cMaOnZF 4uBHPxQEKQ3IsKUAbyjxGyAe2byu4467aDXc9FtVDB1xQmSmM21hKclogYCMwm8wB+M4 SrG7DbePBWwn3tuWv8Z4BMks8QEX8R9rT4TOMsRgIfrfefU07YNDCm3xoLvLjUrb0AmL 0Gth1TmMCIKZ9r293ljLKLYZdbtCsTKmnqqvBg2bLWTsIr4keGVpr7xytvVrU1SQ/JQI wpDmOEtxoyUmrbi96lKJd3O5tSZnqmQiozlCnYzU7Emt1U+o8I0rLxL9PPwqBI0a80sR n6Bg== X-Gm-Message-State: AOAM533r5OyORjf3zKmk3iqTSdhc//y3I86EETKhOnMKLf/RMKiLd2KC JTwcEM8NrQfLCUDymEQr0vRdzVkHCvHf+A== X-Google-Smtp-Source: ABdhPJyTPaghwRdIzclj8b40ozY6hEwRhjt3NmPUHDUQPBlEPxORkmnlByCRWYITDmFxQbwgEpmYgQ== X-Received: by 2002:a05:6602:3155:: with SMTP id m21mr2669503ioy.60.1644346227888; Tue, 08 Feb 2022 10:50:27 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Alexandru Gagniuc , Bin Meng , Heiko Schocher , Heiko Thiery , Heinrich Schuchardt , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , =?utf-8?q?Pali_Roh=C3=A1r?= , Ricardo Salveti , Stefan Roese Subject: [PATCH 03/24] spl: x86: Correct the binman symbols for SPL Date: Tue, 8 Feb 2022 11:49:47 -0700 Message-Id: <20220208185008.35843-2-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 These symbols are incorrect, meaning that binman cannot find the associated entry. This leads to errors like: binman: Section '/binman/simple-bin': Symbol '_binman_spl_prop_size' in entry '/binman/simple-bin/u-boot-spl/u-boot-spl-nodtb': Entry 'spl' not found in list (mkimage,u-boot-spl-nodtb, u-boot-spl-bss-pad,u-boot-spl-dtb,u-boot-spl,u-boot-img,main-section) Fix it. Signed-off-by: Simon Glass --- arch/x86/dts/u-boot.dtsi | 2 +- common/spl/spl.c | 8 ++++---- include/spl.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/dts/u-boot.dtsi b/arch/x86/dts/u-boot.dtsi index ca84d18ad9..24e692f988 100644 --- a/arch/x86/dts/u-boot.dtsi +++ b/arch/x86/dts/u-boot.dtsi @@ -37,7 +37,7 @@ u-boot-tpl-dtb { }; #endif - spl { + u-boot-spl { type = "u-boot-spl"; offset = ; }; diff --git a/common/spl/spl.c b/common/spl/spl.c index 884102bdea..444907432c 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -54,8 +54,8 @@ binman_sym_declare(ulong, u_boot_any, image_pos); binman_sym_declare(ulong, u_boot_any, size); #ifdef CONFIG_TPL -binman_sym_declare(ulong, spl, image_pos); -binman_sym_declare(ulong, spl, size); +binman_sym_declare(ulong, u_boot_spl, image_pos); +binman_sym_declare(ulong, u_boot_spl, size); #endif /* Define board data structure */ @@ -143,14 +143,14 @@ void spl_fixup_fdt(void *fdt_blob) ulong spl_get_image_pos(void) { return spl_phase() == PHASE_TPL ? - binman_sym(ulong, spl, image_pos) : + binman_sym(ulong, u_boot_spl, image_pos) : binman_sym(ulong, u_boot_any, image_pos); } ulong spl_get_image_size(void) { return spl_phase() == PHASE_TPL ? - binman_sym(ulong, spl, size) : + binman_sym(ulong, u_boot_spl, size) : binman_sym(ulong, u_boot_any, size); } diff --git a/include/spl.h b/include/spl.h index bb92bc6ec6..8ceb3c0f09 100644 --- a/include/spl.h +++ b/include/spl.h @@ -269,8 +269,8 @@ struct spl_load_info { */ binman_sym_extern(ulong, u_boot_any, image_pos); binman_sym_extern(ulong, u_boot_any, size); -binman_sym_extern(ulong, spl, image_pos); -binman_sym_extern(ulong, spl, size); +binman_sym_extern(ulong, u_boot_spl, image_pos); +binman_sym_extern(ulong, u_boot_spl, size); /** * spl_get_image_pos() - get the image position of the next phase From patchwork Tue Feb 8 18:49:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590035 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CbUbNyiq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXCc3bCyz9s0B for ; Wed, 9 Feb 2022 05:51:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D2F283DB5; Tue, 8 Feb 2022 19:50:44 +0100 (CET) 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="CbUbNyiq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F86683D88; Tue, 8 Feb 2022 19:50:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 7B3AB83D99 for ; Tue, 8 Feb 2022 19:50:30 +0100 (CET) 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-x136.google.com with SMTP id h11so6634920ilq.9 for ; Tue, 08 Feb 2022 10:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kyS3dCj+tRwP4ONXbS7+SOTGjjKCGvYEzmqa3YXBU7I=; b=CbUbNyiquDsD9z147JadUiAdC1G0htrgZjNOCY6fIHuD1xlh4WtVlZK+LCaSh+zo4b pI7j20T7cyqHIzP+6kFwzRaTXAUI4/N2e3uo8kdYITYfc7o59/vK0+GG8UmP6Zx6oKtO YX2pCJN/2nHvdiPExpLlqdvCj2SgeUxQdkCho= 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=kyS3dCj+tRwP4ONXbS7+SOTGjjKCGvYEzmqa3YXBU7I=; b=1MMoXyqtir9oH9QOkRNZLVeskOFfzybTHS9UuWqETlYv/JKP0nXbZK7aWX1TLBIpI5 Tx+mrmb+GDDH19CyYNVQjhuDcqDBoeQpxjajM7ArsS44FvUHN9fyiI9sfXt3vEvgDw4T vBimoWDZsr9o+NaBQLQc67imW+seeegQomFl4MnSwj3srJDZhbpaU6ldgnJJ2HUMLP9H PBuynvM9iSjlawhy4mnMz9JgxC39TdrTQ2nALPolp6dMwWMlLy60SVKs5BvZW6yHlw6M 4swVUgjUT9L7q11OrwNjvuCkFA99mG2ePp0gXXR1EReubEX6mSMIRcMyjWucHvUw4Idt VMSg== X-Gm-Message-State: AOAM533I6CwSueVD/wNDP+MY9sVncXUX/FwQtzpQHFPoI/7qdG3ikpEU gk9SGjl2GlPgqR9Iuq8QvOpWT2W3Zt2V7Q== X-Google-Smtp-Source: ABdhPJwJ79nm+/gpK3cM+12koIYo+3uMQmP0iqnyla0OgP70vZMQXoVf82HebCNrgnLMDuAt0W5uQQ== X-Received: by 2002:a05:6e02:1c2c:: with SMTP id m12mr2975111ilh.113.1644346228973; Tue, 08 Feb 2022 10:50:28 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Alexandru Gagniuc , Bin Meng , Jaehoon Chung , =?utf-8?q?Marek_Beh=C3=BAn?= , Michal Simek , =?utf-8?q?Pali_Roh=C3=A1r?= , Ricardo Salveti , Stefan Roese Subject: [PATCH 04/24] spl: Allow disabling binman symbols in SPL Date: Tue, 8 Feb 2022 11:49:48 -0700 Message-Id: <20220208185008.35843-3-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 CONFIG_SPL_FIT is enabled we do not access U-Boot directly in the image, since it is embedded in a FIT which is parsed at runtime. Provide a CONFIG option to drop the symbols in this case. Signed-off-by: Simon Glass --- common/spl/Kconfig | 24 ++++++++++++++++++++++++ common/spl/spl.c | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index e0d0a6f77b..9418d37b2e 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -101,6 +101,18 @@ config SPL_SHOW_ERRORS This adds a small amount to SPL code size, perhaps 100 bytes. +config SPL_BINMAN_SYMBOLS + bool "Declare binman symbols in SPL" + depends on SPL_FRAMEWORK && BINMAN + default y + help + This enables use of symbols in SPL which refer to U-Boot, enabling SPL + to obtain the location of U-Boot simply by calling spl_get_image_pos() + and spl_get_image_size(). + + For this to work, you must have a U-Boot image in the binman image, so + binman can update SPL with the location of it. + menu "PowerPC and LayerScape SPL Boot options" config SPL_NAND_BOOT @@ -1321,6 +1333,18 @@ config TPL_SIZE_LIMIT Specifies the maximum length of the U-Boot TPL image. If this value is zero, it is ignored. +config TPL_BINMAN_SYMBOLS + bool "Declare binman symbols in SPL" + depends on SPL_FRAMEWORK && BINMAN + default y + help + This enables use of symbols in TPL which refer to U-Boot, enabling SPL + to obtain the location of U-Boot simply by calling spl_get_image_pos() + and spl_get_image_size(). + + For this to work, you must have a U-Boot image in the binman image, so + binman can update SPL with the location of it. + config TPL_FRAMEWORK bool "Support TPL based upon the common SPL framework" default y if SPL_FRAMEWORK diff --git a/common/spl/spl.c b/common/spl/spl.c index 444907432c..b452d4feeb 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -49,9 +49,11 @@ DECLARE_GLOBAL_DATA_PTR; u32 *boot_params_ptr = NULL; +#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS) /* See spl.h for information about this */ binman_sym_declare(ulong, u_boot_any, image_pos); binman_sym_declare(ulong, u_boot_any, size); +#endif #ifdef CONFIG_TPL binman_sym_declare(ulong, u_boot_spl, image_pos); @@ -140,6 +142,7 @@ void spl_fixup_fdt(void *fdt_blob) #endif } +#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS) ulong spl_get_image_pos(void) { return spl_phase() == PHASE_TPL ? @@ -153,6 +156,7 @@ ulong spl_get_image_size(void) binman_sym(ulong, u_boot_spl, size) : binman_sym(ulong, u_boot_any, size); } +#endif /* BINMAN_SYMBOLS */ ulong spl_get_image_text_base(void) { From patchwork Tue Feb 8 18:49:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590036 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gq4WAzWI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXCq0qRhz9s0B for ; Wed, 9 Feb 2022 05:51:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6574083D91; Tue, 8 Feb 2022 19:50:47 +0100 (CET) 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="gq4WAzWI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BEBA83D91; Tue, 8 Feb 2022 19:50:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 32AE683DA1 for ; Tue, 8 Feb 2022 19:50:31 +0100 (CET) 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-x12e.google.com with SMTP id d3so14751455ilr.10 for ; Tue, 08 Feb 2022 10:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q++H6YDN9x8EMj7IKRuQRp+xPeE5T2eQZncBRLxcKJM=; b=gq4WAzWI/6w6lIF3Pj6WVWHMZ0QPDzJ76/WPDGPknnf+AYQZBerE7IUMDKwsKNh5V+ vwsp+mow4kHDDXMMw+IGeBmkt2EPyIlRipo/6W6XVxFA5eEI8XcmOVkEMzfP+im7m+yL alxzKPW3z1y0Zoc54sf8hxL0uSBIqjyjJBdyI= 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=Q++H6YDN9x8EMj7IKRuQRp+xPeE5T2eQZncBRLxcKJM=; b=GfmSiPOYcFahDJS2a05AETC8ROWQKb9Ijwk53BmfUOHp97XBnFHYIp931Yrc+hp145 T5CH8BRzpLpeYPdG/DDiAbwjI+s6RTxh5DXWfYwoKYrq6cr9pkKf7TchyGxA7ZWAnyxD msGdUqgo52hy/SGbkEFe/+Jh/ZFxL+n79QgGVxPdbSsrR21RY+dSYZ7VzisR8FS4JRAa JgY9OuHqsKeSbDzzimxMDATLoVuAGz9rSjQV7J3WJb7dOqqu+Hm9AN/L+IHVXW2hrKEH 3w4XAvSrT3e21QvG3B5HHgHmx/ECjkK+Rxz6YlOm7PpDasyaL/3iNXjEOrLBB0+E0m4K vV+Q== X-Gm-Message-State: AOAM531XDxAGvlngwQjanXBZKj4Svnv2SGayCLECeKq6rij5Cv0yG4cG pVBzGZY15ykViqUXS82Ir9d6fnar/OqcEw== X-Google-Smtp-Source: ABdhPJxWJaAW6KW7FBzTPbNzfSNdfkkQdm7jAVU0w/O7Bo2hlH1ysspq9HYiGFmnGXstHRRiy3ZyKw== X-Received: by 2002:a92:d304:: with SMTP id x4mr2951981ila.181.1644346229883; Tue, 08 Feb 2022 10:50:29 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 05/24] rockchip: evb-rk3288: Drop raw-image support Date: Tue, 8 Feb 2022 11:49:49 -0700 Message-Id: <20220208185008.35843-4-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 This boards uses SPL_FIT so does not need to support loading a raw image. Drop it to avoid binman trying to insert a symbol which has no value. Signed-off-by: Simon Glass --- configs/evb-rk3288_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig index 97d4c14f65..6143c4d989 100644 --- a/configs/evb-rk3288_defconfig +++ b/configs/evb-rk3288_defconfig @@ -24,6 +24,7 @@ CONFIG_USE_PREBOOT=y CONFIG_DEFAULT_FDT_FILE="rk3288-evb-rk808.dtb" CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_SPL_OPTEE_IMAGE=y From patchwork Tue Feb 8 18:49:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590040 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=H9p1wJ9N; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXDb5CVzz9s0B for ; Wed, 9 Feb 2022 05:51:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5278D83DA1; Tue, 8 Feb 2022 19:50:57 +0100 (CET) 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="H9p1wJ9N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6BC0F83DB5; Tue, 8 Feb 2022 19:50:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 2DABE83DA5 for ; Tue, 8 Feb 2022 19:50:32 +0100 (CET) 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-x135.google.com with SMTP id e8so14733819ilm.13 for ; Tue, 08 Feb 2022 10:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XQp5vnKcWs4xicbrwOBaK+A50/3fA92+ILE1gg6cjr4=; b=H9p1wJ9NS2Jz82Z4y8t5eeg0cpSF8IoC+kydnw0nAb4SL3QfD1TrhzJR1osY4Lmo2Q NkShIhc/p9oJx+NB2aLt/+lGC1cpYEukSNVGn7t1qq2D+/qO2yhsDbElJknAyuEfOHFx hIAnn5DksSqEyXreYvJe0BXzfkNum5Y3SHObg= 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=XQp5vnKcWs4xicbrwOBaK+A50/3fA92+ILE1gg6cjr4=; b=AqHB50neho5m6qYi0vHAvtQU+u21pojTzf2JXyQHWgFC19Yv9YV4uTStLLppcbC9eo 6sjh303w1q0XLn2u34uZhsdyNCZ1Z63NBf+ZFGaPA1hTCaa9SgKl50+em424CUbeC+hz Ulp159rBHbRD08ljtpKzt3oB93EciNsI/UBOeJ0Q38k0ARt7NbMyd7e7Eb7eeMZgQ1zZ EgTAmv2FWfMPE+bBiTitsH6IMn4/2CZc1zWqN8dTtd0xha6x0fi+28OhpFCWC/JsmYte 6Sq7slgjhwn/xTnRkeaTH/YvgE/CrLDiLwBUxort2Utach7L1mKZiSfA5sQ4T7ImONZt TmJg== X-Gm-Message-State: AOAM530PAUTwA14TwS+s+VybBqOoE3ni21351VqFtDc+6vzQEYZlxTba g/Xv/kwxn5Q0FMOb+mrBoIQXcxXsLvs7pw== X-Google-Smtp-Source: ABdhPJz5A9OGA3ASDFvdQDOnshZcI/gqtIyHbuf0XYszsTodd4OnlU0Ml1/qr0kD0Vjq5RecRlQtrg== X-Received: by 2002:a05:6e02:541:: with SMTP id i1mr3014926ils.80.1644346230781; Tue, 08 Feb 2022 10:50:30 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Walter Lozano Subject: [PATCH 06/24] dtoc: Support adding a string list to a device tree Date: Tue, 8 Feb 2022 11:49:50 -0700 Message-Id: <20220208185008.35843-5-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add a new function to add a string list. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 18 ++++++++++++++++++ tools/dtoc/test_fdt.py | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 32a7aa9829..e7197f8f12 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -501,6 +501,24 @@ class Node: val = bytes(val, 'utf-8') return self.AddData(prop_name, val + b'\0') + def AddStringList(self, prop_name, val): + """Add a new string-list property to a node + + The device tree is marked dirty so that the value will be written to + the blob on the next sync. + + Args: + prop_name: Name of property to add + val (list of str): List of strings to add + + Returns: + Prop added + """ + out = b'' + for string in val: + out += bytes(string, 'utf-8') + b'\0' + return self.AddData(prop_name, out) + def AddInt(self, prop_name, val): """Add a new integer property to a node diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 55b70e9876..1a7e73ffce 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -531,6 +531,14 @@ class TestProp(unittest.TestCase): self.node.AddData('data', tools.GetBytes(65, 20000)) self.dtb.Sync(auto_resize=True) + def test_string_list(self): + """Test adding string-list property to a node""" + val = ['123', '456'] + self.node.AddStringList('stringlist', val) + self.dtb.Sync(auto_resize=True) + data = self.fdt.getprop(self.node.Offset(), 'stringlist') + self.assertEqual(b'123\x00456\0', data) + def testFromData(self): dtb2 = fdt.Fdt.FromData(self.dtb.GetContents()) self.assertEqual(dtb2.GetContents(), self.dtb.GetContents()) From patchwork Tue Feb 8 18:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590037 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=AJl7W+fv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXD12RWbz9s0B for ; Wed, 9 Feb 2022 05:51:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64A9583DD5; Tue, 8 Feb 2022 19:50:50 +0100 (CET) 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="AJl7W+fv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 855DB83D8B; Tue, 8 Feb 2022 19:50:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 05A1083D8B for ; Tue, 8 Feb 2022 19:50:33 +0100 (CET) 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-x12e.google.com with SMTP id z18so7269282iln.2 for ; Tue, 08 Feb 2022 10:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eDmEYX8HfxDRtumNAxAHAs4V3/ioTnGDb5+Q4UfoWrQ=; b=AJl7W+fvUKrN4lcrZIy0XZcPabQIW5zhlLH4VgpFlZBsKQKyL1CesPNvLbeRSOghiE ywCun/jxaTjpP+L2YaAvhmBQDdrTAMEIYMMdsGTWwkVuF9kdTeg1BtOoLcykYeWWhqBA rwsyD7Nt6TC804ft81LB9GMSac0hK/SA01eKU= 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=eDmEYX8HfxDRtumNAxAHAs4V3/ioTnGDb5+Q4UfoWrQ=; b=ZxXLp+PRNaUmnC78mn0lQM9WD+PmVIejpVbRg7uqH8uKI4Sx08wHKrLJ0iQsKwbmWv vHc4WvyYy1WfHfaW6sz9mekb4DuDDo9uaT3wJmEl3VSFh0NJyC3QxTDMtyDO1gX0B093 Q5Ma24JpfPuqMtB4xSuZlSEa8YZ7pvyeoNoDdpkkC2JpW4lt48qqBlNoMekosQXoMgMi r0Xi1f8kp2kafHS1vKL01BXxpGJhmfqHJ1iv8k2CwYKomGKpltXvQDR/SsZFwA7fqcD6 r2qgNbuvJbInpKpbISRp/RcWUKUV+o2aJfS0CzyeTfk96GegHaTzHTggugHEcV+qoHdU qzTA== X-Gm-Message-State: AOAM533m/AtZC+1E0XOoj5zqScUzn/E6J7dDJgIr1beMtIrXPHdOrX9K mzounKkoiU2gAI1UA1kEDrqELDBV8QRN5g== X-Google-Smtp-Source: ABdhPJy6FSp6np22bYInr2VLXpY1jDNZvqyW5ULNKuEXZ0rzRLNn0pec0F8NzZxMV+uwNn3pTxD9Ng== X-Received: by 2002:a05:6e02:1a05:: with SMTP id s5mr2922096ild.231.1644346231741; Tue, 08 Feb 2022 10:50:31 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Walter Lozano Subject: [PATCH 07/24] dtoc: Support deleting a node Date: Tue, 8 Feb 2022 11:49:51 -0700 Message-Id: <20220208185008.35843-6-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add a function to delete a node. This is synced to the tree when requested. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 17 +++++++++++++++++ tools/dtoc/test_fdt.py | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index e7197f8f12..8108a86c09 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -548,6 +548,23 @@ class Node: self.subnodes.append(subnode) return subnode + def Delete(self): + """Delete a node + + The node is deleted and the offset cache is invalidated. + + Args: + node (Node): Node to delete + + Raises: + ValueError if the node does not exist + """ + CheckErr(self._fdt._fdt_obj.del_node(self.Offset()), + "Node '%s': delete" % self.path) + parent = self.parent + self._fdt.Invalidate() + parent.subnodes.remove(self) + def Sync(self, auto_resize=False): """Sync node changes back to the device tree diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 1a7e73ffce..22e23c40f5 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -539,6 +539,15 @@ class TestProp(unittest.TestCase): data = self.fdt.getprop(self.node.Offset(), 'stringlist') self.assertEqual(b'123\x00456\0', data) + def test_delete_node(self): + """Test deleting a node""" + old_offset = self.fdt.path_offset('/spl-test') + self.assertGreater(old_offset, 0) + self.node.Delete() + self.dtb.Sync() + new_offset = self.fdt.path_offset('/spl-test', libfdt.QUIET_NOTFOUND) + self.assertEqual(-libfdt.NOTFOUND, new_offset) + def testFromData(self): dtb2 = fdt.Fdt.FromData(self.dtb.GetContents()) self.assertEqual(dtb2.GetContents(), self.dtb.GetContents()) From patchwork Tue Feb 8 18:49:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590038 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JtxCY6Mw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXDC53qrz9s0B for ; Wed, 9 Feb 2022 05:51:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A95083D8E; Tue, 8 Feb 2022 19:50:53 +0100 (CET) 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="JtxCY6Mw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E119783DB7; Tue, 8 Feb 2022 19:50:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 05B0583DA2 for ; Tue, 8 Feb 2022 19:50:34 +0100 (CET) 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-x134.google.com with SMTP id d3so14751580ilr.10 for ; Tue, 08 Feb 2022 10:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B87ogGoUVXcau8k+WFC2ug0k9vF20/UKvyNjaruQtEY=; b=JtxCY6Mw1EY8alSv5OkR0hV2t47h8u0nSzQfm9OfJa1rd/6oIcm6uLaiYOUXmungSg 33TfKs1gx2I4hSxJcQx+NfL2sdm69ZNmcBuRh7wjTVnO5QiPFymSUTs4xzhLMqy68KWH HItsHFjbSd3pThyVggvgf15XP3uQmos6FqsHw= 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=B87ogGoUVXcau8k+WFC2ug0k9vF20/UKvyNjaruQtEY=; b=BXGuiYxuD4KqitHS1oXIMKtLlJ4VNEn0Gv9UNtSejgEliq/6MVaf5mvDX7zjyiE3UP AUpoE8+y6yfe8JjUeCuLVqob12crMpJnNTJuJyjoQr+PBzekEvKCnD2QzbeRcmQ29j58 SRaaKisxFA10So6l4LSIwTFWZYjH+bHJ6m/23UuVh3reH7oVB+om8wnI2Y8TPyxBfoNY jUK4ZT/yPuMF4R0wjIU036hJWYeNOk0FZ9mBbwrOxbuAvjKpeAgxvUbsy+REq5cZE4LW 3mylS274CpyvVpvW6YsbeCsv78aw07tHZihOQ+59JebU+CZKjAJ5fCMvNfnBfB/k4+Q0 k/nw== X-Gm-Message-State: AOAM5334oZKB42dwwghxOHLcTvUSaG3xtFPHJiASPplKAl3sJX8NgqPt vtjl0lYzIFFhv/CgkWlB5aNCMnTlUQ8+8w== X-Google-Smtp-Source: ABdhPJxObbX2A0dTCjAhy869zaAV4qrLUUl05zxif1TfceKKDWsIqs8+depcKXVwvvhgEN51GKob1w== X-Received: by 2002:a05:6e02:1c4c:: with SMTP id d12mr2937255ilg.293.1644346232688; Tue, 08 Feb 2022 10:50:32 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Walter Lozano Subject: [PATCH 08/24] dtoc: Allow deleting nodes and adding them in the same sync Date: Tue, 8 Feb 2022 11:49:52 -0700 Message-Id: <20220208185008.35843-7-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 This does not work at present, since the current algorithm assumes that either there are no nodes or all nodes have an offset. If a node is new, but an old node is still in the tree, then syncing fails due to this assumption. Fix it and add a test. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 2 ++ tools/dtoc/test_fdt.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 8108a86c09..98d6e636ea 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -356,6 +356,8 @@ class Node: offset = fdt_obj.first_subnode(self._offset, QUIET_NOTFOUND) for subnode in self.subnodes: + if subnode._offset is None: + continue if subnode.name != fdt_obj.get_name(offset): raise ValueError('Internal error, node name mismatch %s != %s' % (subnode.name, fdt_obj.get_name(offset))) diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 22e23c40f5..c8fe5fc1de 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -272,6 +272,17 @@ class TestNode(unittest.TestCase): self.dtb.Sync(auto_resize=True) + def testAddOneNode(self): + """Testing deleting and adding a subnode before syncing""" + subnode = self.node.AddSubnode('subnode') + self.node.AddSubnode('subnode2') + self.dtb.Sync(auto_resize=True) + + # Delete a node and add a new one + subnode.Delete() + self.node.AddSubnode('subnode3') + self.dtb.Sync() + def testRefreshNameMismatch(self): """Test name mismatch when syncing nodes and properties""" prop = self.node.AddInt('integer-a', 12) From patchwork Tue Feb 8 18:49:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590039 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FNaU+tq+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXDQ2qYmz9s0B for ; Wed, 9 Feb 2022 05:51:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0FEBF83DAB; Tue, 8 Feb 2022 19:50:55 +0100 (CET) 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="FNaU+tq+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9881F83DB6; Tue, 8 Feb 2022 19:50:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 0AFB983D95 for ; Tue, 8 Feb 2022 19:50:35 +0100 (CET) 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-xd2e.google.com with SMTP id e79so165929iof.13 for ; Tue, 08 Feb 2022 10:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hrhtOiYm06rnthVwx4A23cGa7AHCu7EFMSFsZ8v0T9k=; b=FNaU+tq+Blfn2YmmnHh6PEE6RgnkGvtv8r2ErtPVvO261FWfZCyHG1+S6TP/Y+yi/b 8UMyAAfK/g72eq0qAFvjuzny6I6w8LhNvaJQ+6CreJtRVI8WdIMo01FzXJ2UYRIJeFbj KHmYxnuelJVJwh1hRu0TRGiVpTgzJWku936Qw= 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=hrhtOiYm06rnthVwx4A23cGa7AHCu7EFMSFsZ8v0T9k=; b=o+aNN8pmL2bbhQ3zl6Fo8pbWg8ufvUPT/Ul/tjuQ7mkL+AyZjsDSDkCOyMsDnkNs4U RvmaE8oTz764IpvXMRpXjVwdRvlKhpkLOrdUp/6DmgwjD6mEOF4Avk0muvPnwghmiPKB g6UC51j4e+VmyaNxNwsBjKbliBF6wh8MynsDf48upo2osxY7o36HtPJuEfJzPnhoGaEI 3l6rYOwqpto+n+VW3QOWw9vbiNtd80ZnBclVdaSj3oiP9mYkU24Q5L1HR++jfoN7tHNQ 7SCSALT4aD7CeZOzicajdmZ+fwcybubBzLFBVr05C0JW2fANu50kio9Xac9QQKg0pns1 luiQ== X-Gm-Message-State: AOAM533iQp8ee83W05HnYDQSPZgdG05Yy6pEkMnbf1ks5CoXuoCkeVsA FfiG4ihvtJ9b4hj6txtrDwNRv14eyc6pUg== X-Google-Smtp-Source: ABdhPJyum96QBEhBlgpkQ7Uif68DpqoaOgCzoFF14P0pCcbWJ2Y52tZRVxoPj+po3KOD1dk0u/Evfw== X-Received: by 2002:a02:cc8a:: with SMTP id s10mr2698864jap.263.1644346233654; Tue, 08 Feb 2022 10:50:33 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Walter Lozano Subject: [PATCH 09/24] dtoc: Support reading a list of arguments Date: Tue, 8 Feb 2022 11:49:53 -0700 Message-Id: <20220208185008.35843-8-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 It is helpful to support a string or stringlist containing a list of space-separated arguments, for example: args = "-n fred", "-a", "123"; This resolves to the list: -n fred -a 123 which can be passed to a program as arguments. Add a helper to do the required processing. Signed-off-by: Simon Glass --- tools/dtoc/fdt_util.py | 12 ++++++++++++ tools/dtoc/test/dtoc_test_simple.dts | 1 + tools/dtoc/test_fdt.py | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index 19eb13aef3..59e065884f 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -184,6 +184,18 @@ def GetStringList(node, propname, default=None): return [strval] return value +def GetArgs(node, propname): + prop = node.props.get(propname) + if not prop: + raise ValueError(f"Node '{node.path}': Expected property '{propname}'") + if prop.bytes: + value = GetStringList(node, propname) + else: + value = [] + lists = [v.split() for v in value] + args = [x for l in lists for x in l] + return args + def GetBool(node, propname, default=False): """Get an boolean from a property diff --git a/tools/dtoc/test/dtoc_test_simple.dts b/tools/dtoc/test/dtoc_test_simple.dts index 4c2c70af22..2d321fb034 100644 --- a/tools/dtoc/test/dtoc_test_simple.dts +++ b/tools/dtoc/test/dtoc_test_simple.dts @@ -62,5 +62,6 @@ orig-node { orig = <1 23 4>; + args = "-n first", "second", "-p", "123,456", "-x"; }; }; diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index c8fe5fc1de..5d46e69b8b 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -652,6 +652,21 @@ class TestFdtUtil(unittest.TestCase): self.assertEqual(['test'], fdt_util.GetStringList(self.node, 'missing', ['test'])) + def testGetArgs(self): + node = self.dtb.GetNode('/orig-node') + self.assertEqual(['message'], fdt_util.GetArgs(self.node, 'stringval')) + self.assertEqual( + ['multi-word', 'message'], + fdt_util.GetArgs(self.node, 'stringarray')) + self.assertEqual([], fdt_util.GetArgs(self.node, 'boolval')) + self.assertEqual(['-n', 'first', 'second', '-p', '123,456', '-x'], + fdt_util.GetArgs(node, 'args')) + with self.assertRaises(ValueError) as exc: + fdt_util.GetArgs(self.node, 'missing') + self.assertIn( + "Node '/spl-test': Expected property 'missing'", + str(exc.exception)) + def testGetBool(self): self.assertEqual(True, fdt_util.GetBool(self.node, 'boolval')) self.assertEqual(False, fdt_util.GetBool(self.node, 'missing')) From patchwork Tue Feb 8 18:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590041 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=EFjoQpUx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXDp6HYTz9s0B for ; Wed, 9 Feb 2022 05:52:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 367A483DBA; Tue, 8 Feb 2022 19:50:59 +0100 (CET) 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="EFjoQpUx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BDDB883D95; Tue, 8 Feb 2022 19:50:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 E15CF83DA9 for ; Tue, 8 Feb 2022 19:50:35 +0100 (CET) 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-xd30.google.com with SMTP id h7so245851iof.3 for ; Tue, 08 Feb 2022 10:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J5wi1c/Di7SQFbL7IMqgJLZ3W89EzbSPWktIc58v1HM=; b=EFjoQpUxQqF5oCj/iHMUDcuFEOWYVmbjHaQBkxSVrVMknzcK+L8T6bcHufpY0Uzct2 sCFkNh/hBbiy6RnlXbfmGGuuLqvtcaxNXL2r83ihIXcUQUbmHS2vqvMteRYQaoE0uZ1d cBKourSm/eCZesbFe6/vaSGvZ33whH2Q1c1L0= 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=J5wi1c/Di7SQFbL7IMqgJLZ3W89EzbSPWktIc58v1HM=; b=ENvVXxFgfUIXczW7R/Wlt43zVAVZp5J8ejN5VUhnNrfo7HBhBsLRVZbBcBSv3+KPur Cx0NmI4T8Ehak00aWcwahRAQdoTd4jp61nsX6A7vtfHWGI9rJKGF+igbUskN5LVssuUr JCWLnWC1nDD8nVw5AMVuxFFeSD5fQ/8jH4DwCRmMg2FgRXC4wb/yi29HQu2ctRF8pZAf kYAEVJ4zXAWpAwBElSjvWTLpuMYjI9A5XHLrVJWfQDewE4b8ExzAgoWWMXumvKWLDrj3 S8nPvqmXtLJIBykk1TbL+eC7d3u4FXFDV2taRIc7w9/HfZB2g2AqwHMEnMeBSlxxli5X h75A== X-Gm-Message-State: AOAM532P/9IZmGZGpoa3virh6LDx97MwALTwVIPLe4fVGpDHVPsLZjh4 lOjpmqWl5hJMrBEj3+jRv7guyXbr4KMQ+w== X-Google-Smtp-Source: ABdhPJxRBKU0SRztZNZ7n0uTCwqZjNTtG2KxysajYrU7P7UIa0tXYQLBWWRU2deOccf1gpuXqjyq8A== X-Received: by 2002:a05:6602:2d87:: with SMTP id k7mr2655417iow.215.1644346234579; Tue, 08 Feb 2022 10:50:34 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 10/24] binman: Update docs to indicate mkimage is supported Date: Tue, 8 Feb 2022 11:49:54 -0700 Message-Id: <20220208185008.35843-9-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Now that there is a mkimage entry-type, update the docs to remove the future reference. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/binman.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index ab5a5e06b1..9e39e678a3 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -163,8 +163,8 @@ Consider sunxi. It has the following steps: Binman is intended to replace the last step. The U-Boot build system builds u-boot.bin and sunxi-spl.bin. Binman can then take over creation of -sunxi-spl.bin (by calling mksunxiboot, or hopefully one day mkimage). In any -case, it would then create the image from the component parts. +sunxi-spl.bin by calling mksunxiboot or mkimage. In any case, it would then +create the image from the component parts. This simplifies the U-Boot Makefile somewhat, since various pieces of logic can be replaced by a call to binman. From patchwork Tue Feb 8 18:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590042 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=efKusshH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXF12dfDz9s0B for ; Wed, 9 Feb 2022 05:52:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA34583DCF; Tue, 8 Feb 2022 19:51:01 +0100 (CET) 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="efKusshH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 429C583DB5; Tue, 8 Feb 2022 19:50:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 D111183D8E for ; Tue, 8 Feb 2022 19:50:36 +0100 (CET) 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-xd33.google.com with SMTP id 9so260873iou.2 for ; Tue, 08 Feb 2022 10:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UEU9MooiLExtXqu0R9qrft/1TuuZqc1pDYq/CXLqN0I=; b=efKusshHo0aF+om8TFPGJg512EfKefskXSPbaLtfKu0pooH38ZLGYljxPuHxpt6jyQ HOG4/AfdNbosRB39XjSiORf7XPWicNm2pVtMhclCGL8GU883042Y84J8w1N1dKx8DB9f l86T+zhNNkQhnxWq9jLzEguLOtH+13Mh7yIhc= 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=UEU9MooiLExtXqu0R9qrft/1TuuZqc1pDYq/CXLqN0I=; b=KbD42HjyNi8ObQMDep1xnncS2ImOdxjI248yWIlFhFlz0VBO/xQEpBu6+rq6kMPLoR DYKJM/wrt02kCJab/7Z+4BtImLIBKokj4fvPdVrRVO1krWzxu9qi/bXZjSDA7RD946tJ XgKKwk5ADCbVCL+k6X27SEr+DW0QNy9k9lMPOxVDFT9iC89ObnrlCZ+RlYzGBLtxzVDj +YQwrfgEtOgkqmH7Mck4vYpHMQwZk8TzIBiiC5ygghzBMtmIDd1IcO+hus16MbSo4Cbe 4rKw9w2pd2he0vPl/pCPxQ7Gv6iMuwVTC3hxnME7lcC/3iWaxywZSrlAmYNxxHTK8sbs mM8Q== X-Gm-Message-State: AOAM532rC3ctrBXz0PeYhwiwSyTBD7y1HSTxPWEpt9WjtG4x0eF41Sb1 OWxAqBQYhb34/EsNjmrL1e59ejcttdNvyw== X-Google-Smtp-Source: ABdhPJxHoPaPGHgQPKT1FexzhLoZP7H+3GSPpYIVa935lCNFU13g/OM/VRsyl/XdrJOYReFoMnekew== X-Received: by 2002:a05:6638:130f:: with SMTP id r15mr411745jad.114.1644346235534; Tue, 08 Feb 2022 10:50:35 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 11/24] elf: Add a way to read segment information from an ELF file Date: Tue, 8 Feb 2022 11:49:55 -0700 Message-Id: <20220208185008.35843-10-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add a function which reads the segments and the entry address. Also fix a comment nit in the tests while we are here. Signed-off-by: Simon Glass --- tools/binman/elf.py | 37 +++++++++++++++++++++++++++++++++++++ tools/binman/elf_test.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/tools/binman/elf.py b/tools/binman/elf.py index de2bb4651f..2b83ac1876 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -20,6 +20,7 @@ from patman import tout ELF_TOOLS = True try: from elftools.elf.elffile import ELFFile + from elftools.elf.elffile import ELFError from elftools.elf.sections import SymbolTableSection except: # pragma: no cover ELF_TOOLS = False @@ -369,3 +370,39 @@ def UpdateFile(infile, outfile, start_sym, end_sym, insert): newdata += data[syms[end_sym].offset:] tools.WriteFile(outfile, newdata) tout.Info('Written to offset %#x' % syms[start_sym].offset) + +def read_segments(data): + """Read segments from an ELF file + + Args: + data (bytes): Contents of file + + Returns: + tuple: + list of segments, each: + int: Segment number (0 = first) + int: Start address of segment in memory + bytes: Contents of segment + int: entry address for image + + Raises: + ValueError: elftools is not available + """ + if not ELF_TOOLS: + raise ValueError('Python elftools package is not available') + with io.BytesIO(data) as inf: + try: + elf = ELFFile(inf) + except ELFError as err: + raise ValueError(err) + entry = elf.header['e_entry'] + segments = [] + for i in range(elf.num_segments()): + segment = elf.get_segment(i) + if segment['p_type'] != 'PT_LOAD' or not segment['p_memsz']: + skipped = 1 # To make code-coverage see this line + continue + start = segment['p_offset'] + rend = start + segment['p_filesz'] + segments.append((i, segment['p_paddr'], data[start:rend])) + return segments, entry diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index f727258487..369260c17a 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -56,8 +56,8 @@ class FakeSection: def BuildElfTestFiles(target_dir): """Build ELF files used for testing in binman - This compiles and links the test files into the specified directory. It the - Makefile and source files in the binman test/ directory. + This compiles and links the test files into the specified directory. It uses + the Makefile and source files in the binman test/ directory. Args: target_dir: Directory to put the files into @@ -258,6 +258,33 @@ class TestElf(unittest.TestCase): offset = elf.GetSymbolFileOffset(fname, ['missing_sym']) self.assertEqual({}, offset) + def test_read_segments(self): + """Test for read_segments()""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') + fname = self.ElfTestFile('embed_data') + segments, entry = elf.read_segments(tools.ReadFile(fname)) + + def test_read_segments_fail(self): + """Test for read_segments() without elftools""" + try: + old_val = elf.ELF_TOOLS + elf.ELF_TOOLS = False + fname = self.ElfTestFile('embed_data') + with self.assertRaises(ValueError) as e: + elf.read_segments(tools.ReadFile(fname)) + self.assertIn('Python elftools package is not available', + str(e.exception)) + finally: + elf.ELF_TOOLS = old_val + + def test_read_segments_bad_data(self): + """Test for read_segments() with an invalid ELF file""" + fname = self.ElfTestFile('embed_data') + with self.assertRaises(ValueError) as e: + elf.read_segments(tools.GetBytes(100, 100)) + self.assertIn('Magic number does not match', str(e.exception)) + if __name__ == '__main__': unittest.main() From patchwork Tue Feb 8 18:49:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590045 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hhzzGW2Q; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXFb3ZBrz9s0B for ; Wed, 9 Feb 2022 05:52:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C45D83DEB; Tue, 8 Feb 2022 19:51:09 +0100 (CET) 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="hhzzGW2Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6BEC083DA1; Tue, 8 Feb 2022 19:50:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 E2EA483DA0 for ; Tue, 8 Feb 2022 19:50:37 +0100 (CET) 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-xd2a.google.com with SMTP id m185so190858iof.10 for ; Tue, 08 Feb 2022 10:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LXsWhRTxGWga2LO+3UzldHDtmBJyWnHptJv2jptmnXQ=; b=hhzzGW2QR7REds48Sc/oP29OG0qYotbumTij8SgvKQGmFY81Sef+lBlvfSzsO1jQCc HeU3xjUogNf5cv5DhOkfFcUciFJbaLP1KeGoW6fPylxblvw2SRRVU8j7Ai8mVhJzA36c Do9alRkrnwg9GG/aXz5DinmrxOBl2g1DzCm3w= 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=LXsWhRTxGWga2LO+3UzldHDtmBJyWnHptJv2jptmnXQ=; b=yYXXy98ooBVg8KIO/KX1NQgpXHwRkaOjIml2A3eThvoteN1sTR20NNewDYILTd/lNY 4kVKt+4BVGIxyrC8+2z8kLPfow9Wd0cgstPrGJOqLcaq/2vbaVTMF26k2NaCtJ9bWoKb 9he2p2UxdYtbKd0KiJbJWKMcvQof2GS0LB0G1WX2TVs2dR0vO3ku9vJ/ucvBwPEbWCMB z336iPwGL6KogNbxa0lYctykLyFgYLxBdr+uasd8BhNDqfJFDqkRf9xnMKPXxpRTVfqd 1vX6WTl/ZlBOih35gM1dmrE7Lc7/sO6ClQzbZwqdB7yytEqjdpAAAPpOzTmAKPmiD9ES /x3w== X-Gm-Message-State: AOAM5312t9MfYf/QFg3ghC+qdzLzlARWd9sEebk3LjG0UuWrzmPLI5SP bmEE1QCccmN1Cy57m5pLsqZnr2lp5kYyog== X-Google-Smtp-Source: ABdhPJx/OTRnWbRWkQqc2Iy0RquAZT5JSGTDhkolWUWfk5n3lSiU+1QPA6TnD3G71KuUC0JkPIVnyg== X-Received: by 2002:a05:6638:190a:: with SMTP id p10mr2800685jal.313.1644346236499; Tue, 08 Feb 2022 10:50:36 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH 12/24] WIP: binman: Add support for OP-TEE Date: Tue, 8 Feb 2022 11:49:56 -0700 Message-Id: <20220208185008.35843-11-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add support for an Open Portable Trusted Execution Environment (OP-TEE) blob which is used with ARM Trusted Firmware. Note: This is a placeholder patch as Roger Quadros has already posted one: https://patchwork.ozlabs.org/project/uboot/patch/20220204130031.24610-1-rogerq@kernel.org/ Signed-off-by: Simon Glass --- Makefile | 1 + tools/binman/entries.rst | 13 +++++++++++++ tools/binman/etype/op_tee.py | 23 +++++++++++++++++++++++ tools/binman/missing-blob-help | 4 ++++ 4 files changed, 41 insertions(+) create mode 100644 tools/binman/etype/op_tee.py diff --git a/Makefile b/Makefile index a69cc088a7..ee1dc11e2f 100644 --- a/Makefile +++ b/Makefile @@ -1326,6 +1326,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ -I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \ $(foreach f,$(BINMAN_INDIRS),-I $(f)) \ -a atf-bl31-path=${BL31} \ + -a op-tee-path=${TEE} \ -a opensbi-path=${OPENSBI} \ -a default-dt=$(default_dt) \ -a scp-path=$(SCP) \ diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index c47f7df098..0fb6d56296 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -933,6 +933,19 @@ binman. +Entry: op-tee: Open Portable Trusted Execution Environment (OP-TEE) blob +------------------------------------------------------------------------ + +Properties / Entry arguments: + - op-tee-path: Filename of file to read into entry. This is typically + called tee.elf + +This entry holds the OP-TEE Elf file, typically started by U-Boot SPL. +See the U-Boot README for your architecture or board for how to use it. See +https://https://www.op-tee.org/ for more information about OP-TEE. + + + Entry: opensbi: RISC-V OpenSBI fw_dynamic blob ---------------------------------------------- diff --git a/tools/binman/etype/op_tee.py b/tools/binman/etype/op_tee.py new file mode 100644 index 0000000000..b34f561622 --- /dev/null +++ b/tools/binman/etype/op_tee.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2022 Google LLC +# Written by Simon Glass +# +# Entry-type module for Open Portable Trusted Execution Environment (OP-TEE) +# + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg + +class Entry_op_tee(Entry_blob_named_by_arg): + """Open Portable Trusted Execution Environment (OP-TEE) blob + + Properties / Entry arguments: + - op-tee-path: Filename of file to read into entry. This is typically + called tee.elf + + This entry holds the OP-TEE Elf file, typically started by U-Boot SPL. + See the U-Boot README for your architecture or board for how to use it. See + https://https://www.op-tee.org/ for more information about OP-TEE. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'op-tee') + self.external = True diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help index 551ca87f6c..c8e6b84882 100644 --- a/tools/binman/missing-blob-help +++ b/tools/binman/missing-blob-help @@ -33,3 +33,7 @@ k3-rti-wdt-firmware: If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for the R5F core(s) to trigger the system reset. One possible source is https://github.com/siemens/k3-rti-wdt. + +op-tee: +See the documentation for your board. You may need to build Open Portable +Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.elf From patchwork Tue Feb 8 18:49:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590043 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=cB8llBy9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXFC05Y1z9s0B for ; Wed, 9 Feb 2022 05:52:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C67F083DD4; Tue, 8 Feb 2022 19:51:04 +0100 (CET) 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="cB8llBy9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7834583D8E; Tue, 8 Feb 2022 19:50:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 A876B83DA1 for ; Tue, 8 Feb 2022 19:50:38 +0100 (CET) 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-xd2f.google.com with SMTP id r144so198050iod.9 for ; Tue, 08 Feb 2022 10:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eaBwDz7jSpNINOeAADk2YSjY1hHBEzh3cs38tEr/4vo=; b=cB8llBy9NoGwCfLXaskL11DfokvMpYetQfgn2tdEKPuHBBkB4vAc9SdLxgp+iZnPHK Zi3G8SnQm8bWeYV8xpJWyfSazmTJHNcQXFiofssojkORx2xTpTHgaRnTH7a/gtmMPE6P TcHLL8aPvGW538cnwhQMjjJw9xPTJJqBI4T7I= 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=eaBwDz7jSpNINOeAADk2YSjY1hHBEzh3cs38tEr/4vo=; b=u95XVuL1kvGGt6Amw0ScydhxJCC19PMQ5ISyHn45cMqRzUDplf5ieRuP5lB/Biyabz 9yUVhThjMEwVEFQsH7G6LsdBERcztCnnzyhLKBDuVxFEVInaFhlF3MkZVAiSkpjqwiiV Ve15NxR+ksb9feMNjlXrpvth+aexBomJE4YslnoiY0LrCChkOQbpYJYz3P0JW2SQb9Pb EBxXuJqDYeY3qRWB/yy9aLzH5Yfs7bS/4JEEDipZI+iGw/3zFzq8GctTQTdigX/5WBRl aKBuvoZtCkzjPdRkjUryXpcIsU+Cdq76go7AFM6roxef02afnrIKULb1VMSMSVe1rPUm DhUw== X-Gm-Message-State: AOAM533EZjcCZNC8WGq3EBA03D4dGQsbHW1DAsieoojvK2SRwfEI3SHh f6ez9X5D6S2KhKOYBEnsGWfkEGObLnK6BA== X-Google-Smtp-Source: ABdhPJwjtwtZpKk56Ym9Dv5r9VBH3lrc0NRZYCYUAHzwtJbmYvyblqrEAe4m57q4Pq+whT+Wqg3DFg== X-Received: by 2002:a02:c9ce:: with SMTP id c14mr2949643jap.85.1644346237363; Tue, 08 Feb 2022 10:50:37 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 13/24] binman: Add to the TODO Date: Tue, 8 Feb 2022 11:49:57 -0700 Message-Id: <20220208185008.35843-12-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add some ideas that have come to mind recently. Signed-off-by: Simon Glass --- tools/binman/binman.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 9e39e678a3..d6b95de1f5 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1402,6 +1402,14 @@ Some ideas: - Detect invalid properties in nodes - Sort the fdtmap by offset - Output temporary files to a different directory +- Rationalise the fdt, fdt_util and pylibfdt modules which currently have some + overlapping and confusing functionality +- Update the fdt library to use a better format for Prop.value (the current one + is useful for dtoc but not much else) +- Figure out how to make Fdt support changing the node order, so that + Node.AddSubnode() can support adding a node before another, existing node. + Perhaps it should completely regenerate the flat tree? + -- Simon Glass From patchwork Tue Feb 8 18:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590044 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Eo+enVvm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXFP1F9Tz9s0B for ; Wed, 9 Feb 2022 05:52:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 532B083DDF; Tue, 8 Feb 2022 19:51:07 +0100 (CET) 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="Eo+enVvm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5866983DC4; Tue, 8 Feb 2022 19:50:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 A1CF783DAB for ; Tue, 8 Feb 2022 19:50:39 +0100 (CET) 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-x129.google.com with SMTP id o10so14823591ilh.0 for ; Tue, 08 Feb 2022 10:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nHx0qWpob9zL3QFk8g+M8m3Tc6EJ26Glw4CrR0PRNmg=; b=Eo+enVvmGmP3GHTswFmynM7D4CAWPsO+l7LiIvtZR5thFS+4DfPZz4yBTgV5G/rZdg IPicIHnpzfrzVhfam+FaXjLr65FvxXSeRClOrmBU28Up6NOrUrV8Wx8ucmbkyC+udnTM kY/by+dpzz0Oyd41r2Hf4T+8swIdG5pHN0Cx4= 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=nHx0qWpob9zL3QFk8g+M8m3Tc6EJ26Glw4CrR0PRNmg=; b=dudnnEC1kVGF3cUkxVzgYPms3enK43+V/adKtEinJw7jB+jiKwnBI7NQGBDGN6qpXl /CiRDWsk65fmDoda9Qw/dqs7wfS/NqcjDN9DKo6J5yiMEwlh5XQap1IzJSK92ZkKy53b NEIYRJNF7JKyMbeHUuPMufTD3Vv+sacLdILYpAcC+yN3PwLssJ74cJVNFy2JgT8V3Esf BzXwTiGFyX4CCGsdDFizzDEp1zobc7JPiql4eLKD46IOAe5smV0SGqFdRVul7079FIsG kRaJ/mlxfwohWf82n5idrOZlVh9Tgm3j0t1CrL2k0rpB7WqU2A4FThLHJ1d9sHHVWcx+ y7cg== X-Gm-Message-State: AOAM533WUtQYslFmfLpWhaT8bislhYiMjD5h2C+0u2ZEzgKfoDfxHrEB uzlcYMhaWv9kLtfCoT0xzDdy/SNv1BV5Tg== X-Google-Smtp-Source: ABdhPJw2w8RJ3GPEZlD/1NnZc9GMmY37XrqQInDlQdILwtrE3w6V6qcK70ZfTP14bvoWkqEiBNzCGQ== X-Received: by 2002:a05:6e02:152c:: with SMTP id i12mr2879896ilu.215.1644346238257; Tue, 08 Feb 2022 10:50:38 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Heiko Thiery Subject: [PATCH 14/24] binman: Support a list of strings with the mkimage etype Date: Tue, 8 Feb 2022 11:49:58 -0700 Message-Id: <20220208185008.35843-13-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 At present the 'args' property of the mkimage entry type is a string. This makes it difficult to include CONFIG options in that property. In particular, this does not work: args = "-n CONFIG_SYS_SOC -E" since the preprocessor does not operate within strings, nor does this: args = "-n" CONFIG_SYS_SOC" "-E" since the device tree compiler does not understand string concatenation. With this new feature, we can do: args = "-n", CONFIG_SYS_SOC, "-E"; Signed-off-by: Simon Glass --- tools/binman/entries.rst | 11 +++++++++++ tools/binman/etype/mkimage.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 0fb6d56296..b32dc58933 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -931,6 +931,17 @@ This calls mkimage to create an imximage with u-boot-spl.bin as the input file. The output from mkimage then becomes part of the image produced by binman. +To use CONFIG options in the arguments, use a string list instead, as in +this example which also produces four arguments:: + + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T imximage"; + + u-boot-spl { + }; + }; + + Entry: op-tee: Open Portable Trusted Execution Environment (OP-TEE) blob diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 201ee4b569..9ecd1c2548 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -31,10 +31,21 @@ class Entry_mkimage(Entry): This calls mkimage to create an imximage with u-boot-spl.bin as the input file. The output from mkimage then becomes part of the image produced by binman. + + To use CONFIG options in the arguments, use a string list instead, as in + this example which also produces four arguments:: + + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T imximage"; + + u-boot-spl { + }; + }; + """ def __init__(self, section, etype, node): super().__init__(section, etype, node) - self._args = fdt_util.GetString(self._node, 'args').split(' ') + self._args = fdt_util.GetArgs(self._node, 'args') self._mkimage_entries = OrderedDict() self.align_default = None self.ReadEntries() From patchwork Tue Feb 8 18:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590046 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YgPyA+gQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXFp0G3qz9s0B for ; Wed, 9 Feb 2022 05:53:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A24083E04; Tue, 8 Feb 2022 19:51:11 +0100 (CET) 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="YgPyA+gQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 190D283DA5; Tue, 8 Feb 2022 19:50:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 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 89B8883D91 for ; Tue, 8 Feb 2022 19:50:40 +0100 (CET) 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 o10so14823620ilh.0 for ; Tue, 08 Feb 2022 10:50:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dlX2r/V3RnW819/c+UU6GBvW0f0+gLqm5WKSOLJ4OtI=; b=YgPyA+gQ+8Jp8mSr/BOeEJhEloRoNm6hngAztUGOnbd7EmVT47J9Tp8j2iKtQ/nU1n XAiSBt1VgGtdcM8aX8EwYQ+9bLtQE9a7Vj+pyXVjcCSOKC2MJZ19ZZYum5gVJ1mtemKA auXot7ZzbknsBqiomBkCK6WCOXUfeySPN1V9o= 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=dlX2r/V3RnW819/c+UU6GBvW0f0+gLqm5WKSOLJ4OtI=; b=eMDfzwXpFpM3T7HH7qMatSG7Y3f/wpNV0COZ9E2BSgu7+7Srs4f9ihzvg3DiCDMP8z /GVCmPFLptvJoQRHGcS0NFfANcJl4Uehv6b76WoKhX+qILbAFekqDW35loR1dm5Ma3hm tBqiT8yljjwXBrZINwR729Epb4k8ArsGPNNvx93SbfQ8WLnm+RcTQXUo8K4C167Qe+zg ei88j/157eBeoYFY0ITWLjO/cFszVKxTn8YLUBJ8sypHAJeFLT2DbkHX2znOVHAhKRqn FOL7suya7PfnyWKUtwU6PLUwFOTWA9SC1jG5F+XJfSe3bxTMpOgbf+UTrvWVIHqXfcne N0GQ== X-Gm-Message-State: AOAM532Ji6u7NS2RkUiqSVUasj/ubHOD6X3nF8NBHb/I21PV6MmqHLY1 XQf0nB4p7h8HRFOE4iZEFNYxHWJvMKRkmw== X-Google-Smtp-Source: ABdhPJzrswGjev0Vwktbp50DlzRsXFDmXKCIpK9eTRFsNs3KkM7ja18HMjxGAa7GthxEfpzrl9k2JQ== X-Received: by 2002:a05:6e02:1a09:: with SMTP id s9mr2773525ild.73.1644346239166; Tue, 08 Feb 2022 10:50:39 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 15/24] binman: Add a ELF test file with disjoint text sections Date: Tue, 8 Feb 2022 11:49:59 -0700 Message-Id: <20220208185008.35843-14-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add a file that has two text sections at different addresses, so we can test this behaviour in binman, once added. Signed-off-by: Simon Glass --- tools/binman/test/Makefile | 6 +++++- tools/binman/test/elf_sections.c | 20 +++++++++++++++++++ tools/binman/test/elf_sections.lds | 31 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/elf_sections.c create mode 100644 tools/binman/test/elf_sections.lds diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile index 387ba16335..57057e2d58 100644 --- a/tools/binman/test/Makefile +++ b/tools/binman/test/Makefile @@ -29,11 +29,12 @@ LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds +LDS_EFL_SECTIONS := -T $(SRC)elf_sections.lds TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \ u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \ u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \ - u_boot_binman_embed u_boot_binman_embed_sm + u_boot_binman_embed u_boot_binman_embed_sm elf_sections all: $(TARGETS) @@ -70,6 +71,9 @@ u_boot_binman_embed: u_boot_binman_embed.c u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED) u_boot_binman_embed_sm: u_boot_binman_embed_sm.c +elf_sections: CFLAGS += $(LDS_EFL_SECTIONS) +elf_sections: elf_sections.c + clean: rm -f $(TARGETS) diff --git a/tools/binman/test/elf_sections.c b/tools/binman/test/elf_sections.c new file mode 100644 index 0000000000..9bcce9af02 --- /dev/null +++ b/tools/binman/test/elf_sections.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Google LLC + * + * Program containing two text sections + */ + +int __attribute__((section(".sram_data"))) data[29]; + +int __attribute__((section(".sram_code"))) calculate(int x) +{ + data[0] = x; + + return x * x; +} + +int main(void) +{ + return calculate(123); +} diff --git a/tools/binman/test/elf_sections.lds b/tools/binman/test/elf_sections.lds new file mode 100644 index 0000000000..7b6e932592 --- /dev/null +++ b/tools/binman/test/elf_sections.lds @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2016 Google, Inc + */ + +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) + +SECTIONS +{ + . = 0x00000010; + _start = .; + + . = ALIGN(4); + .text : + { + *(.text*) + } + + . = 0x00001000; + .sram : + { + *(.sram*) + } + + /DISCARD/ : { + *(.comment) + *(.dyn*) + } +} From patchwork Tue Feb 8 18:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590048 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BekX5HAT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXGJ2gGxz9s0B for ; Wed, 9 Feb 2022 05:53:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BAF0A83E14; Tue, 8 Feb 2022 19:51:15 +0100 (CET) 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="BekX5HAT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9D0DA83DB6; Tue, 8 Feb 2022 19:50:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 AF2B183DC2 for ; Tue, 8 Feb 2022 19:50:41 +0100 (CET) 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-x133.google.com with SMTP id z18so14790160ilp.3 for ; Tue, 08 Feb 2022 10:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4S1CA/DOWEupIPb7IxT1RlGCxn/2US4T0YfOB445IMY=; b=BekX5HATUEO+D88vTQ14mywm2Z8v1SrEGScWf+UcShsciJu/YdNol4DnpU8L0HpnG5 +9Y6VFCy177FAqjuFRtE5fNDMxjKO8SzBtq+6EWSHV0GR2BIaySnYKrSruivc2hQv6ou YmKTjX9LH68x7C/MOoe+kBGUnlAnCc05iBcqg= 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=4S1CA/DOWEupIPb7IxT1RlGCxn/2US4T0YfOB445IMY=; b=WHJQ6L45GCU90dp5d+MCL1xH/N8wFOMwAQJI1188tGnRDdvtF+9aRJCFLxdbo6Odn6 p2c33UXhXlI2U0fN4I9426h84mzxLueFwcfRRNFV78GDCUxRBj4SdgPUR0fvKVZ8zNcj OiY+utbSIs4tS6zU/+JPMGz28dT6r+D9c7ZIl9IaGSusCvlPNyc4qQgjO0KvVXgAIh6+ USy1+4u+1tw+mdGE4GRUMkjqECGb0fNKEbidpvTfkEq2KQX7POOV65+S5ZCGZD9EliJv wqMKkgVZ6eORCqfdHxIGVtHuB8o0i3xFAunWP5GZ8NXPEcW+X4TSR45tmlv0ZBFz/EnA e0XQ== X-Gm-Message-State: AOAM532SheKbwWFYMPEXhzkuYMhU/jmQK2NtjOhMV2Tb8StJbD8EvZ79 SS2yVnI+E9NIRlhWwMytqEVsab6IVYHS7w== X-Google-Smtp-Source: ABdhPJzJieSMUHQXKfS4oCICKeciANUneSWgDtjvWuz04OlWAcJ8pkxDPr02AAzH5bS67vhhkTnrtA== X-Received: by 2002:a92:ca4c:: with SMTP id q12mr2984376ilo.141.1644346240112; Tue, 08 Feb 2022 10:50:40 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Heiko Thiery Subject: [PATCH 16/24] binman: Move entry-data collection into a Entry method Date: Tue, 8 Feb 2022 11:50:00 -0700 Message-Id: <20220208114935.16.Ic1c42c06d1559ee11280381470b64b8400703627@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Collecting the data from a list of entries and putting it in a file is a useful operation that will be needed by other entry types. Put this into a method in the Entry class. Add some documentation about how to collect data for an entry type. Signed-off-by: Simon Glass --- tools/binman/binman.rst | 86 +++++++++++++++++++++++++++++++++++ tools/binman/entry.py | 28 ++++++++++++ tools/binman/etype/mkimage.py | 14 ++---- 3 files changed, 118 insertions(+), 10 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index d6b95de1f5..771645380e 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1358,6 +1358,92 @@ development, since dealing with exceptions and problems in threads is more difficult. This avoids any use of ThreadPoolExecutor. +Collecting data for an entry type +--------------------------------- + +Some entry types deal with data obtained from others. For example, +`Entry_mkimage` calls the `mkimage` tool with data from its subnodes:: + + mkimage { + args = "-n test -T script"; + + u-boot-spl { + }; + + u-boot { + }; + }; + +This shows mkimage being passed a file consisting of SPL and U-Boot proper. It +is create by calling `Entry.collect_contents_to_file()`. Note that in this case, +the data is passed to mkimage for processing but does not appear separately in +the image. It may not appear at all, depending on what mkimage does. The +contents of the `mkimage` entry are entirely dependent on the processing done +by the entry, with the provided subnodes (`u-boot-spl` and `u-boot`) simply +providing the input data for that processing. + +Note that `Entry.collect_contents_to_file()` simply concatenates the data from +the different entries together, with no control over alignment, etc. Another +approach is to subclass `Entry_section` so that those features become available, +such as `size` and `pad-byte`. Then the contents of the entry can be obtained by +calling `BuildSectionData()`. + +There are other ways to obtain data also, depending on the situation. If the +entry type is simply signing data which exists elsewhere in the image, then +you can use `Entry_collection` as a base class. It lets you use a property +called `content` which lists the entries containing data to be processed. This +is used by `Entry_vblock`, for example:: + + u_boot: u-boot { + }; + vblock { + content = <&u_boot &dtb>; + keyblock = "firmware.keyblock"; + signprivate = "firmware_data_key.vbprivk"; + version = <1>; + kernelkey = "kernel_subkey.vbpubk"; + preamble-flags = <1>; + }; + + dtb: u-boot-dtb { + }; + +which shows an image containing `u-boot` and `u-boot-dtb`, with the `vblock` +image collecting their contents to produce input for its signing process, +without affecting those entries, which still appear in the final image +untouched. + +Another example is where an entry type needs several independent pieces of input +to function. For example, `Entry_fip` allows a number of different binary blobs +to be placed in their own individual places in a custom data structure in the +output image. To make that work you can add subnodes for each of them and call +`Entry.Create()` on each subnode, as `Entry_fip` does. Then the data for each +blob can come from any suitable place, such as an `Entry_u_boot` or an +`Entry_blob` or anything else:: + + atf-fip { + fip-hdr-flags = /bits/ 64 <0x123>; + soc-fw { + fip-flags = /bits/ 64 <0x123456789abcdef>; + filename = "bl31.bin"; + }; + + u-boot { + fip-uuid = [fc 65 13 92 4a 5b 11 ec + 94 35 ff 2d 1c fc 79 9c]; + }; + }; + +The `soc-fw` node is a `blob-ext` (i.e. it reads in a named binary file) whereas +`u-boot` is a normal entry type. This works because `Entry_fip` selects the +`blob-ext` entry type if the node name (here `soc-fw`) is recognised as being +a known blob type. + +When adding new entry types you are encouraged to use subnodes to provide the +data for processing, unless the `content` approach is more suitable. Ad-hoc +properties and other methods of obtaining data are discouraged, since it adds to +confusion for users. + History / Credits ----------------- diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 08770ec5f0..3eafa078ae 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -1108,3 +1108,31 @@ features to produce new behaviours. btool = bintool.Bintool.create(name) tools[name] = btool return btool + + def collect_contents_to_file(self, entries, prefix): + """Put the contents of a list of entries into a file + + Args: + entries (list of Entry): Entries to collect + prefix (str): Filename prefix of file to write to + + If any entry does not have contents yet, this function returns False + for the data. + + Returns: + Tuple: + bytes: Concatenated data from all the entries (or False) + str: Filename of file written (or False if no data) + str: Unique portion of filename (or False if no data) + """ + data = b'' + for entry in entries: + # First get the input data and put it in a file. If not available, + # try later. + if not entry.ObtainContents(): + return False, False, False + data += entry.GetData() + uniq = self.GetUniqueName() + fname = tools.GetOutputFilename(f'{prefix}.{uniq}') + tools.WriteFile(fname, data) + return data, fname, uniq diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 9ecd1c2548..145a50f1aa 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -51,16 +51,10 @@ class Entry_mkimage(Entry): self.ReadEntries() def ObtainContents(self): - data = b'' - for entry in self._mkimage_entries.values(): - # First get the input data and put it in a file. If not available, - # try later. - if not entry.ObtainContents(): - return False - data += entry.GetData() - uniq = self.GetUniqueName() - input_fname = tools.GetOutputFilename('mkimage.%s' % uniq) - tools.WriteFile(input_fname, data) + data, input_fname, uniq = self.collect_contents_to_file( + self._mkimage_entries.values(), 'mkimage') + if data is False: + return False output_fname = tools.GetOutputFilename('mkimage-out.%s' % uniq) if self.mkimage.run_cmd('-d', input_fname, *self._args, output_fname) is not None: From patchwork Tue Feb 8 18:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590047 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=C1UteXU+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXG33Tnkz9s0B for ; Wed, 9 Feb 2022 05:53:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6138B83DF6; Tue, 8 Feb 2022 19:51:13 +0100 (CET) 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="C1UteXU+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 649FD83DCC; Tue, 8 Feb 2022 19:50:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 92ABC83DA9 for ; Tue, 8 Feb 2022 19:50:42 +0100 (CET) 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-x12d.google.com with SMTP id o10so14823709ilh.0 for ; Tue, 08 Feb 2022 10:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nB7CS1GC1S+FoS1ihIKEXCs8n0MormBXdSlrnJs38vY=; b=C1UteXU+v6G8Ts34ewWL9vcEuVTvdHivqOA6y86fTrBXPJTOrVpiJkAMsb0WVu49Bm ndo+iiuRjX+ngOGozKrEV0kR+QI/9Vw8Z0Ebw0oFBgQo/4rMYfMhzx1UJ6l1xaa8o+1J WLeRpWwFstiuCHOYoWEqBoDKifqfctZKE+n0U= 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=nB7CS1GC1S+FoS1ihIKEXCs8n0MormBXdSlrnJs38vY=; b=oP43c0EHr8ykgC4i+73smvE7+Idtl49cXZeH2dPJa+jGnlb8oVanWl1n1X4T9GkzrW sY1LDim1639oEuRuW/x9UPYxl/RsqGYMN8reKni0afNXUvhMlmNlJu+noZjXctVKp1vF V1NktkB2oRhhf1B0HQPfW+zJKNDx9oQZ2DjQNRfpVNJF2b2YBSA//HJe35qJjypb1FoM zGZeGhNnnTMQU3Kfi0KXEPTe9Qlae+uWYb6cvo/9ZMyGjZZQu7V9B6cBEKkD4bYO+fc+ 8kXTVWVxRrz3ZuS4m2GxQRR9Qi6wFuEH2Pbdj4ESKTUaSpIijuR811Uv/6kf9hw0ucBS OVrQ== X-Gm-Message-State: AOAM531eK7A3HEtQePA2GZDxVNYmFzRSfCKRpV1R6s9dzn1WJmRugXwV pT4wAAOJyiRWITRktWpH2HcFjIfUjbQJuQ== X-Google-Smtp-Source: ABdhPJy+baL4tr7IEuUWtzZDONBZPjQFVrrlNmy3ZqNQHDDchYScVG9klQdk+BsI/qBAc2nN7LArpg== X-Received: by 2002:a05:6e02:1c06:: with SMTP id l6mr2980892ilh.48.1644346241101; Tue, 08 Feb 2022 10:50:41 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Jan Kiszka Subject: [PATCH 17/24] binman: fit: Refactor to reduce function size Date: Tue, 8 Feb 2022 11:50:01 -0700 Message-Id: <20220208114935.17.If9396449efcf221fff4e68e48264faf22b0ffc66@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Split subnode and property processing into separate functions to make the _AddNode() function a little smaller. Tweak a few comments. This does not change any functionality. Signed-off-by: Simon Glass --- tools/binman/etype/fit.py | 116 ++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 6ad4a686df..b159844960 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -141,12 +141,82 @@ class Entry_fit(Entry): super().ReadNode() def ReadEntries(self): + def _process_prop(pname, prop): + """Process special properties + + Handles properties with generated values. At present the only + supported property is 'default', i.e. the default device tree in + the configurations node. + + Args: + pname (str): Name of property + prop (Prop): Property to process + """ + if pname == 'default': + val = prop.value + # Handle the 'default' property + if val.startswith('@'): + if not self._fdts: + return + if not self._fit_default_dt: + self.Raise("Generated 'default' node requires default-dt entry argument") + if self._fit_default_dt not in self._fdts: + self.Raise("default-dt entry argument '%s' not found in fdt list: %s" % + (self._fit_default_dt, + ', '.join(self._fdts))) + seq = self._fdts.index(self._fit_default_dt) + val = val[1:].replace('DEFAULT-SEQ', str(seq + 1)) + fsw.property_string(pname, val) + return + fsw.property(pname, prop.bytes) + + def _generate_node(subnode, depth, in_images): + """Generate nodes from a template + + This creates one node for each member of self._fdts using the + provided template. If a property value contains 'NAME' it is + replaced with the filename of the FDT. If a property value contains + SEQ it is replaced with the node sequence number, where 1 is the + first. + + Args: + subnode (None): Generator node to process + depth: Current node depth (0 is the base 'fit' node) + in_images: True if this is inside the 'images' node, so that + 'data' properties should be generated + """ + if self._fdts: + # Generate nodes for each FDT + for seq, fdt_fname in enumerate(self._fdts): + node_name = subnode.name[1:].replace('SEQ', + str(seq + 1)) + fname = tools.GetInputFilename(fdt_fname + '.dtb') + with fsw.add_node(node_name): + for pname, prop in subnode.props.items(): + val = prop.bytes.replace( + b'NAME', tools.ToBytes(fdt_fname)) + val = val.replace( + b'SEQ', tools.ToBytes(str(seq + 1))) + fsw.property(pname, val) + + # Add data for 'images' nodes (but not 'config') + if depth == 1 and in_images: + fsw.property('data', + tools.ReadFile(fname)) + else: + if self._fdts is None: + if self._fit_list_prop: + self.Raise("Generator node requires '%s' entry argument" % + self._fit_list_prop.value) + else: + self.Raise("Generator node requires 'fit,fdt-list' property") + def _AddNode(base_node, depth, node): """Add a node to the FIT Args: base_node: Base Node of the FIT (with 'description' property) - depth: Current node depth (0 is the base node) + depth: Current node depth (0 is the base 'fit' node) node: Current node to process There are two cases to deal with: @@ -156,23 +226,7 @@ class Entry_fit(Entry): """ for pname, prop in node.props.items(): if not pname.startswith('fit,'): - if pname == 'default': - val = prop.value - # Handle the 'default' property - if val.startswith('@'): - if not self._fdts: - continue - if not self._fit_default_dt: - self.Raise("Generated 'default' node requires default-dt entry argument") - if self._fit_default_dt not in self._fdts: - self.Raise("default-dt entry argument '%s' not found in fdt list: %s" % - (self._fit_default_dt, - ', '.join(self._fdts))) - seq = self._fdts.index(self._fit_default_dt) - val = val[1:].replace('DEFAULT-SEQ', str(seq + 1)) - fsw.property_string(pname, val) - continue - fsw.property(pname, prop.bytes) + _process_prop(pname, prop) rel_path = node.path[len(base_node.path):] in_images = rel_path.startswith('/images') @@ -195,31 +249,7 @@ class Entry_fit(Entry): # fsw.add_node() or _AddNode() for it. pass elif self.GetImage().generate and subnode.name.startswith('@'): - if self._fdts: - # Generate notes for each FDT - for seq, fdt_fname in enumerate(self._fdts): - node_name = subnode.name[1:].replace('SEQ', - str(seq + 1)) - fname = tools.GetInputFilename(fdt_fname + '.dtb') - with fsw.add_node(node_name): - for pname, prop in subnode.props.items(): - val = prop.bytes.replace( - b'NAME', tools.ToBytes(fdt_fname)) - val = val.replace( - b'SEQ', tools.ToBytes(str(seq + 1))) - fsw.property(pname, val) - - # Add data for 'fdt' nodes (but not 'config') - if depth == 1 and in_images: - fsw.property('data', - tools.ReadFile(fname)) - else: - if self._fdts is None: - if self._fit_list_prop: - self.Raise("Generator node requires '%s' entry argument" % - self._fit_list_prop.value) - else: - self.Raise("Generator node requires 'fit,fdt-list' property") + _generate_node(subnode, depth, in_images) else: with fsw.add_node(subnode.name): _AddNode(base_node, depth + 1, subnode) From patchwork Tue Feb 8 18:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590049 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CD+PAA1h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXGV5HlYz9s0B for ; Wed, 9 Feb 2022 05:53:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EB9BE83E1B; Tue, 8 Feb 2022 19:51:17 +0100 (CET) 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="CD+PAA1h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0899783D8B; Tue, 8 Feb 2022 19:50:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 B292983D95 for ; Tue, 8 Feb 2022 19:50:43 +0100 (CET) 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-xd36.google.com with SMTP id r144so198321iod.9 for ; Tue, 08 Feb 2022 10:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E18LE/i1Z0IfTKqSDUg3bHTX3Y3cZQPdnBeF5eY1nJ8=; b=CD+PAA1hZckU+MKAkpuvhJ57BbcuelMMsyk+ppshlY4UjigIhD6T8kbOZ4Dl7Z1rtQ DEoqo7UBZWm5hzGW4V1h7Du6nArp/v/7/xgY5CjOgpytkYL1rij7V7Of7hf+vetu3F0n neLCoBTlcUSbrDyfFJ9aJSzH4iVPAaMAy3zVQ= 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=E18LE/i1Z0IfTKqSDUg3bHTX3Y3cZQPdnBeF5eY1nJ8=; b=vNaAMDYTyF09qdIE4cEWzsmrtAnyi1TU4LzCP+SCwIKHF34GCXTK1KyUFnu6b5kapr rdxGfVfOTAVxEHutgJw2PCUZtUREX9YVHQT5M0otI6knQ+jpI/94x9RB+iwdGUUcROcZ QaN+K5w8Obdt/A5DP1rVdYmaaiLPHjRq3IsH/mrqU8uK85RPs6MRJfpZEuZi4Dml0pfp a52KtG0OSC9srn7Wj8gS9Jhc2l3YljcgwWkrQ2DHWttRG5dPrfAwzve4KIWFPQrMR6oV a5txl0Rd06IHIb9FssUsoMKiXNuByxWNUh4XIgFD4G/z2S+cfA/bQyWXUBJJE1g11kF7 DtNg== X-Gm-Message-State: AOAM531a1Iei821iM1gTD+VZetGOm13cRVcdICd8ubRRhhg800Jehfch So7NM4C9+06PkSUBtHORL5mKp49yhG+ChA== X-Google-Smtp-Source: ABdhPJye9/Ag9z5xuDZ6QtO/D7NF+xppAaUjJOQYpokp3QIm6O7bVyFYN/jlDfMvLIPKwR5mMkceIA== X-Received: by 2002:a02:9569:: with SMTP id y96mr2839480jah.18.1644346242054; Tue, 08 Feb 2022 10:50:42 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Jan Kiszka Subject: [PATCH 18/24] binman: Tidy up the docs a little with fit Date: Tue, 8 Feb 2022 11:50:02 -0700 Message-Id: <20220208185008.35843-15-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add a few quotes and clarify the data property. Signed-off-by: Simon Glass --- tools/binman/entries.rst | 15 ++++++++------- tools/binman/etype/fit.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index b32dc58933..d4a1f333dc 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -554,10 +554,10 @@ For example, this creates an image containing a FIT with U-Boot SPL:: }; U-Boot supports creating fdt and config nodes automatically. To do this, -pass an of-list property (e.g. -a of-list=file1 file2). This tells binman -that you want to generates nodes for two files: file1.dtb and file2.dtb -The fit,fdt-list property (see above) indicates that of-list should be used. -If the property is missing you will get an error. +pass an `of-list` property (e.g. `-a of-list=file1 file2`). This tells +binman that you want to generates nodes for two files: `file1.dtb` and +`file2.dtb`. The `fit,fdt-list` property (see above) indicates that +`of-list` should be used. If the property is missing you will get an error. Then add a 'generator node', a node with a name starting with '@':: @@ -569,10 +569,11 @@ Then add a 'generator node', a node with a name starting with '@':: }; }; -This tells binman to create nodes fdt-1 and fdt-2 for each of your two +This tells binman to create nodes `fdt-1` and `fdt-2` for each of your two files. All the properties you specify will be included in the node. This node acts like a template to generate the nodes. The generator node itself does not appear in the output - it is replaced with what binman generates. +A 'data' property is created with the contents of the FDT file. You can create config nodes in a similar way:: @@ -586,8 +587,8 @@ You can create config nodes in a similar way:: }; }; -This tells binman to create nodes config-1 and config-2, i.e. a config for -each of your two files. +This tells binman to create nodes `config-1` and `config-2`, i.e. a config +for each of your two files. Available substitutions for '@' nodes are: diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index b159844960..bf84246904 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -47,10 +47,10 @@ class Entry_fit(Entry): }; U-Boot supports creating fdt and config nodes automatically. To do this, - pass an of-list property (e.g. -a of-list=file1 file2). This tells binman - that you want to generates nodes for two files: file1.dtb and file2.dtb - The fit,fdt-list property (see above) indicates that of-list should be used. - If the property is missing you will get an error. + pass an `of-list` property (e.g. `-a of-list=file1 file2`). This tells + binman that you want to generates nodes for two files: `file1.dtb` and + `file2.dtb`. The `fit,fdt-list` property (see above) indicates that + `of-list` should be used. If the property is missing you will get an error. Then add a 'generator node', a node with a name starting with '@':: @@ -62,10 +62,11 @@ class Entry_fit(Entry): }; }; - This tells binman to create nodes fdt-1 and fdt-2 for each of your two + This tells binman to create nodes `fdt-1` and `fdt-2` for each of your two files. All the properties you specify will be included in the node. This node acts like a template to generate the nodes. The generator node itself does not appear in the output - it is replaced with what binman generates. + A 'data' property is created with the contents of the FDT file. You can create config nodes in a similar way:: @@ -79,8 +80,8 @@ class Entry_fit(Entry): }; }; - This tells binman to create nodes config-1 and config-2, i.e. a config for - each of your two files. + This tells binman to create nodes `config-1` and `config-2`, i.e. a config + for each of your two files. Available substitutions for '@' nodes are: From patchwork Tue Feb 8 18:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590050 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VlV0UJDs; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXGg7557z9s0B for ; Wed, 9 Feb 2022 05:53:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E402983E2D; Tue, 8 Feb 2022 19:51:20 +0100 (CET) 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="VlV0UJDs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AF4B83D8B; Tue, 8 Feb 2022 19:50:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 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 B026383D8A for ; Tue, 8 Feb 2022 19:50:44 +0100 (CET) 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 f13so2550358ilq.5 for ; Tue, 08 Feb 2022 10:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+4IdX5ofSV8OHbRvIrPp1oIo+kG+nqK6YcXLIdSPmNc=; b=VlV0UJDsJBnF2JN9Xd8mKIiCoILdhB1B+C+6+v3cQqgVFVcX4m87M07TxIA9bKf18M gJluLtA8eh45hCRzUQmPaBnGeYpMxRkGqf4jZMvyQVDBR+ARZ2nnlPa/t3dvC5/9/YPr U/8iIGcwtJAUb8etTGlLQF4f31qM81G6d0u5s= 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=+4IdX5ofSV8OHbRvIrPp1oIo+kG+nqK6YcXLIdSPmNc=; b=YM0QnHoUujfi/eZpG2xN8ow8QFEVbmzEAxbzMPy+Chh5OuPG5IFV373mLcimld0GCh liiy8sms5NBYAzMvRmXjiBT50pgpsO+E8C7hjRj6OxqDleGrTRHFBxnwwukLTpKlV+bG WD69N4XThGILmz5E4vqIIWyrMs0wU5/y+bZuMs7eIOg+Ai+fC3NV8zUloKSNA7CacR3w avFnmd4j7k+T95hVf2p9X+P1l4yNRR0PLm03Uyl/cW44QGEfzFkcWYQe6bBbje2V5u3O QpbVKKLd6Lhk03F09xLkLmCqfTE/2GRYA926eCiQEOROeV1Q4KqXT0EOdPZ9HuRid20m lM7A== X-Gm-Message-State: AOAM532YA4ci6xvEOeiZTAwa3zN6VGc4jxzQs5gxTdzyChTz3OJbwpdH Z6etaNIZKLAUNkQDit67VIh/WoPMDmphnQ== X-Google-Smtp-Source: ABdhPJyTYnrkZ/AIIvAIJiSpofVO+My9/PUii3ws0rOPFLQXkDe+vg/hV01API3HV/Zw1wG/+pKbEQ== X-Received: by 2002:a05:6e02:1c84:: with SMTP id w4mr2923039ill.223.1644346243008; Tue, 08 Feb 2022 10:50:43 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Jan Kiszka Subject: [PATCH 19/24] binman: Allow different operations in FIT generator nodes Date: Tue, 8 Feb 2022 11:50:03 -0700 Message-Id: <20220208114935.19.I656d3463d2fb7d63526527b17a2cf91bd910ca9a@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 At present we only support expanding out FDT nodes. Make the operation into an @operation property, so that others can be supported. Re-arrange and tidy up the documentation so that it has separate headings for each topic. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/entries.rst | 85 +++++++++++----- tools/binman/etype/fit.py | 136 ++++++++++++++++++++----- tools/binman/ftest.py | 7 ++ tools/binman/test/220_fit_bad_oper.dts | 27 +++++ 4 files changed, 206 insertions(+), 49 deletions(-) create mode 100644 tools/binman/test/220_fit_bad_oper.dts diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index d4a1f333dc..d483169712 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -553,6 +553,68 @@ For example, this creates an image containing a FIT with U-Boot SPL:: }; }; +More complex setups can be created, with generated nodes, as described +below. + +Properties (in the 'fit' node itself) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Special properties have a `fit,` prefix, indicating that they should be +processed but not included in the final FIT. + +The top-level 'fit' node supports the following special properties: + + fit,external-offset + Indicates that the contents of the FIT are external and provides the + external offset. This is passed to mkimage via the -E and -p flags. + + fit,fdt-list + Indicates the entry argument which provides the list of device tree + files for the gen-fdt-nodes operation (as below). This is often + `of-list` meaning that `-a of-list="dtb1 dtb2..."` should be passed + to binman. + +Substitutions +~~~~~~~~~~~~~ + +Node names and property values support a basic string-substitution feature. +Available substitutions for '@' nodes (and property values) are: + +SEQ: + Sequence number of the generated fdt (1, 2, ...) +NAME + Name of the dtb as provided (i.e. without adding '.dtb') + +The `default` property, if present, will be automatically set to the name +if of configuration whose devicetree matches the `default-dt` entry +argument, e.g. with `-a default-dt=sun50i-a64-pine64-lts`. + +Available substitutions for property values in these nodes are: + +DEFAULT-SEQ: + Sequence number of the default fdt, as provided by the 'default-dt' + entry argument + +Available operations +~~~~~~~~~~~~~~~~~~~~ + +You can add an operation to an '@' node to indicate which operation is +required:: + + @fdt-SEQ { + fit,operation = "gen-fdt-nodes"; + ... + }; + +Available operations are: + +gen-fdt-nodes + Generate FDT nodes as above. This is the default if there is no + `fit,operation` property. + +Generating nodes from an FDT list (gen-fdt-nodes) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + U-Boot supports creating fdt and config nodes automatically. To do this, pass an `of-list` property (e.g. `-a of-list=file1 file2`). This tells binman that you want to generates nodes for two files: `file1.dtb` and @@ -590,32 +652,9 @@ You can create config nodes in a similar way:: This tells binman to create nodes `config-1` and `config-2`, i.e. a config for each of your two files. -Available substitutions for '@' nodes are: - -SEQ: - Sequence number of the generated fdt (1, 2, ...) -NAME - Name of the dtb as provided (i.e. without adding '.dtb') - Note that if no devicetree files are provided (with '-a of-list' as above) then no nodes will be generated. -The 'default' property, if present, will be automatically set to the name -if of configuration whose devicetree matches the 'default-dt' entry -argument, e.g. with '-a default-dt=sun50i-a64-pine64-lts'. - -Available substitutions for '@' property values are - -DEFAULT-SEQ: - Sequence number of the default fdt,as provided by the 'default-dt' entry - argument - -Properties (in the 'fit' node itself): - fit,external-offset: Indicates that the contents of the FIT are external - and provides the external offset. This is passsed to mkimage via - the -E and -p flags. - - Entry: fmap: An entry which contains an Fmap section diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index bf84246904..6210deeef7 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -13,6 +13,12 @@ from dtoc import fdt_util from dtoc.fdt import Fdt from patman import tools +# Supported operations, with the fit,operation property +OP_GEN_FDT_NODES = range(1) +OPERATIONS = { + 'gen-fdt-nodes': OP_GEN_FDT_NODES, + } + class Entry_fit(Entry): """Flat Image Tree (FIT) @@ -46,6 +52,68 @@ class Entry_fit(Entry): }; }; + More complex setups can be created, with generated nodes, as described + below. + + Properties (in the 'fit' node itself) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Special properties have a `fit,` prefix, indicating that they should be + processed but not included in the final FIT. + + The top-level 'fit' node supports the following special properties: + + fit,external-offset + Indicates that the contents of the FIT are external and provides the + external offset. This is passed to mkimage via the -E and -p flags. + + fit,fdt-list + Indicates the entry argument which provides the list of device tree + files for the gen-fdt-nodes operation (as below). This is often + `of-list` meaning that `-a of-list="dtb1 dtb2..."` should be passed + to binman. + + Substitutions + ~~~~~~~~~~~~~ + + Node names and property values support a basic string-substitution feature. + Available substitutions for '@' nodes (and property values) are: + + SEQ: + Sequence number of the generated fdt (1, 2, ...) + NAME + Name of the dtb as provided (i.e. without adding '.dtb') + + The `default` property, if present, will be automatically set to the name + if of configuration whose devicetree matches the `default-dt` entry + argument, e.g. with `-a default-dt=sun50i-a64-pine64-lts`. + + Available substitutions for property values in these nodes are: + + DEFAULT-SEQ: + Sequence number of the default fdt, as provided by the 'default-dt' + entry argument + + Available operations + ~~~~~~~~~~~~~~~~~~~~ + + You can add an operation to an '@' node to indicate which operation is + required:: + + @fdt-SEQ { + fit,operation = "gen-fdt-nodes"; + ... + }; + + Available operations are: + + gen-fdt-nodes + Generate FDT nodes as above. This is the default if there is no + `fit,operation` property. + + Generating nodes from an FDT list (gen-fdt-nodes) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + U-Boot supports creating fdt and config nodes automatically. To do this, pass an `of-list` property (e.g. `-a of-list=file1 file2`). This tells binman that you want to generates nodes for two files: `file1.dtb` and @@ -83,31 +151,8 @@ class Entry_fit(Entry): This tells binman to create nodes `config-1` and `config-2`, i.e. a config for each of your two files. - Available substitutions for '@' nodes are: - - SEQ: - Sequence number of the generated fdt (1, 2, ...) - NAME - Name of the dtb as provided (i.e. without adding '.dtb') - Note that if no devicetree files are provided (with '-a of-list' as above) then no nodes will be generated. - - The 'default' property, if present, will be automatically set to the name - if of configuration whose devicetree matches the 'default-dt' entry - argument, e.g. with '-a default-dt=sun50i-a64-pine64-lts'. - - Available substitutions for '@' property values are - - DEFAULT-SEQ: - Sequence number of the default fdt,as provided by the 'default-dt' entry - argument - - Properties (in the 'fit' node itself): - fit,external-offset: Indicates that the contents of the FIT are external - and provides the external offset. This is passsed to mkimage via - the -E and -p flags. - """ def __init__(self, section, etype, node): """ @@ -141,6 +186,26 @@ class Entry_fit(Entry): self.ReadEntries() super().ReadNode() + def _get_operation(self, subnode): + """Get the operation referenced by a subnode + + Args: + subnode (Node): Subnode (of the FIT) to check + + Returns: + int: Operation to perform + + Raises: + ValueError: Invalid operation name + """ + oper_name = subnode.props.get('fit,operation') + if not oper_name: + return OP_GEN_FDT_NODES + oper = OPERATIONS.get(oper_name.value) + if not oper: + self.Raise(f"Unknown operation '{oper_name.value}'") + return oper + def ReadEntries(self): def _process_prop(pname, prop): """Process special properties @@ -171,8 +236,8 @@ class Entry_fit(Entry): return fsw.property(pname, prop.bytes) - def _generate_node(subnode, depth, in_images): - """Generate nodes from a template + def _scan_gen_fdt_nodes(subnode, depth, in_images): + """Generate FDT nodes This creates one node for each member of self._fdts using the provided template. If a property value contains 'NAME' it is @@ -212,6 +277,25 @@ class Entry_fit(Entry): else: self.Raise("Generator node requires 'fit,fdt-list' property") + def _scan_node(subnode, depth, in_images): + """Generate nodes from a template + + This creates one node for each member of self._fdts using the + provided template. If a property value contains 'NAME' it is + replaced with the filename of the FDT. If a property value contains + SEQ it is replaced with the node sequence number, where 1 is the + first. + + Args: + subnode (None): Generator node to process + depth: Current node depth (0 is the base 'fit' node) + in_images: True if this is inside the 'images' node, so that + 'data' properties should be generated + """ + oper = self._get_operation(subnode) + if oper == OP_GEN_FDT_NODES: + _scan_gen_fdt_nodes(subnode, depth, in_images) + def _AddNode(base_node, depth, node): """Add a node to the FIT @@ -250,7 +334,7 @@ class Entry_fit(Entry): # fsw.add_node() or _AddNode() for it. pass elif self.GetImage().generate and subnode.name.startswith('@'): - _generate_node(subnode, depth, in_images) + _scan_node(subnode, depth, in_images) else: with fsw.add_node(subnode.name): _AddNode(base_node, depth + 1, subnode) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 5400f76c67..5a0dc70ed9 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5118,6 +5118,13 @@ fdt fdtmap Extract the devicetree blob from the fdtmap finally: shutil.rmtree(tmpdir) + def testFitFdtBadOper(self): + """Check handling of an FDT map when the section cannot be found""" + with self.assertRaises(ValueError) as exc: + self._DoReadFileDtb('220_fit_bad_oper.dts') + self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", + str(exc.exception)) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/220_fit_bad_oper.dts b/tools/binman/test/220_fit_bad_oper.dts new file mode 100644 index 0000000000..cee801e2ea --- /dev/null +++ b/tools/binman/test/220_fit_bad_oper.dts @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + fit { + description = "test-desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + @fdt-SEQ { + fit,operation = "unknown"; + description = "fdt-NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + }; + }; + fdtmap { + }; + }; +}; From patchwork Tue Feb 8 18:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590052 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=it0gtjOk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXH46zrCz9s0B for ; Wed, 9 Feb 2022 05:54:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0013583E38; Tue, 8 Feb 2022 19:51:25 +0100 (CET) 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="it0gtjOk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17C1A83DC9; Tue, 8 Feb 2022 19:50:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 E027E83DA1 for ; Tue, 8 Feb 2022 19:50:45 +0100 (CET) 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-xd2e.google.com with SMTP id i62so267603ioa.1 for ; Tue, 08 Feb 2022 10:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rIntfWU2EbcKyo1A1rM5DPftXLiYQfAq5d+zUzup4Ec=; b=it0gtjOkPI6b/yn9eDipfr+F2uCVsVUjKOvfHcDUbW2uvC6kpyeNwDR+p5mF0kvzZC TFeCC5vN8aDujjQ8ORGANrY0LdNN3Y/oIkBrS915IuIYhXD64IVYZRphYYGZVkuOIMbg buc5bHuVQvuM9xRlUzukKZkeRkfiXK5CmhUAs= 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=rIntfWU2EbcKyo1A1rM5DPftXLiYQfAq5d+zUzup4Ec=; b=7fCMwnlQiUGaavrMC6rQAw9Ef/1cR6Lf7sNX+nM5jUe85XQok598fHnN91nANFgFS9 56p3ogXfPRTnUxYXebKw2/Yhyhu79Pz/enjvy2JUIzlYen0MzHhuC5NoBtE3RNilN0Db ZPVWUK3JSGJ5++bMPF6eHi0oqy2tX1hqZq/5Ytpp4DWJJKXNlq8Kj8L9EuXFBZZH1+Bx 3lHhljpxuaYg3bhQM3fkHfRezGQRXt/XgP+K78kOobB3y//sCOBgtfnLMg44EpyJnuGY Apbym0Yv8R+UY0GYTWbW/o4ObiB+qR6IThqv/ATcYQlhfV+JoQgS1ViyBDAZ5/El71lQ p7rg== X-Gm-Message-State: AOAM532O1tEIyAzGKFrnBJ0TfJsqCYbEdtT2E9LgwqTuGvX+JqD8iRpU 1WCZTmKmCLD9xWcbBRw0Y79OImjvOk9W8g== X-Google-Smtp-Source: ABdhPJzOcJi9wKfYSu8LXG8Sd9YU1sfN5lNlv9azv+5wqEGRImDkWAci++O7uc7FlG1UDEoa3yg+lA== X-Received: by 2002:a05:6638:258d:: with SMTP id s13mr2847965jat.221.1644346244150; Tue, 08 Feb 2022 10:50:44 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Jan Kiszka Subject: [PATCH 20/24] binman: Support splitting an ELF file into multiple nodes Date: Tue, 8 Feb 2022 11:50:04 -0700 Message-Id: <20220208185008.35843-16-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Some boards need to load an ELF file using the 'loadables' property, but the file has segments at different memory addresses. This means that it cannot be supplied as a flat binary. Allow generating a separate node in the FIT for each segment in the ELF, with a different load address for each. Signed-off-by: Simon Glass --- tools/binman/entries.rst | 146 +++++++++++ tools/binman/etype/fit.py | 259 ++++++++++++++++++- tools/binman/ftest.py | 116 +++++++++ tools/binman/test/221_fit_split_elf.dts | 67 +++++ tools/binman/test/222_fit_bad_dir.dts | 9 + tools/binman/test/223_fit_bad_dir_config.dts | 9 + 6 files changed, 594 insertions(+), 12 deletions(-) create mode 100644 tools/binman/test/221_fit_split_elf.dts create mode 100644 tools/binman/test/222_fit_bad_dir.dts create mode 100644 tools/binman/test/223_fit_bad_dir_config.dts diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index d483169712..079fed1a9c 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -612,6 +612,9 @@ gen-fdt-nodes Generate FDT nodes as above. This is the default if there is no `fit,operation` property. +split-elf + Split an ELF file into a separate node for each segment. + Generating nodes from an FDT list (gen-fdt-nodes) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -655,6 +658,149 @@ for each of your two files. Note that if no devicetree files are provided (with '-a of-list' as above) then no nodes will be generated. +Generating nodes from an ELF file (split-elf) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This uses the node as a template to generate multiple nodes. The following +special properties are available: + +split-elf + Split an ELF file into a separate node for each segment. This uses the + node as a template to generate multiple nodes. The following special + properties are available: + + fit,load + Generates a `load = <...>` property with the load address of the + segmnet + + fit,entry + Generates a `entry = <...>` property with the entry address of the + ELF. This is only produced for the first entry + + fit,data + Generates a `data = <...>` property with the contents of the segment + + fit,loadables + Generates a `loadable = <...>` property with a list of the generated + nodes (including all nodes if this operation is used multiple times) + + +Here is an example showing ATF, TEE and a device tree all combined:: + + fit { + description = "test-desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + u-boot { + description = "U-Boot (64-bit)"; + type = "standalone"; + os = "U-Boot"; + arch = "arm64"; + compression = "none"; + load = ; + u-boot-nodtb { + }; + }; + @fdt-SEQ { + description = "fdt-NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + @atf-SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; + + @tee-SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + op-tee { + }; + }; + }; + + configurations { + default = "@config-DEFAULT-SEQ"; + @config-SEQ { + description = "conf-NAME.dtb"; + fdt = "fdt-SEQ"; + firmware = "u-boot"; + fit,loadables; + }; + }; + }; + +If ATF-BL31 is available, this generates a node for each segment in the +ELF file, for example:: + + images { + atf-1 { + data = <...contents of first segment...>; + data-offset = <0x00000000>; + entry = <0x00040000>; + load = <0x00040000>; + compression = "none"; + os = "arm-trusted-firmware"; + arch = "arm64"; + type = "firmware"; + description = "ARM Trusted Firmware"; + }; + atf-2 { + data = <...contents of second segment...>; + load = <0xff3b0000>; + compression = "none"; + os = "arm-trusted-firmware"; + arch = "arm64"; + type = "firmware"; + description = "ARM Trusted Firmware"; + }; + }; + +The same applies for OP-TEE if that is available. + +If each binary is not available, the relevant template node (@atf-SEQ or +@tee-SEQ) is removed from the output. + +This also generates a `config-xxx` node for each device tree in `of-list`. +Note that the U-Boot build system uses `-a of-list=$(CONFIG_OF_LIST)` +so you can use `CONFIG_OF_LIST` to define that list. In this example it is +set up for `firefly-rk3399` with a single device tree and the default set +with `-a default-dt=$(CONFIG_DEFAULT_DEVICE_TREE)`, so the resulting output +is:: + + configurations { + default = "config-1"; + config-1 { + loadables = "atf-1", "atf-2", "atf-3", "tee-1", "tee-2"; + description = "rk3399-firefly.dtb"; + fdt = "fdt-1"; + firmware = "u-boot"; + }; + }; + +U-Boot SPL can then load the firmware (U-Boot proper) and all the loadables +(ATF and TEE), then proceed with the boot. + Entry: fmap: An entry which contains an Fmap section diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 6210deeef7..b2a037c742 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -6,17 +6,20 @@ # from collections import defaultdict, OrderedDict +import io import libfdt from binman.entry import Entry, EntryArg +from binman import elf from dtoc import fdt_util from dtoc.fdt import Fdt from patman import tools # Supported operations, with the fit,operation property -OP_GEN_FDT_NODES = range(1) +OP_GEN_FDT_NODES, OP_SPLIT_ELF = range(2) OPERATIONS = { 'gen-fdt-nodes': OP_GEN_FDT_NODES, + 'split-elf': OP_SPLIT_ELF, } class Entry_fit(Entry): @@ -111,6 +114,9 @@ class Entry_fit(Entry): Generate FDT nodes as above. This is the default if there is no `fit,operation` property. + split-elf + Split an ELF file into a separate node for each segment. + Generating nodes from an FDT list (gen-fdt-nodes) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -153,6 +159,149 @@ class Entry_fit(Entry): Note that if no devicetree files are provided (with '-a of-list' as above) then no nodes will be generated. + + Generating nodes from an ELF file (split-elf) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + This uses the node as a template to generate multiple nodes. The following + special properties are available: + + split-elf + Split an ELF file into a separate node for each segment. This uses the + node as a template to generate multiple nodes. The following special + properties are available: + + fit,load + Generates a `load = <...>` property with the load address of the + segmnet + + fit,entry + Generates a `entry = <...>` property with the entry address of the + ELF. This is only produced for the first entry + + fit,data + Generates a `data = <...>` property with the contents of the segment + + fit,loadables + Generates a `loadable = <...>` property with a list of the generated + nodes (including all nodes if this operation is used multiple times) + + + Here is an example showing ATF, TEE and a device tree all combined:: + + fit { + description = "test-desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + u-boot { + description = "U-Boot (64-bit)"; + type = "standalone"; + os = "U-Boot"; + arch = "arm64"; + compression = "none"; + load = ; + u-boot-nodtb { + }; + }; + @fdt-SEQ { + description = "fdt-NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + @atf-SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; + + @tee-SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + op-tee { + }; + }; + }; + + configurations { + default = "@config-DEFAULT-SEQ"; + @config-SEQ { + description = "conf-NAME.dtb"; + fdt = "fdt-SEQ"; + firmware = "u-boot"; + fit,loadables; + }; + }; + }; + + If ATF-BL31 is available, this generates a node for each segment in the + ELF file, for example:: + + images { + atf-1 { + data = <...contents of first segment...>; + data-offset = <0x00000000>; + entry = <0x00040000>; + load = <0x00040000>; + compression = "none"; + os = "arm-trusted-firmware"; + arch = "arm64"; + type = "firmware"; + description = "ARM Trusted Firmware"; + }; + atf-2 { + data = <...contents of second segment...>; + load = <0xff3b0000>; + compression = "none"; + os = "arm-trusted-firmware"; + arch = "arm64"; + type = "firmware"; + description = "ARM Trusted Firmware"; + }; + }; + + The same applies for OP-TEE if that is available. + + If each binary is not available, the relevant template node (@atf-SEQ or + @tee-SEQ) is removed from the output. + + This also generates a `config-xxx` node for each device tree in `of-list`. + Note that the U-Boot build system uses `-a of-list=$(CONFIG_OF_LIST)` + so you can use `CONFIG_OF_LIST` to define that list. In this example it is + set up for `firefly-rk3399` with a single device tree and the default set + with `-a default-dt=$(CONFIG_DEFAULT_DEVICE_TREE)`, so the resulting output + is:: + + configurations { + default = "config-1"; + config-1 { + loadables = "atf-1", "atf-2", "atf-3", "tee-1", "tee-2"; + description = "rk3399-firefly.dtb"; + fdt = "fdt-1"; + firmware = "u-boot"; + }; + }; + + U-Boot SPL can then load the firmware (U-Boot proper) and all the loadables + (ATF and TEE), then proceed with the boot. """ def __init__(self, section, etype, node): """ @@ -182,6 +331,12 @@ class Entry_fit(Entry): str)])[0] self.mkimage = None + # List of generated split-elf nodes, each a None + self._loadables = [] + + # /configurations/xxx node used as a template + self._config_node = None + def ReadNode(self): self.ReadEntries() super().ReadNode() @@ -251,19 +406,21 @@ class Entry_fit(Entry): in_images: True if this is inside the 'images' node, so that 'data' properties should be generated """ + if depth == 1 and not in_images: + self._config_node = subnode if self._fdts: # Generate nodes for each FDT for seq, fdt_fname in enumerate(self._fdts): - node_name = subnode.name[1:].replace('SEQ', - str(seq + 1)) + node_name = subnode.name[1:].replace('SEQ', str(seq + 1)) fname = tools.GetInputFilename(fdt_fname + '.dtb') with fsw.add_node(node_name): for pname, prop in subnode.props.items(): - val = prop.bytes.replace( - b'NAME', tools.ToBytes(fdt_fname)) - val = val.replace( - b'SEQ', tools.ToBytes(str(seq + 1))) - fsw.property(pname, val) + if not pname.startswith('fit,'): + val = prop.bytes.replace( + b'NAME', tools.ToBytes(fdt_fname)) + val = val.replace( + b'SEQ', tools.ToBytes(str(seq + 1))) + fsw.property(pname, val) # Add data for 'images' nodes (but not 'config') if depth == 1 and in_images: @@ -277,7 +434,18 @@ class Entry_fit(Entry): else: self.Raise("Generator node requires 'fit,fdt-list' property") - def _scan_node(subnode, depth, in_images): + def _scan_split_elf(subnode, rel_path): + #data, input_fname, uniq = self.collect_contents_to_file( + entry = Entry.Create(self.section, subnode, etype='section') + entry.ReadNode() + self._fit_sections[rel_path] = entry + + # Add this as a dummy node so we know the required position in the + # output FIT. It is replaced later in _BuildInput(). + with fsw.add_node(subnode.name): + pass + + def _scan_node(subnode, depth, in_images, rel_path): """Generate nodes from a template This creates one node for each member of self._fdts using the @@ -291,10 +459,14 @@ class Entry_fit(Entry): depth: Current node depth (0 is the base 'fit' node) in_images: True if this is inside the 'images' node, so that 'data' properties should be generated + rel_path (str): Path of subnode relative to the toplevel 'fit' + node """ oper = self._get_operation(subnode) if oper == OP_GEN_FDT_NODES: _scan_gen_fdt_nodes(subnode, depth, in_images) + elif oper == OP_SPLIT_ELF: + _scan_split_elf(subnode, rel_path) def _AddNode(base_node, depth, node): """Add a node to the FIT @@ -334,7 +506,8 @@ class Entry_fit(Entry): # fsw.add_node() or _AddNode() for it. pass elif self.GetImage().generate and subnode.name.startswith('@'): - _scan_node(subnode, depth, in_images) + _scan_node(subnode, depth, in_images, + f'{rel_path}/{subnode.name}') else: with fsw.add_node(subnode.name): _AddNode(base_node, depth + 1, subnode) @@ -383,6 +556,45 @@ class Entry_fit(Entry): return True + def _add_split_elf(self, orig_node, node, data, missing): + """Add nodes for the ELF file, one per group of contiguous segments + + The existing placeholder node is replaced + + Args: + orig_node (Node): Template node from the binman definition + node (Node): Node to replace (in the FIT being built) + data (bytes): ELF-format data to process (may be empty) + """ + # If any pieces are missing, skip this. The missing entries will show + # an error + if not missing: + try: + segments, entry = elf.read_segments(data) + except ValueError as exc: + self.Raise(f'Failed to read ELF file for {orig_node.path}: {str(exc)}') + parent = node.parent + for (seq, start, data) in segments: + node_name = orig_node.name[1:].replace('SEQ', str(seq + 1)) + subnode = parent.AddSubnode(node_name) #, before=node) + self._loadables.append(subnode) + for pname, prop in orig_node.props.items(): + if not pname.startswith('fit,'): + subnode.AddData(pname, prop.bytes) + elif pname == 'fit,load': + subnode.AddInt('load', start) + elif pname == 'fit,entry': + if not seq: + subnode.AddInt('entry', entry) + elif pname == 'fit,data': + subnode.AddData('data', data) + elif pname != 'fit,operation': + self.Raise( + f"Unknown directive in '{subnode.path}': '{pname}'") + + # Delete the template node as it has served its purpose + node.Delete() + def _BuildInput(self, fdt): """Finish the FIT by adding the 'data' properties to it @@ -393,13 +605,36 @@ class Entry_fit(Entry): New fdt contents (bytes) """ for path, section in self._fit_sections.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) + missing_list = [] + section.CheckMissing(missing_list) + + node = fdt.GetNode(path) + oper = self._get_operation(section._node) + if oper == OP_GEN_FDT_NODES: + node.AddData('data', data) + elif oper == OP_SPLIT_ELF: + self._add_split_elf(section._node, node, data, + bool(missing_list)) + + # Set up the 'firmware' and 'loadables' properties in all + # 'configurations' nodes, but only if we are generating FDTs. Note that + # self._config_node is set in _scan_gen_fdt_nodes() + node = fdt.GetNode('/configurations') + if self._config_node: + for subnode in node.subnodes: + for pname, prop in self._config_node.props.items(): + if pname == 'fit,loadables': + subnode.AddStringList( + 'loadables', + [node.name for node in self._loadables]) + elif pname.startswith('fit,'): + self.Raise( + f"Unknown directive in '{subnode.path}': '{pname}'") fdt.Sync(auto_resize=True) data = fdt.GetContents() diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 5a0dc70ed9..dbaf412e9d 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -197,6 +197,13 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('env.txt', ENV_DATA) + # ELF file with two sections in different parts of memory, used for both + # ATF and OP_TEE + TestFunctional._MakeInputFile('bl31.elf', + tools.ReadFile(cls.ElfTestFile('elf_sections'))) + TestFunctional._MakeInputFile('tee.elf', + tools.ReadFile(cls.ElfTestFile('elf_sections'))) + cls.have_lz4 = comp_util.HAVE_LZ4 @classmethod @@ -5125,6 +5132,115 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", str(exc.exception)) + def testFitSplitElf(self): + """Test an image with an FIT with an split-elf operation""" + entry_args = { + 'of-list': 'test-fdt1 test-fdt2', + 'default-dt': 'test-fdt2', + 'atf-bl31-path': 'bl31.elf', + 'op-tee-path': 'tee.elf', + } + test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) + data = self._DoReadFileDtb( + '221_fit_split_elf.dts', + entry_args=entry_args, + extra_indirs=[test_subdir])[0] + + self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):]) + fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)] + + base_keys = {'description', 'type', 'arch', 'os', 'compression', + 'data', 'load'} + dtb = fdt.Fdt.FromData(fit_data) + dtb.Scan() + + elf_data = tools.ReadFile(os.path.join(self._indir, 'bl31.elf')) + segments, entry = elf.read_segments(elf_data) + + # We assume there are two segments + self.assertEquals(2, len(segments)) + + atf1 = dtb.GetNode('/images/atf-1') + _, start, data = segments[0] + self.assertEqual(base_keys | {'entry'}, atf1.props.keys()) + self.assertEqual(entry, + fdt_util.fdt32_to_cpu(atf1.props['entry'].value)) + self.assertEqual(start, + fdt_util.fdt32_to_cpu(atf1.props['load'].value)) + self.assertEqual(data, atf1.props['data'].bytes) + + atf2 = dtb.GetNode('/images/atf-2') + self.assertEqual(base_keys, atf2.props.keys()) + _, start, data = segments[1] + self.assertEqual(start, + fdt_util.fdt32_to_cpu(atf2.props['load'].value)) + self.assertEqual(data, atf2.props['data'].bytes) + + conf = dtb.GetNode('/configurations') + self.assertEqual({'default'}, conf.props.keys()) + + for subnode in conf.subnodes: + self.assertEqual({'description', 'fdt', 'loadables'}, + subnode.props.keys()) + self.assertEqual( + ['atf-1', 'atf-2', 'tee-1', 'tee-2'], + fdt_util.GetStringList(subnode, 'loadables')) + + def _check_bad_fit(self, dts): + """Check a bad FIT + + This runs with the given dts and returns the assertion raised + + Args: + dts (str): dts filename to use + + Returns: + str: Assertion string raised + """ + entry_args = { + 'of-list': 'test-fdt1 test-fdt2', + 'default-dt': 'test-fdt2', + 'atf-bl31-path': 'bl31.elf', + 'op-tee-path': 'tee.elf', + } + test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) + with self.assertRaises(ValueError) as exc: + self._DoReadFileDtb(dts, entry_args=entry_args, + extra_indirs=[test_subdir])[0] + return str(exc.exception) + + def testFitSplitElfBadElf(self): + """Test a FIT split-elf operation with an invalid ELF file""" + TestFunctional._MakeInputFile('bad.elf', tools.GetBytes(100, 100)) + entry_args = { + 'of-list': 'test-fdt1 test-fdt2', + 'default-dt': 'test-fdt2', + 'atf-bl31-path': 'bad.elf', + } + test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) + with self.assertRaises(ValueError) as exc: + self._DoReadFileDtb( + '221_fit_split_elf.dts', + entry_args=entry_args, + extra_indirs=[test_subdir])[0] + self.assertIn( + "Node '/binman/fit': Failed to read ELF file for /binman/fit/images/@atf-SEQ: Magic number does not match", + str(exc.exception)) + + def testFitSplitElfBadDirective(self): + """Test a FIT split-elf invalid fit,xxx directive in an image node""" + err = self._check_bad_fit('222_fit_bad_dir.dts') + self.assertIn( + "Node '/binman/fit': Unknown directive in '/images/atf-1': 'fit,something'", + err) + + def testFitSplitElfBadDirectiveConfig(self): + """Test a FIT split-elf with invalid fit,xxx directive in config""" + err = self._check_bad_fit('223_fit_bad_dir_config.dts') + self.assertEqual( + "Node '/binman/fit': Unknown directive in '/configurations/config-1': 'fit,config'", + err) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/221_fit_split_elf.dts b/tools/binman/test/221_fit_split_elf.dts new file mode 100644 index 0000000000..ec771bd116 --- /dev/null +++ b/tools/binman/test/221_fit_split_elf.dts @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + fit { + description = "test-desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + @fdt-SEQ { + description = "fdt-NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + atf: @atf-SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; + + @tee-SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + op-tee { + }; + }; + }; + + configurations { + default = "@config-DEFAULT-SEQ"; + config: @config-SEQ { + description = "conf-NAME.dtb"; + fdt = "fdt-SEQ"; + fit,loadables; + }; + }; + }; + + u-boot-nodtb { + }; + }; +}; diff --git a/tools/binman/test/222_fit_bad_dir.dts b/tools/binman/test/222_fit_bad_dir.dts new file mode 100644 index 0000000000..91733c74c4 --- /dev/null +++ b/tools/binman/test/222_fit_bad_dir.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include "221_fit_split_elf.dts" + +&atf { + fit,something = "bad"; +}; diff --git a/tools/binman/test/223_fit_bad_dir_config.dts b/tools/binman/test/223_fit_bad_dir_config.dts new file mode 100644 index 0000000000..17dae0c5b6 --- /dev/null +++ b/tools/binman/test/223_fit_bad_dir_config.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include "221_fit_split_elf.dts" + +&config { + fit,config = "bad"; +}; From patchwork Tue Feb 8 18:50:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590051 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=d2VINv/F; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXGt2lS5z9s0B for ; Wed, 9 Feb 2022 05:53:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91A5883E32; Tue, 8 Feb 2022 19:51:23 +0100 (CET) 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="d2VINv/F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E393283DC2; Tue, 8 Feb 2022 19:50:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 A3A6F83DAB for ; Tue, 8 Feb 2022 19:50:46 +0100 (CET) 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-x130.google.com with SMTP id z7so14759381ilb.6 for ; Tue, 08 Feb 2022 10:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F5lxZwIXGPneZA3lpOTvfVhybV46oneTTu9WRVwTk2s=; b=d2VINv/FvrTNF5iDmBr6aXOfcr8HxMeUegadiwkydqxtHUV1YTE0RhLjdAVYMfEXAP nTkWM0abIzGjXLgozNwGioTKx2gWJulm5QpQLf7RERw68jIyB25rTDMYg36u5K0YpwLF jtw2WhI5aBh+4uSu7MdL7AyZ3NvVfEk2+YXlI= 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=F5lxZwIXGPneZA3lpOTvfVhybV46oneTTu9WRVwTk2s=; b=rC52RqTSL2u6nvltstey2qR3jPzoTiY9LPqfted02BzzIUejD/yexuJ2fMPz1Ms4lB EaZAM6XyZXXZv8BLVSuexEIAyqrpubxs7JBLIgz05XvbbP72xQmkemPkO6eGu1xf15g3 XVhP6ixfeeL313oyC9y9pVAcOzOi6fSkEg8abTyHINUh0Pt/7ERmiPMH9KIN9XLZtlzJ gRont9osiDQftxaa9TJ7GoeybffP8HTQlBoWRUo6Pe44A8lQUqACCkgkARanhVdiGwAQ qlk1SVzt0VFNQobTFKKxBFOo6lg7O2oLwpTMCdI637KYpMlFGqgDp3l0IodEV+QpsjHX Zy+g== X-Gm-Message-State: AOAM5339Kim5hgbWhZSKtOQNsQZLXsUTxRgDrM/tvxPkNbQBNJqcDBpX FLznCTqiTNgzLEaGv7IXmPx+Qe5KY9OUAQ== X-Google-Smtp-Source: ABdhPJz8EFTziEniXvOiVnAaKartEzhHcWc0gPEtIAmpSdPWO32XRufCyjq0noLNhRPQQngcpuzwUQ== X-Received: by 2002:a92:c530:: with SMTP id m16mr2866254ili.155.1644346245273; Tue, 08 Feb 2022 10:50:45 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Chris Morgan , Heiko Stuebner , Jagan Teki , Jon Lin , Joseph Chen , Nico Cheng , Philipp Tomsich Subject: [PATCH 21/24] rockchip: Include binman script in 64-bit boards Date: Tue, 8 Feb 2022 11:50:05 -0700 Message-Id: <20220208185008.35843-17-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Include the rockchip-u-boot.dtsi file with 64-bit boards and enable binman so that these boards can also use it, rather than using special Makefile rules and scripts. This does not change the Makefile nor remove any scripts, but sets it up so that this is possible. Signed-off-by: Simon Glass --- arch/arm/dts/px30-u-boot.dtsi | 2 ++ arch/arm/dts/rk3308-u-boot.dtsi | 2 ++ arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 2 ++ arch/arm/dts/rk3328-u-boot.dtsi | 2 ++ arch/arm/dts/rk3368-u-boot.dtsi | 1 + arch/arm/dts/rk3399-u-boot.dtsi | 5 +++-- arch/arm/dts/rk3568-u-boot.dtsi | 2 ++ arch/arm/mach-rockchip/Kconfig | 6 ++++++ 8 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/px30-u-boot.dtsi b/arch/arm/dts/px30-u-boot.dtsi index f102b2aef4..462eaf68f8 100644 --- a/arch/arm/dts/px30-u-boot.dtsi +++ b/arch/arm/dts/px30-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3308-u-boot.dtsi b/arch/arm/dts/rk3308-u-boot.dtsi index 4bfad31fba..ab5bfc2ce9 100644 --- a/arch/arm/dts/rk3308-u-boot.dtsi +++ b/arch/arm/dts/rk3308-u-boot.dtsi @@ -3,6 +3,8 @@ *(C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi index 95f2652494..16c33735eb 100644 --- a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi +++ b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH */ +#include "rockchip-u-boot.dtsi" + / { chosen { u-boot,spl-boot-order = &sdmmc; diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi index 1633558264..d4a7540a92 100644 --- a/arch/arm/dts/rk3328-u-boot.dtsi +++ b/arch/arm/dts/rk3328-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3368-u-boot.dtsi b/arch/arm/dts/rk3368-u-boot.dtsi index 2767c2678d..b37da4e851 100644 --- a/arch/arm/dts/rk3368-u-boot.dtsi +++ b/arch/arm/dts/rk3368-u-boot.dtsi @@ -3,6 +3,7 @@ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH */ +#include "rockchip-u-boot.dtsi" #include / { diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi index 716b9a433a..fd4150e3f0 100644 --- a/arch/arm/dts/rk3399-u-boot.dtsi +++ b/arch/arm/dts/rk3399-u-boot.dtsi @@ -60,8 +60,9 @@ }; -#ifdef CONFIG_ROCKCHIP_SPI_IMAGE &binman { + multiple-images; +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE rom { filename = "u-boot.rom"; size = <0x400000>; @@ -81,8 +82,8 @@ fdtmap { }; }; -}; #endif +}; &cru { u-boot,dm-pre-reloc; diff --git a/arch/arm/dts/rk3568-u-boot.dtsi b/arch/arm/dts/rk3568-u-boot.dtsi index 5a80dda275..fa9b6ae23b 100644 --- a/arch/arm/dts/rk3568-u-boot.dtsi +++ b/arch/arm/dts/rk3568-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2021 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &sdhci; diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 92f35309e4..c8df65980f 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -15,6 +15,7 @@ config ROCKCHIP_PX30 select DEBUG_UART_BOARD_INIT imply ROCKCHIP_COMMON_BOARD imply SPL_ROCKCHIP_COMMON_BOARD + imply BINMAN help The Rockchip PX30 is a ARM-based SoC with a quad-core Cortex-A35 including NEON and GPU, Mali-400 graphics, several DDR3 options @@ -146,6 +147,7 @@ config ROCKCHIP_RK3308 imply SPL_SERIAL imply TPL_SERIAL imply SPL_SEPARATE_BSS + imply BINMAN help The Rockchip RK3308 is a ARM-based Soc which embedded with quad Cortex-A35 and highly integrated audio interfaces. @@ -167,6 +169,7 @@ config ROCKCHIP_RK3328 select ENABLE_ARM_SOC_BOOT0_HOOK select DEBUG_UART_BOARD_INIT select SYS_NS16550 + imply BINMAN help The Rockchip RK3328 is a ARM-based SoC with a quad-core Cortex-A53. including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two @@ -186,6 +189,7 @@ config ROCKCHIP_RK3368 imply SPL_SERIAL imply TPL_SERIAL imply TPL_ROCKCHIP_COMMON_BOARD + imply BINMAN help The Rockchip RK3368 is a ARM-based SoC with a octa-core (organised into a big and little cluster with 4 cores each) Cortex-A53 including @@ -244,6 +248,7 @@ config ROCKCHIP_RK3399 imply TPL_ROCKCHIP_COMMON_BOARD imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT imply CMD_BOOTCOUNT if BOOTCOUNT_LIMIT + imply BINMAN help The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72 and quad-core Cortex-A53. @@ -264,6 +269,7 @@ config ROCKCHIP_RK3568 select SYSCON select BOARD_LATE_INIT imply ROCKCHIP_COMMON_BOARD + imply BINMAN help The Rockchip RK3568 is a ARM-based SoC with quad-core Cortex-A55, including NEON and GPU, 512K L3 cache, Mali-G52 based graphics, From patchwork Tue Feb 8 18:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590053 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ExzcUXbf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXHH6QP0z9s0B for ; Wed, 9 Feb 2022 05:54:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 622D483DF3; Tue, 8 Feb 2022 19:51:28 +0100 (CET) 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="ExzcUXbf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31C6283DA1; Tue, 8 Feb 2022 19:50:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 8B99283D9C for ; Tue, 8 Feb 2022 19:50:47 +0100 (CET) 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-xd2c.google.com with SMTP id r144so198558iod.9 for ; Tue, 08 Feb 2022 10:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wKc2LXqtvZC9qsWHuvJEHohaPqu4lMbNifp9W2C55IU=; b=ExzcUXbf6ZFmIn8R39Ul+6qy+VC3QnKtN18kOAUpbidxx/fZ0Yhld5/XtOKpnJMz3k bqli3EapprmNjRk5VEG9v+HIbLqKWjBD7ZCWzTkCB7Ql5EnbFZ5Ez7cp1h9F+Lm9ej8V 3PEzPttoO9dr9ICwk8vjW83gsAd9ZgNylSb+s= 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=wKc2LXqtvZC9qsWHuvJEHohaPqu4lMbNifp9W2C55IU=; b=kCz0Z8XFwKzl0K23KsQKwmmJ8ws6N0TZpTUbM8doizW0yu6OghYsjaDGHrTcGiPi43 5zhnh1Knp6xa4h49jpA3B0KU9DeoqCICl3eacYCPbhKtDHCmtLcgbhSEzbZ6H/btBhWv Fr1OYvAsEKikllvntHHCcBEU1E0tubIW5QLCY8D9Lv1CRYif1oEphB/Oqs9X/6rnJweI 6k2FDurPifeFpownz1Gd2ne63pPsynQjxzhFuocAlawQOxE3D1R0gxOvtZP4kXHmGk5J 7W2soqN9x+qt9Uh6KFWuE6133y0xDZXhikPRkJXD60GDTwZRANfmxIJXrhcPa+Yi5tcI /z9g== X-Gm-Message-State: AOAM530YgGXJjGtDid/H4kdPAETL7dvRwRzcPnbYL4BS1dy+7JjfQ9mv qHiWT4GRhtbA3NJV2NSgWVaWRy5NBMDWfw== X-Google-Smtp-Source: ABdhPJx4uPJoCc/g0BNZJcdFd9hNkmt/n61nxkMktptWSyRYH6PF6Xrh+oYmKEb7WWVDy2IoUzwiRg== X-Received: by 2002:a02:7a56:: with SMTP id z22mr2752966jad.304.1644346246189; Tue, 08 Feb 2022 10:50:46 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov Subject: [PATCH 22/24] rockchip: Support building the all output files in binman Date: Tue, 8 Feb 2022 11:50:06 -0700 Message-Id: <20220208185008.35843-18-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Add the required binman images to replace the Makefile rules which are currently used. This includes subsuming: - tpl/u-boot-tpl-rockchip.bin if TPL is enabled - idbloader.img if either or both of SPL and TPL are enabled - u-boot.itb2 if SPL_FIT is enabled - u-boot-rockchip.bin if SPL is used, either using u-boot.itb2 when SPL_FIT is enabled or u-boot.img when it isn't For now u-boot.itb2 is used as the FIT filename to avoid conflicting with the current u-boot.itb file. This will be updated in a future patch. Note that the intermediate files are dropped with binman, since it producing everything in one pass. This means that tpl/u-boot-tpl-rockchip.bin is not created, for example. Note that for some 32-bit rk3288 boards, rockchip-optee.dtsi is included. Signed-off-by: Simon Glass --- arch/arm/dts/rockchip-u-boot.dtsi | 84 ++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index eae3ee715d..6246ca12b7 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -17,13 +17,93 @@ filename = "u-boot-rockchip.bin"; pad-byte = <0xff>; - blob { - filename = "idbloader.img"; +#ifdef CONFIG_TPL + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T rksd"; + + u-boot-tpl { + }; + }; + + u-boot-spl { }; +#elif defined(CONFIG_SPL) /* SPL only */ + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T rksd"; + + u-boot-spl { + }; + }; +#endif +#if defined(CONFIG_SPL_FIT) && defined(CONFIG_ARM64) + fit: fit { + description = "FIT image for U-Boot with bl31 (TF-A)"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + fit,external-offset = ; + images { + u-boot { + description = "U-Boot (64-bit)"; + type = "standalone"; + os = "U-Boot"; + arch = "arm64"; + compression = "none"; + load = ; + u-boot-nodtb { + }; + }; + @atf-SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; + @tee-SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + op-tee { + }; + }; + + @fdt-SEQ { + description = "fdt-NAME"; + compression = "none"; + type = "flat_dt"; + }; + }; + + configurations { + default = "@config-DEFAULT-SEQ"; + @config-SEQ { + description = "NAME.dtb"; + fdt = "fdt-SEQ"; + firmware = "u-boot"; + fit,loadables; + }; + }; + }; +#else u-boot-img { offset = ; }; +#endif /* CONFIG_ARM64 */ }; }; #endif From patchwork Tue Feb 8 18:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590054 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FDGmOiMo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXHV3HpHz9s0B for ; Wed, 9 Feb 2022 05:54:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5607E83E2F; Tue, 8 Feb 2022 19:51:30 +0100 (CET) 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="FDGmOiMo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7727C83D9C; Tue, 8 Feb 2022 19:50:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 A25A183DC8 for ; Tue, 8 Feb 2022 19:50:48 +0100 (CET) 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-x12d.google.com with SMTP id b5so8432706ile.11 for ; Tue, 08 Feb 2022 10:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wf4K5fXSnZ3dI0I+RA2lD1kLF0CJt8F5dHC9Vqle8+Q=; b=FDGmOiMoOsXb0VTnucLiElUBMLB9AlZREI0hMDdIaWWV7bwXBsZYtpB6tTWkHUbkNt W9Wg5cTS4b76dft08o4R4ivFzQ9CUAU2MpE9pKOnR1A7Y0JeiOXJQJxYhPpuA2ChmYfX ib8tYR4ER36VfSsB9tpEvsP3JFiWecZrw1tI8= 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=Wf4K5fXSnZ3dI0I+RA2lD1kLF0CJt8F5dHC9Vqle8+Q=; b=J6qYPNSxeU6GIG2Kk2cQlt75a6nB7vita8fcU/hkidQsKrqnZOKuHhmMwI/4DPfTd7 9J10nJKbPU2TyW0YBB0oZOXBbq+4yAEBw3bBWeNzRvoae7NGPeujatl+mChTaQNYJ3wa 8YfG31uqhYimTvSQnwl9QXCaKb5IcfbGb3+glfcUGtfO3J4pKCms4+NaluuCTRzpAwLC O5LHgGZV65PtoSjruF7kk/h0TxPqHAjxoOMNqc2AaFwYFlznGk+V8Ksgi9lUYAiHNwwV FmqhmtLhQNyfHzTCs/PJyrJ0m1Hg/+L6fM2zkGdO073jYUDjLdoZ5c/pMrNIsclxMT6r K05g== X-Gm-Message-State: AOAM531p+MQw3QzzfO2IvNeQ1Hiiv0ajUlABaorCcr6Xwelmf2koba58 dDFw2uhiW4lLBevD7R8CTeH2U/7MD+/GyA== X-Google-Smtp-Source: ABdhPJxQETZKoO0ZEl/8Yvd4sfVIsxmVFppCURJgaFd/uBhHTISPk+v8NyitgCBxZOvHAXgcgknpnQ== X-Received: by 2002:a05:6e02:1c2c:: with SMTP id m12mr2975674ilh.113.1644346247344; Tue, 08 Feb 2022 10:50:47 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Alexandru Gagniuc , Andre Przywara , Klaus Heinrich Kiwi , =?utf-8?q?Marek_Beh=C3=BAn?= , Steffen Jaeckel Subject: [PATCH 23/24] rockchip: Convert all boards to use binman Date: Tue, 8 Feb 2022 11:50:07 -0700 Message-Id: <20220208185008.35843-19-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 Instead of the bash script, use binman to generate the FIT for arm64. For 32-bit boards, use binman for all images, dropping the intermediate files. With this change, only Zynq is now using SPL_FIT_GENERATOR so update the Kconfig rule accordingly. Clean up the Makefile to the extent possible. Unfortunately, two boards do not use SPL_FRAMEWORK so don't enable the u-boot.img rule: evb-rk3036 kylin-rk3036 So a small remnant remains. Signed-off-by: Simon Glass --- Makefile | 39 ++------------------------------------- boot/Kconfig | 2 +- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index ee1dc11e2f..c7f1cb3d2e 100644 --- a/Makefile +++ b/Makefile @@ -976,19 +976,8 @@ ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy) INPUTS-y += u-boot-with-dtb.bin endif -ifeq ($(CONFIG_ARCH_ROCKCHIP),y) -# On ARM64 this target is produced by binman so we don't need this dep -ifeq ($(CONFIG_ARM64),y) -ifeq ($(CONFIG_SPL),y) -# TODO: Get binman to generate this too -INPUTS-y += u-boot-rockchip.bin -endif -else -ifeq ($(CONFIG_SPL),y) -# Generate these inputs for binman which will create the output files -INPUTS-y += idbloader.img u-boot.img -endif -endif +ifeq ($(CONFIG_ARCH_ROCKCHIP)_$(CONFIG_SPL_FRAMEWORK),y_) +INPUTS-y += u-boot.img endif INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ @@ -1472,30 +1461,6 @@ OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE $(call if_changed,pad_cat) -ifeq ($(CONFIG_ARCH_ROCKCHIP),y) - -# TPL + SPL -ifeq ($(CONFIG_SPL)$(CONFIG_TPL),yy) -MKIMAGEFLAGS_u-boot-tpl-rockchip.bin = -n $(CONFIG_SYS_SOC) -T rksd -tpl/u-boot-tpl-rockchip.bin: tpl/u-boot-tpl.bin FORCE - $(call if_changed,mkimage) -idbloader.img: tpl/u-boot-tpl-rockchip.bin spl/u-boot-spl.bin FORCE - $(call if_changed,cat) -else -MKIMAGEFLAGS_idbloader.img = -n $(CONFIG_SYS_SOC) -T rksd -idbloader.img: spl/u-boot-spl.bin FORCE - $(call if_changed,mkimage) -endif - -ifeq ($(CONFIG_ARM64),y) -OBJCOPYFLAGS_u-boot-rockchip.bin = -I binary -O binary \ - --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff -u-boot-rockchip.bin: idbloader.img u-boot.itb FORCE - $(call if_changed,pad_cat) -endif # CONFIG_ARM64 - -endif # CONFIG_ARCH_ROCKCHIP - ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy) MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) diff --git a/boot/Kconfig b/boot/Kconfig index b83a4e8400..ae1a37ae92 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -275,7 +275,7 @@ config SPL_FIT_SOURCE config USE_SPL_FIT_GENERATOR bool "Use a script to generate the .its script" - default y if SPL_FIT && (!ARCH_SUNXI && !RISCV) + default y if SPL_FIT && ARCH_ZYNQMP config SPL_FIT_GENERATOR string ".its file generator script for U-Boot FIT image" From patchwork Tue Feb 8 18:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590055 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jIxYh45a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtXHj0fDCz9s0B for ; Wed, 9 Feb 2022 05:54:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68E9483E28; Tue, 8 Feb 2022 19:51:32 +0100 (CET) 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="jIxYh45a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7598883DCD; Tue, 8 Feb 2022 19:51:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 CD80F83DCF for ; Tue, 8 Feb 2022 19:50:49 +0100 (CET) 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-xd36.google.com with SMTP id i62so267776ioa.1 for ; Tue, 08 Feb 2022 10:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hk4e3Da9TlT1XGXFy4KN1BPrwtocN73uiDYDNCTsQLo=; b=jIxYh45ayyNJ4LNIgQ0mG2zV0GfaM2+QW/cqyRGpidUOpvZMoY8uAM3IpYZLfDUaRK 6Nyh05Qf6FIk3VFwevn1nwBdqeFLgUD/oLZ8ax8p22n7J/xFJ7eh0Prj5h2TmmcybrXD UAvhLRdM9woYjNNPAw5HYUnVZL2DhXGm5Rs0I= 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=Hk4e3Da9TlT1XGXFy4KN1BPrwtocN73uiDYDNCTsQLo=; b=HP59zolRhgn79JXK7nsjyuxAslHAyllDGD0oLwDpuS16w03pEl1ff2LlLNeEY/VuxX 5/04CAn7fvhPtVSU7/DVuwBK34uaWCVT9UJOE70woXFLr7eWIuzfJg0D0klgshy9FkC2 wg7/aJzegAr7QUecsrUXeBMPotSSqt5CmqA0x3jyTL8PDn7Y0si9kQFeFw5CW32C8uSY BCMxSz9DP4luhUmTlBEDdqyz8neVZ9py6ybOmrW1MoMyBLlIn/8Ar7fvNPRh/6qJiRps Q5YE39Jj+7hCApPurspAvIc7jN+NbsVwlgVitMFNEI9fx+P+atk8jKDybzKARr/wmXqQ YmTg== X-Gm-Message-State: AOAM531ysWiatJDPLaknZnFYG6HHc1IkEB143b0byhjDbaDmkfZxrKCn 2gBtPvMoaz1aQMGInTpkOegUmqQrBhfQ5A== X-Google-Smtp-Source: ABdhPJxwDPFKKTEGRbIl6pQSuEa+3kkQ5gPUMPc69cyCcv64o2X3b5nPeJN9Nhe6gRR4eXJC+HVeIQ== X-Received: by 2002:a5e:a806:: with SMTP id c6mr2743682ioa.104.1644346248397; Tue, 08 Feb 2022 10:50:48 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Alexandru Gagniuc , Andre Przywara , Bin Meng , =?utf-8?q?Marek_Beh=C3=BAn?= , Masahisa Kojima , Philipp Tomsich , Steffen Jaeckel Subject: [PATCH 24/24] rockchip: Drop the FIT generator script Date: Tue, 8 Feb 2022 11:50:08 -0700 Message-Id: <20220208185008.35843-20-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 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 This is not used anymore. Drop it. Signed-off-by: Simon Glass --- Makefile | 3 - arch/arm/mach-rockchip/make_fit_atf.py | 240 ------------------------- boot/Kconfig | 1 - 3 files changed, 244 deletions(-) delete mode 100755 arch/arm/mach-rockchip/make_fit_atf.py diff --git a/Makefile b/Makefile index c7f1cb3d2e..cc7d358148 100644 --- a/Makefile +++ b/Makefile @@ -1351,9 +1351,6 @@ $(U_BOOT_ITS): $(subst ",,$(CONFIG_SPL_FIT_SOURCE)) else ifneq ($(CONFIG_USE_SPL_FIT_GENERATOR),) U_BOOT_ITS := u-boot.its -ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-rockchip/make_fit_atf.py") -U_BOOT_ITS_DEPS += u-boot -endif $(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE $(srctree)/$(CONFIG_SPL_FIT_GENERATOR) \ $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@ diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py deleted file mode 100755 index f3224d2555..0000000000 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python3 -""" -# SPDX-License-Identifier: GPL-2.0+ -# -# A script to generate FIT image source for rockchip boards -# with ARM Trusted Firmware -# and multiple device trees (given on the command line) -# -# usage: $0 [ [; - - images { -""" - -DT_UBOOT = """ - uboot { - description = "U-Boot (64-bit)"; - data = /incbin/("u-boot-nodtb.bin"); - type = "standalone"; - os = "U-Boot"; - arch = "arm64"; - compression = "none"; - load = <0x%08x>; - }; - -""" - -DT_IMAGES_NODE_END = """ }; - -""" - -DT_END = "};" - -def append_bl31_node(file, atf_index, phy_addr, elf_entry): - # Append BL31 DT node to input FIT dts file. - data = 'bl31_0x%08x.bin' % phy_addr - file.write('\t\tatf_%d {\n' % atf_index) - file.write('\t\t\tdescription = \"ARM Trusted Firmware\";\n') - file.write('\t\t\tdata = /incbin/("%s");\n' % data) - file.write('\t\t\ttype = "firmware";\n') - file.write('\t\t\tarch = "arm64";\n') - file.write('\t\t\tos = "arm-trusted-firmware";\n') - file.write('\t\t\tcompression = "none";\n') - file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) - if atf_index == 1: - file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) - file.write('\t\t};\n') - file.write('\n') - -def append_tee_node(file, atf_index, phy_addr, elf_entry): - # Append TEE DT node to input FIT dts file. - data = 'tee_0x%08x.bin' % phy_addr - file.write('\t\tatf_%d {\n' % atf_index) - file.write('\t\t\tdescription = \"TEE\";\n') - file.write('\t\t\tdata = /incbin/("%s");\n' % data) - file.write('\t\t\ttype = "tee";\n') - file.write('\t\t\tarch = "arm64";\n') - file.write('\t\t\tos = "tee";\n') - file.write('\t\t\tcompression = "none";\n') - file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) - file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) - file.write('\t\t};\n') - file.write('\n') - -def append_fdt_node(file, dtbs): - # Append FDT nodes. - cnt = 1 - for dtb in dtbs: - dtname = os.path.basename(dtb) - file.write('\t\tfdt_%d {\n' % cnt) - file.write('\t\t\tdescription = "%s";\n' % dtname) - file.write('\t\t\tdata = /incbin/("%s");\n' % dtb) - file.write('\t\t\ttype = "flat_dt";\n') - file.write('\t\t\tcompression = "none";\n') - file.write('\t\t};\n') - file.write('\n') - cnt = cnt + 1 - -def append_conf_section(file, cnt, dtname, segments): - file.write('\t\tconfig_%d {\n' % cnt) - file.write('\t\t\tdescription = "%s";\n' % dtname) - file.write('\t\t\tfirmware = "atf_1";\n') - file.write('\t\t\tloadables = "uboot"') - if segments > 1: - file.write(',') - for i in range(1, segments): - file.write('"atf_%d"' % (i + 1)) - if i != (segments - 1): - file.write(',') - else: - file.write(';\n') - if segments <= 1: - file.write(';\n') - file.write('\t\t\tfdt = "fdt_%d";\n' % cnt) - file.write('\t\t};\n') - file.write('\n') - -def append_conf_node(file, dtbs, segments): - # Append configeration nodes. - cnt = 1 - file.write('\tconfigurations {\n') - file.write('\t\tdefault = "config_1";\n') - for dtb in dtbs: - dtname = os.path.basename(dtb) - append_conf_section(file, cnt, dtname, segments) - cnt = cnt + 1 - file.write('\t};\n') - file.write('\n') - -def generate_atf_fit_dts_uboot(fit_file, uboot_file_name): - segments = unpack_elf(uboot_file_name) - if len(segments) != 1: - raise ValueError("Invalid u-boot ELF image '%s'" % uboot_file_name) - index, entry, p_paddr, data = segments[0] - fit_file.write(DT_UBOOT % p_paddr) - -def generate_atf_fit_dts_bl31(fit_file, bl31_file_name, tee_file_name, dtbs_file_name): - segments = unpack_elf(bl31_file_name) - for index, entry, paddr, data in segments: - append_bl31_node(fit_file, index + 1, paddr, entry) - num_segments = len(segments) - - if tee_file_name: - tee_segments = unpack_elf(tee_file_name) - for index, entry, paddr, data in tee_segments: - append_tee_node(fit_file, num_segments + index + 1, paddr, entry) - num_segments = num_segments + len(tee_segments) - - append_fdt_node(fit_file, dtbs_file_name) - fit_file.write(DT_IMAGES_NODE_END) - append_conf_node(fit_file, dtbs_file_name, num_segments) - -def generate_atf_fit_dts(fit_file_name, bl31_file_name, tee_file_name, uboot_file_name, dtbs_file_name): - # Generate FIT script for ATF image. - if fit_file_name != sys.stdout: - fit_file = open(fit_file_name, "wb") - else: - fit_file = sys.stdout - - fit_file.write(DT_HEADER) - generate_atf_fit_dts_uboot(fit_file, uboot_file_name) - generate_atf_fit_dts_bl31(fit_file, bl31_file_name, tee_file_name, dtbs_file_name) - fit_file.write(DT_END) - - if fit_file_name != sys.stdout: - fit_file.close() - -def generate_atf_binary(bl31_file_name): - for index, entry, paddr, data in unpack_elf(bl31_file_name): - file_name = 'bl31_0x%08x.bin' % paddr - with open(file_name, "wb") as atf: - atf.write(data) - -def generate_tee_binary(tee_file_name): - if tee_file_name: - for index, entry, paddr, data in unpack_elf(tee_file_name): - file_name = 'tee_0x%08x.bin' % paddr - with open(file_name, "wb") as atf: - atf.write(data) - -def unpack_elf(filename): - with open(filename, 'rb') as file: - elf = file.read() - if elf[0:7] != b'\x7fELF\x02\x01\x01' or elf[18:20] != b'\xb7\x00': - raise ValueError("Invalid arm64 ELF file '%s'" % filename) - - e_entry, e_phoff = struct.unpack_from('<2Q', elf, 0x18) - e_phentsize, e_phnum = struct.unpack_from('<2H', elf, 0x36) - segments = [] - - for index in range(e_phnum): - offset = e_phoff + e_phentsize * index - p_type, p_flags, p_offset = struct.unpack_from(' 0: - p_data = elf[p_offset:p_offset + p_filesz] - segments.append((index, e_entry, p_paddr, p_data)) - return segments - -def main(): - uboot_elf = "./u-boot" - fit_its = sys.stdout - if "BL31" in os.environ: - bl31_elf=os.getenv("BL31"); - elif os.path.isfile("./bl31.elf"): - bl31_elf = "./bl31.elf" - else: - os.system("echo 'int main(){}' > bl31.c") - os.system("${CROSS_COMPILE}gcc -c bl31.c -o bl31.elf") - bl31_elf = "./bl31.elf" - logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) - logging.warning(' BL31 file bl31.elf NOT found, resulting binary is non-functional') - logging.warning(' Please read Building section in doc/README.rockchip') - - if "TEE" in os.environ: - tee_elf = os.getenv("TEE") - elif os.path.isfile("./tee.elf"): - tee_elf = "./tee.elf" - else: - tee_elf = "" - - opts, args = getopt.getopt(sys.argv[1:], "o:u:b:t:h") - for opt, val in opts: - if opt == "-o": - fit_its = val - elif opt == "-u": - uboot_elf = val - elif opt == "-b": - bl31_elf = val - elif opt == "-t": - tee_elf = val - elif opt == "-h": - print(__doc__) - sys.exit(2) - - dtbs = args - - generate_atf_fit_dts(fit_its, bl31_elf, tee_elf, uboot_elf, dtbs) - generate_atf_binary(bl31_elf) - generate_tee_binary(tee_elf) - -if __name__ == "__main__": - main() diff --git a/boot/Kconfig b/boot/Kconfig index ae1a37ae92..1ae5b3a793 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -280,7 +280,6 @@ config USE_SPL_FIT_GENERATOR config SPL_FIT_GENERATOR string ".its file generator script for U-Boot FIT image" depends on USE_SPL_FIT_GENERATOR - default "arch/arm/mach-rockchip/make_fit_atf.py" if SPL_LOAD_FIT && ARCH_ROCKCHIP default "arch/arm/mach-zynqmp/mkimage_fit_atf.sh" if SPL_LOAD_FIT && ARCH_ZYNQMP help Specifies a (platform specific) script file to generate the FIT