public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alex Deymo <deymo@google.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/6] image: Update include/android_image.h
Date: Sun,  2 Apr 2017 01:49:47 -0700	[thread overview]
Message-ID: <20170402084952.5102-2-deymo@google.com> (raw)
In-Reply-To: <20170402084952.5102-1-deymo@google.com>

Update the Android image header format to the latest version published
in AOSP. The original code moved to a new repository, so this patch also
updates the reference to that path.

Signed-off-by: Alex Deymo <deymo@google.com>
---
 common/image-android.c  |  9 +++++++++
 include/android_image.h | 24 +++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/common/image-android.c b/common/image-android.c
index ee03b96aaa..c668407817 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -161,6 +161,9 @@ int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
 void android_print_contents(const struct andr_img_hdr *hdr)
 {
 	const char * const p = IMAGE_INDENT_STRING;
+	/* os_version = ver << 11 | lvl */
+	u32 os_ver = hdr->os_version >> 11;
+	u32 os_lvl = hdr->os_version & ((1U << 11) - 1);
 
 	printf("%skernel size:      %x\n", p, hdr->kernel_size);
 	printf("%skernel address:   %x\n", p, hdr->kernel_addr);
@@ -170,6 +173,12 @@ void android_print_contents(const struct andr_img_hdr *hdr)
 	printf("%ssecond address:   %x\n", p, hdr->second_addr);
 	printf("%stags address:     %x\n", p, hdr->tags_addr);
 	printf("%spage size:        %x\n", p, hdr->page_size);
+	/* ver = A << 14 | B << 7 | C         (7 bits for each of A, B, C)
+	 * lvl = ((Y - 2000) & 127) << 4 | M  (7 bits for Y, 4 bits for M) */
+	printf("%sos_version:       %x (ver: %u.%u.%u, level: %u.%u)\n",
+	       p, hdr->os_version,
+	       (os_ver >> 7) & 0x7F, (os_ver >> 14) & 0x7F, os_ver & 0x7F,
+	       (os_lvl >> 4) + 2000, os_lvl & 0x0F);
 	printf("%sname:             %s\n", p, hdr->name);
 	printf("%scmdline:          %s\n", p, hdr->cmdline);
 }
diff --git a/include/android_image.h b/include/android_image.h
index 094d60afe8..dfd4d9d72c 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -1,8 +1,8 @@
 /*
  * This is from the Android Project,
- * Repository: https://android.googlesource.com/platform/bootable/bootloader/legacy
- * File: include/boot/bootimg.h
- * Commit: 4205b865141ff2e255fe1d3bd16de18e217ef06a
+ * Repository: https://android.googlesource.com/platform/system/core/
+ * File: mkbootimg/bootimg.h
+ * Commit: d162828814b08ada310846a33205befb69ef5799
  *
  * Copyright (C) 2008 The Android Open Source Project
  *
@@ -12,10 +12,13 @@
 #ifndef _ANDROID_IMAGE_H_
 #define _ANDROID_IMAGE_H_
 
+typedef struct andr_img_hdr andr_img_hdr;
+
 #define ANDR_BOOT_MAGIC "ANDROID!"
 #define ANDR_BOOT_MAGIC_SIZE 8
 #define ANDR_BOOT_NAME_SIZE 16
 #define ANDR_BOOT_ARGS_SIZE 512
+#define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
 
 struct andr_img_hdr {
 	char magic[ANDR_BOOT_MAGIC_SIZE];
@@ -31,14 +34,25 @@ struct andr_img_hdr {
 
 	u32 tags_addr;		/* physical addr for kernel tags */
 	u32 page_size;		/* flash page size we assume */
-	u32 unused[2];		/* future expansion: should be 0 */
+	u32 unused;		/* reserved for future expansion: MUST be 0 */
+
+	/* operating system version and security patch level; for
+	 * version "A.B.C" and patch level "Y-M-D":
+	 * ver = A << 14 | B << 7 | C         (7 bits for each of A, B, C)
+	 * lvl = ((Y - 2000) & 127) << 4 | M  (7 bits for Y, 4 bits for M)
+	 * os_version = ver << 11 | lvl */
+	u32 os_version;
 
 	char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
 
 	char cmdline[ANDR_BOOT_ARGS_SIZE];
 
 	u32 id[8]; /* timestamp / checksum / sha1 / etc */
-};
+
+	/* Supplemental command line data; kept here to maintain
+	 * binary compatibility with older versions of mkbootimg */
+	char extra_cmdline[ANDR_BOOT_EXTRA_ARGS_SIZE];
+} __attribute__((packed));
 
 /*
  * +-----------------+
-- 
2.12.2.564.g063fe858b8-goog

  reply	other threads:[~2017-04-02  8:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a74b3d5e65b4bf5c2edca98bba9e678be762ebe7>
2017-04-02  8:49 ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Alex Deymo
2017-04-02  8:49   ` Alex Deymo [this message]
2017-04-02  8:49     ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Alex Deymo
2017-04-02  8:49       ` [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images Alex Deymo
2017-04-02  8:49         ` [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name() Alex Deymo
2017-04-02  8:49           ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Alex Deymo
2017-04-02  8:49             ` [U-Boot] [PATCH 6/6] cmd: Add "boot_android" command Alex Deymo
2017-04-04 14:46               ` Lukasz Majewski
2017-04-09 19:27             ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Simon Glass
2017-04-06 22:42           ` [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name() Simon Glass
2017-05-12 17:18           ` [U-Boot] [U-Boot, " Tom Rini
2017-04-06 22:42         ` [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images Simon Glass
2017-04-06 22:42       ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Simon Glass
2017-04-06 22:42     ` [U-Boot] [PATCH 1/6] image: Update include/android_image.h Simon Glass
2017-05-12 17:18     ` [U-Boot] [U-Boot,1/6] " Tom Rini
2017-04-19  8:42   ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Kever Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170402084952.5102-2-deymo@google.com \
    --to=deymo@google.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox