]> git.sur5r.net Git - u-boot/blobdiff - tools/image-host.c
mkimage: Automatically make space in FDT when full
[u-boot] / tools / image-host.c
index 651f1c2f8b46727eb6aa9dffc470452b3e641026..2be5e8043c1dd9cefa7b0380dd51533bee473fea 100644 (file)
@@ -224,7 +224,9 @@ static int fit_image_process_sig(const char *keydir, void *keydest,
        ret = fit_image_write_sig(fit, noffset, value, value_len, comment,
                        NULL, 0);
        if (ret) {
-               printf("Can't write signature for '%s' signature node in '%s' image node: %s\n",
+               if (ret == -FDT_ERR_NOSPACE)
+                       return -ENOSPC;
+               printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n",
                       node_name, image_name, fdt_strerror(ret));
                return -1;
        }
@@ -589,10 +591,13 @@ static int fit_config_process_sig(const char *keydir, void *keydest,
                return -1;
        }
 
-       if (fit_image_write_sig(fit, noffset, value, value_len, comment,
-                               region_prop, region_proplen)) {
-               printf("Can't write signature for '%s' signature node in '%s' conf node\n",
-                      node_name, conf_name);
+       ret = fit_image_write_sig(fit, noffset, value, value_len, comment,
+                               region_prop, region_proplen);
+       if (ret) {
+               if (ret == -FDT_ERR_NOSPACE)
+                       return -ENOSPC;
+               printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n",
+                      node_name, conf_name, fdt_strerror(ret));
                return -1;
        }
        free(value);
@@ -602,10 +607,13 @@ static int fit_config_process_sig(const char *keydir, void *keydest,
        info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
 
        /* Write the public key into the supplied FDT file */
-       if (keydest && info.algo->add_verify_data(&info, keydest)) {
-               printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
-                      node_name, conf_name);
-               return -1;
+       if (keydest) {
+               ret = info.algo->add_verify_data(&info, keydest);
+               if (ret) {
+                       printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
+                              node_name, conf_name);
+                       return ret == FDT_ERR_NOSPACE ? -ENOSPC : -EIO;
+               }
        }
 
        return 0;