public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: Peter Geis <pgwipeout@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [RFC] [PATCH] binman: support mkimage split files
Date: Fri, 4 Mar 2022 00:11:16 +0300	[thread overview]
Message-ID: <151a4dcc-4ce5-744f-bc33-60b55a7807cf@gmail.com> (raw)
In-Reply-To: <20220301024826.1228290-1-pgwipeout@gmail.com>

On 01/03/2022 05:48, Peter Geis wrote:
> Good Evening,
> 
> I successfully tested your v2 patch series to create a bootable sdcard
> image out of the box for rockpro64-rk3399.
> Unfortunately, rk356x and rk3399-spi modes are broken, due to the
> inability to pass multiple images to mkimage at the same time.
> rk3399-spi mode is already supported manually, see:
> https://elixir.bootlin.com/u-boot/v2022.04-rc3/source/doc/board/rockchip/rockchip.rst#L182
> 
> rk356x is currently only supported manually, the image built by the old
> Makefile method is non functional. (u-boot-rockchip.bin)
> 
> Knowing absolutely nothing about python, I've hacked together something
> that works for splitting the image in the way mkimage expects.
> The file name passed to mkimage with the -d flag is:
> ./mkimage.simple-bin.mkimage.1:./mkimage.simple-bin.mkimage.2
> 
> I definitely don't expect this to be accepted as is, I just use it as an
> example of what we need to fully support this in binman.
> Adding the following allows me to build images automatically for rk356x:
> 
> mkimage {
> 	args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
> 	mkimage,separate_files;

Adding a property to toggle this sounds reasonable to me. The prefix
might not be necessary, and I think dashes are preferred to underscores
in property names.

> 
> 	ddrl {
> 		type = "blob-ext";
> 		filename = "rk3568_ddr_1560MHz_v1.12.bin";
> 	};
> 
> 	u-boot-spl {
> 	};
> };
> 
> This is my first attempt to use in-reply-to, so I hope this works.

FYI, I see it as a reply to 00/25 of the series.

> 
> Thanks,
> Peter Geis
> 
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
>  tools/binman/entry.py         | 43 ++++++++++++++++++++++++++---------
>  tools/binman/etype/mkimage.py |  3 ++-
>  2 files changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/binman/entry.py b/tools/binman/entry.py
> index 249f117ace56..48e552fc6af3 100644
> --- a/tools/binman/entry.py
> +++ b/tools/binman/entry.py
> @@ -114,6 +114,8 @@ class Entry(object):
>          self.bintools = {}
>          self.missing_bintools = []
>          self.update_hash = True
> +        self.fname_tmp = str()
> +        self.index = 0
>  
>      @staticmethod
>      def FindEntryClass(etype, expanded):
> @@ -1134,7 +1136,7 @@ features to produce new behaviours.
>          """
>          self.update_hash = update_hash
>  
> -    def collect_contents_to_file(self, entries, prefix, fake_size=0):
> +    def collect_contents_to_file(self, entries, prefix, fake_size=0, separate=False):
>          """Put the contents of a list of entries into a file
>  
>          Args:
> @@ -1152,13 +1154,32 @@ features to produce new behaviours.
>                  str: Unique portion of filename (or None if no data)
>          """
>          data = b''
> -        for entry in entries:
> -            # First get the input data and put it in a file. If not available,
> -            # try later.
> -            if not entry.ObtainContents(fake_size=fake_size):
> -                return None, None, None
> -            data += entry.GetData()
> -        uniq = self.GetUniqueName()
> -        fname = tools.get_output_filename(f'{prefix}.{uniq}')
> -        tools.write_file(fname, data)
> -        return data, fname, uniq
> +        if separate is False:
> +            for entry in entries:
> +                # First get the input data and put it in a file. If not available,
> +                # try later.
> +                if not entry.ObtainContents(fake_size=fake_size):
> +                    return None, None, None
> +                data += entry.GetData()
> +            uniq = self.GetUniqueName()
> +            fname = tools.get_output_filename(f'{prefix}.{uniq}')
> +            tools.write_file(fname, data)
> +            return data, fname, uniq
> +        else:
> +            for entry in entries:
> +                self.index = (self.index + 1)
> +                if (self.index > 2):
> +                    print('BINMAN Warn: mkimage only supports a maximum of two separate files')
> +                    break
> +                # First get the input data and put it in a file. If not available,
> +                # try later.
> +                if not entry.ObtainContents(fake_size=fake_size):
> +                    return None, None, None
> +                data = entry.GetData()
> +                uniq = self.GetUniqueName()
> +                fname = tools.get_output_filename(f'{prefix}.{uniq}.{self.index}')
> +                tools.write_file(fname, data)
> +                self.fname_tmp = [''.join(self.fname_tmp),fname]
> +            fname = ':'.join(self.fname_tmp)
> +            uniq = self.GetUniqueName()
> +            return data, fname, uniq

I would keep this function as-is and call it multiple times in the
mkimage etype code below (once per subentry), and also do the
mkimage-specific checks and 'file1:file2' argument joining there as well.

> diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
> index 5f6def2287f6..ce5f6b6b543a 100644
> --- a/tools/binman/etype/mkimage.py
> +++ b/tools/binman/etype/mkimage.py
> @@ -46,6 +46,7 @@ class Entry_mkimage(Entry):
>      def __init__(self, section, etype, node):
>          super().__init__(section, etype, node)
>          self._args = fdt_util.GetArgs(self._node, 'args')
> +        self._mkimage_separate = fdt_util.GetBool(self._node, 'mkimage,separate_files')
>          self._mkimage_entries = OrderedDict()
>          self.align_default = None
>          self.ReadEntries()
> @@ -53,7 +54,7 @@ class Entry_mkimage(Entry):
>      def ObtainContents(self):
>          # Use a non-zero size for any fake files to keep mkimage happy
>          data, input_fname, uniq = self.collect_contents_to_file(
> -            self._mkimage_entries.values(), 'mkimage', 1024)
> +            self._mkimage_entries.values(), 'mkimage', 1024, self._mkimage_separate)
>          if data is None:
>              return False
>          output_fname = tools.get_output_filename('mkimage-out.%s' % uniq)

  reply	other threads:[~2022-03-03 21:19 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 23:00 [PATCH v2 00/25] binman: rockchip: Migrate from rockchip SPL_FIT_GENERATOR script Simon Glass
2022-02-23 23:00 ` [PATCH v2 01/25] dtoc: Make GetArgs() more flexible Simon Glass
2022-03-03 21:07   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 02/25] moveconfig: Remove remove_defconfig() Simon Glass
2022-03-03 21:07   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 03/25] moveconfig: Use re.fullmatch() to avoid extra check Simon Glass
2022-03-03 21:07   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 04/25] spl: Correct Kconfig help for TPL_BINMAN_SYMBOLS Simon Glass
2022-03-03 21:08   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 05/25] dtoc: Tidy up implementation of AddStringList() Simon Glass
2022-03-03 21:08   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 06/25] elf: Rename load_segments() and module failure Simon Glass
2022-03-03 21:08   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 07/25] binman: Tweak collect_contents_to_file() and docs Simon Glass
2022-03-03 21:08   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 08/25] binman: Rename ExpandToLimit to extend_to_limit Simon Glass
2022-03-03 21:08   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 09/25] binman: Rename ExpandEntries to gen_entries Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 10/25] binman: Refactor fit to generate output at the end Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 11/25] binman: Rename tools parameter to btools Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 12/25] binman: Change how faked blobs are created Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-03-10 19:29       ` Alper Nebi Yasak
2022-03-12  5:02         ` Simon Glass
2022-03-14 21:29           ` Alper Nebi Yasak
2022-03-14 22:20             ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 13/25] binman: Make fake blobs zero-sized by default Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 14/25] binman: Allow mkimage to use a non-zero fake-blob size Simon Glass
2022-03-03 21:09   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-03-10 19:30       ` Alper Nebi Yasak
2022-03-12  5:02         ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 15/25] binman: Read the fit entries only once Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 16/25] binman: Fix some pylint warnings in fit Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 17/25] binman: Add a consistent way to report errors with fit Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 18/25] binman: Update fit to use node instead of subnode Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 19/25] binman: Keep a separate list of entries for fit Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-03-10 19:30       ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 20/25] binman: Support splitting an ELF file into multiple nodes Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-03-06  3:08     ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 21/25] rockchip: evb-rk3288: Drop raw-image support Simon Glass
2022-02-23 23:00 ` [PATCH v2 22/25] rockchip: Include binman script in 64-bit boards Simon Glass
2022-03-03 21:10   ` Alper Nebi Yasak
2022-02-23 23:00 ` [PATCH v2 23/25] rockchip: Support building the all output files in binman Simon Glass
2022-03-02 22:16   ` Peter Geis
2022-03-03 21:11     ` Alper Nebi Yasak
2022-03-03 22:34       ` Peter Geis
2022-03-06  3:08         ` Simon Glass
2022-02-23 23:00 ` [PATCH v2 24/25] rockchip: Convert all boards to use binman Simon Glass
2022-02-23 23:00 ` [PATCH v2 25/25] rockchip: Drop the FIT generator script Simon Glass
2022-03-01  2:48 ` [RFC] [PATCH] binman: support mkimage split files Peter Geis
2022-03-03 21:11   ` Alper Nebi Yasak [this message]
2022-03-04 17:47     ` Peter Geis
2022-03-04 19:56       ` [PATCH v2] binman: support mkimage separate files Peter Geis
2022-03-06  3:08         ` Simon Glass
2022-03-06 14:44           ` Peter Geis
2022-03-10 19:29             ` Alper Nebi Yasak
2022-03-10 23:19               ` Peter Geis

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=151a4dcc-4ce5-744f-bc33-60b55a7807cf@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=pgwipeout@gmail.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