Skip to contentSkip to conversation

image: Support relative-addresses property in FIT images

PATCH New Stephen Warren 2 participants 9 messages Sep 30, 2011 – Oct 13, 2011 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

uImage files contain absolute "load" and "entry" addresses. Such a concept is incompatible with using the same kernel image on multiple SoCs, each with a potentially different SDRAM base. To support that, augment the FIT image syntax with a "relative-addresses" property, which indicates that the "load" and "entry" properties are an offset from SDRAM, rather than an absolute address.

In theory, a similar change could be made to the legacy uImage format. However, representing the a "relative-addresses" flag in that format is problematic, so I have ignored that possibility for now.

---
 common/image.c                        |   14 ++++++++++++++
 doc/uImage.FIT/source_file_format.txt |    3 +++
 include/image.h                       |    1 +
 3 files changed, 18 insertions(+), 0 deletions(-)
common/image.c +14 -0
index d38ce4a..e62fc76 100644
@@ -2299,6 +2299,13 @@ int fit_image_get_load (const void *fit, int noffset, ulong *load)
 	}
 
 	*load = uimage_to_cpu (*data);
+
+#ifndef USE_HOSTCC
+	data = fdt_getprop(fit, noffset, FIT_REL_ADDRS_PROP, &len);
+	if (data != NULL)
+		*load += getenv_bootm_low();
+#endif
+
 	return 0;
 }
 
@@ -2327,6 +2334,13 @@ int fit_image_get_entry (const void *fit, int noffset, ulong *entry)
 	}
 
 	*entry = uimage_to_cpu (*data);
+
+#ifndef USE_HOSTCC
+	data = fdt_getprop(fit, noffset, FIT_REL_ADDRS_PROP, &len);
+	if (data != NULL)
+		*entry += getenv_bootm_low();
+#endif
+
 	return 0;
 }
 
doc/uImage.FIT/source_file_format.txt +3 -0
index 6d20707..c2ae67e 100644
@@ -183,6 +183,9 @@ the '/images' node should have the following layout:
   Optional nodes:
   - hash at 1 : Each hash sub-node represents separate hash or checksum
     calculated for node's data according to specified algorithm.
+  - relative-addresses : Indicates the the values of the load and entry
+    properties are to be interpreted as relative to the base of SDRAM, rather
+    than as an absolute values.
 
 
 5) Hash nodes
include/image.h +1 -0
index 352e4a0..aefba5d 100644
@@ -538,6 +538,7 @@ static inline int image_check_target_arch (const image_header_t *hdr)
 #define FIT_COMP_PROP		"compression"
 #define FIT_ENTRY_PROP		"entry"
 #define FIT_LOAD_PROP		"load"
+#define FIT_REL_ADDRS_PROP	"relative-addresses"
 
 /* configuration node */
 #define FIT_KERNEL_PROP		"kernel"
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Stephen Warren wrote at Friday, September 30, 2011 1:53 PM:

Quoted 6 lines

uImage files contain absolute "load" and "entry" addresses. Such a concept is incompatible with using the same kernel image on multiple SoCs, each with a potentially different SDRAM base. To support that, augment the FIT image syntax with a "relative-addresses" property, which indicates that the "load" and "entry" properties are an offset from SDRAM, rather than an absolute address.

Wolfgang, does this change look like a reasonable approach?

Quoted 3 lines

In theory, a similar change could be made to the legacy uImage format. However, representing the a "relative-addresses" flag in that format is problematic, so I have ignored that possibility for now.

What are your thoughts on the legacy format; should we ignore it? We could probably steal some bit in one of the fields for this flag, although technically that would be a change to the format, with potential compatibility issues.

Thanks.

Signature · 1 line
nvpublic
#2 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Dear Stephen Warren,

Quoted 2 lines · In message <[email protected]>…

Wolfgang, does this change look like a reasonable approach?

Yes, looks good to me - with the nitpick of a bit more explicit comment. See previous message.

Quoted 4 lines

What are your thoughts on the legacy format; should we ignore it? We could probably steal some bit in one of the fields for this flag, although technically that would be a change to the format, with potential compatibility issues.

I would really like to see this supported as well - so far only a minority of users use FIT images.

I suggest we define a new image type (say, IH_TYPE_KERNEL_REL) for this purpose. This would probably cause the least conflicts.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I find this a nice feature but it is not according to  the  documen-
tation. Or is it a BUG?"   "Let's call it an accidental feature. :-)"
                       - Larry Wall in <[email protected]>
#3 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Wolfgang Denk wrote at Thursday, October 06, 2011 1:20 PM:

Quoted 12 lines
Quoted 2 lines · In message <[email protected]>…

Wolfgang, does this change look like a reasonable approach?

Yes, looks good to me - with the nitpick of a bit more explicit comment. See previous message.

Quoted 4 lines

What are your thoughts on the legacy format; should we ignore it? We could probably steal some bit in one of the fields for this flag, although technically that would be a change to the format, with potential compatibility issues.

Quoted 5 lines

I would really like to see this supported as well - so far only a minority of users use FIT images.

I suggest we define a new image type (say, IH_TYPE_KERNEL_REL) for this purpose. This would probably cause the least conflicts.

OK. Wouldn't we also need e.g. IH_TYPE_STANDALONE_REL, IH_TYPE_RAMDISK_REL and perhaps other too?

Signature · 1 line
nvpublic
#4 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Dear Stephen Warren,

Quoted 6 lines · In message <[email protected]>…
Quoted 3 lines

I suggest we define a new image type (say, IH_TYPE_KERNEL_REL) for this purpose. This would probably cause the least conflicts.

OK. Wouldn't we also need e.g. IH_TYPE_STANDALONE_REL, IH_TYPE_RAMDISK_REL and perhaps other too?

I don't think so - either these don't have (and use) load and entry point addesses (like in the ramdisk case), or they are not easily relocatable in the same way as the Linux kernel.

No, at the moment only the Linux kernel images need to support tis property.

OK, eventually this might be useful for multi-part images, too, but these have been deprecated for a long time, and here the user should just use a FIT image instead,

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"How is this place run - is it an anarchy?"
"No, I wouldn't say so; it is not that well organised..."
#5 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Wolfgang Denk wrote at Thursday, October 06, 2011 2:52 PM:

Quoted 11 lines
Quoted 6 lines · In message <[email protected]>…
Quoted 3 lines

I suggest we define a new image type (say, IH_TYPE_KERNEL_REL) for this purpose. This would probably cause the least conflicts.

OK. Wouldn't we also need e.g. IH_TYPE_STANDALONE_REL, IH_TYPE_RAMDISK_REL and perhaps other too?

I don't think so - either these don't have (and use) load and entry point addesses (like in the ramdisk case), or they are not easily relocatable in the same way as the Linux kernel.

Sorry, I don't quite understand then; in both boot_get_ramdisk() and boot_get_fdt(), I see calls to image_get_load() and fit_image_get_load(). I guess in the ramdisk case, this just sets rd_load, which isn't used, but in the FDT case, it sets load_start, which is used to derive load_end and fdt_blob.

Quoted 6 lines

No, at the moment only the Linux kernel images need to support tis property.

OK, eventually this might be useful for multi-part images, too, but these have been deprecated for a long time, and here the user should just use a FIT image instead,

Signature · 1 line
nvpublic
#6 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

Dear Stephen Warren,

Quoted 10 lines · In message <[email protected]>…
Quoted 7 lines
Quoted 3 lines

OK. Wouldn't we also need e.g. IH_TYPE_STANDALONE_REL, IH_TYPE_RAMDISK_REL and perhaps other too?

I don't think so - either these don't have (and use) load and entry point addesses (like in the ramdisk case), or they are not easily relocatable in the same way as the Linux kernel.

Sorry, I don't quite understand then; in both boot_get_ramdisk() and boot_get_fdt(), I see calls to image_get_load() and fit_image_get_load().

Agreed for FDT images, but you wrote IH_TYPE_STANDALONE_REL - standanole images are something differend, and usually not relocatable. And ramdisks have neither a load address nor an entry point associated with them; no matter where they are located in memory, we just pass their address to the Linux kernel.

Quoted 3 lines

I guess in the ramdisk case, this just sets rd_load, which isn't used, but in the FDT case, it sets load_start, which is used to derive load_end and fdt_blob.

Agreed. But that's not what you wrote above.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"There's only one way to have a happy marriage and as soon as I learn
what it is I'll get married again."                  - Clint Eastwood
#7 lore raw

PATCH 2/2 tegra2: Enable new image format (FIT)

In reply to Stephen Warren
---
 include/configs/tegra2-common.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/tegra2-common.h +1 -0
index 73e0f05..22ac2f2 100644
@@ -48,6 +48,7 @@
 
 #define CONFIG_CMDLINE_TAG		/* enable passing of ATAGs */
 #define CONFIG_OF_LIBFDT		/* enable passing of devicetree */
+#define CONFIG_FIT			/* enable new image format */
 
 /* Environment */
 #define CONFIG_ENV_IS_NOWHERE
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 1/2 image: Support relative-addresses property in FIT images

In reply to Stephen Warren

Dear Stephen Warren,

Quoted 10 lines · In message <[email protected]> you wrote:

uImage files contain absolute "load" and "entry" addresses. Such a concept is incompatible with using the same kernel image on multiple SoCs, each with a potentially different SDRAM base. To support that, augment the FIT image syntax with a "relative-addresses" property, which indicates that the "load" and "entry" properties are an offset from SDRAM, rather than an absolute address.

In theory, a similar change could be made to the legacy uImage format. However, representing the a "relative-addresses" flag in that format is problematic, so I have ignored that possibility for now.

...

doc/uImage.FIT/source_file_format.txt the '/images' node should have the following layout: · line 188

Quoted 3 lines
doc/uImage.FIT/source_file_format.txt +3 -0
+  - relative-addresses : Indicates the the values of the load and entry
+    properties are to be interpreted as relative to the base of SDRAM, rather
+    than as an absolute values.

How is "base of SDRAM" defined, for example in the case of several non-contiguously mapped banks of RAM?

Please add this to the comment.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  What's a light-year?
A:  One-third less calories than a regular year.