All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] FDT on second address of android image
@ 2016-06-12  8:40 Michael Trimarchi
  2016-06-13 18:51 ` [U-Boot] [RFC PATCH] common: image-fdt: support dts from the " Michael Trimarchi
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Trimarchi @ 2016-06-12  8:40 UTC (permalink / raw)
  To: u-boot

This is not a patch, but just an idea of what I would like
to have. I don't know what is the best option to change
the image-fit file. So I have just tried because the boot_get_fdt
start to be a very long function and would make sense to split
in some way.
There are two point where make sense to insert this code in my
opinion. As you can see here or complicated this condition

  } else if (images->legacy_hdr_valid &&
                        image_check_type(&images->legacy_hdr_os_copy,
                                         IH_TYPE_MULTI)) {

I don't test it so far. Anyway, I have seen that some android
image (aka fsl) use this address.


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..cdcdfd3 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -345,6 +345,30 @@ 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: {
+				ulong fdt_data, fdt_len;
+				android_image_get_dts(buf, &fdt_data, &fdt_len);
+				if (fdt_len) {
+					fdt_blob = (char *)fdt_data;
+					printf("   Booting using the fdt at 0x%p\n", fdt_blob);
+
+					if (fdt_check_header(fdt_blob) != 0) {
+						fdt_error("image is not a fdt");
+						goto error;
+					}
+
+					if (fdt_totalsize(fdt_blob) != fdt_len) {
+						fdt_error("fdt size != image size");
+						goto error;
+					}
+				} else {
+					debug("## No Flattened Device Tree\n");
+					goto no_fdt;
+				}
+			}
+			break;
+#endif
 		case IMAGE_FORMAT_FIT:
 			/*
 			 * This case will catch both: new uImage format
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);
-- 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-16  7:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-12  8:40 [U-Boot] FDT on second address of android image Michael Trimarchi
2016-06-13 18:51 ` [U-Boot] [RFC PATCH] common: image-fdt: support dts from the " Michael Trimarchi
2016-06-13 19:39   ` [U-Boot] [RFC PATCH V2] " Michael Trimarchi
2016-06-13 19:53     ` [U-Boot] [RFC PATCH V3] " Michael Trimarchi
2016-06-16  0:39       ` Simon Glass
2016-06-16  7:31         ` Michael Trimarchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.