From patchwork Mon Oct 26 23:40:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1388210 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=R8LZFVR1; 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 4CKrzc3l8vz9sRK for ; Tue, 27 Oct 2020 10:45:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7A08824F1; Tue, 27 Oct 2020 00:41: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="R8LZFVR1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1816824E5; Tue, 27 Oct 2020 00:40: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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED 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 D3A74824A7 for ; Tue, 27 Oct 2020 00:40: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-xd30.google.com with SMTP id u19so13043962ion.3 for ; Mon, 26 Oct 2020 16:40:43 -0700 (PDT) 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=vWzBGMNg72WqnieOENVRJlGJCNpk9syriedIe/wwIyQ=; b=R8LZFVR1xztpp4w5PdKvagD1m6QAvu1gOSUmJTmN63khH7B2Ibz6VVWdXAN1ic57k8 AvvryWIRHhaH/gSFrNrvcmbO5195zhorRx+17/ODUfZLHMkm5kynta15pj5eE5LQP1sL as+fl8wXf0WeZhHvWUccBnccj5WfAJ5RNmj14= 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=vWzBGMNg72WqnieOENVRJlGJCNpk9syriedIe/wwIyQ=; b=ZOjXuDxSMyD4UTgWbT/H0Y8PvwkaO4Qr55t20MFoMvKc0gLKMJWj47lHXy/j9MpACg EyInTZEO1GvX8noFIqUjzWWM75FayuAPJ3/lC4Zp7a43S3ld3Peft1EpwZ1lH/sxz8vq J9uUIBSxwyV3eh0nig2edBbNmJD/i7amE2yWv1NvWnfKt8Fl631Ngkp6pQIxEj71I2bE 3gjTr46b/dhpaGb0GccfAJDQVRkIxWXzuJs/Qblxq3WeyAL+TgO1xyqMeWJkgDRe95wb ENRgph30jHyM935N9IBhPhrErt5DytUgibrOeT3JvaM5UcB58i0brh26vPG640YexiV3 xPEQ== X-Gm-Message-State: AOAM533tuF2A2d6sTrNkxavsKMO8gZEhCXd6P0Qf8E7p+GPozV/dxOKD 6ZKqZQ1pwUqfMQPgl8Hb0gWtNm8bo9blETZU X-Google-Smtp-Source: ABdhPJxEKs+WJayH/CrOLYoPrSosHQMCMnO+pjmIzCUn2/UJW5g4mk9YdbVhyUb0hu+oSBDNY0/kEA== X-Received: by 2002:a5d:898c:: with SMTP id m12mr12768861iol.196.1603755642566; Mon, 26 Oct 2020 16:40:42 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id e17sm7066857ile.60.2020.10.26.16.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 16:40:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 15/28] binman: Move section padding to the parent Date: Mon, 26 Oct 2020 17:40:13 -0600 Message-Id: <20201026234026.1903778-15-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026234026.1903778-1-sjg@chromium.org> References: <20201026234026.1903778-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 Each section is padded up to its size, if the contents are not large enough. Move this logic from _BuildSectionData() to GetPaddedDataForEntry() so that all the padding is in one place. With this, the testDual test is working again, so enable it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: - Update testSkipAtStartSectionPad which now works as expected tools/binman/etype/section.py | 18 ++++++++++-------- tools/binman/ftest.py | 6 ++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index f80432914f2..7cbb50057a3 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -159,17 +159,23 @@ class Entry_section(Entry): Contents of the entry along with any pad bytes before and after it (bytes) """ + pad_byte = (entry._pad_byte if isinstance(entry, Entry_section) + else self._pad_byte) + data = b'' # Handle padding before the entry if entry.pad_before: - data += tools.GetBytes(self._pad_byte, entry.pad_before) + data += tools.GetBytes(pad_byte, entry.pad_before) # Add in the actual entry data data += entry.GetData() # Handle padding after the entry if entry.pad_after: - data += tools.GetBytes(self._pad_byte, entry.pad_after) + data += tools.GetBytes(pad_byte, entry.pad_after) + + if entry.size: + data += tools.GetBytes(pad_byte, entry.size - len(data)) self.Detail('GetPaddedDataForEntry: size %s' % ToHexSize(self.data)) @@ -198,9 +204,6 @@ class Entry_section(Entry): # Add in the actual entry data section_data += data - if self.size: - section_data += tools.GetBytes(self._pad_byte, - self.size - len(section_data)) self.Detail('GetData: %d entries, total size %#x' % (len(self._entries), len(section_data))) return self.CompressData(section_data) @@ -219,9 +222,8 @@ class Entry_section(Entry): Contents of the section along with any pad bytes before and after it (bytes) """ - if self.section: - return super().GetPaddedData() - return self.GetData() + section = self.section or self + return section.GetPaddedDataForEntry(self) def GetData(self): return self._BuildSectionData() diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 82be9976c32..31e93c647fe 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -708,7 +708,6 @@ class TestFunctional(unittest.TestCase): """Test a simple binman run with debugging enabled""" self._DoTestFile('005_simple.dts', debug=True) - @unittest.skip('Disable for now until padding of images is supported') def testDual(self): """Test that we can handle creating two images @@ -3872,9 +3871,7 @@ class TestFunctional(unittest.TestCase): before = tools.GetBytes(0, 8) after = tools.GetBytes(0, 4) all = before + U_BOOT_DATA + after - - # This is not correct, but it is what binman currently produces - self.assertEqual(before + U_BOOT_DATA + tools.GetBytes(0, 16), data) + self.assertEqual(all, data) image = control.images['image'] entries = image.GetEntries() @@ -3882,6 +3879,7 @@ class TestFunctional(unittest.TestCase): self.assertEqual(0, section.offset) self.assertEqual(len(all), section.size) self.assertIsNone(section.data) + self.assertEqual(all, section.GetPaddedData()) entry = section.GetEntries()['u-boot'] self.assertEqual(16, entry.offset)