From patchwork Sat Jan 27 05:59:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Chen X-Patchwork-Id: 866712 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Qejhqlpg"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zT4rT2nw7z9sPk for ; Sat, 27 Jan 2018 17:00:41 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 03629C21FAB; Sat, 27 Jan 2018 06:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 38BC8C21E41; Sat, 27 Jan 2018 06:00:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D4ED4C21F91; Sat, 27 Jan 2018 05:59:47 +0000 (UTC) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by lists.denx.de (Postfix) with ESMTPS id B8974C21E41 for ; Sat, 27 Jan 2018 05:59:44 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id b25so1551586pfd.9 for ; Fri, 26 Jan 2018 21:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=toOa7gVFweBgZgf5q7BKpYgZ0JQ6JDVhBsesJThG8Ko=; b=QejhqlpgBb1vxmoGe06JTeWRIxblAKYRnTzpxM2toPPqFzOKC2HR0tJdIljDYSPzkG /b7Xw9EHcSTRDUtFZiQyR6NR2qnnxKNpgiXAmFsYwSb7COyKsolYFDlyh/w71KPeucko wo2RZz9G28uAsPyJCYcrLogeYYTPIZ8N6IYm4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=toOa7gVFweBgZgf5q7BKpYgZ0JQ6JDVhBsesJThG8Ko=; b=lEWI6q3cMur9hOxYhlVkoV2A1m6xiIRvoiAdXEdy4TK6n8nIxwNtTPypfhC6R6bbP9 B6GL1pUy6RxyhyzOu486Q51bbLm7I+TBEjIheALDs12W0LTt3fEp/M6zKTSbQFPtfnKo 6z7f0MBnTzcRaGaJ8/fC2Ck2z7be9FUGbk+sswup8mThHYP7giNbBg0rwT4FNB4KsX3+ G/30VsEbARiv/2DjJsHBAkWmd5WhklCXhYaYO+K3r9cTeHQHetvpE5deLUmqD9sRfmIa ummYuT+37hYG+mPYbG1HGxPWL90HZ0M/CFZzRr3/GLC2uBgO31yCt5Goe4yvOswPPuGd 93Kw== X-Gm-Message-State: AKwxytc1HCVQRdEWWX7xPh1MR4JExRwaDRahjRBn0BLrgAMCpKTCa0fj pe/FozW0fFr8TGRRsaLjLxPGcuWDqE8= X-Google-Smtp-Source: AH8x227hDJUI+sGjK6O1yYYnlZqEGrs0qZLmK35OVjHe4+07XhA+vj1cru2h7tB1u7drk6rfLhvsfQ== X-Received: by 10.99.170.73 with SMTP id x9mr17260808pgo.393.1517032783279; Fri, 26 Jan 2018 21:59:43 -0800 (PST) Received: from localhost.localdomain (c27-253-115-177.carlnfd2.nsw.optusnet.com.au. [27.253.115.177]) by smtp.gmail.com with ESMTPSA id 184sm18395035pfg.87.2018.01.26.21.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 21:59:42 -0800 (PST) From: Bin Chen To: u-boot@lists.denx.de, trini@konsulko.com Date: Sat, 27 Jan 2018 16:59:08 +1100 Message-Id: <20180127055909.12962-2-bin.chen@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180127055909.12962-1-bin.chen@linaro.org> References: <20180127055909.12962-1-bin.chen@linaro.org> Cc: rob.herring@linaro.org Subject: [U-Boot] [PATCH 1/2] parse the second area of android image X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The second area of android image was intended to put a 2nd stage bootloader but in practice were rarely used (in my knowledge). An proposal was made to the AOSP to (re)use the second area as the dtb[1], This patch itself doesn't depend on that proposal being accepted but it won't be that helpful as well if that proposal won't be accepted. But don't do any harm as well. [1] https://android-review.googlesource.com/#/c/417447/ Signed-off-by: Bin Chen Reviewed-by: Tom Rini Reviewed-by: Kever Yang --- common/image-android.c | 19 +++++++++++++++++++ include/image.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/common/image-android.c b/common/image-android.c index e74d0aafca..5ad3a1fa38 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -146,6 +146,25 @@ int android_image_get_ramdisk(const struct andr_img_hdr *hdr, return 0; } +int android_image_get_second(const struct andr_img_hdr *hdr, + ulong *second_data, ulong *second_len) +{ + if (!hdr->second_size) { + *second_data = *second_len = 0; + return -1; + } + + *second_data = (unsigned long)hdr; + *second_data += hdr->page_size; + *second_data += ALIGN(hdr->kernel_size, hdr->page_size); + *second_data += ALIGN(hdr->ramdisk_size, hdr->page_size); + + printf("second address is 0x%lx\n",*second_data); + + *second_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/include/image.h b/include/image.h index b2b23a96f1..c8ce4da901 100644 --- a/include/image.h +++ b/include/image.h @@ -1263,6 +1263,8 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, ulong *os_data, ulong *os_len); int android_image_get_ramdisk(const struct andr_img_hdr *hdr, ulong *rd_data, ulong *rd_len); +int android_image_get_second(const struct andr_img_hdr *hdr, + ulong *second_data, ulong *second_len); ulong android_image_get_end(const struct andr_img_hdr *hdr); ulong android_image_get_kload(const struct andr_img_hdr *hdr); void android_print_contents(const struct andr_img_hdr *hdr);