From 874f40588d3eb7e406521117c6e24d5a3376a77e Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Mon, 18 Jul 2016 15:56:53 +0800 Subject: Implement the -a option to pad dtb aligned There is one condition that need cat the dtb files into one dtb.img which can support several boards use same SoC platform. And the original dtb file size is not aligned to any base. This may cause "Synchronous Abort" when load from a unligned address on some SoC machine, such as ARM. So this patch implement the -a option to pad zero at the end of dtb files and make the dtb size aligned to . Then, the aligned dtbs can cat together and load without "Synchronous Abort". Signed-off-by: Tim Wang Signed-off-by: David Gibson --- flattree.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'flattree.c') diff --git a/flattree.c b/flattree.c index 089b976..a9d9520 100644 --- a/flattree.c +++ b/flattree.c @@ -398,15 +398,22 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version) */ if (minsize > 0) { padlen = minsize - fdt32_to_cpu(fdt.totalsize); - if ((padlen < 0) && (quiet < 1)) - fprintf(stderr, - "Warning: blob size %d >= minimum size %d\n", - fdt32_to_cpu(fdt.totalsize), minsize); + if (padlen < 0) { + padlen = 0; + if (quiet < 1) + fprintf(stderr, + "Warning: blob size %d >= minimum size %d\n", + fdt32_to_cpu(fdt.totalsize), minsize); + } } if (padsize > 0) padlen = padsize; + if (alignsize > 0) + padlen = ALIGN(fdt32_to_cpu(fdt.totalsize) + padlen, alignsize) + - fdt32_to_cpu(fdt.totalsize); + if (padlen > 0) { int tsize = fdt32_to_cpu(fdt.totalsize); tsize += padlen; @@ -572,6 +579,8 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) if (padsize > 0) { fprintf(f, "\t.space\t%d, 0\n", padsize); } + if (alignsize > 0) + asm_emit_align(f, alignsize); emit_label(f, symprefix, "blob_abs_end"); data_free(strbuf); -- cgit v1.2.3-59-g8ed1b