summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMartin Kaiser <martin@kaiser.cx>2017-01-02 22:24:17 +0100
committerStefano Babic <sbabic@denx.de>2017-01-27 10:27:32 +0100
commit97f17fa6278747d059fccb8eef7f79ec3dfc9502 (patch)
tree36a84caece2a456c8031a7aa36f35731b4de1d80 /tools
parentcf4128e53caa4f7b0a6586fc3f10690d5c05db31 (diff)
downloadu-boot-97f17fa6278747d059fccb8eef7f79ec3dfc9502.tar.gz
tools: imximage: refactor header length calculations for imximage v1
We can use the same header length calculations for both imximage v1 and v2. This addresses TODO comments about imximage v1 in the current code. With this patch applied, *header_size_ptr in imximage_set_header() will have the correct value for both imximage v1 and v2. This is necessary for people wanting to add proprietary data behind the created imximage. Signed-off-by: Martin Kaiser <martin@kaiser.cx> Cc: sbabic@denx.de
Diffstat (limited to 'tools')
-rw-r--r--tools/imximage.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/tools/imximage.c b/tools/imximage.c
index 2cd8d88487..0c43196ac1 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -300,8 +300,7 @@ static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
/* Set magic number */
fhdr_v1->app_code_barker = APP_CODE_BARKER;
- /* TODO: check i.MX image V1 handling, for now use 'old' style */
- hdr_base = entry_point - 4096;
+ hdr_base = entry_point - imximage_init_loadsize + flash_offset;
fhdr_v1->app_dest_ptr = hdr_base - flash_offset;
fhdr_v1->app_code_jump_vector = entry_point;
@@ -833,18 +832,19 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
/* Parse dcd configuration file */
dcd_len = parse_cfg_file(imxhdr, params->imagename);
- if (imximage_version == IMXIMAGE_V2) {
+ if (imximage_version == IMXIMAGE_V1)
+ header_size = sizeof(flash_header_v1_t);
+ else {
header_size = sizeof(flash_header_v2_t) + sizeof(boot_data_t);
if (!plugin_image)
header_size += sizeof(dcd_v2_t);
else
header_size += MAX_PLUGIN_CODE_SIZE;
-
- if (imximage_init_loadsize < imximage_ivt_offset + header_size)
- imximage_init_loadsize = imximage_ivt_offset +
- header_size;
}
+ if (imximage_init_loadsize < imximage_ivt_offset + header_size)
+ imximage_init_loadsize = imximage_ivt_offset + header_size;
+
/* Set the imx header */
(*set_imx_hdr)(imxhdr, dcd_len, params->ep, imximage_ivt_offset);
@@ -913,23 +913,21 @@ static int imximage_generate(struct image_tool_params *params,
/* Parse dcd configuration file */
parse_cfg_file(&imximage_header, params->imagename);
- /* TODO: check i.MX image V1 handling, for now use 'old' style */
- if (imximage_version == IMXIMAGE_V1) {
- alloc_len = 4096;
- header_size = 4096;
- } else {
+ if (imximage_version == IMXIMAGE_V1)
+ header_size = sizeof(imx_header_v1_t);
+ else {
header_size = sizeof(flash_header_v2_t) + sizeof(boot_data_t);
if (!plugin_image)
header_size += sizeof(dcd_v2_t);
else
header_size += MAX_PLUGIN_CODE_SIZE;
-
- if (imximage_init_loadsize < imximage_ivt_offset + header_size)
- imximage_init_loadsize = imximage_ivt_offset +
- header_size;
- alloc_len = imximage_init_loadsize - imximage_ivt_offset;
}
+ if (imximage_init_loadsize < imximage_ivt_offset + header_size)
+ imximage_init_loadsize = imximage_ivt_offset + header_size;
+
+ alloc_len = imximage_init_loadsize - imximage_ivt_offset;
+
if (alloc_len < header_size) {
fprintf(stderr, "%s: header error\n",
params->cmdname);
@@ -959,11 +957,7 @@ static int imximage_generate(struct image_tool_params *params,
pad_len = ROUND(sbuf.st_size, 4096) - sbuf.st_size;
- /* TODO: check i.MX image V1 handling, for now use 'old' style */
- if (imximage_version == IMXIMAGE_V1)
- return 0;
- else
- return pad_len;
+ return pad_len;
}