From patchwork Tue Jan 15 14:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1025211 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; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MaIBzScQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43fCNL3sZmz9sCr for ; Wed, 16 Jan 2019 01:27:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2FAB7C21F5B; Tue, 15 Jan 2019 14:27:17 +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_H3, RCVD_IN_MSPIKE_WL, 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 9F97DC21F5B; Tue, 15 Jan 2019 14:27:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 76DFDC21F5B; Tue, 15 Jan 2019 14:27:13 +0000 (UTC) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by lists.denx.de (Postfix) with ESMTPS id C58D9C21C8B for ; Tue, 15 Jan 2019 14:27:12 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id 101so1366924pld.6 for ; Tue, 15 Jan 2019 06:27:12 -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; bh=1Mm0d1LaYhZkBQZIMN/TcsDfYbVOYid2OPIkrQD8GoU=; b=MaIBzScQvF+JKs3YNPfXme8kKkuOxfV8+2GprE4H94NNAPoqKNAHJ0VhvwkMc+JDmQ GVNtrTBO51tttRgISExW9RkB/Em03ykPVXamiK0RLMjiXdwpXhGTgG+Abh2prh8OCXVi b4JRuAzhZFu/K5NaK0Xo3ccCw7V40x78ajpeo= 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=1Mm0d1LaYhZkBQZIMN/TcsDfYbVOYid2OPIkrQD8GoU=; b=RVcKDlIEZDjFpj7SYEMFwkvwqrqGmsj1a8uhAKyCfwX4vRQ9Q4Qzc/ZZPUOGNl9vqi 93xzi3k7pe2Af9nKPIQvMnY5KlDcBArBkWBywLkWdfmWL7S0a8a/TPxqX9rTawxel2Ne my8p3oKo50oGKZ/1PMAnN/WAya7r/A2kRQAQLZL0jOHh43aw920rEbExRFIbxcr6tF3H JewZtONQD1ng3UUkbPJdEkcRWZ/1gEYXWWyyUel3rPo05dV+m1yEWu/MrfoyznbYMnWA zkaSqX4JIiXFFkI+xVTO9LtDRsf5pYoA4WgI9z8fnnnACGQ4DPrNWQ/cjUepP7KkJguJ L1MA== X-Gm-Message-State: AJcUukfqYgOGuCwKhYAuQgT6ZbtdTHQGgNscUIH//BiSdfYY6FqWw9gP P9T7P8yUFjT/O7U81qdoq53bfg== X-Google-Smtp-Source: ALg8bN7q7jq/R2+fC9Smlm0hs7rJUUPPX6h4I7SE6s+pd/6ZY/EOWb4sYn1dDfK/r7xBikuHUTDrXQ== X-Received: by 2002:a17:902:5a86:: with SMTP id r6mr4241813pli.301.1547562431182; Tue, 15 Jan 2019 06:27:11 -0800 (PST) Received: from localhost.localdomain (61-216-91-114.HINET-IP.hinet.net. [61.216.91.114]) by smtp.gmail.com with ESMTPSA id 125sm5384135pfg.39.2019.01.15.06.27.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Jan 2019 06:27:09 -0800 (PST) From: Shawn Guo To: Tom Rini Date: Tue, 15 Jan 2019 22:26:37 +0800 Message-Id: <20190115142637.13817-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] fdt: support booting with dtb in 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" Some platforms choose to store device tree blob in Android image second area. Let's try to look for dtb from there when booting an Android image, and use it for booting if found. Signed-off-by: Shawn Guo --- common/image-fdt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/image-fdt.c b/common/image-fdt.c index 95748f0ae108..57f150311392 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -230,6 +230,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, ulong load, load_end; ulong image_start, image_data, image_end; #endif + ulong img_addr; ulong fdt_addr; char *fdt_blob = NULL; void *buf; @@ -245,6 +246,9 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, *of_flat_tree = NULL; *of_size = 0; + img_addr = simple_strtoul(argv[0], NULL, 16); + buf = map_sysmem(img_addr, 0); + if (argc > 2) select = argv[2]; if (select || genimg_has_config(images)) { @@ -415,6 +419,23 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, debug("## No Flattened Device Tree\n"); goto no_fdt; } +#ifdef CONFIG_ANDROID_BOOT_IMAGE + } else if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) { + struct andr_img_hdr *hdr = buf; + ulong fdt_data, fdt_len; + + if (android_image_get_second(hdr, &fdt_data, &fdt_len) != 0) + goto no_fdt; + + fdt_blob = (char *)fdt_data; + if (fdt_check_header(fdt_blob) != 0) + goto no_fdt; + + if (fdt_totalsize(fdt_blob) != fdt_len) + goto error; + + debug("## Using FDT found in Android image second area\n"); +#endif } else { debug("## No Flattened Device Tree\n"); goto no_fdt;