* [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list
@ 2020-11-24 13:39 Philippe Reynes
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Philippe Reynes @ 2020-11-24 13:39 UTC (permalink / raw)
To: u-boot
This commit creates a function fit_config_add_hash that will be
used in the next commit to support several 'sub-images'.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
tools/image-host.c | 132 ++++++++++++++++++++++++++-------------------
1 file changed, 76 insertions(+), 56 deletions(-)
diff --git a/tools/image-host.c b/tools/image-host.c
index e32cc64257..ce829a8ec9 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -700,13 +700,84 @@ static const char *fit_config_get_image_list(void *fit, int noffset,
return default_list;
}
+static int fit_config_add_hash(void *fit, const char *conf_name, const char *sig_name,
+ struct strlist *node_inc, const char *iname, int image_noffset)
+{
+ char name[200], path[200];
+ int noffset;
+ int hash_count;
+ int ret;
+
+ ret = fdt_get_path(fit, image_noffset, path, sizeof(path));
+ if (ret < 0)
+ goto err_path;
+ if (strlist_add(node_inc, path))
+ goto err_mem;
+
+ snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH,
+ conf_name);
+
+ /* Add all this image's hashes */
+ hash_count = 0;
+ for (noffset = fdt_first_subnode(fit, image_noffset);
+ noffset >= 0;
+ noffset = fdt_next_subnode(fit, noffset)) {
+ const char *name = fit_get_name(fit, noffset, NULL);
+
+ if (strncmp(name, FIT_HASH_NODENAME,
+ strlen(FIT_HASH_NODENAME)))
+ continue;
+ ret = fdt_get_path(fit, noffset, path, sizeof(path));
+ if (ret < 0)
+ goto err_path;
+ if (strlist_add(node_inc, path))
+ goto err_mem;
+ hash_count++;
+ }
+
+ if (!hash_count) {
+ printf("Failed to find any hash nodes in configuration '%s/%s' image '%s' - without these it is not possible to verify this image\n",
+ conf_name, sig_name, iname);
+ return -ENOMSG;
+ }
+
+ /* Add this image's cipher node if present */
+ noffset = fdt_subnode_offset(fit, image_noffset,
+ FIT_CIPHER_NODENAME);
+ if (noffset != -FDT_ERR_NOTFOUND) {
+ if (noffset < 0) {
+ printf("Failed to get cipher node in configuration '%s/%s' image '%s': %s\n",
+ conf_name, sig_name, iname,
+ fdt_strerror(noffset));
+ return -EIO;
+ }
+ ret = fdt_get_path(fit, noffset, path, sizeof(path));
+ if (ret < 0)
+ goto err_path;
+ if (strlist_add(node_inc, path))
+ goto err_mem;
+ }
+
+ return 0;
+
+err_mem:
+ printf("Out of memory processing configuration '%s/%s'\n", conf_name,
+ sig_name);
+ return -ENOMEM;
+
+err_path:
+ printf("Failed to get path for image '%s' in configuration '%s/%s': %s\n",
+ iname, conf_name, sig_name, fdt_strerror(ret));
+ return -ENOENT;
+}
+
static int fit_config_get_hash_list(void *fit, int conf_noffset,
int sig_offset, struct strlist *node_inc)
{
int allow_missing;
const char *prop, *iname, *end;
const char *conf_name, *sig_name;
- char name[200], path[200];
+ char name[200];
int image_count;
int ret, len;
@@ -733,9 +804,7 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
end = prop + len;
image_count = 0;
for (iname = prop; iname < end; iname += strlen(iname) + 1) {
- int noffset;
int image_noffset;
- int hash_count;
image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
iname);
@@ -748,55 +817,11 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
return -ENOENT;
}
- ret = fdt_get_path(fit, image_noffset, path, sizeof(path));
+ ret = fit_config_add_hash(fit, conf_name,
+ sig_name, node_inc,
+ iname, image_noffset);
if (ret < 0)
- goto err_path;
- if (strlist_add(node_inc, path))
- goto err_mem;
-
- snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH,
- conf_name);
-
- /* Add all this image's hashes */
- hash_count = 0;
- for (noffset = fdt_first_subnode(fit, image_noffset);
- noffset >= 0;
- noffset = fdt_next_subnode(fit, noffset)) {
- const char *name = fit_get_name(fit, noffset, NULL);
-
- if (strncmp(name, FIT_HASH_NODENAME,
- strlen(FIT_HASH_NODENAME)))
- continue;
- ret = fdt_get_path(fit, noffset, path, sizeof(path));
- if (ret < 0)
- goto err_path;
- if (strlist_add(node_inc, path))
- goto err_mem;
- hash_count++;
- }
-
- if (!hash_count) {
- printf("Failed to find any hash nodes in configuration '%s/%s' image '%s' - without these it is not possible to verify this image\n",
- conf_name, sig_name, iname);
- return -ENOMSG;
- }
-
- /* Add this image's cipher node if present */
- noffset = fdt_subnode_offset(fit, image_noffset,
- FIT_CIPHER_NODENAME);
- if (noffset != -FDT_ERR_NOTFOUND) {
- if (noffset < 0) {
- printf("Failed to get cipher node in configuration '%s/%s' image '%s': %s\n",
- conf_name, sig_name, iname,
- fdt_strerror(noffset));
- return -EIO;
- }
- ret = fdt_get_path(fit, noffset, path, sizeof(path));
- if (ret < 0)
- goto err_path;
- if (strlist_add(node_inc, path))
- goto err_mem;
- }
+ return ret;
image_count++;
}
@@ -813,11 +838,6 @@ err_mem:
printf("Out of memory processing configuration '%s/%s'\n", conf_name,
sig_name);
return -ENOMEM;
-
-err_path:
- printf("Failed to get path for image '%s' in configuration '%s/%s': %s\n",
- iname, conf_name, sig_name, fdt_strerror(ret));
- return -ENOENT;
}
static int fit_config_get_data(void *fit, int conf_noffset, int noffset,
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] tools: image-host: add support for several sub-images
2020-11-24 13:39 [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Philippe Reynes
@ 2020-11-24 13:39 ` Philippe Reynes
2020-11-30 20:12 ` Simon Glass
2021-01-23 17:45 ` Tom Rini
2020-11-30 20:12 ` [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Simon Glass
2021-01-23 17:45 ` Tom Rini
2 siblings, 2 replies; 6+ messages in thread
From: Philippe Reynes @ 2020-11-24 13:39 UTC (permalink / raw)
To: u-boot
The propoerty sign-images points to images in the configuration
node. But thoses images may references severals "sub-images" (for
example for images loadable). This commit adds the support of
severals sub-images.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
tools/image-host.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/tools/image-host.c b/tools/image-host.c
index ce829a8ec9..33a224129a 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -805,25 +805,31 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
image_count = 0;
for (iname = prop; iname < end; iname += strlen(iname) + 1) {
int image_noffset;
+ int index, max_index;
- image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
- iname);
- if (image_noffset < 0) {
- printf("Failed to find image '%s' in configuration '%s/%s'\n",
- iname, conf_name, sig_name);
- if (allow_missing)
- continue;
+ max_index = fdt_stringlist_count(fit, conf_noffset, iname);
- return -ENOENT;
- }
+ for (index = 0; index < max_index; index++) {
+ image_noffset = fit_conf_get_prop_node_index(fit, conf_noffset,
+ iname, index);
- ret = fit_config_add_hash(fit, conf_name,
- sig_name, node_inc,
- iname, image_noffset);
- if (ret < 0)
- return ret;
+ if (image_noffset < 0) {
+ printf("Failed to find image '%s' in configuration '%s/%s'\n",
+ iname, conf_name, sig_name);
+ if (allow_missing)
+ continue;
- image_count++;
+ return -ENOENT;
+ }
+
+ ret = fit_config_add_hash(fit, conf_name,
+ sig_name, node_inc,
+ iname, image_noffset);
+ if (ret < 0)
+ return ret;
+
+ image_count++;
+ }
}
if (!image_count) {
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list
2020-11-24 13:39 [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Philippe Reynes
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
@ 2020-11-30 20:12 ` Simon Glass
2021-01-23 17:45 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2020-11-30 20:12 UTC (permalink / raw)
To: u-boot
Hi Philippe,
On Tue, 24 Nov 2020 at 06:40, Philippe Reynes
<philippe.reynes@softathome.com> wrote:
>
> This commit creates a function fit_config_add_hash that will be
> used in the next commit to support several 'sub-images'.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
> tools/image-host.c | 132 ++++++++++++++++++++++++++-------------------
> 1 file changed, 76 insertions(+), 56 deletions(-)
>
Reviewed-by: Simon Glass <sjg@chromium.org>
I'm not quite clear what you are doing in this series or why. Can you
add some documentation updates please?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] tools: image-host: add support for several sub-images
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
@ 2020-11-30 20:12 ` Simon Glass
2021-01-23 17:45 ` Tom Rini
1 sibling, 0 replies; 6+ messages in thread
From: Simon Glass @ 2020-11-30 20:12 UTC (permalink / raw)
To: u-boot
Hi Philippe,
On Tue, 24 Nov 2020 at 06:40, Philippe Reynes
<philippe.reynes@softathome.com> wrote:
>
> The propoerty sign-images points to images in the configuration
spelling
> node. But thoses images may references severals "sub-images" (for
reference several
> example for images loadable). This commit adds the support of
> severals sub-images.
several
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
> tools/image-host.c | 36 +++++++++++++++++++++---------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
The code looks OK but is missing docs.
>
> diff --git a/tools/image-host.c b/tools/image-host.c
> index ce829a8ec9..33a224129a 100644
> --- a/tools/image-host.c
> +++ b/tools/image-host.c
> @@ -805,25 +805,31 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
> image_count = 0;
> for (iname = prop; iname < end; iname += strlen(iname) + 1) {
> int image_noffset;
> + int index, max_index;
>
> - image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
> - iname);
> - if (image_noffset < 0) {
> - printf("Failed to find image '%s' in configuration '%s/%s'\n",
> - iname, conf_name, sig_name);
> - if (allow_missing)
> - continue;
> + max_index = fdt_stringlist_count(fit, conf_noffset, iname);
>
> - return -ENOENT;
> - }
> + for (index = 0; index < max_index; index++) {
> + image_noffset = fit_conf_get_prop_node_index(fit, conf_noffset,
> + iname, index);
>
> - ret = fit_config_add_hash(fit, conf_name,
> - sig_name, node_inc,
> - iname, image_noffset);
> - if (ret < 0)
> - return ret;
> + if (image_noffset < 0) {
> + printf("Failed to find image '%s' in configuration '%s/%s'\n",
> + iname, conf_name, sig_name);
> + if (allow_missing)
> + continue;
>
> - image_count++;
> + return -ENOENT;
> + }
> +
> + ret = fit_config_add_hash(fit, conf_name,
> + sig_name, node_inc,
> + iname, image_noffset);
> + if (ret < 0)
> + return ret;
> +
> + image_count++;
> + }
> }
>
> if (!image_count) {
> --
> 2.17.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list
2020-11-24 13:39 [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Philippe Reynes
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
2020-11-30 20:12 ` [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Simon Glass
@ 2021-01-23 17:45 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2021-01-23 17:45 UTC (permalink / raw)
To: u-boot
On Tue, Nov 24, 2020 at 02:39:47PM +0100, Philippe Reynes wrote:
> This commit creates a function fit_config_add_hash that will be
> used in the next commit to support several 'sub-images'.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210123/d0983825/attachment.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] tools: image-host: add support for several sub-images
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
2020-11-30 20:12 ` Simon Glass
@ 2021-01-23 17:45 ` Tom Rini
1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2021-01-23 17:45 UTC (permalink / raw)
To: u-boot
On Tue, Nov 24, 2020 at 02:39:48PM +0100, Philippe Reynes wrote:
> The propoerty sign-images points to images in the configuration
> node. But thoses images may references severals "sub-images" (for
> example for images loadable). This commit adds the support of
> severals sub-images.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210123/bdc28b35/attachment.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-23 17:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 13:39 [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Philippe Reynes
2020-11-24 13:39 ` [PATCH 2/2] tools: image-host: add support for several sub-images Philippe Reynes
2020-11-30 20:12 ` Simon Glass
2021-01-23 17:45 ` Tom Rini
2020-11-30 20:12 ` [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list Simon Glass
2021-01-23 17:45 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.