mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts: imx: add support for additional hab Blocks
@ 2021-03-11 17:07 Denis Osterland-Heim
  2021-03-22  5:50 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Osterland-Heim @ 2021-03-11 17:07 UTC (permalink / raw)
  To: barebox

From: Denis Osterland-Heim <Denis.Osterland@diehl.com>

This allows to specifiy additional singed blocks
in the format `offset+size@address` within the imximg.

It is needed by the uuu tool, which loads the image different to
the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM.
So this area have to be signed as well.

In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`.

It supports to remove quotes to support Kconfig variable here.

Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
---
 scripts/imx/imx.c | 62 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 6b8dabd04..d37e200ca 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 {
 char *str;
 int ret;
+int i;
 uint32_t signed_size = data->load_size;
 uint32_t offset = data->image_ivt_offset;

@@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 }

 if (signed_size > 0) {
-ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
+ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
 data->image_load_addr + data->image_ivt_offset, offset,
 signed_size - data->image_ivt_offset, data->outfile);
 } else {
@@ -365,10 +366,67 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 return -ENOMEM;

 ret = hab_add_str(data, str);
+free(str);
 if (ret)
 return ret;

-return 0;
+for (i = 1; i < argc; i++)
+{
+uint32_t addr;
+uint32_t off;
+uint32_t size;
+char *b;
+char *e;
+
+b = argv[i];
+if (b[0] == '"') // remove qoutes
+{
+b++;
+for (e = b; *e; e++)
+/* find end of string */;
+e--;
+if (*e == '"')
+*e = '\0';
+else
+fprintf(stderr, "warning: no '\"' at the end of '%s' [b=%p'%s', e=%p'%s']\n", argv[i], b, b, e, e);
+}
+if (!*b)
+continue; // skip if empty
+
+e = strchr(b, '+');
+if (!e)
+{
+fprintf(stderr, "failed to find '+' in '%s'\n", b);
+fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+return -EINVAL;
+}
+*e = '\0';
+off = strtoul(b, NULL, 0);
+
+b = e + 1;
+e = strchr(b, '@');
+if (!e)
+{
+fprintf(stderr, "failed to find '@' in '%s'\n", b);
+fprintf(stderr, "format off+size@addr expected, but given: %s", argv[i]);
+return -EINVAL;
+}
+*e = '\0';
+size = strtoul(b, NULL, 0);
+
+addr = strtoul(e + 1, NULL, 0);
+
+ret = asprintf(&str, ", 0x%08x 0x%08x 0x%08x \"%s\"", addr, off, size, data->outfile);
+if (ret < 0)
+return -ENOMEM;
+
+ret = hab_add_str(data, str);
+free(str);
+if (ret)
+return ret;
+}
+
+return hab_add_str(data, "\n");
 }

 static int do_hab_encrypt(struct config_data *data, int argc, char *argv[])
--
2.30.2

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315

________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.

- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:

https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.

- For general information on data protection and your respective rights please visit:

https://www.diehl.com/group/en/transparency-and-information-obligations/



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: imx: add support for additional hab Blocks
  2021-03-11 17:07 [PATCH] scripts: imx: add support for additional hab Blocks Denis Osterland-Heim
@ 2021-03-22  5:50 ` Sascha Hauer
  2021-03-22  6:26   ` Denis Osterland-Heim
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2021-03-22  5:50 UTC (permalink / raw)
  To: Denis Osterland-Heim; +Cc: barebox

Hi Denis,

On Thu, Mar 11, 2021 at 05:07:20PM +0000, Denis Osterland-Heim wrote:
> From: Denis Osterland-Heim <Denis.Osterland@diehl.com>
> 
> This allows to specifiy additional singed blocks
> in the format `offset+size@address` within the imximg.
> 
> It is needed by the uuu tool, which loads the image different to
> the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM.
> So this area have to be signed as well.
> 
> In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`.
> 
> It supports to remove quotes to support Kconfig variable here.
> 
> Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
> ---
>  scripts/imx/imx.c | 62 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 60 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
> index 6b8dabd04..d37e200ca 100644
> --- a/scripts/imx/imx.c
> +++ b/scripts/imx/imx.c
> @@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  {
>  char *str;
>  int ret;
> +int i;
>  uint32_t signed_size = data->load_size;
>  uint32_t offset = data->image_ivt_offset;
> 
> @@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  }
> 
>  if (signed_size > 0) {
> -ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
> +ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
>  data->image_load_addr + data->image_ivt_offset, offset,
>  signed_size - data->image_ivt_offset, data->outfile);
>  } else {
> @@ -365,10 +366,67 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  return -ENOMEM;
> 
>  ret = hab_add_str(data, str);
> +free(str);
>  if (ret)
>  return ret;
> 
> -return 0;
> +for (i = 1; i < argc; i++)
> +{

Ciding style: The open brace should be on previous line.

> +uint32_t addr;
> +uint32_t off;
> +uint32_t size;
> +char *b;
> +char *e;
> +
> +b = argv[i];
> +if (b[0] == '"') // remove qoutes
> +{
> +b++;
> +for (e = b; *e; e++)
> +/* find end of string */;
> +e--;
> +if (*e == '"')
> +*e = '\0';

To make this less efficient but better readable, how about:

e = b + strlen(b) - 1?

Note this fails when 'b' is an empty string, but your version fails
there as well. It needs an additional check.

> +else
> +fprintf(stderr, "warning: no '\"' at the end of '%s' [b=%p'%s', e=%p'%s']\n", argv[i], b, b, e, e);
> +}
> +if (!*b)
> +continue; // skip if empty
> +
> +e = strchr(b, '+');
> +if (!e)
> +{
> +fprintf(stderr, "failed to find '+' in '%s'\n", b);
> +fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
> +return -EINVAL;
> +}
> +*e = '\0';
> +off = strtoul(b, NULL, 0);

No need to set the place where the '+' is to zero. You can do it like
this:

	char *plus;

	off = strtoul(b, &plus, 0);

	if (*plus != '+')
		/* complain */


> +
> +b = e + 1;
> +e = strchr(b, '@');
> +if (!e)
> +{
> +fprintf(stderr, "failed to find '@' in '%s'\n", b);
> +fprintf(stderr, "format off+size@addr expected, but given: %s", argv[i]);
> +return -EINVAL;
> +}
> +*e = '\0';
> +size = strtoul(b, NULL, 0);

Same here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: imx: add support for additional hab Blocks
  2021-03-22  5:50 ` Sascha Hauer
@ 2021-03-22  6:26   ` Denis Osterland-Heim
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Osterland-Heim @ 2021-03-22  6:26 UTC (permalink / raw)
  To: sha; +Cc: barebox

Hi Sasha,

Am Montag, den 22.03.2021, 06:50 +0100 schrieb Sascha Hauer:
> Hi Denis,
>
> On Thu, Mar 11, 2021 at 05:07:20PM +0000, Denis Osterland-Heim wrote:
> > From: Denis Osterland-Heim <Denis.Osterland@diehl.com>
> >
> > This allows to specifiy additional singed blocks
> > in the format `offset+size@address` within the imximg.
> >
> > It is needed by the uuu tool, which loads the image different to
> > the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM.
> > So this area have to be signed as well.
> >
> > In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`.
> >
> > It supports to remove quotes to support Kconfig variable here.
> >
> > Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
> > ---
> >  scripts/imx/imx.c | 62 +++++++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 60 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
> > index 6b8dabd04..d37e200ca 100644
> > --- a/scripts/imx/imx.c
> > +++ b/scripts/imx/imx.c
> > @@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
> >  {
> >  char *str;
> >  int ret;
> > +int i;
> >  uint32_t signed_size = data->load_size;
> >  uint32_t offset = data->image_ivt_offset;
> >
> > @@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
> >  }
> >
> >  if (signed_size > 0) {
> > -ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
> > +ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
> >  data->image_load_addr + data->image_ivt_offset, offset,
> >  signed_size - data->image_ivt_offset, data->outfile);
> >  } else {
> > @@ -365,10 +366,67 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
> >  return -ENOMEM;
> >
> >  ret = hab_add_str(data, str);
> > +free(str);
> >  if (ret)
> >  return ret;
> >
> > -return 0;
> > +for (i = 1; i < argc; i++)
> > +{
>
> Ciding style: The open brace should be on previous line.
okay

>
> > +uint32_t addr;
> > +uint32_t off;
> > +uint32_t size;
> > +char *b;
> > +char *e;
> > +
> > +b = argv[i];
> > +if (b[0] == '"') // remove qoutes
> > +{
> > +b++;
> > +for (e = b; *e; e++)
> > +/* find end of string */;
> > +e--;
> > +if (*e == '"')
> > +*e = '\0';
>
> To make this less efficient but better readable, how about:
>
> e = b + strlen(b) - 1?
definitely easier to read
I will use it

>
> Note this fails when 'b' is an empty string, but your version fails
> there as well. It needs an additional check.
In case of an empty string, b[0] will be '\0' and `b[0] == '"'` will eval to false.
In case of a "\"" input string, first eval of `*e` will be false and your version would give `e = b + 1 - 1`
which looks both correct to me.

But with the hints below, I could remove this lookup entirely
and change to:

```c
char *sep;
if (b[0] == '"')
b++; // remove leading qoute
if (!*b || *b == '"')
continue; // skip if empty
off = strtoul(b, &sep, 0);
if (*sep != '+') {
// complain
}
b = sep + 1;
size = strtoul(b, &sep, 0);
if (*sep != '@') {
// complain
}
b = sep + 1;
addr = strtoul(b, &sep, 0);
if (*sep && *sep != '"') {
// complain
}
```

Regards, Denis

>
> > +else
> > +fprintf(stderr, "warning: no '\"' at the end of '%s' [b=%p'%s', e=%p'%s']\n", argv[i], b, b, e, e);
> > +}
> > +if (!*b)
> > +continue; // skip if empty
> > +
> > +e = strchr(b, '+');
> > +if (!e)
> > +{
> > +fprintf(stderr, "failed to find '+' in '%s'\n", b);
> > +fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
> > +return -EINVAL;
> > +}
> > +*e = '\0';
> > +off = strtoul(b, NULL, 0);
>
> No need to set the place where the '+' is to zero. You can do it like
> this:
>
> char *plus;
>
> off = strtoul(b, &plus, 0);
>
> if (*plus != '+')
> /* complain */
>
>
> > +
> > +b = e + 1;
> > +e = strchr(b, '@');
> > +if (!e)
> > +{
> > +fprintf(stderr, "failed to find '@' in '%s'\n", b);
> > +fprintf(stderr, "format off+size@addr expected, but given: %s", argv[i]);
> > +return -EINVAL;
> > +}
> > +*e = '\0';
> > +size = strtoul(b, NULL, 0);
>
> Same here.
>
> Sascha
>
Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315

________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.

- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:

https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.

- For general information on data protection and your respective rights please visit:

https://www.diehl.com/group/en/transparency-and-information-obligations/


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: imx: add support for additional hab Blocks
  2021-03-22 12:05 Denis Osterland-Heim
@ 2021-03-22 12:06 ` Denis Osterland-Heim
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Osterland-Heim @ 2021-03-22 12:06 UTC (permalink / raw)
  To: barebox

[-- Attachment #1: Type: text/plain, Size: 4327 bytes --]

Am Montag, den 22.03.2021, 13:02 +0100 schrieb Denis Osterland-Heim:
> This allows to specifiy additional signed blocks
> in the format `offset+size@address` within the imximg.
>
> It is needed by the uuu tool, which loads the image different to
> the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM.
> So this area have to be signed as well.
>
> In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`.
>
> It supports to remove quotes to support Kconfig variable here.
>
> Signed-off-by: Denis Osterland-Heim <denis.osterland@diehl.com>
> ---
>  scripts/imx/imx.c | 52 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
> index 6b8dabd04..ce18778f5 100644
> --- a/scripts/imx/imx.c
> +++ b/scripts/imx/imx.c
> @@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  {
>  char *str;
>  int ret;
> +int i;
>  uint32_t signed_size = data->load_size;
>  uint32_t offset = data->image_ivt_offset;
>
> @@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  }
>
>  if (signed_size > 0) {
> -ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
> +ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
>  data->image_load_addr + data->image_ivt_offset, offset,
>  signed_size - data->image_ivt_offset, data->outfile);
>  } else {
> @@ -365,10 +366,57 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
>  return -ENOMEM;
>
>  ret = hab_add_str(data, str);
> +free(str);
>  if (ret)
>  return ret;
>
> -return 0;
> +for (i = 1; i < argc; i++) {
> +uint32_t addr;
> +uint32_t off;
> +uint32_t size;
> +char *b;
> +char *e;
> +
> +b = argv[i];
> +if (*b == '"') // remove leading qoute
> +b++;
> +if (!*b || *b == '"')
> +continue; // skip if empty
> +
> +off = strtoul(b, &e, 0);
> +if (*e != '+') {
> +fprintf(stderr, "failed to find '+' in '%s'\n", b);
> +fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
> +return -EINVAL;
> +}
> +
> +b = e + 1;
> +size = strtoul(b, &e, 0);
> +if (*e != '@') {
> +fprintf(stderr, "failed to find '@' in '%s'\n", b);
> +fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
> +return -EINVAL;
> +}
> +
> +b = e + 1;
> +addr = strtoul(b, &e, 0);
> +if (*e && *e != '"') { // ignore trailing qoute
> +fprintf(stderr, "unexpected char at the end: '%c'\n", *e);
> +fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
> +return -EINVAL;
> +}
> +
> +ret = asprintf(&str, ", 0x%08x 0x%08x 0x%08x \"%s\"", addr, off, size, data->outfile);
> +if (ret < 0)
> +return -ENOMEM;
> +
> +ret = hab_add_str(data, str);
> +free(str);
> +if (ret)
> +return ret;
> +}
> +
> +return hab_add_str(data, "\n");
>  }
>
>  static int do_hab_encrypt(struct config_data *data, int argc, char *argv[])
Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315

________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.

- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:

https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.

- For general information on data protection and your respective rights please visit:

https://www.diehl.com/group/en/transparency-and-information-obligations/



[-- Attachment #2: 1616414542.Vfd01Idfd8d0M526972.mbox --]
[-- Type: application/mbox, Size: 3420 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] scripts: imx: add support for additional hab Blocks
@ 2021-03-22 12:05 Denis Osterland-Heim
  2021-03-22 12:06 ` Denis Osterland-Heim
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Osterland-Heim @ 2021-03-22 12:05 UTC (permalink / raw)
  To: barebox

This allows to specifiy additional signed blocks
in the format `offset+size@address` within the imximg.

It is needed by the uuu tool, which loads the image different to
the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM.
So this area have to be signed as well.

In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`.

It supports to remove quotes to support Kconfig variable here.

Signed-off-by: Denis Osterland-Heim <denis.osterland@diehl.com>
---
 scripts/imx/imx.c | 52 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 6b8dabd04..ce18778f5 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 {
 char *str;
 int ret;
+int i;
 uint32_t signed_size = data->load_size;
 uint32_t offset = data->image_ivt_offset;

@@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 }

 if (signed_size > 0) {
-ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
+ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
 data->image_load_addr + data->image_ivt_offset, offset,
 signed_size - data->image_ivt_offset, data->outfile);
 } else {
@@ -365,10 +366,57 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
 return -ENOMEM;

 ret = hab_add_str(data, str);
+free(str);
 if (ret)
 return ret;

-return 0;
+for (i = 1; i < argc; i++) {
+uint32_t addr;
+uint32_t off;
+uint32_t size;
+char *b;
+char *e;
+
+b = argv[i];
+if (*b == '"') // remove leading qoute
+b++;
+if (!*b || *b == '"')
+continue; // skip if empty
+
+off = strtoul(b, &e, 0);
+if (*e != '+') {
+fprintf(stderr, "failed to find '+' in '%s'\n", b);
+fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+return -EINVAL;
+}
+
+b = e + 1;
+size = strtoul(b, &e, 0);
+if (*e != '@') {
+fprintf(stderr, "failed to find '@' in '%s'\n", b);
+fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+return -EINVAL;
+}
+
+b = e + 1;
+addr = strtoul(b, &e, 0);
+if (*e && *e != '"') { // ignore trailing qoute
+fprintf(stderr, "unexpected char at the end: '%c'\n", *e);
+fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+return -EINVAL;
+}
+
+ret = asprintf(&str, ", 0x%08x 0x%08x 0x%08x \"%s\"", addr, off, size, data->outfile);
+if (ret < 0)
+return -ENOMEM;
+
+ret = hab_add_str(data, str);
+free(str);
+if (ret)
+return ret;
+}
+
+return hab_add_str(data, "\n");
 }

 static int do_hab_encrypt(struct config_data *data, int argc, char *argv[])
--
2.31.0

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315

________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.

- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:

https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.

- For general information on data protection and your respective rights please visit:

https://www.diehl.com/group/en/transparency-and-information-obligations/



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-22 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 17:07 [PATCH] scripts: imx: add support for additional hab Blocks Denis Osterland-Heim
2021-03-22  5:50 ` Sascha Hauer
2021-03-22  6:26   ` Denis Osterland-Heim
2021-03-22 12:05 Denis Osterland-Heim
2021-03-22 12:06 ` Denis Osterland-Heim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox