]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tools: imx8image: flatten container header only when creating container
authorPeng Fan <peng.fan@nxp.com>
Mon, 5 Nov 2018 09:53:31 +0000 (09:53 +0000)
committerStefano Babic <sbabic@denx.de>
Tue, 6 Nov 2018 10:24:10 +0000 (11:24 +0100)
If there is no CONTAINER entry, there is no need to flatten container
header.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
tools/imx8image.c

index ac89c821c9ebcce4121100d3f354cb6967fd9192..6e8ac464e7cf938d456f2ecc3ef29973b592d7bd 100644 (file)
@@ -914,17 +914,19 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
                exit(EXIT_FAILURE);
        }
 
-       /* Note: Image offset are not contained in the image */
-       tmp = flatten_container_header(&imx_header, container + 1, &size,
-                                      file_padding);
-       /* Write image header */
-       if (write(ofd, tmp, size) != size) {
-               fprintf(stderr, "error writing image hdr\n");
-               exit(EXIT_FAILURE);
-       }
+       if (container >= 0) {
+               /* Note: Image offset are not contained in the image */
+               tmp = flatten_container_header(&imx_header, container + 1,
+                                              &size, file_padding);
+               /* Write image header */
+               if (write(ofd, tmp, size) != size) {
+                       fprintf(stderr, "error writing image hdr\n");
+                       exit(EXIT_FAILURE);
+               }
 
-       /* Clean-up memory used by the headers */
-       free(tmp);
+               /* Clean-up memory used by the headers */
+               free(tmp);
+       }
 
        /*
         * step through the image stack again this time copying