From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CACA7C4338F for ; Mon, 26 Jul 2021 18:37:09 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95CB060F58 for ; Mon, 26 Jul 2021 18:37:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 95CB060F58 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2BED833B5; Mon, 26 Jul 2021 20:37:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gateworks-com.20150623.gappssmtp.com header.i=@gateworks-com.20150623.gappssmtp.com header.b="hdjzJnHg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CED81833A8; Mon, 26 Jul 2021 20:37:03 +0200 (CEST) Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 9E345833A8 for ; Mon, 26 Jul 2021 20:36:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tharvey@gateworks.com Received: by mail-pj1-x102e.google.com with SMTP id u9-20020a17090a1f09b029017554809f35so197356pja.5 for ; Mon, 26 Jul 2021 11:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/PEuuWlEKB41rGGLXstSZu0YA2gLT+rokUu3GBpsI/Q=; b=hdjzJnHgk65DHN/CUB7z/Jju3AEKn8sV4Kq6bQ6O6wImX9LM8Vtj1ko8FKhjSHbYKU fq24Y36T/p6BIEOkbimw+FAynj5r2FQ6QdKkFRotIn2eaBnRW9Krgf0S0R42r+RORwkx /I00YVMdsRt68s2kzD9CvyxrPN0c5fnPX4Uqxrg+cRExkdujY1T7M93+4a72aSCLIUpd tLPMS4GoMxOKQ0117OX40BrRpFFa/CdNGm+/gNcn0j6+xJMIPm4su+Fv0Fkuw7bya/a6 wGBmSUmcCah6wXGPbPyIfeqfSDi7sv5ljhp9QXGKwAoZWyuAvdP0jGdB0P8rjMayvLi+ nMHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/PEuuWlEKB41rGGLXstSZu0YA2gLT+rokUu3GBpsI/Q=; b=YEHDJvS38PMNlM94cXLPlkKd6JYf4ltaiCek+y7nGNdcoLAVJgtWHbjU95VGyGEX2l Gjsh8LDhV9jKSQVy7RdnY25yS83FYkaMZNtFQHRyqim35mzFVb+pzBgmXJMBGwwji4jW tf5mLXypbsxvzQX7hNDcayDpY2oyxuFPzDeT8lsX0zeZOP6EAlywLcmsD5X9vMdR5fGQ uspIKQH98LhkOMUYzsaBeVF8aZiIpbU2xblzKQ3q2XbS5dRnUjqn+LCuFmEoKx20xid/ BKzW7i8TVI57a3s2DwBivpxZGBHtH4dvItEY4DcaMdTzBXSoInz9TSC0vAma0ZoGoEHm F0BA== X-Gm-Message-State: AOAM533iK93WwbN+gzxd1EEYtH7lMR1jDQ0jAPZiLfD7i0cdrAlafcDk 2hPlhci0qub5NuxEnRYCQGRry38MQsWInoZI8zE5nA== X-Google-Smtp-Source: ABdhPJxotNGtJYLodSFuBJ8hkfGK3cfOb+Q8A/uaA4V8mpKbhdeyGA0tYRVUpyxymbZhL1mgzP9Gae83FTiZCCLQ88g= X-Received: by 2002:a65:6a0a:: with SMTP id m10mr19363423pgu.145.1627324617993; Mon, 26 Jul 2021 11:36:57 -0700 (PDT) MIME-Version: 1.0 References: <20210725165416.470735-1-sjg@chromium.org> <20210725105408.v2.3.Id1246d1ff1cb5750f8c7ddde9665cf6f09615a7c@changeid> In-Reply-To: <20210725105408.v2.3.Id1246d1ff1cb5750f8c7ddde9665cf6f09615a7c@changeid> From: Tim Harvey Date: Mon, 26 Jul 2021 11:36:47 -0700 Message-ID: Subject: Re: [PATCH v2 3/3] binman: Show an error if __image_copy_start is missing To: Simon Glass Cc: U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" 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.103.2 at phobos.denx.de X-Virus-Status: Clean On Sun, Jul 25, 2021 at 9:54 AM Simon Glass wrote: > > Binman needs this symbol to be able to figure out the start of the image. > Detect if it is missing and report an error if any symbols are needed. > > Add more documentation about possible binman warnings. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > tools/binman/binman.rst | 109 +++++++++++++++++++++++++++++++++++++++ > tools/binman/elf.py | 6 ++- > tools/binman/elf_test.py | 7 ++- > 3 files changed, 118 insertions(+), 4 deletions(-) > > diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst > index 09e7b571982..81e0a1364ff 100644 > --- a/tools/binman/binman.rst > +++ b/tools/binman/binman.rst > @@ -1158,6 +1158,115 @@ development, since dealing with exceptions and problems in threads is more > difficult. This avoids any use of ThreadPoolExecutor. > > > +Dealing with warnings and errors > +-------------------------------- > + > +__image_copy_start > +~~~~~~~~~~~~~~~~~~ > + > +If you see:: > + > + Cannot process symbol 'xxx' since there is no __image_copy_start > + > +this means that your SPL image does not include an `__image_copy_start` symbol. > +You can check this with:: > + > + nm spl/u-boot-spl |grep __image_copy_start > + > +If there is no output them you don't have that symbol. It is normally created > +in a `u-boot-spl.lds` file, like this:: > + > + text : > + { > + __image_copy_start = .; > + *(.vectors) > + CPUDIR/start.o (.text*) > + *(.text*) > + *(.glue*) > + } > + > +Check the appropriate file for your board, typically in the `arch/xxx/cpu` > +or `arch/xxx/cpu/xxx` directory. > + > +Entry xx not found in list > +~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +If you see something like:: > + > + output: 'binman: Section '/binman/u-boot-spl-ddr': > + Symbol '_binman_u_boot_any_prop_image_pos' > + in entry '/binman/u-boot-spl-ddr/u-boot-spl/u-boot-spl-nodtb': > + Entry 'u-boot-any' not found in list (u-boot-spl-nodtb,u-boot-spl-dtb, > + u-boot-spl,blob-ext@1,blob-ext@2,blob-ext@3,blob-ext@4,main-section) > + > +this means that binman knows it should set the value of a symbol called > +`_binman_u_boot_any_prop_image_pos` but does not know how. That symbol name is > +generated by the `binman_symname` macro (see `binman_sym.h`):: > + > + #define binman_symname(_entry_name, _prop_name) \ > + _binman_ ## _entry_name ## _prop_ ## _prop_name > + > +so binman decodes it into: > + > +_binman_ > + prefix for all symbols > +u_boot_any > + entry to find > +_prop_ > + prefix for property > +image_pos > + image_pos property > + > +It therefore looks for u-boot-any, which means any U-Boot symbol. Supported ones > +are: > + > +- u-boot > +- u-boot-img > +- u-boot-nodtb > + > +You can see a list of the symbols it tried, in brackets. None of these matches > +the above list. The source definition in this example is:: > + > + &binman { > + u-boot-spl-ddr { > + filename = "u-boot-spl-ddr.bin"; > + pad-byte = <0xff>; > + align-size = <4>; > + align = <4>; > + > + u-boot-spl { > + align-end = <4>; > + }; > + > + blob-ext-1 { > + filename = "lpddr4_pmu_train_1d_imem.bin"; > + size = <0x8000>; > + }; > + > + blob-ext-2 { > + filename = "lpddr4_pmu_train_1d_dmem.bin"; > + size = <0x4000>; > + }; > + > + blob-ext-3 { > + filename = "lpddr4_pmu_train_2d_imem.bin"; > + size = <0x8000>; > + }; > + > + blob-ext-4 { > + filename = "lpddr4_pmu_train_2d_dmem.bin"; > + size = <0x4000>; > + }; > + }; > + > +and you can see that, while `u-boot-spl` is present, `u-boot` is not. Binman > +must find the required symbol somewhere in the same image. > + > +In this case the problem is that CONFIG_SPL_RAW_IMAGE_SUPPORT is enabled, even > +though U-Boot is actually stored in a FIT. This means that > +spl_set_header_raw_uboot() is called and it looks for a symbol for U-Boot. > +Disabling that option fixes the error. > + > History / Credits > ----------------- > > diff --git a/tools/binman/elf.py b/tools/binman/elf.py > index 03b49d7163c..f14d07da157 100644 > --- a/tools/binman/elf.py > +++ b/tools/binman/elf.py > @@ -112,12 +112,14 @@ def LookupAndWriteSymbols(elf_fname, entry, section): > if not syms: > return > base = syms.get('__image_copy_start') > - if not base: > - return > for name, sym in syms.items(): > if name.startswith('_binman'): > msg = ("Section '%s': Symbol '%s'\n in entry '%s'" % > (section.GetPath(), name, entry.GetPath())) > + if not base: > + raise ValueError("Cannot process symbol '%s' since there is no __image_copy_start" % > + name) > + > offset = sym.address - base.address > if offset < 0 or offset + sym.size > entry.contents_size: > raise ValueError('%s has offset %x (size %x) but the contents ' > diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py > index 7a128018d9f..96630502b2f 100644 > --- a/tools/binman/elf_test.py > +++ b/tools/binman/elf_test.py > @@ -134,8 +134,11 @@ class TestElf(unittest.TestCase): > entry = FakeEntry(10) > section = FakeSection() > elf_fname = self.ElfTestFile('u_boot_binman_syms_bad') > - self.assertEqual(elf.LookupAndWriteSymbols(elf_fname, entry, section), > - None) > + with self.assertRaises(ValueError) as e: > + self.assertEqual(elf.LookupAndWriteSymbols(elf_fname, entry, section), > + None) > + self.assertIn("Cannot process symbol '_binman_u_boot_spl_any_prop_offset' since there is no __image_copy_start", > + str(e.exception)) > > def testBadSymbolSize(self): > """Test that an attempt to use an 8-bit symbol are detected > -- > 2.32.0.432.gabb21c7263-goog > Simon, Thanks - this is very helpful. Reviewed-by: Tim Harvey Tim