[U-Boot] [RFC PATCH V3] common: image-fdt: support dts from the second address of android image

Michael Trimarchi michael at amarulasolutions.com
Mon Jun 13 21:53:24 CEST 2016


We can support dts load from the second address of android image.
This let us to boot board (aka freescale)

Signed-off-by: Michael Trimarchi <michael at amarulasolutions.com>
---
Changes:
	v2 -> v3: Move variable fdt_data and fdt_len in main body
	v1 -> v2: reduce code and cleanup
---
 common/image-android.c | 21 +++++++++++++++++++++
 common/image-fdt.c     | 13 +++++++++++--
 include/image.h        |  2 ++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/common/image-android.c b/common/image-android.c
index ee03b96..9701acd 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -146,6 +146,27 @@ int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
 	return 0;
 }
 
+int android_image_get_dts(const struct andr_img_hdr *hdr,
+			  ulong *dts_data, ulong *dts_len)
+{
+	if (!hdr->second_size) {
+		*dts_data = *dts_len = 0;
+		return -1;
+	}
+
+	printf("Dts load addr 0x%08x size %u KiB\n",
+	       hdr->second_addr, DIV_ROUND_UP(hdr->second_size, 1024));
+
+	*dts_data = (unsigned long)hdr;
+	*dts_data += hdr->page_size;
+	*dts_data += ALIGN(hdr->kernel_size, hdr->page_size);
+	*dts_data += ALIGN(hdr->ramdisk_size, hdr->page_size);
+
+	*dts_len = hdr->second_size;
+	return 0;
+}
+
+
 #if !defined(CONFIG_SPL_BUILD)
 /**
  * android_print_contents - prints out the contents of the Android format image
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 6cac7db..fb4cceb 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -237,6 +237,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 	ulong		default_addr;
 	int		fdt_noffset;
 #endif
+	ulong fdt_data, fdt_len;
 	const char *select = NULL;
 	int		ok_no_fdt = 0;
 
@@ -345,6 +346,12 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 			fdt_addr = load;
 			break;
 #endif
+#if defined(CONFIG_ANDROID_BOOT_IMAGE)
+		case IMAGE_FORMAT_ANDROID:
+			android_image_get_dts(buf, &fdt_data, &fdt_len);
+			goto boot_fdt;
+			break;
+#endif
 		case IMAGE_FORMAT_FIT:
 			/*
 			 * This case will catch both: new uImage format
@@ -389,8 +396,6 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 	} else if (images->legacy_hdr_valid &&
 			image_check_type(&images->legacy_hdr_os_copy,
 					 IH_TYPE_MULTI)) {
-		ulong fdt_data, fdt_len;
-
 		/*
 		 * Now check if we have a legacy multi-component image,
 		 * get second entry data start address and len.
@@ -400,6 +405,10 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 
 		image_multi_getimg(images->legacy_hdr_os, 2, &fdt_data,
 				   &fdt_len);
+
+#if defined(CONFIG_ANDROID_BOOT_IMAGE)
+boot_fdt:
+#endif
 		if (fdt_len) {
 			fdt_blob = (char *)fdt_data;
 			printf("   Booting using the fdt at 0x%p\n", fdt_blob);
diff --git a/include/image.h b/include/image.h
index 61b5d3b..f475481 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1147,6 +1147,8 @@ struct andr_img_hdr;
 int android_image_check_header(const struct andr_img_hdr *hdr);
 int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
 			     ulong *os_data, ulong *os_len);
+int android_image_get_dts(const struct andr_img_hdr *hdr,
+			  ulong *dts_data, ulong *dts_len);
 int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
 			      ulong *rd_data, ulong *rd_len);
 ulong android_image_get_end(const struct andr_img_hdr *hdr);
-- 
2.8.4



More information about the U-Boot mailing list