From patchwork Thu Jan 7 04:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423147 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=n14zYtCg; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD1p205rz9sVm for ; Thu, 7 Jan 2021 15:35:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA0BA827C3; Thu, 7 Jan 2021 05:35: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=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="n14zYtCg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E0333827AE; Thu, 7 Jan 2021 05:35:28 +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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 21A918278A for ; Thu, 7 Jan 2021 05:35:26 +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 x15so5573079ilq.1 for ; Wed, 06 Jan 2021 20:35:26 -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=mCq7su9acgMGLANrjxcV2uoDWsMhc3VvjN4q6yk1lgY=; b=n14zYtCgklIph7gmF2yN1eCl//8aib3Ib3+E4M3TOp8p1uf1sNLNYVLSONQzwGLOvm NasUoTrg1nkmLuus5CtwQovXqqBB0gV+38LyQsvAfQBSjqVsQMqgN6AG9mM4sxZPxVk5 BsBvANnEXUnTNt5qnTdrndlw1hFAT+3jIPbrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mCq7su9acgMGLANrjxcV2uoDWsMhc3VvjN4q6yk1lgY=; b=nlI0uscwGYfQwCm0zMt6GXjfbQQWpqvGhPSuJCGobLXoHskv0WWTwMGSk1lbpqr0Rn +VDST5F7HY7JOI7/1rZUQou/UUJnHhc98ahviAXSoMp+0e4v484q66A6FTQgbhikr+T4 3TFiozVckhCuRJnheczThZjDOf0/s6eTmItIr1G7Vdi8zD6yDMRACX8fmdtsUBQ9it7c 2DYCToQPEOAswN51g8vgq/nqua1KrT12kO6UYTm5EprfgWicWUYkZG15dO8HrA9lVLSQ 2JrniaH0/q59vxbqTP8m+C1F2FCeqXR+TxrX4UexLsZGMyGIDkXE0PCF91IFzmUVoJ0f IOCw== X-Gm-Message-State: AOAM533UBAb2L2TkIBQp0UHVP4JujTwNRr0O0TRcm26nllOIze9PD/Ry iQS4Rq40Ws5TBMLwd6HJtmDD6Ym3tiFwPuaQ X-Google-Smtp-Source: ABdhPJxG5wei4CI+gvxPcmnhkblbOiZ38/trm9hLqeuwbYNbiN7Kuq2X49Aa6r2iNpvMjiMQ6OApeQ== X-Received: by 2002:a92:4019:: with SMTP id n25mr7339944ila.25.1609994124808; Wed, 06 Jan 2021 20:35:24 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 01/10] dtoc: binman: Drop Python 2 code Date: Wed, 6 Jan 2021 21:35:10 -0700 Message-Id: <20210107043519.2634625-2-sjg@chromium.org> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Drop a few more Python 2 relics that are no-longer needed. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/fmap_util.py | 4 ++-- tools/dtoc/fdt.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/binman/fmap_util.py b/tools/binman/fmap_util.py index b03fc28fbb4..8277619768c 100644 --- a/tools/binman/fmap_util.py +++ b/tools/binman/fmap_util.py @@ -53,8 +53,8 @@ FmapArea = collections.namedtuple('FmapArea', FMAP_AREA_NAMES) def NameToFmap(name): - if type(name) == bytes and sys.version_info[0] >= 3: - name = name.decode('utf-8') # pragma: no cover (for Python 2) + if type(name) == bytes: + name = name.decode('utf-8') return name.replace('\0', '').replace('-', '_').upper() def ConvertName(field_names, fields): diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 4a78c737252..965106a3b28 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -460,8 +460,7 @@ class Node: prop_name: Name of property to add val: String value of property """ - if sys.version_info[0] >= 3: # pragma: no cover - val = bytes(val, 'utf-8') + val = bytes(val, 'utf-8') self.AddData(prop_name, val + b'\0') def AddSubnode(self, name): From patchwork Thu Jan 7 04:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423148 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=PGYKCuTk; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD1z2fklz9sVm for ; Thu, 7 Jan 2021 15:35:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8E386827D8; Thu, 7 Jan 2021 05:35: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=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="PGYKCuTk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A0D3827C3; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 ECB118279F for ; Thu, 7 Jan 2021 05:35:26 +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 e22so4442460iom.5 for ; Wed, 06 Jan 2021 20:35:26 -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=oAluhUvJMcCsq5OxA6NXeaqqi2gV8zp8JTi0mPiWgQs=; b=PGYKCuTk1qaDQgM8lnEAISb2RtlkVGp5/X5WXTuooJsgpjZCVJNjp6qloF9zk5bzZR XUC3VRYZk+1S5zNbDiVjHtbLOjrHWKcroHJ61IYSwIfKBEkrtcAPWYuJ72uSBd7FoVjD gvrha0VU1PFqWw0fSHhCrWFI41ZFKpoi43C4M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oAluhUvJMcCsq5OxA6NXeaqqi2gV8zp8JTi0mPiWgQs=; b=o8GL3F+hsERuD6nkhM9hpJgBWO0t9+aKEWO/t4fA/FxWCeJwrYPVpQWM77CKshfiDI fpb3U/TRvgM2VdwaRrzLY6doAimGvYkgH8/Rc1DkBQe2DOo0DEeEHYguYnDN1Gr6bhX+ K/J/pSdqvkgeTzMhfESz7e+8Pe+Evdes8ft0hS6gT3LQjGJTg009Bj4/S6QQBkQkFVU6 9RqcCZYXOco+D9MGoCi7vU0ehKN6vNLzkXad88l0t+/x/yTnqCXX3LQIN6DpyxzgO5qU kUSgw2VeH3EyMkn6IhCudhhslLFa2Z929JFv497zw9OiWDExlXlqiExJRgjVKyLsZjeF KHwQ== X-Gm-Message-State: AOAM531fVaZ8lnzMkCU8mDGVcFBaJWhsnflCARs6+nWt+zQp2xVz7Ko8 9xObmF573UROynBDtGB4OBL6MxgU9Zb+sMro X-Google-Smtp-Source: ABdhPJwyuKajQ1mOmoXO00+y7EYeIncruq1J9mSvO2h/0LCAfsB7ggGQ1pCAFtsIpNoWqxkIqv76eA== X-Received: by 2002:a5e:de08:: with SMTP id e8mr5326314iok.203.1609994125630; Wed, 06 Jan 2021 20:35:25 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 02/10] patman: Correct lz4 compression parameters Date: Wed, 6 Jan 2021 21:35:11 -0700 Message-Id: <20210106213503.2.Ice90ef82a59cb480c8364f78f7c796412bffccfd@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present on large files, lz4 uses a larger block size (e.g. 256KB) than the 64KB supported by the U-Boot decompression implementation. Also it is optimised for maximum compression speed, producing larger output than we would like. Update the parameters to correct these problems. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/patman/tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/patman/tools.py b/tools/patman/tools.py index d8e01a3e60e..10997e43868 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -476,7 +476,8 @@ def Compress(indata, algo, with_header=True): fname = GetOutputFilename('%s.comp.tmp' % algo) WriteFile(fname, indata) if algo == 'lz4': - data = Run('lz4', '--no-frame-crc', '-c', fname, binary=True) + data = Run('lz4', '--no-frame-crc', '-B4', '-5', '-c', fname, + binary=True) # cbfstool uses a very old version of lzma elif algo == 'lzma': outfname = GetOutputFilename('%s.comp.otmp' % algo) From patchwork Thu Jan 7 04:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423150 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=G20alpI6; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD2M3X4Zz9sVm for ; Thu, 7 Jan 2021 15:36:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0CA0B827D5; Thu, 7 Jan 2021 05:35: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="G20alpI6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31D51827C5; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 EEFF2827B3 for ; Thu, 7 Jan 2021 05:35: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-il1-x132.google.com with SMTP id 14so4266109ilq.2 for ; Wed, 06 Jan 2021 20:35: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=ulRrmWAz9wLuJw57QNm7ZC1zRCfSnAqtm+AV3kRY10A=; b=G20alpI6wCislYXBtuIO9+aAmgKeHKAHOLNbINoanUhbjhNi7cCW8NRnE4UdrbIzUz E5tKcqejX8a+p/Je6X+DexYf+WGTwTFG5hQzV+FfzgZUGqOdU32L0Cf54XkHD3HSGHAT 5JDzsVvs6UrEHZoiMxijDFcIwL2+hNsuufsJM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ulRrmWAz9wLuJw57QNm7ZC1zRCfSnAqtm+AV3kRY10A=; b=p0kMU/k+iXPiTpt6YzsHgacoDG8GCIMdoC1uzIwXRD/g9uCtONTxH5dekxk2h0r9++ opOavO3EgMkg6oDypNYbD2RIDWett9o4Zfelt3mQC8WrgHvNcnIGhZIcvThk4aiYCEqp 5/IL8uyUO3UHitjg3Wt0tYBU7hsKTUfpOWXATJo3eKPXuQaZKuhAXql/AUcLrxS1957W 9FL8DfD0kWZMH6RV+v0HqwIgscMGhvkMNPSEl/TZb+kQxROqKtPFlnDjZ15C+iivYj4x N0T1o+lED8jUw+RJ7ksabMHAxuBGy2uuv8K1i+e3zBAHbuBv9iJoeX3HMRxzJMPn7Ayp RWEQ== X-Gm-Message-State: AOAM530CXbOP0/JBf7BtFwbHDmFK1Vkxl3Jr9Gr/sRUepp8pcdSxx6RG 2ea2BNd1dwnjoDhubyKj+rN4+d6F/0slnXsn X-Google-Smtp-Source: ABdhPJxGC41TglenDN1hZQ7m//LDkGmzFQt42qAahjYFCF2FHbsu6y54q/dQWNqkmn3kTPtVSxhQyg== X-Received: by 2002:a92:650b:: with SMTP id z11mr7451404ilb.84.1609994126657; Wed, 06 Jan 2021 20:35:26 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 03/10] binman: Update the TODO list Date: Wed, 6 Jan 2021 21:35:12 -0700 Message-Id: <20210106213503.3.I13bcc6cd0071a58030a460ef7b2f795a237d2cf6@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Two of the items have been completed and I thought of another one. Update the list. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/README | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/binman/README b/tools/binman/README index de1eedfc3f7..a00c9026163 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -1050,10 +1050,9 @@ Some ideas: - Allow easy building of images by specifying just the board name - Support building an image for a board (-b) more completely, with a configurable build directory -- Support adding FITs to an image -- Support for ARM Trusted Firmware (ATF) - Detect invalid properties in nodes - Sort the fdtmap by offset +- Output temporary files to a different directory -- Simon Glass From patchwork Thu Jan 7 04:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423149 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=Hqgqib8B; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD292Jx0z9sVm for ; Thu, 7 Jan 2021 15:36:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E72CF827BD; Thu, 7 Jan 2021 05:35: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=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="Hqgqib8B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D47E2827CB; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 D3711827B7 for ; Thu, 7 Jan 2021 05:35: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-xd35.google.com with SMTP id d9so4992965iob.6 for ; Wed, 06 Jan 2021 20:35: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=fftlLaLzBV5+drAkabiUjXvFd1lpK5ux1LhlPWOEokI=; b=Hqgqib8BZYcsngutQyGBfsHa+AyJx3BmlD8gRWbkxsNCmmyrj6bt42zvOzUIa+fj5Z LmKo/z4xhzacJmgDgA6PVrHHh7hnr7d14HRpZb72Za5Jk6kDlR5JV/C7kRPTTl1WU1OA C89wv+tD3RcHLXsJbYaYmXVoA5KhIfy3LZeLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fftlLaLzBV5+drAkabiUjXvFd1lpK5ux1LhlPWOEokI=; b=T5g37cUETytxPVZfAa8Ajs9KwnE75laIhfihCp5jfTu38DOcoREOWb9jqrko4CoKfv aCfsv/ywwkUY3aZ2tZS8Pe1PCl1GVh2W0PxFgiRlrEuyfZJGdlp/JVWyafgck9ciu/a+ Yt9QYim+lQDPd5wb/g0YBVrOSvjyM8t1bYCk0OTk2zyillTY59Uu13/i9tIcEeBgcOl+ nmwwC661wmmSSP9A1Pk+LIvmEJ2O/QwPWH8yrxtGYqlDX2GfizHBq3wBXXrqzHxhHAsJ M/GeipaCN+jdcrcv6CyaN2cOapjj3L/Z+Degm2VYVF+X1vXGeMwDRzGfC8XD66ms7+M8 yREA== X-Gm-Message-State: AOAM530hIT9CzB1EhvCs3GKimAbRFwX5+zORdQ0wXxurEUmycPhfs600 vD/XxPrDDz59/IEM2HD//GA72IRuqk86aJ/e X-Google-Smtp-Source: ABdhPJwVR8qiScaEVJ8xRDNUHga+zIg2p4VG/CaJ+5CHmR8DLReZSZGcpmDQYxlJ7J3qiBeqIivZjQ== X-Received: by 2002:a05:6602:2157:: with SMTP id y23mr5449288ioy.202.1609994127494; Wed, 06 Jan 2021 20:35:27 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 04/10] binman: Show the size when writing entries Date: Wed, 6 Jan 2021 21:35:13 -0700 Message-Id: <20210106213503.4.Ib16c91d01d6ae3d1f6ab814813410de7b887f9aa@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Update the log output to show the size, since this is useful information. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/control.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index 072417f3644..1952b2abf48 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -244,7 +244,8 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths, if not os.path.exists(fname): os.makedirs(fname) fname = os.path.join(fname, 'root') - tout.Notice("Write entry '%s' to '%s'" % (entry.GetPath(), fname)) + tout.Notice("Write entry '%s' size %x to '%s'" % + (entry.GetPath(), len(data), fname)) tools.WriteFile(fname, data) return einfos From patchwork Thu Jan 7 04:35:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423151 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=hFaRCUt6; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD2Z0L7Bz9sVm for ; Thu, 7 Jan 2021 15:36:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E68398268D; Thu, 7 Jan 2021 05:35: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=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="hFaRCUt6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF4C3827C5; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 C7EE7827AE for ; Thu, 7 Jan 2021 05:35: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-il1-x12a.google.com with SMTP id 14so4266161ilq.2 for ; Wed, 06 Jan 2021 20:35: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=F4KQk4qV4gNGn2XkCB2tAwdGHUPZANtTjVmJCfaafRw=; b=hFaRCUt6E3eWxcPsOpKRYoiv3EDPqXPlns+41dAtvdxkJcgEs7qVgNLo7Ma1oNLJ9z VklK04lw9PXhoeZOlOxctXpd++DJvYSr02ZTvy2jjO3q/aMbV4+R2JXGBPmX9uKe9qpU 9Iap/lsqHmjno/PiqNYfsC0U9MRL2uN0Zii7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F4KQk4qV4gNGn2XkCB2tAwdGHUPZANtTjVmJCfaafRw=; b=hyOWBV1G4BXYrAJs43WkdTwZ7TjV1O94O74FVLNJxIEY8zrZl6upr+yKYwKwPVGKrm fCHaj0MJdkBW0xZx/PfRlw4GtdRHk3SDMpxsHypUtShhseLyZk6HyB0dYddWLBwXc2gy Y3j5iuohTRZ2O2QFB+Tsm93Sg4QoiFumhr1+fUpZa44T2ABzVSZvYp/3MwRe4MjYm3pT unPKhZrpilye7Df8ARrfkub/zzE1TcBfxXFN11YO81tOenxqTTxxSB/GQlhoOifBflZv uGBdyE5WYkuHYwMOEtHfuUOEH8EYX5o0K+yEHlFT+QIh57uuhahG8xrd+BNaUxazODPe MX0Q== X-Gm-Message-State: AOAM532RDV8NTEsUqCuby6XhfklqT1ZIyu5sh/se8rJqHEwRVnrwaXum oPcOav0eppXO0Ij810BURmjgkb5F1FCCDb5B X-Google-Smtp-Source: ABdhPJyCjhS4dGlDjIXi1e/D4H0TY8qiO5PmnW/tWbrKR48vRWrgKmMyKk8DZxWfC5FO6918swdqNw== X-Received: by 2002:a92:cd46:: with SMTP id v6mr7379336ilq.149.1609994128453; Wed, 06 Jan 2021 20:35:28 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng Subject: [PATCH 05/10] binman: Fix a few file comments Date: Wed, 6 Jan 2021 21:35:14 -0700 Message-Id: <20210106213503.5.Id96ae0b503ef09529d8e900bd6dcf63bb046ffc4@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Two files have the wrong comment at the top of them. Fix this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/u_boot_spl_bss_pad.py | 1 - tools/binman/etype/u_boot_spl_nodtb.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py b/tools/binman/etype/u_boot_spl_bss_pad.py index 596b2bed97e..df15cd24ce7 100644 --- a/tools/binman/etype/u_boot_spl_bss_pad.py +++ b/tools/binman/etype/u_boot_spl_bss_pad.py @@ -9,7 +9,6 @@ from binman import elf from binman.entry import Entry -from patman import command from binman.etype.blob import Entry_blob from patman import tools diff --git a/tools/binman/etype/u_boot_spl_nodtb.py b/tools/binman/etype/u_boot_spl_nodtb.py index 6f4529396d8..c154cfde57b 100644 --- a/tools/binman/etype/u_boot_spl_nodtb.py +++ b/tools/binman/etype/u_boot_spl_nodtb.py @@ -2,7 +2,7 @@ # Copyright (c) 2016 Google, Inc # Written by Simon Glass # -# Entry-type module for 'u-boot-nodtb.bin' +# Entry-type module for 'u-boot-spl-nodtb.bin' # from binman.entry import Entry From patchwork Thu Jan 7 04:35:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423152 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=Eb4FIu0V; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD2m1yClz9sVm for ; Thu, 7 Jan 2021 15:36:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 285E0827EE; Thu, 7 Jan 2021 05:35: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=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="Eb4FIu0V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1516827DD; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 D339F827BF for ; Thu, 7 Jan 2021 05:35: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-io1-xd36.google.com with SMTP id u26so5005643iof.3 for ; Wed, 06 Jan 2021 20:35: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=4yk8HGhIwX/BTJzHcvqWD0y6uP+iFn05jPHC4cc+zWA=; b=Eb4FIu0V0Ko4fwShLz2EH0yCbwHYjFCXDt0smo9uCyuHoszXqzilNluuyPVjzB5mzv R+3+SGFRTrdUj+Ht7/pt2ZYevY5rsM1ccmvU3kYG0WyMC8s+39Q+2qlPU90LipaBp/ql t/DhOb5y7F0yff5fClEXEjwlGPGqN8dvv9izw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4yk8HGhIwX/BTJzHcvqWD0y6uP+iFn05jPHC4cc+zWA=; b=Vh1Wg8r65E2DpNhyd9E/3gkhzm/J32ER+2GPTxZPhvveNlSnL94sSCg/TxrqlPiuUC nBTphvMWBxNep+cRCxXL+T94P/2oE2HtnvXmlhLUdipbj1Hxs/znq+J53M54j/huseMl EpaPMRJxoQSEA5OSZvrlijjRv2L4cG6Ob7WOlfDbF+ljgRlid1LtqLBSUc2ZM152D0eF bl/grx4+cO7t77TWNGMlIgxYKd/aMpnGs7dTnNMXQU4yQ95hUeHsAAD/O89jVwiB5+Fz tKODfyziuUVyL81AXUqGuha9q4O/bkm3U20OSVTk/fQpLDKZdH30vsGieLxM9HOJoRk9 bKzg== X-Gm-Message-State: AOAM532vX+zHQJu+B5MO0T2krC7LuFvVB8N2wGEFuwDkbZR6fhGbqt0O 6/hrlSHVlbIE7dPQSyZkM/g97dFV4geJF9xu X-Google-Smtp-Source: ABdhPJzRjLO+G6oUPwGUa9e3Aq3cAElsksNj/+6pCF0BaZUZ71tWpjgxaD0z5Wj/lViZdHNXoBg3HA== X-Received: by 2002:a6b:cd02:: with SMTP id d2mr4432iog.4.1609994129376; Wed, 06 Jan 2021 20:35:29 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak , Bin Meng Subject: [PATCH 06/10] binman: Support finding symbols in sub-sections Date: Wed, 6 Jan 2021 21:35:15 -0700 Message-Id: <20210106213503.6.Ie335edad4943ae1f521ff2ddf782215eab888e91@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present binman only supports resolving symbols in the same section as the binary that uses it. This is quite limited because we often need to group entries into different sections. Enhance the algorithm to search the entire image for symbols. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/elf.py | 3 +- tools/binman/elf_test.py | 4 ++- tools/binman/etype/section.py | 41 +++++++++++++++++++++--- tools/binman/ftest.py | 15 +++++++++ tools/binman/image.py | 45 +++++++++++++++++++++++++++ tools/binman/test/187_symbols_sub.dts | 22 +++++++++++++ 6 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 tools/binman/test/187_symbols_sub.dts diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 249074a334a..03b49d7163c 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -132,7 +132,8 @@ def LookupAndWriteSymbols(elf_fname, entry, section): (msg, sym.size)) # Look up the symbol in our entry tables. - value = section.LookupSymbol(name, sym.weak, msg, base.address) + value = section.GetImage().LookupImageSymbol(name, sym.weak, msg, + base.address) if value is None: value = -1 pack_string = pack_string.lower() diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index e3d218a89e9..7a128018d9f 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -45,10 +45,12 @@ class FakeSection: def GetPath(self): return 'section_path' - def LookupSymbol(self, name, weak, msg, base_addr): + def LookupImageSymbol(self, name, weak, msg, base_addr): """Fake implementation which returns the same value for all symbols""" return self.sym_value + def GetImage(self): + return self def BuildElfTestFiles(target_dir): """Build ELF files used for testing in binman diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 3dd5f58c4c2..9c6334c4504 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -385,7 +385,7 @@ class Entry_section(Entry): return entry.GetData() source_entry.Raise("Cannot find entry for node '%s'" % node.name) - def LookupSymbol(self, sym_name, optional, msg, base_addr): + def LookupSymbol(self, sym_name, optional, msg, base_addr, entries=None): """Look up a symbol in an ELF file Looks up a symbol in an ELF file. Only entry types which come from an @@ -428,18 +428,20 @@ class Entry_section(Entry): (msg, sym_name)) entry_name, prop_name = m.groups() entry_name = entry_name.replace('_', '-') - entry = self._entries.get(entry_name) + if not entries: + entries = self._entries + entry = entries.get(entry_name) if not entry: if entry_name.endswith('-any'): root = entry_name[:-4] - for name in self._entries: + for name in entries: if name.startswith(root): rest = name[len(root):] if rest in ['', '-img', '-nodtb']: - entry = self._entries[name] + entry = entries[name] if not entry: err = ("%s: Entry '%s' not found in list (%s)" % - (msg, entry_name, ','.join(self._entries.keys()))) + (msg, entry_name, ','.join(entries.keys()))) if optional: print('Warning: %s' % err, file=sys.stderr) return None @@ -648,3 +650,32 @@ class Entry_section(Entry): """ for entry in self._entries.values(): entry.CheckMissing(missing_list) + + def _CollectEntries(self, entries, entries_by_name, add_entry): + """Collect all the entries in an section + + This builds up a dict of entries in this section and all subsections. + Entries are indexed by path and by name. + + Since all paths are unique, entries will not have any conflicts. However + entries_by_name make have conflicts if two entries have the same name + (e.g. with different parent sections). In this case, an entry at a + higher level in the hierarchy will win over a lower-level entry. + + Args: + entries: dict to put entries: + key: entry path + value: Entry object + entries_by_name: dict to put entries + key: entry name + value: Entry object + add_entry: Entry to add + """ + entries[add_entry.GetPath()] = add_entry + to_add = add_entry.GetEntries() + if to_add: + for entry in to_add.values(): + entries[entry.GetPath()] = entry + for entry in to_add.values(): + self._CollectEntries(entries, entries_by_name, entry) + entries_by_name[add_entry.name] = add_entry diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index e753a342c8f..5016060ea68 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4139,6 +4139,21 @@ class TestFunctional(unittest.TestCase): } self.assertEqual(expected, props) + def testSymbolsSubsection(self): + """Test binman can assign symbols from a subsection""" + elf_fname = self.ElfTestFile('u_boot_binman_syms') + syms = elf.GetSymbols(elf_fname, ['binman', 'image']) + addr = elf.GetSymbolAddress(elf_fname, '__image_copy_start') + self.assertEqual(syms['_binman_u_boot_spl_prop_offset'].address, addr) + + self._SetupSplElf('u_boot_binman_syms') + data = self._DoReadFile('187_symbols_sub.dts') + sym_values = struct.pack('_prop_ where is the name of + the entry and is the property to find (e.g. + _binman_u_boot_prop_offset). As a special case, you can append + _any to to have it search for any matching entry. E.g. + _binman_u_boot_any_prop_offset will match entries called u-boot, + u-boot-img and u-boot-nodtb) + optional: True if the symbol is optional. If False this function + will raise if the symbol is not found + msg: Message to display if an error occurs + base_addr: Base address of image. This is added to the returned + image_pos in most cases so that the returned position indicates + where the targeted entry/binary has actually been loaded. But + if end-at-4gb is used, this is not done, since the binary is + already assumed to be linked to the ROM position and using + execute-in-place (XIP). + + Returns: + Value that should be assigned to that symbol, or None if it was + optional and not found + + Raises: + ValueError if the symbol is invalid or not found, or references a + property which is not supported + """ + entries = OrderedDict() + entries_by_name = {} + self._CollectEntries(entries, entries_by_name, self) + return self.LookupSymbol(sym_name, optional, msg, base_addr, + entries_by_name) diff --git a/tools/binman/test/187_symbols_sub.dts b/tools/binman/test/187_symbols_sub.dts new file mode 100644 index 00000000000..54511a73711 --- /dev/null +++ b/tools/binman/test/187_symbols_sub.dts @@ -0,0 +1,22 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + section { + pad-byte = <0xff>; + u-boot-spl { + }; + + u-boot { + offset = <24>; + }; + }; + + u-boot-spl2 { + type = "u-boot-spl"; + }; + }; +}; From patchwork Thu Jan 7 04:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423153 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=jjsZRyqP; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD2z5nnZz9sVm for ; Thu, 7 Jan 2021 15:36:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5CFD9827F5; Thu, 7 Jan 2021 05:35: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=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="jjsZRyqP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED522827DD; Thu, 7 Jan 2021 05:35:35 +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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 EE148827B7 for ; Thu, 7 Jan 2021 05:35: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-x132.google.com with SMTP id u12so5546097ilv.3 for ; Wed, 06 Jan 2021 20:35: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=s9xfmQmOd6vd4lzbFlzcTFejexArPAVulPCT9fSxETk=; b=jjsZRyqPY0zttpPZ4dno9HIvYHFSS+O/Vw2CyhhCTrm8RjhIEObP7PKEpj+cLWQJHF qJpBkV+HOVfyH09q4Q/eThXTcWp31x0kOTYYeEwqUiAc73cRzEsNtD8+IBbJ233VKbbi AX1Q3/BvBvir1g+H6fJfYfXNwMqHwcXvFAfVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s9xfmQmOd6vd4lzbFlzcTFejexArPAVulPCT9fSxETk=; b=aUIGqyXIkXakHBTuAVRXFH4v5DooStdB3BdUZb7kvRYBbh/HgVJCFu5WTfTNLz80TM PDWGtptyLifgwZrTQ0RXUcJXvs6jjAcWzNoL5FIVidTu2cVAnjAH2fBMYVJ1fESVVy/E p6gQAhcBzC0UukvCNKNqroR+at0H0XGwD9MfHqeQGuDkdVWCYRq74OVclSbG5dOcOFh9 BvU4vneFwCvNYMmipxxdwyygzbJ49Lxkpmsh431NYM26uHtm0ZzoCBv6X+V8Kz5DaxZ3 T+d+qm0Ym6hrgUL17stAZL+Vv/kFamoi13/3GcIrcY4rBZLpUSi4LqynSsyNqONl6TXN 6THA== X-Gm-Message-State: AOAM532wV/iCe/2CFEjWlz+3JsE4eS5/pAI1JXGqxibjmWVPVV3cJqV3 DAZYNumgP40TC2JB5flxFkaYepFcYwWXxe0X X-Google-Smtp-Source: ABdhPJwx/HZe4zynn7NbdwNfZGaUnST2q6bizxIF0t+nar65STiIO1sAjkPNGkWXoNARaXnnlA0oFQ== X-Received: by 2002:a92:ba42:: with SMTP id o63mr7434761ili.93.1609994130474; Wed, 06 Jan 2021 20:35:30 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak , Bin Meng Subject: [PATCH 07/10] binman: Support reading an image with entry args Date: Wed, 6 Jan 2021 21:35:16 -0700 Message-Id: <20210106213503.7.I1e24d731dc789a02dc72134d1beac84f24830eb8@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Normally when an entry is created, any entry arguments it has are required to be provided, so it can actually generate its contents correctly. However when an existing image is read, Entry objects are created for each of the entries in the image. This happens as part of the process of reading the image into binman. In this case we don't need the entry arguments, since we do not intend to regenerate the entries, or at least not unless requested. So there is no sense in reporting an error for missing entry arguments. Add a new property for the Image to handle this case. Update the error reporting to be conditional on this property. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/entry.py | 3 +-- tools/binman/etype/section.py | 15 +++++++++++++++ tools/binman/ftest.py | 19 +++++++++++++++++++ tools/binman/image.py | 10 ++++++++-- tools/binman/test/188_image_entryarg.dts | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 tools/binman/test/188_image_entryarg.dts diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 2be0d8e0532..d58a730f3d5 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -434,8 +434,7 @@ class Entry(object): missing.append(prop.name) values.append(value) if missing: - self.Raise('Missing required properties/entry args: %s' % - (', '.join(missing))) + self.GetImage().MissingArgs(self, missing) return values def GetPath(self): diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 9c6334c4504..28a888776af 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -679,3 +679,18 @@ class Entry_section(Entry): for entry in to_add.values(): self._CollectEntries(entries, entries_by_name, entry) entries_by_name[add_entry.name] = add_entry + + def MissingArgs(self, entry, missing): + """Report a missing argument, if enabled + + For entries which require arguments, this reports an error if some are + missing. If missing entries are being ignored (e.g. because we read the + entry from an image rather than creating it), this function does + nothing. + + Args: + missing: List of missing properties / entry args, each a string + """ + if not self._ignore_missing: + entry.Raise('Missing required properties/entry args: %s' % + (', '.join(missing))) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 5016060ea68..8b928eb406d 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4154,6 +4154,25 @@ class TestFunctional(unittest.TestCase): U_BOOT_SPL_DATA[20:]) self.assertEqual(expected, data) + def testReadImageEntryArg(self): + """Test reading an image that would need an entry arg to generate""" + entry_args = { + 'cros-ec-rw-path': 'ecrw.bin', + } + data = self.data = self._DoReadFileDtb( + '188_image_entryarg.dts',use_real_dtb=True, update_dtb=True, + entry_args=entry_args) + + image_fname = tools.GetOutputFilename('image.bin') + orig_image = control.images['image'] + + # This should not generate an error about the missing 'cros-ec-rw-path' + # since we are reading the image from a file. Compare with + # testEntryArgsRequired() + image = Image.FromFile(image_fname) + self.assertEqual(orig_image.GetEntries().keys(), + image.GetEntries().keys()) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/image.py b/tools/binman/image.py index 3622efc6862..3c2fe5ea620 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -43,8 +43,13 @@ class Image(section.Entry_section): test: True if this is being called from a test of Images. This this case there is no device tree defining the structure of the section, so we create a section manually. + ignore_missing: Ignore any missing entry arguments (i.e. don't raise an + exception). This should be used if the Image is being loaded from + a file rather than generated. In that case we obviously don't need + the entry arguments since the contents already exists. """ - def __init__(self, name, node, copy_to_orig=True, test=False): + def __init__(self, name, node, copy_to_orig=True, test=False, + ignore_missing=False): super().__init__(None, 'section', node, test=test) self.copy_to_orig = copy_to_orig self.name = 'main-section' @@ -53,6 +58,7 @@ class Image(section.Entry_section): self.fdtmap_dtb = None self.fdtmap_data = None self.allow_repack = False + self._ignore_missing = ignore_missing if not test: self.ReadNode() @@ -100,7 +106,7 @@ class Image(section.Entry_section): # Return an Image with the associated nodes root = dtb.GetRoot() - image = Image('image', root, copy_to_orig=False) + image = Image('image', root, copy_to_orig=False, ignore_missing=True) image.image_node = fdt_util.GetString(root, 'image-node', 'image') image.fdtmap_dtb = dtb diff --git a/tools/binman/test/188_image_entryarg.dts b/tools/binman/test/188_image_entryarg.dts new file mode 100644 index 00000000000..29d81491623 --- /dev/null +++ b/tools/binman/test/188_image_entryarg.dts @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <0xc00>; + u-boot { + }; + cros-ec-rw { + }; + fdtmap { + }; + image-header { + location = "end"; + }; + }; +}; From patchwork Thu Jan 7 04:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423154 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=aZF36oea; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD3C1SBwz9sVm for ; Thu, 7 Jan 2021 15:36:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 95DB6827FA; Thu, 7 Jan 2021 05:35: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="aZF36oea"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC306827E5; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 112BC827BD for ; Thu, 7 Jan 2021 05:35: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-io1-xd31.google.com with SMTP id z5so4957722iob.11 for ; Wed, 06 Jan 2021 20:35: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=m09D4yz8bqlr3OOjXFZRqnZWvU+0yQIlfdVopFeGWWk=; b=aZF36oeaaVMO2XUYzIC8/0VSdkuOSp2j6hoJD1EcjgB/NJw/UK/jxnTUcnDQibj4aS w9G8uuU1x0l4m/F9VfbvnzeMHgAMlouYEGtnFQ28Posr4NpnjxEPGuzdA97InweS4Hm6 L7XzGdTuJeUuV0/bfuJeXtn++bye9r0jkzUhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m09D4yz8bqlr3OOjXFZRqnZWvU+0yQIlfdVopFeGWWk=; b=JnBR1VffF8T/pnAsjGsPx5Q8paEgjciZucuflKSXBWtm/Z2VD4PsPGEzIebQ3W9ViG JY7luPWhpNIU6k9cfPO0ZUD1f5KmRzJpbep8ZWP86SOdVlqnP/whGQB7YlQMe7AZ57rC gNgleziaU7UjVPHfzd9OWw+iNBOuKS01Vr6bXlzUper/HwDhdK75rOGXrQr65lkToSPq PdvvGM21fJ9VKCW/NtCEDhF3gz+ji9gAU8WwAsOAO0Vhm4fQyLp2HuRoAaEasPTAevD4 YKvVQR0ZmD1qh2jmtYsMKmBSYkefbdi5wPk8dK4zt/smczdOXELEiiVHONio6ozVS75n c56g== X-Gm-Message-State: AOAM531uR3Rz6bYyzvRijUqcSDWdoYmysTzo5itmjb9xkd3AjGnbcv9l H4PvaioO1iFeZKTlHi8KpD61gG87UQI1TjPe X-Google-Smtp-Source: ABdhPJzzU6QnwNcdm3Jo9kjh1grxtevPBDU8P3sP3pkePurHo2p/2p3/qxXSnXZOjXKeUvobWBJ/7A== X-Received: by 2002:a5e:970d:: with SMTP id w13mr5452314ioj.166.1609994131526; Wed, 06 Jan 2021 20:35:31 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andy Shevchenko , Bin Meng Subject: [PATCH 08/10] binman: Allow vblock to include devicetree blobs Date: Wed, 6 Jan 2021 21:35:17 -0700 Message-Id: <20210106213503.8.I42090f9e05e07d927b611da096f80900a4a44a73@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present if a devicetree blob is included in a vblock it does not deal with updates. This is because the vblock is created once at the start and does not have a method to update itself later, after all the entry contents are finalised. Fix this by adjusting how the vblock is created. Also simplify Image.ProcessEntryContents() since it effectively duplicates the code in Section.ProcessContents(). Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/blob.py | 4 ++ tools/binman/etype/vblock.py | 15 +++++++- tools/binman/ftest.py | 49 +++++++++++++++++++++++- tools/binman/image.py | 7 +--- tools/binman/test/189_vblock_content.dts | 31 +++++++++++++++ 5 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 tools/binman/test/189_vblock_content.dts diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index 301ac55e3b2..81756c326d9 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -66,3 +66,7 @@ class Entry_blob(Entry): def GetDefaultFilename(self): return self._filename + + def ProcessContents(self): + # The blob may have changed due to WriteSymbols() + return self.ProcessContentsUpdate(self.data) diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py index f734fbaec49..eba5351dd52 100644 --- a/tools/binman/etype/vblock.py +++ b/tools/binman/etype/vblock.py @@ -49,7 +49,7 @@ class Entry_vblock(Entry): EntryArg('kernelkey', str), EntryArg('preamble-flags', int)]) - def ObtainContents(self): + def GetVblock(self): # Join up the data files to be signed input_data = b'' for entry_phandle in self.content: @@ -76,5 +76,16 @@ class Entry_vblock(Entry): ] #out.Notice("Sign '%s' into %s" % (', '.join(self.value), self.label)) stdout = tools.Run('futility', *args) - self.SetContents(tools.ReadFile(output_fname)) + return tools.ReadFile(output_fname) + + def ObtainContents(self): + data = self.GetVblock() + if data is False: + return False + self.SetContents(data) return True + + def ProcessContents(self): + # The blob may have changed due to WriteSymbols() + data = self.GetVblock() + return self.ProcessContentsUpdate(data) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 8b928eb406d..7f7827b6a7d 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -1638,15 +1638,37 @@ class TestFunctional(unittest.TestCase): str(e.exception)) def _HandleVblockCommand(self, pipe_list): - """Fake calls to the futility utility""" + """Fake calls to the futility utility + + The expected pipe is: + + [('futility', 'vbutil_firmware', '--vblock', + 'vblock.vblock', '--keyblock', 'devkeys/firmware.keyblock', + '--signprivate', 'devkeys/firmware_data_key.vbprivk', + '--version', '1', '--fv', 'input.vblock', '--kernelkey', + 'devkeys/kernel_subkey.vbpubk', '--flags', '1')] + + This writes to the output file (here, 'vblock.vblock'). If + self._hash_data is False, it writes VBLOCK_DATA, else it writes a hash + of the input data (here, 'input.vblock'). + """ if pipe_list[0][0] == 'futility': fname = pipe_list[0][3] with open(fname, 'wb') as fd: - fd.write(VBLOCK_DATA) + if self._hash_data: + infile = pipe_list[0][11] + m = hashlib.sha256() + data = tools.ReadFile(infile) + m.update(data) + fd.write(m.digest()) + else: + fd.write(VBLOCK_DATA) + return command.CommandResult() def testVblock(self): """Test for the Chromium OS Verified Boot Block""" + self._hash_data = False command.test_result = self._HandleVblockCommand entry_args = { 'keydir': 'devkeys', @@ -1677,6 +1699,29 @@ class TestFunctional(unittest.TestCase): self.assertIn("Node '/binman/vblock': Cannot find entry for node " "'other'", str(e.exception)) + def testVblockContent(self): + """Test that the vblock signs the right data""" + self._hash_data = True + command.test_result = self._HandleVblockCommand + entry_args = { + 'keydir': 'devkeys', + } + data = self._DoReadFileDtb( + '189_vblock_content.dts', use_real_dtb=True, update_dtb=True, + entry_args=entry_args)[0] + hashlen = 32 # SHA256 hash is 32 bytes + self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)]) + hashval = data[-hashlen:] + dtb = data[len(U_BOOT_DATA):-hashlen] + + expected_data = U_BOOT_DATA + dtb + + # The hashval should be a hash of the dtb + m = hashlib.sha256() + m.update(expected_data) + expected_hashval = m.digest() + self.assertEqual(expected_hashval, hashval) + def testTpl(self): """Test that an image with TPL and its device tree can be created""" # ELF file with a '__bss_size' symbol diff --git a/tools/binman/image.py b/tools/binman/image.py index 3c2fe5ea620..e9494352413 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -136,12 +136,7 @@ class Image(section.Entry_section): Returns: True if the new data size is OK, False if expansion is needed """ - sizes_ok = True - for entry in self._entries.values(): - if not entry.ProcessContents(): - sizes_ok = False - tout.Debug("Entry '%s' size change" % self._node.path) - return sizes_ok + return super().ProcessContents() def WriteSymbols(self): """Write symbol values into binary files for access at run time""" diff --git a/tools/binman/test/189_vblock_content.dts b/tools/binman/test/189_vblock_content.dts new file mode 100644 index 00000000000..dcc74449c17 --- /dev/null +++ b/tools/binman/test/189_vblock_content.dts @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u_boot: u-boot { + }; + + dtb: u-boot-dtb { + }; + + /* + * Put the vblock after the dtb so that the dtb is updated + * before the vblock reads its data. At present binman does not + * understand dependencies between entries, but simply + * iterates again when it thinks something needs to be + * recalculated. + */ + vblock { + content = <&u_boot &dtb>; + keyblock = "firmware.keyblock"; + signprivate = "firmware_data_key.vbprivk"; + version = <1>; + kernelkey = "kernel_subkey.vbpubk"; + preamble-flags = <1>; + }; + }; +}; From patchwork Thu Jan 7 04:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423156 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=au9An9p2; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD3Z0J4pz9sVm for ; Thu, 7 Jan 2021 15:37:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0671682800; Thu, 7 Jan 2021 05:35:51 +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="au9An9p2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9157A827D9; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 03D1B827D2 for ; Thu, 7 Jan 2021 05:35: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-io1-xd36.google.com with SMTP id e22so4442618iom.5 for ; Wed, 06 Jan 2021 20:35: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=oIdM5UVelXSk5H5m4dZRsbqo5un+7FmAYsyj1Tl/jUI=; b=au9An9p2BaIWkUAlutIhBVm0tQiFTMmfsuhN/DhXU1pUgd8JsisbKUdN8Nzb0w5R9g VNkP2Ncb1XY/HOWxz7LN1JSxzzgRkuTLiHjX2Druu72Bp295cX0+sQZfxHYUHW0xW4w6 f9ChWT9V6XqJSDiaS5BYcb+02T9YKjjAU3od4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oIdM5UVelXSk5H5m4dZRsbqo5un+7FmAYsyj1Tl/jUI=; b=BRdoF3RuDUHCG7ISAjpgJdzyoRs+z0EuG2r8TS6ulul70TGsTq9YidB+WuoIxoopRS Mvoti+S8F7kKlQsSktZofxRxutufbEeRCWK1bJC28HkcelbyTgGyoGe80rW7kxfPe1Sz pF61q3I00cifnBd3mw0Eqb7qigmdZy7EwOx9GE3lkx09wA6LtQgghDbYQ/bXLdhzQ/Tl qWWBZNObZRwz3EzjviOha1H6QatZa4+p9W2bHepna/wR+SuT8LRDEvjaMhdxMxeRZlur 0zVXkMJdA4aDkVmA0DYJDtCKygX3mgiiNVayYI97dqP4z+k+D6uPDcmzQvmS2YqLRyuT 32eQ== X-Gm-Message-State: AOAM530Ss939vwSyQqiKeiA85wOcQDcoXu4dda1Aw8iOIcc4mJqkkZet xSyD6EM1xBHvIzBB+TSPVFc7G7q5dZm1bd9S X-Google-Smtp-Source: ABdhPJwGvjjArRm+RAPqZpma8DSN2ov12bDMhaNfMHyD7BpUtDhA1CvxwF/JEGH/539r+LG1GrizcQ== X-Received: by 2002:a5d:80d2:: with SMTP id h18mr5297056ior.117.1609994132563; Wed, 06 Jan 2021 20:35:32 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng Subject: [PATCH 09/10] binman: Support alignment of files Date: Wed, 6 Jan 2021 21:35:18 -0700 Message-Id: <20210106213503.9.I5725faed150cbd090c1d3c9b82431c57c2fa3b9d@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean When packing files it is sometimes useful to align the start of each file, e.g. if the flash driver can only access 32-bit-aligned data. Provides a new property to support this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/files.py | 4 ++++ tools/binman/ftest.py | 8 ++++++++ tools/binman/state.py | 10 ++++++++++ tools/binman/test/084_files.dts | 2 +- tools/binman/test/190_files_align.dts | 12 ++++++++++++ tools/dtoc/fdt.py | 12 ++++++++++++ tools/dtoc/test_fdt.py | 6 ++++++ 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/190_files_align.dts diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py index ce3832e3cdd..1feebd0510e 100644 --- a/tools/binman/etype/files.py +++ b/tools/binman/etype/files.py @@ -22,6 +22,7 @@ class Entry_files(Entry_section): - files-compress: Compression algorithm to use: none: No compression lz4: Use lz4 compression (via 'lz4' command-line utility) + - files-align: Align each file to the given alignment This entry reads a number of files and places each in a separate sub-entry within this entry. To access these you need to enable device-tree updates @@ -38,6 +39,7 @@ class Entry_files(Entry_section): self.Raise("Missing 'pattern' property") self._files_compress = fdt_util.GetString(self._node, 'files-compress', 'none') + self._files_align = fdt_util.GetInt(self._node, 'files-align'); self._require_matches = fdt_util.GetBool(self._node, 'require-matches') @@ -55,6 +57,8 @@ class Entry_files(Entry_section): state.AddString(subnode, 'type', 'blob') state.AddString(subnode, 'filename', fname) state.AddString(subnode, 'compress', self._files_compress) + if self._files_align: + state.AddInt(subnode, 'align', self._files_align) # Read entries again, now that we have some self._ReadEntries() diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 7f7827b6a7d..b31a7305a33 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4218,6 +4218,14 @@ class TestFunctional(unittest.TestCase): self.assertEqual(orig_image.GetEntries().keys(), image.GetEntries().keys()) + def testFilesAlign(self): + """Test alignment with files""" + data = self._DoReadFile('190_files_align.dts') + + # The first string is 15 bytes so will align to 16 + expect = FILES_DATA[:15] + b'\0' + FILES_DATA[15:] + self.assertEqual(expect, data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/state.py b/tools/binman/state.py index 36bc5135354..bb3e36ea7af 100644 --- a/tools/binman/state.py +++ b/tools/binman/state.py @@ -314,6 +314,16 @@ def AddString(node, prop, value): for n in GetUpdateNodes(node): n.AddString(prop, value) +def AddInt(node, prop, value): + """Add a new string property to affected device trees + + Args: + prop_name: Name of property + val: Integer value of property + """ + for n in GetUpdateNodes(node): + n.AddInt(prop, value) + def SetInt(node, prop, value, for_repack=False): """Update an integer property in affected device trees with an integer value diff --git a/tools/binman/test/084_files.dts b/tools/binman/test/084_files.dts index 83ddb78f8e7..8f09afd24ea 100644 --- a/tools/binman/test/084_files.dts +++ b/tools/binman/test/084_files.dts @@ -5,7 +5,7 @@ binman { files { pattern = "files/*.dat"; - compress = "none"; + files-compress = "none"; }; }; }; diff --git a/tools/binman/test/190_files_align.dts b/tools/binman/test/190_files_align.dts new file mode 100644 index 00000000000..213ba966d35 --- /dev/null +++ b/tools/binman/test/190_files_align.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +/ { + binman { + files { + pattern = "files/*.dat"; + files-compress = "none"; + files-align = <4>; + }; + }; +}; diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 965106a3b28..25ce5136ebf 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -463,6 +463,18 @@ class Node: val = bytes(val, 'utf-8') self.AddData(prop_name, val + b'\0') + def AddInt(self, prop_name, val): + """Add a new integer 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: Integer value of property + """ + self.AddData(prop_name, struct.pack('>I', val)) + def AddSubnode(self, name): """Add a new subnode to the node diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index dc6943f7337..e8fbbd5d10a 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -397,6 +397,12 @@ class TestProp(unittest.TestCase): data = self.fdt.getprop(self.node.Offset(), 'one') self.assertEqual(1, fdt32_to_cpu(data)) + val = 1234 + self.node.AddInt('integer', val) + self.dtb.Sync(auto_resize=True) + data = self.fdt.getprop(self.node.Offset(), 'integer') + self.assertEqual(val, fdt32_to_cpu(data)) + val = '123' + chr(0) + '456' self.node.AddString('string', val) self.dtb.Sync(auto_resize=True) From patchwork Thu Jan 7 04:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1423155 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=bMGNrt89; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DBD3N4QbKz9sVm for ; Thu, 7 Jan 2021 15:37:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 50C96827EB; Thu, 7 Jan 2021 05:35: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=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="bMGNrt89"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 690A8827D3; Thu, 7 Jan 2021 05:35: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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE 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 EBABF827D3 for ; Thu, 7 Jan 2021 05:35: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-x133.google.com with SMTP id 14so4266293ilq.2 for ; Wed, 06 Jan 2021 20:35: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=P7pwaRTuUKAplr2Jd/of0xFGeCY+cqnWTk1PAB6fMYc=; b=bMGNrt89dbbqGA3cBPRr/4AW2Hubh1/Wj32kqRyQkaEmStWgaLy+EBHTICupMDcox+ klEc0pOsk8QP8NQX/Gl6rWjuhTpgc9KBr3QM5iZgqh/1I2hJaD/ZLxwBNgo41a6tn7da GS1NKVeCaf+TaGz1fxUzx2c4YinhKvjaH1BFA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P7pwaRTuUKAplr2Jd/of0xFGeCY+cqnWTk1PAB6fMYc=; b=pgsxsTCF9aGS6ANw4g8Andd2L2pJGjeieSimqxtfRX/KC9hKdRPIrm68STuUZcyr9e 7QphW7G9ILv/7DK6dvQOBPNhAKGOi/sFddE9suZ0FdbTso5V9aGf1xBUtqPUj7SMYi8+ 0E9jtr3SAJpVVrSH/+PYlB1lo+jH/0es6ZzztspWcQ4fjsmPh/cIU8Eze31CoZZ5LQdm mOSE5RR8JANYifN6C8UZWoBBN8wiZ1nzEAspHM0ph6krnWJUPf96HLKcTJ7x9DpRIOxM EtwSC+e2TzYtRRwEnjClt4eQWnYWKd89Bjl8FX98bj1hnhC58Y6STiZq74OffyFqgfqN fgHA== X-Gm-Message-State: AOAM5303eUPa8IfdsdsS+C45zWGCHYo+ke9XmY5VsfY/HCUYA5Ok8yoV chsyt6osqTmH09XkD97n75MGCeQBTtgFWrUZ X-Google-Smtp-Source: ABdhPJwhuXdRk8v4YmQpCyjxPA+uf7mT7xXAxQzOWYQoF5EgW/GJNFHCJWJmD1cByEkUsp26S0oYkQ== X-Received: by 2002:a92:da46:: with SMTP id p6mr7316425ilq.136.1609994133550; Wed, 06 Jan 2021 20:35:33 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l78sm3724562ild.30.2021.01.06.20.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 20:35:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak , Bin Meng Subject: [PATCH 10/10] binman: Allow for skip_at_start when reading entries Date: Wed, 6 Jan 2021 21:35:19 -0700 Message-Id: <20210107043519.2634625-3-sjg@chromium.org> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20210107043519.2634625-1-sjg@chromium.org> References: <20210107043519.2634625-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The offset of an entry needs to be adjusted by its skip-at-start value. This is currently missing when reading entry data. Fix it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/section.py | 10 ++++++---- tools/binman/ftest.py | 19 +++++++++++++++++++ tools/binman/test/191_read_image_skip.dts | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 tools/binman/test/191_read_image_skip.dts diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 28a888776af..1ceadef13f3 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -605,10 +605,12 @@ class Entry_section(Entry): def ReadData(self, decomp=True): tout.Info("ReadData path='%s'" % self.GetPath()) parent_data = self.section.ReadData(True) - tout.Info('%s: Reading data from offset %#x-%#x, size %#x' % - (self.GetPath(), self.offset, self.offset + self.size, - self.size)) - data = parent_data[self.offset:self.offset + self.size] + offset = self.offset - self.section._skip_at_start + data = parent_data[offset:offset + self.size] + tout.Info( + '%s: Reading data from offset %#x-%#x (real %#x), size %#x, got %#x' % + (self.GetPath(), self.offset, self.offset + self.size, offset, + self.size, len(data))) return data def ReadChildData(self, child, decomp=True): diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index b31a7305a33..814e91d42e9 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4226,6 +4226,25 @@ class TestFunctional(unittest.TestCase): expect = FILES_DATA[:15] + b'\0' + FILES_DATA[15:] self.assertEqual(expect, data) + def testReadImageSkip(self): + """Test reading an image and accessing its FDT map""" + data = self.data = self._DoReadFileRealDtb('191_read_image_skip.dts') + image_fname = tools.GetOutputFilename('image.bin') + orig_image = control.images['image'] + image = Image.FromFile(image_fname) + self.assertEqual(orig_image.GetEntries().keys(), + image.GetEntries().keys()) + + orig_entry = orig_image.GetEntries()['fdtmap'] + entry = image.GetEntries()['fdtmap'] + self.assertEqual(orig_entry.offset, entry.offset) + self.assertEqual(orig_entry.size, entry.size) + self.assertEqual(16, entry.image_pos) + + u_boot = image.GetEntries()['section'].GetEntries()['u-boot'] + + self.assertEquals(U_BOOT_DATA, u_boot.ReadData()) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/191_read_image_skip.dts b/tools/binman/test/191_read_image_skip.dts new file mode 100644 index 00000000000..31df518fae6 --- /dev/null +++ b/tools/binman/test/191_read_image_skip.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + end-at-4gb; + size = <0x400>; + section { + size = <0x10>; + u-boot { + }; + }; + fdtmap { + }; + image-header { + location = "end"; + }; + }; +};