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: 126024 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp840438ljd; Fri, 26 Jan 2018 22:00:46 -0800 (PST) X-Google-Smtp-Source: AH8x227IsVY5abZ5WQArHxcpplN49w7G64hu3F4RPZZCucwMOml9p2OUi8OwwrOlZCqhySvqMlQx X-Received: by 10.80.151.155 with SMTP id e27mr38179442edb.108.1517032845966; Fri, 26 Jan 2018 22:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517032845; cv=none; d=google.com; s=arc-20160816; b=Aq7zJL62CGzTTJBkzIUwyDCeiEfyF3RkI6QJaJ2nnzQ8D5hkTM709rFQ+ju9z+uklP RzlcCjtLFCtZhnvmqqcxCNXHyPxyCcT3WnCWZy9zQoa90vvQy2ofuo4Re1Q96F5i2/vD kaK4GKcNhukHOgkzkMwGnPKlFd6Mf8Zt6LW2itfwS8ogw1vm7UJEaKw6S+rvqr6koD+t GThG3iE5Ax/0ltSkFHdkuCc1zO4xiNnG5QTXT2OkqBV5cKMdE/bAauYrxljLF+SdVAkF SYclBD5n9f8Hy2YVr/9ChSK7KgqrGI3kYWzsdeZhtuxEqdv5fG7SjfTPRP13kJUxuVjc 2IMw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=kBboDVedihZRJQhiUd6FPjkVds3r0In8y7pekf0PcNU=; b=IHx9s7R6Jcd8l7M8/Qg59cJSuRvrnYvGgZd7L7KXZCjLrvGAeWEHOJZdE/mr61teMf Gnu5RKXYWKp6yaPszjoGqpCKfjV5UYJyRNMX39lsJsbmuPvrOi8XpumvoM88aH6KlVvn K5iJ0LPONmo5sz4MxdMWfQXF/Dc6MobDQTvCjvYVpozdZwk/dhLrNvRmsh0owks2YvKi TOrjxn3Z0ZkFwlN57lZ+wbWrtoJz0P6kSbfWv/VKD74smzPcaBB7xaif+WwSZcedxfrk IlPVXEqEiY6xDM+LVebe2sX2VdctXbq7G1mNdjG6voMlo5iSBwxspUHRk2+Qrgmddl+5 /Egg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Qejhqlpg; 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 m2si3064775edf.99.2018.01.26.22.00.45; Fri, 26 Jan 2018 22:00:45 -0800 (PST) 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.s=google header.b=Qejhqlpg; 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 8C6BFC21E6C; 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-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);