[U-Boot] [PATCH v2 1/6] fdt_relocate: fix fdt size and endian bugs
John Rigby
john.rigby at linaro.org
Wed Sep 29 17:48:07 CEST 2010
Fix two problems in fdt_relocate.
First, for the non relocation case current code calculates
fdt blob size by subtracting the fdt address from the end
of bootmap. This wrong because it assumes that the fdt_blob
is located at the top (high) of the bootmap. Use the current
size plus padding instead. For example if the blob is at
the beginning of bootmap then the calculated size will be
the size of the entire bootmapped area.
Second, fdt_relocate returns bad size info on little endian
platforms because it calls be32_to_cpu on the value returned
by fdt_totalsize. This is wrong because the value returned
by fdt_totalsize is already cpu endian.
Signed-off-by: John Rigby <john.rigby at linaro.org>
---
common/image.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/image.c b/common/image.c
index 3a2f25e..4aec9d6 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1252,7 +1252,7 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,
*of_size = of_len;
} else {
*of_flat_tree = fdt_blob;
- of_len = (CONFIG_SYS_BOOTMAPSZ + bootmap_base) - (ulong)fdt_blob;
+ of_len = *of_size + (unsigned)CONFIG_SYS_FDT_PAD;
lmb_reserve(lmb, (ulong)fdt_blob, of_len);
fdt_set_totalsize(*of_flat_tree, of_len);
@@ -1561,7 +1561,7 @@ int boot_get_fdt (int flag, int argc, char * const argv[], bootm_headers_t *imag
goto error;
}
- if (be32_to_cpu (fdt_totalsize (fdt_blob)) != fdt_len) {
+ if (fdt_totalsize(fdt_blob) != fdt_len) {
fdt_error ("fdt size != image size");
goto error;
}
@@ -1575,7 +1575,7 @@ int boot_get_fdt (int flag, int argc, char * const argv[], bootm_headers_t *imag
}
*of_flat_tree = fdt_blob;
- *of_size = be32_to_cpu (fdt_totalsize (fdt_blob));
+ *of_size = fdt_totalsize(fdt_blob);
debug (" of_flat_tree at 0x%08lx size 0x%08lx\n",
(ulong)*of_flat_tree, *of_size);
--
1.7.0.4
More information about the U-Boot
mailing list