From patchwork Tue Jul 11 05:56:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Chen X-Patchwork-Id: 107479 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp695744qge; Wed, 12 Jul 2017 04:40:21 -0700 (PDT) X-Received: by 10.80.154.131 with SMTP id p3mr5842975edb.181.1499859621292; Wed, 12 Jul 2017 04:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499859621; cv=none; d=google.com; s=arc-20160816; b=GlrzFJYN9EA0tCJ33iZocciBqAl5AN3ZksoKQlukCyJYBxAsGz6tOMCLgTfXZoeWte 7M+vSunFreKda8evIFtnMXvdghBXg9qyIIzYfL7nleB0vwB7D4ggtOOCpDBhh3vfpPmV /LIqwb1G3iIijZ5Vv26tWAaMqxmSq8GhXBH7+6x2dFAZWJFyKXC1TUoglCaxi0gGTKed 2r1XGfmdTYAJrdh1Ca+lRWJRV00DT0GZwrxQNWaXFBDSvCIMj0rJhbRqOI55dEjEEWef Di8U4p2KPCBfZCsiNWoR270TnNzkGT2vVljkDhX3PqDvFuayABIJS2WmRTo/tXks+3bD mtEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=y30+UczLyyGW/zHElh1TJDH1ej1SptFb1Ej4qfoPOQ0=; b=V73Os8xsH2oBO9yueF0ihE+BqK4WeEIhujT4zSWUzLF+rqFK8aaLgvkclLMI6UBH4n fSOnMKivQhjBrfymdgGc1Abacnu25uScJ0aJG5FEGxIW2CDMuLuTtZi0JqyPbErEfb1J A7zU+wTq5gLB9sAJkTtDeu5U+1qfRgzmgobuCVPOB77OcVSTEFbuEnyz3Z2zOXm95Zms dvuFPa6dy059qw9UCREFn0UaQEpH8Nf8hrhoigwfsI0z6cIwz+zFEG3tMsoYz0rcWRo+ HTA7y8Db0O8s+ZAZvhrHG4wwZgT8aJ5q1tzOoGyD+lW8q96wCvxtuAPXG9JXIFB+f8L2 ydEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=N0791qev; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id a90si1248162edf.164.2017.07.12.04.40.21; Wed, 12 Jul 2017 04:40:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=N0791qev; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id A5B98C21DED; Wed, 12 Jul 2017 11:38:52 +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_NONE, 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 A5798C21F28; Wed, 12 Jul 2017 11:38:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8DA7CC21C61; Tue, 11 Jul 2017 05:56:21 +0000 (UTC) Received: from mail-pg0-f48.google.com (mail-pg0-f48.google.com [74.125.83.48]) by lists.denx.de (Postfix) with ESMTPS id 71883C21C4C for ; Tue, 11 Jul 2017 05:56:20 +0000 (UTC) Received: by mail-pg0-f48.google.com with SMTP id j186so60953702pge.2 for ; Mon, 10 Jul 2017 22:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=hKZvB8kXWqlekexeYbAc3ljNBbavF/ptr4uO3h0EBns=; b=N0791qev8SBjxaCuUVVaYeV85d/IFjHv+H2nF7NxBQmes2auYC7+F1wqeHrmlsBLWN sWGnC/b4bZIBWhg9kdqhe0p36XBBSnQX/dEbJNMKjHxSXJscuzNM0mUYuYX3ztPLoMQo FzOLBT9ttoTg/maSxpm/dyQc/w6q9gt0fPuNo= 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; bh=hKZvB8kXWqlekexeYbAc3ljNBbavF/ptr4uO3h0EBns=; b=GVpP4jglwOZMLpK+XfAzOrk9XOuOulUqxTzbyTqZ5lYZcy53Pr9CS87yFfFnbcUuWx 21FAXW4sZfdBxFqQ5O6PozINzxL7kkaP9R404VJ3Ex14B5H9Vah8ADTitu0MnKfxABY8 IaVxZCNCraqf1tNTOUlxaYxQauKhJoWJex8MeIhKixDsWa0xt4NQllqZhtNog/ZoVtCa TFLu7Emwugd3s1kPfNgK9hR/ddaSoA1as98mKI2vVxte0azEzaNOE7Evd4cytpK5+rKA eIX22m7uxJQHcJojkHqBnln1n7fEcVWDkwh0HOGwVJKEbqGQepdwyf9lpAAb1mV+0SER aNng== X-Gm-Message-State: AIVw112RTnrIOM7AhPuqrWtB2BtDXYgYQKjnF2g5lkPG8kth0uDjLD9k cHsoxTY4k0EhSvUBv880EA== X-Received: by 10.98.66.198 with SMTP id h67mr843185pfd.2.1499752578714; Mon, 10 Jul 2017 22:56:18 -0700 (PDT) Received: from localhost.localdomain (c110-21-50-193.carlnfd1.nsw.optusnet.com.au. [110.21.50.193]) by smtp.gmail.com with ESMTPSA id 75sm30305866pfk.84.2017.07.10.22.56.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 22:56:17 -0700 (PDT) From: Bin Chen To: u-boot@lists.denx.de Date: Tue, 11 Jul 2017 15:56:03 +1000 Message-Id: <1499752564-10488-1-git-send-email-bin.chen@linaro.org> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Wed, 12 Jul 2017 11:38:13 +0000 Cc: rob.herring@linaro.org, daniel.thompson@linaro.org, john.stultz@linaro.org, elder@linaro.org, jorge.ramirez-ortiz@linaro.org Subject: [U-Boot] [PATCH 1/2] [rfc] 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 --- 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 ee03b96..7daa5fa 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 3f26f9b..8264c52 100644 --- a/include/image.h +++ b/include/image.h @@ -1237,6 +1237,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);