+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2009
* (C) Copyright 2008
* Marvell Semiconductor <www.marvell.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include "imagetool.h"
#include <image.h>
#include "imximage.h"
+#include <generated/autoconf.h>
#define UNDEFINED 0xFFFFFFFF
+#if !defined(CONFIG_IMX_DCD_ADDR)
+#define CONFIG_IMX_DCD_ADDR 0x00910000
+#endif
/*
* Supported commands for configuration file
*/
{CMD_BOOT_OFFSET, "BOOT_OFFSET", "Boot offset", },
{CMD_WRITE_DATA, "DATA", "Reg Write Data", },
{CMD_WRITE_CLR_BIT, "CLR_BIT", "Reg clear bit", },
+ {CMD_WRITE_SET_BIT, "SET_BIT", "Reg set bit", },
{CMD_CHECK_BITS_SET, "CHECK_BITS_SET", "Reg Check bits set", },
{CMD_CHECK_BITS_CLR, "CHECK_BITS_CLR", "Reg Check bits clr", },
{CMD_CSF, "CSF", "Command Sequence File", },
d->write_dcd_command.length = cpu_to_be16(4);
d->write_dcd_command.param = DCD_WRITE_CLR_BIT_PARAM;
break;
+ case CMD_WRITE_SET_BIT:
+ if ((d->write_dcd_command.tag == DCD_WRITE_DATA_COMMAND_TAG) &&
+ (d->write_dcd_command.param == DCD_WRITE_SET_BIT_PARAM))
+ break;
+ d = d2;
+ d->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG;
+ d->write_dcd_command.length = cpu_to_be16(4);
+ d->write_dcd_command.param = DCD_WRITE_SET_BIT_PARAM;
+ break;
/*
* Check data command only supports one entry,
*/
/* 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;
genimg_print_size(hdr_v2->boot_data.size);
printf("Load Address: %08x\n", (uint32_t)fhdr_v2->boot_data_ptr);
printf("Entry Point: %08x\n", (uint32_t)fhdr_v2->entry);
- if (fhdr_v2->csf && (imximage_ivt_offset != UNDEFINED) &&
- (imximage_csf_size != UNDEFINED)) {
+ if (fhdr_v2->csf) {
uint16_t dcdlen;
int offs;
offs = (char *)&hdr_v2->data.dcd_table
- (char *)hdr_v2;
- printf("HAB Blocks: %08x %08x %08x\n",
+ /*
+ * The HAB block is the first part of the image, from
+ * start of IVT header (fhdr_v2->self) to the start of
+ * the CSF block (fhdr_v2->csf). So HAB size is
+ * calculated as:
+ * HAB_size = fhdr_v2->csf - fhdr_v2->self
+ */
+ printf("HAB Blocks: 0x%08x 0x%08x 0x%08x\n",
(uint32_t)fhdr_v2->self, 0,
- hdr_v2->boot_data.size - imximage_ivt_offset -
- imximage_csf_size);
- printf("DCD Blocks: 00910000 %08x %08x\n",
- offs, be16_to_cpu(dcdlen));
+ (uint32_t)(fhdr_v2->csf - fhdr_v2->self));
+ printf("DCD Blocks: 0x%08x 0x%08x 0x%08x\n",
+ CONFIG_IMX_DCD_ADDR, offs, be16_to_cpu(dcdlen));
}
} else {
imx_header_v2_t *next_hdr_v2;
break;
case CMD_WRITE_DATA:
case CMD_WRITE_CLR_BIT:
+ case CMD_WRITE_SET_BIT:
case CMD_CHECK_BITS_SET:
case CMD_CHECK_BITS_CLR:
value = get_cfg_value(token, name, lineno);
switch(*cmd) {
case CMD_WRITE_DATA:
case CMD_WRITE_CLR_BIT:
+ case CMD_WRITE_SET_BIT:
case CMD_CHECK_BITS_SET:
case CMD_CHECK_BITS_CLR:
/* 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);
/* 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);
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;
}