dcd_v1_t *dcd_v1 = &hdr_v1->dcd_table;
        uint32_t base_offset;
 
-       /* Exit if there is no BOOT_FROM field specifying the flash_offset */
-       if(imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) {
-               fprintf(stderr, "Error: Header v1: No BOOT_FROM tag in %s\n",
-                       params->imagename);
-               exit(EXIT_FAILURE);
-       }
-
        /* Set magic number */
        fhdr_v1->app_code_barker = APP_CODE_BARKER;
 
        imx_header_v2_t *hdr_v2 = &imxhdr->header.hdr_v2;
        flash_header_v2_t *fhdr_v2 = &hdr_v2->fhdr;
 
-       /* Exit if there is no BOOT_FROM field specifying the flash_offset */
-       if(imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) {
-               fprintf(stderr, "Error: Header v2: No BOOT_FROM tag in %s\n",
-                       params->imagename);
-               exit(EXIT_FAILURE);
-       }
-
        /* Set magic number */
        fhdr_v2->header.tag = IVT_HEADER_TAG; /* 0xD1 */
        fhdr_v2->header.length = cpu_to_be16(sizeof(flash_header_v2_t));
        (*set_dcd_rst)(imxhdr, dcd_len, name, lineno);
        fclose(fd);
 
+       /* Exit if there is no BOOT_FROM field specifying the flash_offset */
+       if (imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) {
+               fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name);
+               exit(EXIT_FAILURE);
+       }
        return dcd_len;
 }