From patchwork Tue Jul 17 19:25:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 945297 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41VW3v39NPz9s0w for ; Wed, 18 Jul 2018 05:46:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 13222C21E74; Tue, 17 Jul 2018 19:41:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0F157C21FA3; Tue, 17 Jul 2018 19:27:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7B477C21FA3; Tue, 17 Jul 2018 19:26:56 +0000 (UTC) Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202]) by lists.denx.de (Postfix) with ESMTPS id EC025C21F49 for ; Tue, 17 Jul 2018 19:26:46 +0000 (UTC) Received: by mail-io0-f202.google.com with SMTP id z9-v6so1619443iom.14 for ; Tue, 17 Jul 2018 12:26:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=hCQApv5Tf8UPSdaM/CIxCJiY7+Pp5C4zGA5CHtGbvSs=; b=mh2gIOFqokRZE7i+uhiPKn8Q4tsN3GmL+HHAvzUH6HJrq++Nyz5mFZ2b7Iu0py9PKa p372hNh3Anzs3+D58RcfdnenP0cyjeyrT5+WP2PqLKJByW0MTOe4FtElmTUE3pii6fXH OZ8/jzq9CPf9/nmKGjl8RSj1ot14vQ6vhrk1b9+mByTno5JB9YNLcOI9cPs5Ispxrp+8 KtKSotIuVRSPailOFwr1sVLjIKanP+14VtBtSxY045U036Iu04UcqyfFzv3mXZJFzL03 H3zinjuNXsVyRpn11zx4+6gzh4Hq3Rtok1RN0euLaR38yJ79rcz1Yrw8+c39PaDiC0gd HOuA== X-Gm-Message-State: AOUpUlHLol578oujIm+gl5nTbI9tHEsqhJAvpapAGQZm2QiG7/+zUhHt 1OYoDvmDoWSJjgYRcQs9qHo4DmQ= X-Google-Smtp-Source: AAOMgpcxiEpI6z7Rs80bUakPiT+DfxYbpJx/deg46rF0YFezB5O1DDdo6jayGcDGxtdQ5B13xhiK72k= MIME-Version: 1.0 X-Received: by 2002:a24:228c:: with SMTP id o134-v6mr1335887ito.30.1531855606016; Tue, 17 Jul 2018 12:26:46 -0700 (PDT) Date: Tue, 17 Jul 2018 13:25:48 -0600 In-Reply-To: <20180717192552.198496-1-sjg@chromium.org> Message-Id: <20180717192552.198496-26-sjg@chromium.org> References: <20180717192552.198496-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH 25/29] binman: Add support for adding TPL binaries X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Add support for U-Boot's TPL and TPL device tree. Also fix a few comments in the other device-tree entries. Signed-off-by: Simon Glass --- tools/binman/README.entries | 38 +++++++++++++++++++++++- tools/binman/etype/u_boot_spl.py | 2 +- tools/binman/etype/u_boot_spl_dtb.py | 2 +- tools/binman/etype/u_boot_tpl.py | 43 ++++++++++++++++++++++++++++ tools/binman/etype/u_boot_tpl_dtb.py | 25 ++++++++++++++++ tools/binman/ftest.py | 22 ++++++++++++-- tools/binman/test/78_u_boot_tpl.dts | 11 +++++++ 7 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 tools/binman/etype/u_boot_tpl.py create mode 100644 tools/binman/etype/u_boot_tpl_dtb.py create mode 100644 tools/binman/test/78_u_boot_tpl.dts diff --git a/tools/binman/README.entries b/tools/binman/README.entries index 1b75ca0052..c6e7b22609 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -365,7 +365,7 @@ This is the U-Boot SPL (Secondary Program Loader) binary. This is a small binary which loads before U-Boot proper, typically into on-chip SRAM. It is responsible for locating, loading and jumping to U-Boot. Note that SPL is not relocatable so must be loaded to the correct address in SRAM, or written -to run from the correct address is direct flash execution is possible (e.g. +to run from the correct address if direct flash execution is possible (e.g. on x86 devices). SPL can access binman symbols at runtime. See: @@ -433,6 +433,42 @@ process. +Entry: u-boot-tpl: U-Boot TPL binary +------------------------------------ + +Properties / Entry arguments: + - filename: Filename of u-boot-tpl.bin (default 'tpl/u-boot-tpl.bin') + +This is the U-Boot TPL (Tertiary Program Loader) binary. This is a small +binary which loads before SPL, typically into on-chip SRAM. It is +responsible for locating, loading and jumping to SPL, the next-stage +loader. Note that SPL is not relocatable so must be loaded to the correct +address in SRAM, or written to run from the correct address if direct +flash execution is possible (e.g. on x86 devices). + +SPL can access binman symbols at runtime. See: + + 'Access to binman entry offsets at run time (symbols)' + +in the binman README for more information. + +The ELF file 'tpl/u-boot-tpl' must also be available for this to work, since +binman uses that to look up symbols to write into the TPL binary. + + + +Entry: u-boot-tpl-dtb: U-Boot TPL device tree +--------------------------------------------- + +Properties / Entry arguments: + - filename: Filename of u-boot.dtb (default 'tpl/u-boot-tpl.dtb') + +This is the TPL device tree, containing configuration information for +TPL. TPL needs this to know what devices are present and which drivers +to activate. + + + Entry: u-boot-ucode: U-Boot microcode block ------------------------------------------- diff --git a/tools/binman/etype/u_boot_spl.py b/tools/binman/etype/u_boot_spl.py index 0e99a2d2a7..ab78714c8d 100644 --- a/tools/binman/etype/u_boot_spl.py +++ b/tools/binman/etype/u_boot_spl.py @@ -20,7 +20,7 @@ class Entry_u_boot_spl(Entry_blob): binary which loads before U-Boot proper, typically into on-chip SRAM. It is responsible for locating, loading and jumping to U-Boot. Note that SPL is not relocatable so must be loaded to the correct address in SRAM, or written - to run from the correct address is direct flash execution is possible (e.g. + to run from the correct address if direct flash execution is possible (e.g. on x86 devices). SPL can access binman symbols at runtime. See: diff --git a/tools/binman/etype/u_boot_spl_dtb.py b/tools/binman/etype/u_boot_spl_dtb.py index 6a30edc83c..cb29ba3fd8 100644 --- a/tools/binman/etype/u_boot_spl_dtb.py +++ b/tools/binman/etype/u_boot_spl_dtb.py @@ -2,7 +2,7 @@ # Copyright (c) 2016 Google, Inc # Written by Simon Glass # -# Entry-type module for U-Boot device tree +# Entry-type module for U-Boot device tree in SPL (Secondary Program Loader) # from entry import Entry diff --git a/tools/binman/etype/u_boot_tpl.py b/tools/binman/etype/u_boot_tpl.py new file mode 100644 index 0000000000..4d4bb92596 --- /dev/null +++ b/tools/binman/etype/u_boot_tpl.py @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass +# +# Entry-type module for tpl/u-boot-tpl.bin +# + +import elf + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_tpl(Entry_blob): + """U-Boot TPL binary + + Properties / Entry arguments: + - filename: Filename of u-boot-tpl.bin (default 'tpl/u-boot-tpl.bin') + + This is the U-Boot TPL (Tertiary Program Loader) binary. This is a small + binary which loads before SPL, typically into on-chip SRAM. It is + responsible for locating, loading and jumping to SPL, the next-stage + loader. Note that SPL is not relocatable so must be loaded to the correct + address in SRAM, or written to run from the correct address if direct + flash execution is possible (e.g. on x86 devices). + + SPL can access binman symbols at runtime. See: + + 'Access to binman entry offsets at run time (symbols)' + + in the binman README for more information. + + The ELF file 'tpl/u-boot-tpl' must also be available for this to work, since + binman uses that to look up symbols to write into the TPL binary. + """ + def __init__(self, section, etype, node): + Entry_blob.__init__(self, section, etype, node) + self.elf_fname = 'tpl/u-boot-tpl' + + def GetDefaultFilename(self): + return 'tpl/u-boot-tpl.bin' + + def WriteSymbols(self, section): + elf.LookupAndWriteSymbols(self.elf_fname, self, section) diff --git a/tools/binman/etype/u_boot_tpl_dtb.py b/tools/binman/etype/u_boot_tpl_dtb.py new file mode 100644 index 0000000000..9c4e668347 --- /dev/null +++ b/tools/binman/etype/u_boot_tpl_dtb.py @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2018 Google, Inc +# Written by Simon Glass +# +# Entry-type module for U-Boot device tree in TPL (Tertiary Program Loader) +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_tpl_dtb(Entry_blob): + """U-Boot TPL device tree + + Properties / Entry arguments: + - filename: Filename of u-boot.dtb (default 'tpl/u-boot-tpl.dtb') + + This is the TPL device tree, containing configuration information for + TPL. TPL needs this to know what devices are present and which drivers + to activate. + """ + def __init__(self, section, etype, node): + Entry_blob.__init__(self, section, etype, node) + + def GetDefaultFilename(self): + return 'tpl/u-boot-tpl.dtb' diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index a6de4cb93b..d09868588c 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -30,11 +30,13 @@ import tout U_BOOT_DATA = '1234' U_BOOT_IMG_DATA = 'img' U_BOOT_SPL_DATA = '56780123456789abcde' +U_BOOT_TPL_DATA = 'tpl' BLOB_DATA = '89' ME_DATA = '0abcd' VGA_DATA = 'vga' U_BOOT_DTB_DATA = 'udtb' U_BOOT_SPL_DTB_DATA = 'spldtb' +U_BOOT_TPL_DTB_DATA = 'tpldtb' X86_START16_DATA = 'start16' X86_START16_SPL_DATA = 'start16spl' U_BOOT_NODTB_DATA = 'nodtb with microcode pointer somewhere in here' @@ -82,11 +84,11 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('u-boot.bin', U_BOOT_DATA) TestFunctional._MakeInputFile('u-boot.img', U_BOOT_IMG_DATA) TestFunctional._MakeInputFile('spl/u-boot-spl.bin', U_BOOT_SPL_DATA) + TestFunctional._MakeInputFile('tpl/u-boot-tpl.bin', U_BOOT_TPL_DATA) TestFunctional._MakeInputFile('blobfile', BLOB_DATA) TestFunctional._MakeInputFile('me.bin', ME_DATA) TestFunctional._MakeInputFile('vga.bin', VGA_DATA) - TestFunctional._MakeInputFile('u-boot.dtb', U_BOOT_DTB_DATA) - TestFunctional._MakeInputFile('spl/u-boot-spl.dtb', U_BOOT_SPL_DTB_DATA) + self._ResetDtbs() TestFunctional._MakeInputFile('u-boot-x86-16bit.bin', X86_START16_DATA) TestFunctional._MakeInputFile('spl/u-boot-x86-16bit-spl.bin', X86_START16_SPL_DATA) @@ -126,6 +128,12 @@ class TestFunctional(unittest.TestCase): """Remove the temporary output directory""" tools._FinaliseForTest() + @classmethod + def _ResetDtbs(self): + TestFunctional._MakeInputFile('u-boot.dtb', U_BOOT_DTB_DATA) + TestFunctional._MakeInputFile('spl/u-boot-spl.dtb', U_BOOT_SPL_DTB_DATA) + TestFunctional._MakeInputFile('tpl/u-boot-tpl.dtb', U_BOOT_TPL_DTB_DATA) + def _RunBinman(self, *args, **kwargs): """Run binman using the command line @@ -257,7 +265,7 @@ class TestFunctional(unittest.TestCase): finally: # Put the test file back if use_real_dtb: - TestFunctional._MakeInputFile('u-boot.dtb', U_BOOT_DTB_DATA) + self._ResetDtbs() def _DoReadFile(self, fname, use_real_dtb=False): """Helper function which discards the device-tree binary @@ -1345,6 +1353,14 @@ class TestFunctional(unittest.TestCase): self.assertIn("Node '/binman/vblock': Cannot find entry for node " "'other'", str(e.exception)) + def testTpl(self): + """Test that an image with TPL and ots device tree can be created""" + # ELF file with a '__bss_size' symbol + with open(self.TestFile('bss_data')) as fd: + TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read()) + data = self._DoReadFile('78_u_boot_tpl.dts') + self.assertEqual(U_BOOT_TPL_DATA + U_BOOT_TPL_DTB_DATA, data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/78_u_boot_tpl.dts b/tools/binman/test/78_u_boot_tpl.dts new file mode 100644 index 0000000000..6c60b4c46f --- /dev/null +++ b/tools/binman/test/78_u_boot_tpl.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +/ { + binman { + u-boot-tpl { + }; + u-boot-tpl-dtb { + }; + }; +};