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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8875CC433EF for ; Sat, 19 Feb 2022 15:53:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6275283C17; Sat, 19 Feb 2022 16:53:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="nnOc1aR5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD84583C19; Sat, 19 Feb 2022 16:53:36 +0100 (CET) Received: from mail-ua1-x929.google.com (mail-ua1-x929.google.com [IPv6:2607:f8b0:4864:20::929]) (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 A8DD483BD2 for ; Sat, 19 Feb 2022 16:53:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ua1-x929.google.com with SMTP id 60so5752148uae.1 for ; Sat, 19 Feb 2022 07:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p6JQBqiTQ+z+eDYm3j4iuAwtDo2b0D7CcSriq+wb3sg=; b=nnOc1aR5vVfvSpYiNwrTxn75N2VzTEwpHFGYk1AmWSAZDh4RBAeQ14ON0sT5JDDu4E 1drOoEiUsUGumVtkRGGq4YNfJaP6zBcje3pFXWrK5K6i3Y1UpZcKvl0upNU7rU+7j04O k3x9rFgkhWzQQloo/Y6Kj8UqgFTtSpzYLTLic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p6JQBqiTQ+z+eDYm3j4iuAwtDo2b0D7CcSriq+wb3sg=; b=tfHghUvMQxNpek/wueK+DCfOvQdl9wrch03HWuU1Oe8MuJUFRa9rWsdkUe20/PArO8 7X0VcqYBSnBXE0v4BEIU+DLkuWULf/Dxt8fpB3LH1kIyyUOLbimL1hFw3zaqxDTmhRib lJleFmZ6bMrfYt5Vu3+XcvKqPQ9a2x0sHUsZYu0j0vmg76kK/Qias6stY+XenqPgFqV4 QbABf56IvGLE7hZogKdrpE4sg9rV+u84bT3C86UA7Wso5NzBgQD4pnXNrZ0fv8LfA/wy pSvXPkC4RUKfKXb9r2DFjGcUuVBpFDV55rnVOSie+KUabN0W156FzNMIjJH+ONErKlFI /LiA== X-Gm-Message-State: AOAM533VVwgNAqHveYndtJXEx2oTxLaudrsGrIG0EQcVn671hXeTEb7I 1IoJDhAYZtN8mViZ17mVXfZ4yUkWsVDZ9Pmv9wmT2A== X-Google-Smtp-Source: ABdhPJwRHC/rSeduBXoootwUUE8yv0kZYtuSA/AptsIxQv+pHnbgjTN52oblbjLrPCmKweU4kuzNm2mrf3DJAQldt4o= X-Received: by 2002:ab0:5403:0:b0:341:9b6c:935a with SMTP id n3-20020ab05403000000b003419b6c935amr2629259uaa.140.1645286011202; Sat, 19 Feb 2022 07:53:31 -0800 (PST) MIME-Version: 1.0 References: <20220207220809.4497-1-alpernebiyasak@gmail.com> <20220207220809.4497-5-alpernebiyasak@gmail.com> <1c7e5656-87f8-7d87-cb50-aead7b9a5ff1@siemens.com> <3d176bab-dc74-3ee2-9014-81401971ba8d@siemens.com> <10793ff6-12b6-7b3b-840b-c6f49f9185da@siemens.com> In-Reply-To: From: Simon Glass Date: Sat, 19 Feb 2022 08:53:19 -0700 Message-ID: Subject: Re: [PATCH v2 4/5] binman: Convert FIT entry type to a subclass of Section entry type To: Alper Nebi Yasak Cc: Jan Kiszka , U-Boot Mailing List , Heiko Thiery Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Hi Alper, On Fri, 18 Feb 2022 at 10:34, Alper Nebi Yasak wrote: > > On 18/02/2022 19:50, Jan Kiszka wrote: > > On 15.02.22 18:06, Jan Kiszka wrote: > >> On 15.02.22 17:50, Jan Kiszka wrote: > >>> On 15.02.22 13:27, Alper Nebi Yasak wrote: > >>>> The AddMissingProperties() and SetCalculatedProperties() methods were > >>>> disabled for FIT as a fixup to this patch, that's why image-pos etc. > >>>> aren't available. See comments at [1] for some context. > >>>> > >>>> Hopefully my two patches [2][3] fix things, can you test with them? > >>>> > >>>> [1] "binman: Correct the error message for a bad hash algorithm" > >>>> https://patchwork.ozlabs.org/project/uboot/patch/20220208105941.1.I8f212a1150defebaf8b7b15a79f7a2fc62c276b2@changeid/ > >>>> > >>>> [2] "binman: Skip processing "hash" subnodes of FIT subsections" > >>>> https://patchwork.ozlabs.org/project/uboot/patch/20220209190236.26479-1-alpernebiyasak@gmail.com/ > >>>> > >>> > >>> This one helped, indeed. > >>> > >> > >> ...not completely: > >> > >> $ source/tools/binman/binman replace -i flash.bin -f fit@0x380000.fit > >> fit@0x380000binman: [Errno 13] Permission denied: '/.fit@0x380000.itb' > >> > > > > Ping. > > > > $ source/tools/binman/binman -D replace -i flash.bin -f fit@0x380000.fit fit@0x380000 > > binman: [Errno 13] Permission denied: '/.fit@0x380000.itb' > > > > Traceback (most recent call last): > > File "source/tools/binman/binman", line 141, in RunBinman > > ret_code = control.Binman(args) > > File "u-boot/tools/binman/control.py", line 644, in Binman > > allow_resize=not args.fix_size, write_map=args.map) > > File "u-boot/tools/binman/control.py", line 404, in ReplaceEntries > > allow_resize=allow_resize, write_map=write_map) > > File "u-boot/tools/binman/control.py", line 341, in WriteEntryToImage > > AfterReplace(image, allow_resize=allow_resize, write_map=write_map) > > File "u-boot/tools/binman/control.py", line 333, in AfterReplace > > get_contents=False, allow_resize=allow_resize) > > File "u-boot/tools/binman/control.py", line 560, in ProcessImage > > image.PackEntries() > > File "u-boot/tools/binman/image.py", line 155, in PackEntries > > super().Pack(0) > > File "u-boot/tools/binman/etype/section.py", line 385, in Pack > > self._PackEntries() > > File "u-boot/tools/binman/etype/section.py", line 403, in _PackEntries > > offset = entry.Pack(offset) > > File "u-boot/tools/binman/etype/section.py", line 390, in Pack > > data = self.BuildSectionData(True) > > File "u-boot/tools/binman/etype/fit.py", line 265, in BuildSectionData > > tools.write_file(input_fname, data) > > File "u-boot/tools/patman/tools.py", line 482, in write_file > > with open(filename(fname), binary and 'wb' or 'w') as fd: > > PermissionError: [Errno 13] Permission denied: '/.fit@0x380000.itb' > > > > Something seems fairly broken here. That '/.' does not come from the > > output directory name, it's generated by Entry.GetUniqueName. Looks like > > this path should not been taken under these conditions. > > I can reproduce this and tried a few things, but more issues just kept > popping up (outside u-boot as well). I got it to a point where the > command re-packs the FIT and the image but quite wrongly. The offset and > image-pos properties get added in the FIT, and the image main-section > just concatenates all entries without regard to set offsets. I'll > need more time to work those out, then to add tests and send patches. I am going to try to merge my fit generator series today. One issue I notice is that the conversion to use entry_Section changes the contents of the self._fit_entries dict. Before it was keyed by relative path, but entry_section keys self._entries by node name. We may need to split it up. I will see if I can at least merge my series, which should not make things any worse, then see if I can come up with ideas. Thanks for the diff. Regards, Simon > > Here's the diff I got so far in case it helps: > > diff --git a/tools/binman/control.py b/tools/binman/control.py > index a179f7812988..24ec89b26302 100644 > --- a/tools/binman/control.py > +++ b/tools/binman/control.py > @@ -390,6 +390,7 @@ def ReplaceEntries(image_fname, input_fname, indir, > entry_paths, > """ > image_fname = os.path.abspath(image_fname) > image = Image.FromFile(image_fname) > + image.CollectBintools() > > # Replace an entry from a single file, as a special case > if input_fname: > diff --git a/tools/binman/entry.py b/tools/binman/entry.py > index 631215dfc88a..8173e91af96a 100644 > --- a/tools/binman/entry.py > +++ b/tools/binman/entry.py > @@ -767,7 +767,7 @@ def GetUniqueName(self): > node = self._node > while node.parent: > node = node.parent > - if node.name == 'binman': > + if node.name == 'binman' or node.name == '/': > break > name = '%s.%s' % (node.name, name) > return name > diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py > index 1e957023f354..9b2c33bc2b34 100644 > --- a/tools/binman/etype/fit.py > +++ b/tools/binman/etype/fit.py > @@ -137,10 +137,6 @@ def __init__(self, section, etype, node): > str)])[0] > self.mkimage = None > > - def ReadNode(self): > - self.ReadEntries() > - super().ReadNode() > - > def ReadEntries(self): > def _AddNode(base_node, depth, node): > """Add a node to the FIT > @@ -184,11 +180,12 @@ def _AddNode(base_node, depth, node): > # section entries for them here to merge the content > subnodes > # together and put the merged contents in the subimage > node's > # 'data' property later. > - entry = Entry.Create(self.section, node, etype='section') > + entry = Entry.Create(self, node, etype='section') > entry.ReadNode() > # The hash subnodes here are for mkimage, not binman. > entry.SetUpdateHash(False) > - self._entries[rel_path] = entry > + image_name = rel_path[len('/images/'):] > + self._entries[image_name] = entry > > for subnode in node.subnodes: > if has_images and not (subnode.name.startswith('hash') or > @@ -284,7 +281,8 @@ def _BuildInput(self, fdt): > Returns: > New fdt contents (bytes) > """ > - for path, section in self._entries.items(): > + for image_name, section in self._entries.items(): > + path = f"/images/{image_name}" > node = fdt.GetNode(path) > data = section.GetData() > node.AddData('data', data) > @@ -312,7 +310,8 @@ def SetImagePos(self, image_pos): > fdt = Fdt.FromData(self.GetData()) > fdt.Scan() > > - for path, section in self._entries.items(): > + for image_name, section in self._entries.items(): > + path = f"/images/{image_name}" > node = fdt.GetNode(path) > > data_prop = node.props.get("data")