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: 155673 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4953477jaa; Tue, 15 Jan 2019 06:27:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN7KYTFhB82kAiFvQ/9FMnhJldJJHjrTwh8fndqNZ6fVQBO8glHzO4Hv6kTzHCs1YnSygR2j X-Received: by 2002:aa7:d416:: with SMTP id z22mr3607627edq.3.1547562438269; Tue, 15 Jan 2019 06:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547562438; cv=none; d=google.com; s=arc-20160816; b=y5XcG/Rdhc4YgD9evUgjFcdaDnCjXPSZVr82g5mG723FPuBs/8xmRFR/1tRqwXyWZ6 1fPHQJcZWcb15YPDa4O4/bQKJ/M7kGF+YC6QPX56KJ9j2a40ZWER0yTIl68YeZ8x2rjB 9Dey/Vx64nsgkHxc4jN8E497UV0woRzRji1Zgw0OGHWAlrraVOjTUO3VjaSCY63qC0+U 3SdsXoGHTvPUfG1WBgfkn8MoqLK2sZ8pbvs5OuKHXDxO2CC2BgAQgln6m4kc1DhqVjWn XtIb7Drq8fNsohrZPVXepFD45CF431BPKKMW5s4mpFrcDxzMoOO2q39ELeO8RpBr/L4K Wy2A== 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; bh=tLD81MfL6FnH3EW+wLNiXp/n0k+6pdKzcSgEpGQdlSU=; b=wOf28t2qkRs6Z/RKUKTokk+7dtfU3J7SYc7jWq+iBkh6UuUYnGp/I7mTTvlL/UF3MB CAABBr4ZzmfoIjMf+L0PicQ1c05mCY2x2krmynA/UuEknTve2wHz2Z4qchaXwWyXHfeR cI/V+yT7nXGVAhF4T60g9+L+55vIekdnyCdc/R/Vf+hDu+8NmTXJHptV7yWek0Yt7g/i G0gtMU9efb9sYk6L3AiXnrTH11d7WZsuJM3s8ekEA7O/UzcK0M6C8BOxbD4aJUdKaZkP JU66VOeK612OJmmF2J6XghyHfKhHgXbbwRMEhreWpYTKKpUG0SOFa8n8XLeNe/6Dqzsw qzcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MaIBzScQ; 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 ci26-v6si2498694ejb.48.2019.01.15.06.27.16; Tue, 15 Jan 2019 06:27:18 -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=MaIBzScQ; 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 93B53C22058; Tue, 15 Jan 2019 14:27:16 +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-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;