[U-Boot] [PATCH] imximage: header v2: Remove overwriting of flash_offset

Dirk Behme dirk.behme at de.bosch.com
Wed Feb 22 09:14:12 CET 2012


On 21.02.2012 22:49, stefano babic wrote:
> Am 21/02/2012 20:18, schrieb Dirk Behme:
> 
>>> I think we have then a problem when there is not a BOOT_FROM statement
>>> in the configuration file, that let  imxhdr->flash_offset unset.
>>>
>>> We need to set it with the default value
>> Hmm, my understanding is that there can't be any default value? 
> 
> This is desirable, but it does not correspond to the code.
> 
>> What do
>> you think would be a default value? The one for SD boot? The one for
>> NAND? Or? Who will decide what the default should be?
> 
> Whatever we choose, it is wrong. We can select SD, and one board has not
> a SD interface. The same with NAND, ...
> 
> The best one is we have not a default value.

Yes, agree.

>>> at the beginning of the
>>> processing or to raise an error if we want to make this statement
>>> mandatory in the configuration file.
>> If there can't be a default value, I think to raise an error if no
>> BOOT_FROM statement is there is the only option.
> 
> Agree - BOOT_FROM must be mandatory.

What do you think about anything like below then [1]?

I looked through the imximage.c code and, well, due to the mixture to 
support the v1 and v2 header format, the execution path isn't the 
cleanest one. So, while it doesn't seem to be the cleanest way to exit 
directly in set_imx_hdr_v2, it seems to be the easiest and best place to 
add this check. Some other functions have some exit() calls, too, so it 
seems to be common practice in this code.

If this is ok, I will send a v2 of the patch.

Best regards

Dirk

[1]

--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -253,8 +253,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 == 0) {
+		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 */


More information about the U-Boot mailing list