diff mbox series

[v2,1/4] mkimage: add a flag to describe whether -A is specified

Message ID 20210619091838.646779-2-icenowy@aosc.io
State New
Delegated to: Andre Przywara
Headers show
Series mkimage: sunxi_egon: add riscv support | expand

Commit Message

Icenowy Zheng June 19, 2021, 9:18 a.m. UTC
The sunxi_egon type used to take no -A argument (because we assume sunxi
targets are all ARM). However, as Allwinner D1 appears as the first
RISC-V sunxi target, we need to support -A; in addition, as external
projects rely on U-Boot mkimage to generate sunxi eGON.BT0 header, we
need to keep compatibility with command line without -A.

As the default value of arch in mkimage is not proper (IH_ARCH_PPC
instead of IH_ARCH_INVALID), to keep more compatibility, add an Aflag
field to image parameters to describe whether an architecture is
explicitly specified.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
Changes in v2:
- Added Tom Rini's Review tag.

 tools/imagetool.h | 1 +
 tools/mkimage.c   | 1 +
 2 files changed, 2 insertions(+)

Comments

Simon Glass June 26, 2021, 6:31 p.m. UTC | #1
Hi Icenowy,

On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io> wrote:
>
> The sunxi_egon type used to take no -A argument (because we assume sunxi
> targets are all ARM). However, as Allwinner D1 appears as the first
> RISC-V sunxi target, we need to support -A; in addition, as external
> projects rely on U-Boot mkimage to generate sunxi eGON.BT0 header, we
> need to keep compatibility with command line without -A.
>
> As the default value of arch in mkimage is not proper (IH_ARCH_PPC
> instead of IH_ARCH_INVALID), to keep more compatibility, add an Aflag
> field to image parameters to describe whether an architecture is
> explicitly specified.
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
> Changes in v2:
> - Added Tom Rini's Review tag.

This is not actually a change so should not appear in the log.

Also note 'patman status' can be used to automatically collect these.

>
>  tools/imagetool.h | 1 +
>  tools/mkimage.c   | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/tools/imagetool.h b/tools/imagetool.h
> index e229a34ffc..5dc28312c2 100644
> --- a/tools/imagetool.h
> +++ b/tools/imagetool.h
> @@ -51,6 +51,7 @@ struct image_tool_params {
>         int pflag;
>         int vflag;
>         int xflag;
> +       int Aflag;

aflag

>         int skipcpy;
>         int os;
>         int arch;
> diff --git a/tools/mkimage.c b/tools/mkimage.c
> index cc7b242faf..54d8e3835a 100644
> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -168,6 +168,7 @@ static void process_args(int argc, char **argv)
>                                 show_valid_options(IH_ARCH);
>                                 usage("Invalid architecture");
>                         }
> +                       params.Aflag = 1;
>                         break;
>                 case 'b':
>                         if (add_content(IH_TYPE_FLATDT, optarg)) {
> --
> 2.30.2

Regards,
Simon
Icenowy Zheng June 26, 2021, 11:57 p.m. UTC | #2
在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> Hi Icenowy,
> 
> On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io> wrote:
> > 
> > The sunxi_egon type used to take no -A argument (because we assume
> > sunxi
> > targets are all ARM). However, as Allwinner D1 appears as the first
> > RISC-V sunxi target, we need to support -A; in addition, as
> > external
> > projects rely on U-Boot mkimage to generate sunxi eGON.BT0 header,
> > we
> > need to keep compatibility with command line without -A.
> > 
> > As the default value of arch in mkimage is not proper (IH_ARCH_PPC
> > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > Aflag
> > field to image parameters to describe whether an architecture is
> > explicitly specified.
> > 
> > Reviewed-by: Tom Rini <trini@konsulko.com>
> > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > ---
> > Changes in v2:
> > - Added Tom Rini's Review tag.
> 
> This is not actually a change so should not appear in the log.
> 
> Also note 'patman status' can be used to automatically collect these.
> 
> > 
> >  tools/imagetool.h | 1 +
> >  tools/mkimage.c   | 1 +
> >  2 files changed, 2 insertions(+)
> > 
> > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > index e229a34ffc..5dc28312c2 100644
> > --- a/tools/imagetool.h
> > +++ b/tools/imagetool.h
> > @@ -51,6 +51,7 @@ struct image_tool_params {
> >         int pflag;
> >         int vflag;
> >         int xflag;
> > +       int Aflag;
> 
> aflag

I think a problem is that -a is a different flag than -A.

-a is addr, -A is architecture.

> 
> >         int skipcpy;
> >         int os;
> >         int arch;
> > diff --git a/tools/mkimage.c b/tools/mkimage.c
> > index cc7b242faf..54d8e3835a 100644
> > --- a/tools/mkimage.c
> > +++ b/tools/mkimage.c
> > @@ -168,6 +168,7 @@ static void process_args(int argc, char **argv)
> >                                 show_valid_options(IH_ARCH);
> >                                 usage("Invalid architecture");
> >                         }
> > +                       params.Aflag = 1;
> >                         break;
> >                 case 'b':
> >                         if (add_content(IH_TYPE_FLATDT, optarg)) {
> > --
> > 2.30.2
> 
> Regards,
> Simon
Simon Glass June 27, 2021, 7:32 p.m. UTC | #3
Hi Icenowy,

On Sat, 26 Jun 2021 at 17:57, Icenowy Zheng <icenowy@aosc.io> wrote:
>
> 在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> > Hi Icenowy,
> >
> > On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io> wrote:
> > >
> > > The sunxi_egon type used to take no -A argument (because we assume
> > > sunxi
> > > targets are all ARM). However, as Allwinner D1 appears as the first
> > > RISC-V sunxi target, we need to support -A; in addition, as
> > > external
> > > projects rely on U-Boot mkimage to generate sunxi eGON.BT0 header,
> > > we
> > > need to keep compatibility with command line without -A.
> > >
> > > As the default value of arch in mkimage is not proper (IH_ARCH_PPC
> > > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > > Aflag
> > > field to image parameters to describe whether an architecture is
> > > explicitly specified.
> > >
> > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > ---
> > > Changes in v2:
> > > - Added Tom Rini's Review tag.
> >
> > This is not actually a change so should not appear in the log.
> >
> > Also note 'patman status' can be used to automatically collect these.
> >
> > >
> > >  tools/imagetool.h | 1 +
> > >  tools/mkimage.c   | 1 +
> > >  2 files changed, 2 insertions(+)
> > >
> > > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > > index e229a34ffc..5dc28312c2 100644
> > > --- a/tools/imagetool.h
> > > +++ b/tools/imagetool.h
> > > @@ -51,6 +51,7 @@ struct image_tool_params {
> > >         int pflag;
> > >         int vflag;
> > >         int xflag;
> > > +       int Aflag;
> >
> > aflag
>
> I think a problem is that -a is a different flag than -A.
>
> -a is addr, -A is architecture.

Yes OK, but the code style doesn't allow capital letters, as I understand it.

How about addr_flag ?


>
> >
> > >         int skipcpy;
> > >         int os;
> > >         int arch;
> > > diff --git a/tools/mkimage.c b/tools/mkimage.c
> > > index cc7b242faf..54d8e3835a 100644
> > > --- a/tools/mkimage.c
> > > +++ b/tools/mkimage.c
> > > @@ -168,6 +168,7 @@ static void process_args(int argc, char **argv)
> > >                                 show_valid_options(IH_ARCH);
> > >                                 usage("Invalid architecture");
> > >                         }
> > > +                       params.Aflag = 1;
> > >                         break;
> > >                 case 'b':
> > >                         if (add_content(IH_TYPE_FLATDT, optarg)) {
> > > --
> > > 2.30.2

Regards,
Simon
Icenowy Zheng June 27, 2021, 10:17 p.m. UTC | #4
在 2021-06-27星期日的 13:32 -0600,Simon Glass写道:
> Hi Icenowy,
> 
> On Sat, 26 Jun 2021 at 17:57, Icenowy Zheng <icenowy@aosc.io> wrote:
> > 
> > 在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> > > Hi Icenowy,
> > > 
> > > On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io>
> > > wrote:
> > > > 
> > > > The sunxi_egon type used to take no -A argument (because we
> > > > assume
> > > > sunxi
> > > > targets are all ARM). However, as Allwinner D1 appears as the
> > > > first
> > > > RISC-V sunxi target, we need to support -A; in addition, as
> > > > external
> > > > projects rely on U-Boot mkimage to generate sunxi eGON.BT0
> > > > header,
> > > > we
> > > > need to keep compatibility with command line without -A.
> > > > 
> > > > As the default value of arch in mkimage is not proper
> > > > (IH_ARCH_PPC
> > > > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > > > Aflag
> > > > field to image parameters to describe whether an architecture
> > > > is
> > > > explicitly specified.
> > > > 
> > > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > > ---
> > > > Changes in v2:
> > > > - Added Tom Rini's Review tag.
> > > 
> > > This is not actually a change so should not appear in the log.
> > > 
> > > Also note 'patman status' can be used to automatically collect
> > > these.
> > > 
> > > > 
> > > >  tools/imagetool.h | 1 +
> > > >  tools/mkimage.c   | 1 +
> > > >  2 files changed, 2 insertions(+)
> > > > 
> > > > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > > > index e229a34ffc..5dc28312c2 100644
> > > > --- a/tools/imagetool.h
> > > > +++ b/tools/imagetool.h
> > > > @@ -51,6 +51,7 @@ struct image_tool_params {
> > > >         int pflag;
> > > >         int vflag;
> > > >         int xflag;
> > > > +       int Aflag;
> > > 
> > > aflag
> > 
> > I think a problem is that -a is a different flag than -A.
> > 
> > -a is addr, -A is architecture.
> 
> Yes OK, but the code style doesn't allow capital letters, as I
> understand it.
> 
> How about addr_flag ?

maybe we just call -a aflag, and -A arch_flag?

> 
> 
> > 
> > > 
> > > >         int skipcpy;
> > > >         int os;
> > > >         int arch;
> > > > diff --git a/tools/mkimage.c b/tools/mkimage.c
> > > > index cc7b242faf..54d8e3835a 100644
> > > > --- a/tools/mkimage.c
> > > > +++ b/tools/mkimage.c
> > > > @@ -168,6 +168,7 @@ static void process_args(int argc, char
> > > > **argv)
> > > >                                 show_valid_options(IH_ARCH);
> > > >                                 usage("Invalid architecture");
> > > >                         }
> > > > +                       params.Aflag = 1;
> > > >                         break;
> > > >                 case 'b':
> > > >                         if (add_content(IH_TYPE_FLATDT,
> > > > optarg)) {
> > > > --
> > > > 2.30.2
> 
> Regards,
> Simon
Tom Rini June 27, 2021, 11:42 p.m. UTC | #5
On Mon, Jun 28, 2021 at 06:17:27AM +0800, Icenowy Zheng wrote:
> 在 2021-06-27星期日的 13:32 -0600,Simon Glass写道:
> > Hi Icenowy,
> > 
> > On Sat, 26 Jun 2021 at 17:57, Icenowy Zheng <icenowy@aosc.io> wrote:
> > > 
> > > 在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> > > > Hi Icenowy,
> > > > 
> > > > On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io>
> > > > wrote:
> > > > > 
> > > > > The sunxi_egon type used to take no -A argument (because we
> > > > > assume
> > > > > sunxi
> > > > > targets are all ARM). However, as Allwinner D1 appears as the
> > > > > first
> > > > > RISC-V sunxi target, we need to support -A; in addition, as
> > > > > external
> > > > > projects rely on U-Boot mkimage to generate sunxi eGON.BT0
> > > > > header,
> > > > > we
> > > > > need to keep compatibility with command line without -A.
> > > > > 
> > > > > As the default value of arch in mkimage is not proper
> > > > > (IH_ARCH_PPC
> > > > > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > > > > Aflag
> > > > > field to image parameters to describe whether an architecture
> > > > > is
> > > > > explicitly specified.
> > > > > 
> > > > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > > > ---
> > > > > Changes in v2:
> > > > > - Added Tom Rini's Review tag.
> > > > 
> > > > This is not actually a change so should not appear in the log.
> > > > 
> > > > Also note 'patman status' can be used to automatically collect
> > > > these.
> > > > 
> > > > > 
> > > > >  tools/imagetool.h | 1 +
> > > > >  tools/mkimage.c   | 1 +
> > > > >  2 files changed, 2 insertions(+)
> > > > > 
> > > > > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > > > > index e229a34ffc..5dc28312c2 100644
> > > > > --- a/tools/imagetool.h
> > > > > +++ b/tools/imagetool.h
> > > > > @@ -51,6 +51,7 @@ struct image_tool_params {
> > > > >         int pflag;
> > > > >         int vflag;
> > > > >         int xflag;
> > > > > +       int Aflag;
> > > > 
> > > > aflag
> > > 
> > > I think a problem is that -a is a different flag than -A.
> > > 
> > > -a is addr, -A is architecture.
> > 
> > Yes OK, but the code style doesn't allow capital letters, as I
> > understand it.
> > 
> > How about addr_flag ?
> 
> maybe we just call -a aflag, and -A arch_flag?

Frankly I think Aflag is the most readable option here.  They're all
literally ${FLAG_USE}flag variables, yes?  CamelCase isn't great, but
there's times where the most readable thing isn't always what we use
everywhere else.
Simon Glass June 27, 2021, 11:48 p.m. UTC | #6
Hi Icenowy,

On Sun, 27 Jun 2021 at 16:17, Icenowy Zheng <icenowy@aosc.io> wrote:
>
> 在 2021-06-27星期日的 13:32 -0600,Simon Glass写道:
> > Hi Icenowy,
> >
> > On Sat, 26 Jun 2021 at 17:57, Icenowy Zheng <icenowy@aosc.io> wrote:
> > >
> > > 在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> > > > Hi Icenowy,
> > > >
> > > > On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io>
> > > > wrote:
> > > > >
> > > > > The sunxi_egon type used to take no -A argument (because we
> > > > > assume
> > > > > sunxi
> > > > > targets are all ARM). However, as Allwinner D1 appears as the
> > > > > first
> > > > > RISC-V sunxi target, we need to support -A; in addition, as
> > > > > external
> > > > > projects rely on U-Boot mkimage to generate sunxi eGON.BT0
> > > > > header,
> > > > > we
> > > > > need to keep compatibility with command line without -A.
> > > > >
> > > > > As the default value of arch in mkimage is not proper
> > > > > (IH_ARCH_PPC
> > > > > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > > > > Aflag
> > > > > field to image parameters to describe whether an architecture
> > > > > is
> > > > > explicitly specified.
> > > > >
> > > > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > > > ---
> > > > > Changes in v2:
> > > > > - Added Tom Rini's Review tag.
> > > >
> > > > This is not actually a change so should not appear in the log.
> > > >
> > > > Also note 'patman status' can be used to automatically collect
> > > > these.
> > > >
> > > > >
> > > > >  tools/imagetool.h | 1 +
> > > > >  tools/mkimage.c   | 1 +
> > > > >  2 files changed, 2 insertions(+)
> > > > >
> > > > > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > > > > index e229a34ffc..5dc28312c2 100644
> > > > > --- a/tools/imagetool.h
> > > > > +++ b/tools/imagetool.h
> > > > > @@ -51,6 +51,7 @@ struct image_tool_params {
> > > > >         int pflag;
> > > > >         int vflag;
> > > > >         int xflag;
> > > > > +       int Aflag;
> > > >
> > > > aflag
> > >
> > > I think a problem is that -a is a different flag than -A.
> > >
> > > -a is addr, -A is architecture.
> >
> > Yes OK, but the code style doesn't allow capital letters, as I
> > understand it.
> >
> > How about addr_flag ?
>
> maybe we just call -a aflag, and -A arch_flag?

Sure if you prefer.

Regards,
Simon
Simon Glass June 27, 2021, 11:50 p.m. UTC | #7
Hi Tom,

On Sun, 27 Jun 2021 at 17:43, Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Jun 28, 2021 at 06:17:27AM +0800, Icenowy Zheng wrote:
> > 在 2021-06-27星期日的 13:32 -0600,Simon Glass写道:
> > > Hi Icenowy,
> > >
> > > On Sat, 26 Jun 2021 at 17:57, Icenowy Zheng <icenowy@aosc.io> wrote:
> > > >
> > > > 在 2021-06-26星期六的 12:31 -0600,Simon Glass写道:
> > > > > Hi Icenowy,
> > > > >
> > > > > On Sat, 19 Jun 2021 at 03:19, Icenowy Zheng <icenowy@aosc.io>
> > > > > wrote:
> > > > > >
> > > > > > The sunxi_egon type used to take no -A argument (because we
> > > > > > assume
> > > > > > sunxi
> > > > > > targets are all ARM). However, as Allwinner D1 appears as the
> > > > > > first
> > > > > > RISC-V sunxi target, we need to support -A; in addition, as
> > > > > > external
> > > > > > projects rely on U-Boot mkimage to generate sunxi eGON.BT0
> > > > > > header,
> > > > > > we
> > > > > > need to keep compatibility with command line without -A.
> > > > > >
> > > > > > As the default value of arch in mkimage is not proper
> > > > > > (IH_ARCH_PPC
> > > > > > instead of IH_ARCH_INVALID), to keep more compatibility, add an
> > > > > > Aflag
> > > > > > field to image parameters to describe whether an architecture
> > > > > > is
> > > > > > explicitly specified.
> > > > > >
> > > > > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > > > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > > > > ---
> > > > > > Changes in v2:
> > > > > > - Added Tom Rini's Review tag.
> > > > >
> > > > > This is not actually a change so should not appear in the log.
> > > > >
> > > > > Also note 'patman status' can be used to automatically collect
> > > > > these.
> > > > >
> > > > > >
> > > > > >  tools/imagetool.h | 1 +
> > > > > >  tools/mkimage.c   | 1 +
> > > > > >  2 files changed, 2 insertions(+)
> > > > > >
> > > > > > diff --git a/tools/imagetool.h b/tools/imagetool.h
> > > > > > index e229a34ffc..5dc28312c2 100644
> > > > > > --- a/tools/imagetool.h
> > > > > > +++ b/tools/imagetool.h
> > > > > > @@ -51,6 +51,7 @@ struct image_tool_params {
> > > > > >         int pflag;
> > > > > >         int vflag;
> > > > > >         int xflag;
> > > > > > +       int Aflag;
> > > > >
> > > > > aflag
> > > >
> > > > I think a problem is that -a is a different flag than -A.
> > > >
> > > > -a is addr, -A is architecture.
> > >
> > > Yes OK, but the code style doesn't allow capital letters, as I
> > > understand it.
> > >
> > > How about addr_flag ?
> >
> > maybe we just call -a aflag, and -A arch_flag?
>
> Frankly I think Aflag is the most readable option here.  They're all
> literally ${FLAG_USE}flag variables, yes?  CamelCase isn't great, but
> there's times where the most readable thing isn't always what we use
> everywhere else.

I mean, sort of, but 'a' and 'A' are not that descriptive so you could
make the case that they should be named for the full flag
meaning/purpose.

Anyway, I see it has your review tag, so I'll leave it to you.

Regards,
Simon
diff mbox series

Patch

diff --git a/tools/imagetool.h b/tools/imagetool.h
index e229a34ffc..5dc28312c2 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -51,6 +51,7 @@  struct image_tool_params {
 	int pflag;
 	int vflag;
 	int xflag;
+	int Aflag;
 	int skipcpy;
 	int os;
 	int arch;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index cc7b242faf..54d8e3835a 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -168,6 +168,7 @@  static void process_args(int argc, char **argv)
 				show_valid_options(IH_ARCH);
 				usage("Invalid architecture");
 			}
+			params.Aflag = 1;
 			break;
 		case 'b':
 			if (add_content(IH_TYPE_FLATDT, optarg)) {