[PATCH 3/4] of/dtc: force dtb size to modulo 32 bytes
dirk.brandewie at gmail.com
dirk.brandewie at gmail.com
Fri Nov 12 11:03:49 EST 2010
From: Dirk Brandewie <dirk.brandewie at gmail.com>
This patch forces the size of the DTB to be modulo 32 bytes. This is
needed to support linking multiple DTB's into a single section in the
image. GCC wants structures to be 32 byte aligned without this change
DTB's after the first in the section may not be properly aligned so
the flat tree parsing code will fall over.
Signed-off-by: Dirk Brandewie <dirk.brandewie at gmail.com>
---
scripts/dtc/flattree.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c
index 76acd28..ccca797 100644
--- a/scripts/dtc/flattree.c
+++ b/scripts/dtc/flattree.c
@@ -358,6 +358,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
struct data strbuf = empty_data;
struct fdt_header fdt;
int padlen = 0;
+ int align_size;
for (i = 0; i < ARRAY_SIZE(version_table); i++) {
if (version_table[i].version == version)
@@ -395,6 +396,9 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
fdt.totalsize = cpu_to_fdt32(tsize);
}
+ align_size = ALIGN(fdt32_to_cpu(fdt.totalsize), 32);
+ fdt.totalsize = cpu_to_fdt32(align_size);
+
/*
* Assemble the blob: start with the header, add with alignment
* the reserve buffer, add the reserve map terminating zeroes,
@@ -412,7 +416,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
*/
if (padlen > 0)
blob = data_append_zeroes(blob, padlen);
-
+ blob = data_append_align(blob, 32);
fwrite(blob.val, blob.len, 1, f);
if (ferror(f))
--
1.7.2.3
More information about the devicetree-discuss
mailing list