From 369e944c844f783508b7839ae86a3418e2f63bc7 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 12 Dec 2019 18:07:07 +0800 Subject: [PATCH] fdt/Makefile: make u-boot-dtb.bin 8-byte aligned The dts/kern.dtb is appended after u-boot-dtb.bin for U-disk boot. Make sure u-boot-dtb.bin is 8-byte aligned to avoid data-abort on calling: fdt_check_header(gd->fdt_blob_kern). Signed-off-by: Joseph Chen Change-Id: Id5f2daf0c5446e7ea828cb970d3d4879e3acda86 --- Makefile | 5 +++++ lib/fdtdec.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ddea829dbf..b9473f7495 100644 --- a/Makefile +++ b/Makefile @@ -887,6 +887,9 @@ endif quiet_cmd_copy = COPY $@ cmd_copy = cp $< $@ +quiet_cmd_truncate = ALIGN $@ + cmd_truncate = truncate -s "%8" $@ + ifeq ($(CONFIG_MULTI_DTB_FIT),y) fit-dtb.blob: dts/dt.dtb FORCE @@ -909,11 +912,13 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt-spl.dtb FORCE ifneq ($(wildcard dts/kern.dtb),) u-boot-dtb-kern.bin: u-boot-dtb.bin FORCE $(call if_changed,copy) + $(call if_changed,truncate) u-boot.bin: u-boot-dtb-kern.bin dts/kern.dtb FORCE $(call if_changed,cat) else u-boot.bin: u-boot-dtb.bin FORCE $(call if_changed,copy) + $(call if_changed,truncate) endif else diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 589cec3e94..5b637f2639 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1286,8 +1286,8 @@ int fdtdec_setup(void) gd->fdt_blob = (ulong *)&_end; # ifdef CONFIG_USING_KERNEL_DTB - gd->fdt_blob_kern = - (ulong *)((ulong)gd->fdt_blob + fdt_totalsize(gd->fdt_blob)); + gd->fdt_blob_kern = (ulong *)((ulong)gd->fdt_blob + + ALIGN(fdt_totalsize(gd->fdt_blob), 8)); # endif # endif # elif defined(CONFIG_OF_BOARD)