fdtdec: support pack "kern.dtb" to the end of u-boot.bin

- It provides a way to promise kernel dtb can be loaded successfully
  even when the image is damaged.
- This makes developers easily to add what they what just like a "U-Boot" dtb.
- The kern.dtb file is pack into the end of u-boot.bin while ./dts/kern.dtb
  is exist.

Change-Id: I93a36a9c65ea8719e5610cdcbcc7708e5337c53f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-10-21 09:08:50 +08:00 committed by Jianhong Chen
parent 6069a2cc24
commit 5704c899ed
3 changed files with 22 additions and 3 deletions

View File

@ -904,13 +904,24 @@ u-boot.bin: u-boot-fit-dtb.bin FORCE
else ifeq ($(CONFIG_OF_SEPARATE),y)
ifeq ($(CONFIG_USING_KERNEL_DTB),y)
u-boot-dtb.bin: u-boot-nodtb.bin dts/dt-spl.dtb FORCE
else
u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
endif
$(call if_changed,cat)
ifneq ($(wildcard dts/kern.dtb),)
u-boot-dtb-kern.bin: u-boot-dtb.bin FORCE
$(call if_changed,copy)
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)
endif
else
u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
$(call if_changed,cat)
u-boot.bin: u-boot-dtb.bin FORCE
$(call if_changed,copy)
endif
else
u-boot.bin: u-boot-nodtb.bin FORCE
$(call if_changed,copy)

View File

@ -83,6 +83,9 @@ typedef struct global_data {
struct udevice *timer; /* Timer instance for Driver Model */
#endif
#ifdef CONFIG_USING_KERNEL_DTB
const void *fdt_blob_kern; /* Kernel dtb at the tail of u-boot.bin */
#endif
const void *fdt_blob; /* Our device tree, NULL if none */
void *new_fdt; /* Relocated FDT */
unsigned long fdt_size; /* Space reserved for relocated FDT */

View File

@ -1284,6 +1284,11 @@ int fdtdec_setup(void)
# else
/* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
# ifdef CONFIG_USING_KERNEL_DTB
gd->fdt_blob_kern =
(ulong *)((ulong)gd->fdt_blob + fdt_totalsize(gd->fdt_blob));
# endif
# endif
# elif defined(CONFIG_OF_BOARD)
/* Allow the board to override the fdt address. */