summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDirk Behme <dirk.behme@de.bosch.com>2012-02-22 22:50:19 (GMT)
committerStefano Babic <sbabic@denx.de>2012-03-27 07:41:14 (GMT)
commit49d3e2721164eaef5df702a26cfca6efd430be30 (patch)
treee60d714e465b7058275f16461a42bd4fb0ec1f08 /tools
parentcd207cde948ecf9ff50a0fa1ae2650f65579c9c9 (diff)
downloadu-boot-49d3e2721164eaef5df702a26cfca6efd430be30.tar.xz
imximage: Remove overwriting of flash_offset
The flash header supports different flash offsets for different boot devices. E.g. parallel NOR or OneNAND use a different offset than FLASH_OFFSET_STANDARD (== 0x400). The flash offset is correctly read from the configuration in parse_cfg_cmd(). But is then overwritten wrongly in set_imx_hdr_v1/2(). Fix this by removing this overwriting. Use the flash offset correctly read from the configuration, instead. If there is no flash_offset read from the configuration file, i.e. the BOOT_FROM tag is missing, exit with an error message. Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com> CC: Jason Liu <liu.h.jason@gmail.com> CC: Stefano Babic <sbabic@denx.de> Tested-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/imximage.c18
-rw-r--r--tools/imximage.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/tools/imximage.c b/tools/imximage.c
index 1e0f5d4..03a7716 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -216,8 +216,12 @@ static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
dcd_v1_t *dcd_v1 = &hdr_v1->dcd_table;
uint32_t base_offset;
- /* Set default offset */
- imxhdr->flash_offset = FLASH_OFFSET_STANDARD;
+ /* 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;
@@ -253,8 +257,12 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr, uint32_t dcd_len,
imx_header_v2_t *hdr_v2 = &imxhdr->header.hdr_v2;
flash_header_v2_t *fhdr_v2 = &hdr_v2->fhdr;
- /* Set default offset */
- imxhdr->flash_offset = FLASH_OFFSET_STANDARD;
+ /* 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 */
@@ -525,6 +533,8 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
* set up function ptr group to V1 by default.
*/
imximage_version = IMXIMAGE_V1;
+ /* Be able to detect if the cfg file has no BOOT_FROM tag */
+ imxhdr->flash_offset = FLASH_OFFSET_UNDEFINED;
set_hdr_func(imxhdr);
/* Parse dcd configuration file */
diff --git a/tools/imximage.h b/tools/imximage.h
index d784a8d..34f293d 100644
--- a/tools/imximage.h
+++ b/tools/imximage.h
@@ -32,6 +32,7 @@
#define HEADER_OFFSET 0x400
#define CMD_DATA_STR "DATA"
+#define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF
#define FLASH_OFFSET_STANDARD 0x400
#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
#define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD