]> Git Repo - J-u-boot.git/blobdiff - tools/imx8image.c
Merge tag 'u-boot-imx-20181106' of git://git.denx.de/u-boot-imx
[J-u-boot.git] / tools / imx8image.c
index 019b875773be99e4183c125182005bde551e66ec..6e8ac464e7cf938d456f2ecc3ef29973b592d7bd 100644 (file)
@@ -812,6 +812,10 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
                case SCFW:
                case DATA:
                case MSG_BLOCK:
+                       if (container < 0) {
+                               fprintf(stderr, "No container found\n");
+                               exit(EXIT_FAILURE);
+                       }
                        check_file(&sbuf, img_sp->filename);
                        tmp_filename = img_sp->filename;
                        set_image_array_entry(&imx_header.fhdr[container],
@@ -825,6 +829,10 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
                        break;
 
                case SECO:
+                       if (container < 0) {
+                               fprintf(stderr, "No container found\n");
+                               exit(EXIT_FAILURE);
+                       }
                        check_file(&sbuf, img_sp->filename);
                        tmp_filename = img_sp->filename;
                        set_image_array_entry(&imx_header.fhdr[container],
@@ -906,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
This page took 0.02249 seconds and 4 git commands to generate.