]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - tools/fit_image.c
arm64: mvebu: Armada 7K/8K: Add COMPHY device tree nodes
[karo-tx-uboot.git] / tools / fit_image.c
index ddefa72f3479ffacf746d9b5d46a3b017b92937a..10fd6d4929374728732efd63e327cab36275766e 100644 (file)
@@ -51,8 +51,10 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
        }
 
        /* for first image creation, add a timestamp at offset 0 i.e., root  */
-       if (params->datafile)
-               ret = fit_set_timestamp(ptr, 0, sbuf.st_mtime);
+       if (params->datafile) {
+               time_t time = imagetool_get_source_date(params, sbuf.st_mtime);
+               ret = fit_set_timestamp(ptr, 0, time);
+       }
 
        if (!ret) {
                ret = fit_add_verification_data(params->keydir, dest_blob, ptr,
@@ -193,7 +195,8 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
        fdt_begin_node(fdt, str);
        fdt_property_string(fdt, "description", params->imagename);
        fdt_property_string(fdt, "type", typename);
-       fdt_property_string(fdt, "arch", genimg_get_arch_name(params->arch));
+       fdt_property_string(fdt, "arch",
+                           genimg_get_arch_short_name(params->arch));
        fdt_property_string(fdt, "os", genimg_get_os_short_name(params->os));
        fdt_property_string(fdt, "compression",
                            genimg_get_comp_short_name(params->comp));
@@ -343,7 +346,6 @@ static int fit_build(struct image_tool_params *params, const char *fname)
        if (ret != size) {
                fprintf(stderr, "%s: Can't write %s: %s\n",
                        params->cmdname, fname, strerror(errno));
-               close(fd);
                goto err;
        }
        close(fd);
@@ -417,7 +419,13 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
                        ret = -EPERM;
                        goto err_munmap;
                }
-               fdt_setprop_u32(fdt, node, "data-offset", buf_ptr);
+               if (params->external_offset > 0) {
+                       /* An external offset positions the data absolutely. */
+                       fdt_setprop_u32(fdt, node, "data-position",
+                                       params->external_offset + buf_ptr);
+               } else {
+                       fdt_setprop_u32(fdt, node, "data-offset", buf_ptr);
+               }
                fdt_setprop_u32(fdt, node, "data-size", len);
 
                buf_ptr += (len + 3) & ~3;
@@ -438,6 +446,17 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
                ret = -EIO;
                goto err;
        }
+
+       /* Check if an offset for the external data was set. */
+       if (params->external_offset > 0) {
+               if (params->external_offset < new_size) {
+                       debug("External offset %x overlaps FIT length %x",
+                             params->external_offset, new_size);
+                       ret = -EINVAL;
+                       goto err;
+               }
+               new_size = params->external_offset;
+       }
        if (lseek(fd, new_size, SEEK_SET) < 0) {
                debug("%s: Failed to seek to end of file: %s\n", __func__,
                      strerror(errno));
@@ -632,8 +651,8 @@ static int fit_handle_file(struct image_tool_params *params)
        }
 
        if (ret) {
-               fprintf(stderr, "%s Can't add hashes to FIT blob\n",
-                       params->cmdname);
+               fprintf(stderr, "%s Can't add hashes to FIT blob: %d\n",
+                       params->cmdname, ret);
                goto err_system;
        }