public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ivan Mikhaylov <fr0st61te@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>,
	Ivan Mikhaylov <ivan.mikhaylov@siemens.com>,
	Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [PATCH 1/3] binman: add sign option for binman
Date: Tue, 13 Dec 2022 21:51:15 +0000	[thread overview]
Message-ID: <a50acc54bf98c0b36d10e60e9f84d6662287f940.camel@gmail.com> (raw)
In-Reply-To: <CAPnjgZ1TzOgGuyNVcOquosKo4Ca5A=m30CvEcrc=8L+Va_vvCg@mail.gmail.com>

On Fri, 2022-11-18 at 13:50 -0700, Simon Glass wrote:
> Hi Ivan,
> 
> On Thu, 15 Sept 2022 at 13:44, Ivan Mikhaylov <fr0st61te@gmail.com>
> wrote:
> > 
> > On Wed, 2022-09-07 at 15:10 -0600, Simon Glass wrote:
> > > Hi Ivan,
> > > 
> > > Section data comes from the BuildSectionData() method, so you
> > > could
> > > try calling that.
> > > 
> > > See also collect_contents_to_file()
> > > 
> > > Regards,
> > > Simon
> > 
> > Simon, I've tried both these ways and they both don't work to me.
> > What
> > I've got:
> > 
> > def SignEntries(image_fname, input_fname, privatekey_fname, algo,
> > entry_paths):
> >     image_fname = os.path.abspath(image_fname)
> >     image = Image.FromFile(image_fname)
> >     state.PrepareFromLoadedData(image)
> >     image.LoadData()
> > 
> > 1. BuildSectionData
> > 
> >     for entry_path in entry_paths:
> >         entry = image.FindEntryPath(entry_path)
> > 
> >         try:
> >             entry.BuildSectionData(True)
> >         except Exception as e:
> >             logging.error(traceback.format_exc())
> > 
> > 
> > ERROR:root:AttributeError: 'NoneType' object has no attribute 'run'

Hi Simon, sorry for long delay.

binman: 'NoneType' object has no attribute 'run'

Traceback (most recent call last):
  File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in
RunBinman
    ret_code = control.Binman(args)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 684, in
Binman
    SignEntries(args.image, args.file, args.key, args.algo, args.paths)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 469, in
SignEntries
    entry.BuildSectionData(True)
  File "/home/fr/upstream_uboot/tools/binman/etype/fit.py", line 426,
in BuildSectionData
    if self.mkimage.run(reset_timestamp=True,
output_fname=output_fname,
AttributeError: 'NoneType' object has no attribute 'run'


> > 
> > 2. collect_contents_to_file
> > 
> >     for entry_path in entry_paths:
> >         entry = image.FindEntryPath(entry_path)
> > 
> >         try:
> >             entry.collect_contents_to_file([entry.name], "prefix",
> > 1024)
> >         except Exception as e:
> >             logging.error(traceback.format_exc())
> > 
> > ERROR:root:AttributeError: 'str' object has no attribute
> > 'ObtainContents'
> 
> This seems to be getting a string instead of an entry object. Can you
> try -D to see? See 'Writing new entries and debugging'.

Yea, you're right, seems I've added here entry.name instead of entry
but result still messy. entry here is FIT container which is 'fit':

<binman.etype.fit.Entry_fit object at 0x7f6b239cfe20>
<class 'binman.etype.fit.Entry_fit'>

binman: [Errno 2] No such file or directory: 'u-boot.bin'

Traceback (most recent call last):
  File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in
RunBinman
    ret_code = control.Binman(args)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 686, in
Binman
    SignEntries(args.image, args.file, args.key, args.algo, args.paths)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 471, in
SignEntries
    entry.collect_contents_to_file([entry], "prefix", 1024)
  File "/home/fr/upstream_uboot/tools/binman/entry.py", line 1253, in
collect_contents_to_file
    if not entry.ObtainContents(fake_size=fake_size):
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
250, in ObtainContents
    return self.GetEntryContents(skip_entry=skip_entry)
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
696, in GetEntryContents
    job.result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in
result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in
__get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in
run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
668, in _CheckDone
    if not entry.ObtainContents():
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
250, in ObtainContents
    return self.GetEntryContents(skip_entry=skip_entry)
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
696, in GetEntryContents
    job.result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in
result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in
__get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in
run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
668, in _CheckDone
    if not entry.ObtainContents():
  File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 52,
in ObtainContents
    self.ReadBlobContents()
  File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 82,
in ReadBlobContents
    data = self.ReadFileContents(self._pathname)
  File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 74,
in ReadFileContents
    indata = tools.read_file(pathname)
  File "/home/fr/upstream_uboot/tools/patman/tools.py", line 467, in
read_file
    with open(filename(fname), binary and 'rb' or 'r') as fd:
FileNotFoundError: [Errno 2] No such file or directory: 'u-boot.bin'

> 
> > 
> > 3. GetData
> > 
> >     for entry_path in entry_paths:
> >         entry = image.FindEntryPath(entry_path)
> > 
> >         print("--- DATA ---")
> >         data = entry.GetData(True)
> >         print(data)
> >         print("~~~ DATA ~~~")
> > 
> > --- DATA ---
> > Node '/fit/images/u-boot-1/u-boot': GetData: size 0x4
> >    Node '/fit/images/u-boot-1': GetPaddedDataForEntry: size None
> >    Node '/fit/images/u-boot-1': GetData: 1 entries, total size 0x4
> > Node '/fit/images/fdt-1/u-boot-spl-dtb': GetData: size 0x4f7
> >       Node '/fit/images/fdt-1': GetPaddedDataForEntry: size None
> >       Node '/fit/images/fdt-1': GetData: 1 entries, total size
> > 0x4f7
> > Deleted temporary directory '/tmp/binman.z81eqcfz'
> > binman: 'NoneType' object has no attribute 'run'
> 
> This might be trying to call tools.run() so use -D to see where the
> error is.
> 

--- DATA ---
Node '/fit/images/u-boot-1/u-boot': GetData: size 0x4
   Node '/fit/images/u-boot-1': GetPaddedDataForEntry: size None
   Node '/fit/images/u-boot-1': GetData: 1 entries, total size 0x4
Node '/fit/images/fdt-1/u-boot-spl-dtb': GetData: size 0x4f7
      Node '/fit/images/fdt-1': GetPaddedDataForEntry: size None
      Node '/fit/images/fdt-1': GetData: 1 entries, total size 0x4f7
Deleted temporary directory '/tmp/binman.0x74lr_s'
binman: 'NoneType' object has no attribute 'run'

Traceback (most recent call last):
  File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in
RunBinman
    ret_code = control.Binman(args)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 684, in
Binman
    SignEntries(args.image, args.file, args.key, args.algo, args.paths)
  File "/home/fr/upstream_uboot/tools/binman/control.py", line 468, in
SignEntries
    print(entry.GetData())
  File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line
362, in GetData
    data = self.BuildSectionData(required)
  File "/home/fr/upstream_uboot/tools/binman/etype/fit.py", line 426,
in BuildSectionData
    if self.mkimage.run(reset_timestamp=True,
output_fname=output_fname,
AttributeError: 'NoneType' object has no attribute 'run'

This one strange to me because mkimage exists in tools directory and
has the symbolic link to /usr/local.

> > 
> > There is no problem with getting data from GetData around start of
> > the
> > year. Maybe some regression?
> > 
> > All this ran with this:
> > binman -v5 sign -i image.bin -k test_key.key -a sha256,rsa4096 fit
> > 
> > `fit` in entry_paths and image contains FIT section with name
> > `fit`.
> > 
> > binman ls -i image.bin
> > Name                  Image-pos  Size     Entry-type      Offset
> > Uncomp-size
> > -------------------------------------------------------------------
> > ----
> > --------
> > main-section                  0   100000  section              0
> >   fit                     10000      c0a  fit              10000
> >     u-boot-1              10104        4  section            104
> >       u-boot              10104        4  u-boot               0
> >     fdt-1                 101c8      4f7  section            1c8
> >       u-boot-spl-dtb      101c8      4f7  u-boot-spl-dtb       0
> >   fdtmap                  10c0a      4f5  fdtmap           10c0a
> > 
> > 
> > Seems something went wrong, any ideas? Or did I misuse?
> 
> Can you please push a tree somewhere so I can try this?

Sure, https://github.com/fr0st61te/u-boot/tree/signfit , rebased to
current master.

Thanks.


  reply	other threads:[~2022-12-13 20:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 21:43 [PATCH 0/3] Introduce new sign binman's option Ivan Mikhaylov
2022-03-21 21:43 ` [PATCH 1/3] binman: add sign option for binman Ivan Mikhaylov
2022-04-05 18:54   ` Alper Nebi Yasak
2022-04-06 20:28     ` Ivan Mikhaylov
2022-04-06 22:22       ` Alper Nebi Yasak
2022-09-06 16:27         ` Ivan Mikhaylov
2022-09-07 21:10           ` Simon Glass
2022-09-15 22:44             ` Ivan Mikhaylov
2022-11-18 20:50               ` Simon Glass
2022-12-13 21:51                 ` Ivan Mikhaylov [this message]
2022-12-17 22:02                   ` Simon Glass
2022-12-25  1:35                     ` Ivan Mikhaylov
2023-01-13 18:00                       ` Simon Glass
2023-01-16  2:54                         ` Ivan Mikhaylov
2023-02-04 22:23                           ` Simon Glass
2023-02-14 23:37                             ` Ivan Mikhaylov
2023-02-17 23:49                               ` Simon Glass
2022-03-21 21:43 ` [PATCH 2/3] binman: add documentation for binman sign option Ivan Mikhaylov
2022-03-21 21:43 ` [PATCH 3/3] binman: add test for " Ivan Mikhaylov
2022-04-08 15:39   ` Sean Anderson
2022-04-08 19:26     ` Ivan Mikhaylov
2022-04-10 22:37       ` Alper Nebi Yasak
2022-04-11 15:02         ` Sean Anderson
2022-08-13 14:59 ` [PATCH 0/3] Introduce new sign binman's option Simon Glass
2022-08-15 21:51   ` Ivan Mikhaylov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a50acc54bf98c0b36d10e60e9f84d6662287f940.camel@gmail.com \
    --to=fr0st61te@gmail.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=ivan.mikhaylov@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox