diff mbox series

[U-Boot,6/6] fdt: boot_get_fdt: android: use ENV 'fdtaddr' as fallback

Message ID 20190331020838.26683-6-erosca@de.adit-jv.com
State Superseded
Delegated to: Simon Glass
Headers show
Series [U-Boot,1/6] fdt: boot_get_fdt: remove redundant zeroing out | expand

Commit Message

Eugeniu Rosca March 31, 2019, 2:08 a.m. UTC
Our platform doesn't store the DTB into the Android image second area,
but rather copies the DTB to RAM from a dedicated dtb.img partition [0],
prior to booting the Android image by calling bootm.

Similar to [1], we find it useful to just call 'bootm' and have the
right DTB being passed to OS (assuming its address has been previously
stored in 'fdtaddr' by calling `fdt addr <dtb-addr>`).

Booting Android with DTB from 'fdtaddr' will only occur if:
 - No DTB is embedded in the second area of Android image
 - 'fdtaddr' points to a valid DTB in RAM

[0] https://source.android.com/devices/architecture/dto/partitions
[1] https://patchwork.ozlabs.org/patch/1046652/
    ("Support boot Android image without address on bootm command")

Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
 common/image-fdt.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/common/image-fdt.c b/common/image-fdt.c
index 8fea54335e99..3307c990672f 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -462,7 +462,16 @@  int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 			fdt_blob = (char *)fdt_data;
 			debug("## Using FDT in Android image second area\n");
 		} else {
-			goto no_fdt;
+			fdt_addr = env_get_hex("fdtaddr", 0);
+			if (!fdt_addr)
+				goto no_fdt;
+
+			fdt_blob = map_sysmem(fdt_addr, 0);
+			if (fdt_check_header(fdt_blob))
+				goto no_fdt;
+
+			fdt_len = fdt_totalsize(fdt_blob);
+			debug("## Using FDT at ${fdtaddr}=Ox%lx\n", fdt_addr);
 		}
 #endif
 	} else {