From patchwork Thu Aug 16 20:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 958593 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="EEr/1VVe"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41ryk01blYz9s47 for ; Fri, 17 Aug 2018 06:34:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F3A27C21E1A; Thu, 16 Aug 2018 20:34:21 +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_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 EC1ADC21C57; Thu, 16 Aug 2018 20:34:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0F243C21C57; Thu, 16 Aug 2018 20:34:15 +0000 (UTC) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by lists.denx.de (Postfix) with ESMTPS id 91862C21C38 for ; Thu, 16 Aug 2018 20:34:15 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id j8-v6so4355359lfb.4 for ; Thu, 16 Aug 2018 13:34:15 -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=I2OUxI1oH0x7w6ssavSCtMWBMW7Ht/ibdBj+xTu5NKA=; b=EEr/1VVeBEIBPof15Ccp36YLi0VBnKraU7Azdbh89xP6PjOWbS6QDIUY8y4p+kYdcj wRkEXqDXOnmJ8/yxMJ/UBXVBsZAnXkvZH/RnxZZ/q80Bmw+nOBd22mxNmCFIEQ79RfNs agVOP0tJjvKbNZcvLsrGVv1nwOStrKqzG3p7s= 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=I2OUxI1oH0x7w6ssavSCtMWBMW7Ht/ibdBj+xTu5NKA=; b=OlxWUBusMHvvmY7pKDalu9dlxHwVWg1qn0LEcEpxtcvVa1VEv5N3TiyBNAOEIYn9/X +e4BvebrmeXiRIQG4ltkHWSkqOPJ2FG9vOphrhnTVkFEBrBQDWiF+3JvM4qRIyUZbmWY R/g/xKzPtyK5Qh5J2dFQaBFYp0EznC1ME6Kkt8gpLLT77hzeAYbdzHDkX5A+GlDmzklM vWMLkl+KS5bkovB1fxya9lFuWZJDugCzf6OoGg4FUgmwDcsPmJeczjR8v3s8tuhY0nPw qmQvhAwE7BdXrZ2cON1+lmisuwBa+WJb7cViwskDe176aEZFuVpUkuLqk5oQO++7UHZt eJEQ== X-Gm-Message-State: AOUpUlEATkbJOlaxXZzPvsSSaZAWdtJeDL90TbH9hQzUhzsOOudBY9fV m/hSAY9UZpL6K0sNf92rGhKfXDdpZ8o= X-Google-Smtp-Source: AA+uWPwo3jP42NUHLjy5e1qI05WHCjUapYNtVuHlh1DvSTxcij2wtC61YgIVfbEtqG0skNo26gDsmA== X-Received: by 2002:a19:4c57:: with SMTP id z84-v6mr20878509lfa.67.1534451654604; Thu, 16 Aug 2018 13:34:14 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id u84-v6sm49617lff.35.2018.08.16.13.34.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Aug 2018 13:34:13 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 16 Aug 2018 23:34:12 +0300 Message-Id: <20180816203413.1598-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: Tom Rini , Sandeep Patil , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v4 1/2] common: Add support for Android DT 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" Android documentation recommends new image format for storing DTB/DTBO files: [1]. To support that format, this patch adds helper functions for Android DTB/DTBO format. In image-android-dt.* files you can find helper functions to work with Android DT image format, such us routines for: - printing the dump of image structure - getting the address and size of desired dtb/dtbo file This patch uses dt_table.h file, that was added in commit 643cefa4d848 ("Import Android's dt_table.h for DT image format") by Alex Deymo. [1] https://source.android.com/devices/architecture/dto/partitions Signed-off-by: Sam Protsenko Reviewed-by: Tom Rini --- Changes in v4: - fix SPDX tags - renamed .reserved[] to .version (just reflect changes in dt_image.h) Changes in v3: - dropped include/dt_image.h (was sent in another patch by Alex Deymo) - rebased on top of last master common/image-android-dt.c | 156 +++++++++++++++++++++++++++++++++++++ include/image-android-dt.h | 20 +++++ 2 files changed, 176 insertions(+) create mode 100644 common/image-android-dt.c create mode 100644 include/image-android-dt.h diff --git a/common/image-android-dt.c b/common/image-android-dt.c new file mode 100644 index 0000000000..c0683ee70f --- /dev/null +++ b/common/image-android-dt.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 Linaro Ltd. + * Sam Protsenko + */ + +#include +#include +#include +#include +#include + +/** + * Check if image header is correct. + * + * @param hdr_addr Start address of DT image + * @return true if header is correct or false if header is incorrect + */ +bool android_dt_check_header(ulong hdr_addr) +{ + const struct dt_table_header *hdr; + u32 magic; + + hdr = map_sysmem(hdr_addr, sizeof(*hdr)); + magic = fdt32_to_cpu(hdr->magic); + unmap_sysmem(hdr); + + return magic == DT_TABLE_MAGIC; +} + +/** + * Get the address of FDT (dtb or dtbo) in memory by its index in image. + * + * @param hdr_addr Start address of DT image + * @param index Index of desired FDT in image (starting from 0) + * @param[out] addr If not NULL, will contain address to specified FDT + * @param[out] size If not NULL, will contain size of specified FDT + * + * @return true on success or false on error + */ +bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr, + u32 *size) +{ + const struct dt_table_header *hdr; + const struct dt_table_entry *e; + u32 entry_count, entries_offset, entry_size; + ulong e_addr; + u32 dt_offset, dt_size; + + hdr = map_sysmem(hdr_addr, sizeof(*hdr)); + entry_count = fdt32_to_cpu(hdr->dt_entry_count); + entries_offset = fdt32_to_cpu(hdr->dt_entries_offset); + entry_size = fdt32_to_cpu(hdr->dt_entry_size); + unmap_sysmem(hdr); + + if (index > entry_count) { + printf("Error: index > dt_entry_count (%u > %u)\n", index, + entry_count); + return false; + } + + e_addr = hdr_addr + entries_offset + index * entry_size; + e = map_sysmem(e_addr, sizeof(*e)); + dt_offset = fdt32_to_cpu(e->dt_offset); + dt_size = fdt32_to_cpu(e->dt_size); + unmap_sysmem(e); + + if (addr) + *addr = hdr_addr + dt_offset; + if (size) + *size = dt_size; + + return true; +} + +#if !defined(CONFIG_SPL_BUILD) +static void android_dt_print_fdt_info(const struct fdt_header *fdt) +{ + u32 fdt_size; + int root_node_off; + const char *compatible = NULL; + + fdt_size = fdt_totalsize(fdt); + root_node_off = fdt_path_offset(fdt, "/"); + if (root_node_off < 0) { + printf("Error: Root node not found\n"); + } else { + compatible = fdt_getprop(fdt, root_node_off, "compatible", + NULL); + } + + printf(" (FDT)size = %d\n", fdt_size); + printf(" (FDT)compatible = %s\n", + compatible ? compatible : "(unknown)"); +} + +/** + * Print information about DT image structure. + * + * @param hdr_addr Start address of DT image + */ +void android_dt_print_contents(ulong hdr_addr) +{ + const struct dt_table_header *hdr; + u32 entry_count, entries_offset, entry_size; + u32 i; + + hdr = map_sysmem(hdr_addr, sizeof(*hdr)); + entry_count = fdt32_to_cpu(hdr->dt_entry_count); + entries_offset = fdt32_to_cpu(hdr->dt_entries_offset); + entry_size = fdt32_to_cpu(hdr->dt_entry_size); + + /* Print image header info */ + printf("dt_table_header:\n"); + printf(" magic = %08x\n", fdt32_to_cpu(hdr->magic)); + printf(" total_size = %d\n", fdt32_to_cpu(hdr->total_size)); + printf(" header_size = %d\n", fdt32_to_cpu(hdr->header_size)); + printf(" dt_entry_size = %d\n", entry_size); + printf(" dt_entry_count = %d\n", entry_count); + printf(" dt_entries_offset = %d\n", entries_offset); + printf(" page_size = %d\n", fdt32_to_cpu(hdr->page_size)); + printf(" version = %d\n", fdt32_to_cpu(hdr->version)); + + unmap_sysmem(hdr); + + /* Print image entries info */ + for (i = 0; i < entry_count; ++i) { + const ulong e_addr = hdr_addr + entries_offset + i * entry_size; + const struct dt_table_entry *e; + const struct fdt_header *fdt; + u32 dt_offset, dt_size; + u32 j; + + e = map_sysmem(e_addr, sizeof(*e)); + dt_offset = fdt32_to_cpu(e->dt_offset); + dt_size = fdt32_to_cpu(e->dt_size); + + printf("dt_table_entry[%d]:\n", i); + printf(" dt_size = %d\n", dt_size); + printf(" dt_offset = %d\n", dt_offset); + printf(" id = %08x\n", fdt32_to_cpu(e->id)); + printf(" rev = %08x\n", fdt32_to_cpu(e->rev)); + for (j = 0; j < 4; ++j) { + printf(" custom[%d] = %08x\n", j, + fdt32_to_cpu(e->custom[j])); + } + + unmap_sysmem(e); + + /* Print FDT info for this entry */ + fdt = map_sysmem(hdr_addr + dt_offset, sizeof(*fdt)); + android_dt_print_fdt_info(fdt); + unmap_sysmem(fdt); + } +} +#endif diff --git a/include/image-android-dt.h b/include/image-android-dt.h new file mode 100644 index 0000000000..9a3aa8fa30 --- /dev/null +++ b/include/image-android-dt.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2018 Linaro Ltd. + * Sam Protsenko + */ + +#ifndef IMAGE_ANDROID_DT_H +#define IMAGE_ANDROID_DT_H + +#include + +bool android_dt_check_header(ulong hdr_addr); +bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr, + u32 *size); + +#if !defined(CONFIG_SPL_BUILD) +void android_dt_print_contents(ulong hdr_addr); +#endif + +#endif /* IMAGE_ANDROID_DT_H */ From patchwork Thu Aug 16 20:34:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 958594 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="TdH81NcD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41rykw5Zd9z9s47 for ; Fri, 17 Aug 2018 06:35:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7221EC21E1A; Thu, 16 Aug 2018 20:34:45 +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_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 ADBCAC21DF3; Thu, 16 Aug 2018 20:34:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7199EC21C57; Thu, 16 Aug 2018 20:34:17 +0000 (UTC) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by lists.denx.de (Postfix) with ESMTPS id 10F88C21C38 for ; Thu, 16 Aug 2018 20:34:17 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id u7-v6so4706571lji.3 for ; Thu, 16 Aug 2018 13:34:17 -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:in-reply-to:references; bh=DDj1n+5+WElJh1nzJXtI2QbWkeOxJC6P8+wDN581Qbk=; b=TdH81NcDu3zHBn9nleL0qym+1aPW+JK7e5AtT6D4AuK7Vg5jdyliMZDLq1CASNxF0W GFSH/2zGQ5QoQTVLC9xVhhkr9HGKiy1q8ZTh580EsgSdfF1c+Vu1PlB8g6SYSTIm9IUX dq9eP48W45tENBeI8CE5iEICw3yWi7uI9rikI= 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=DDj1n+5+WElJh1nzJXtI2QbWkeOxJC6P8+wDN581Qbk=; b=Ehp85FE7OupqeDhuLWJAOX+iHCU1vVb9TKxFNFaaFxtkcLs5xf0g0C7//rYtACptdV YFnGcvcR6tk8AKVAe2zYVm2ruHP4YDn29sQnu+/mcgT93z7QDfDex6viMwi4yW/pdJIJ rL6dfx9JU2xHqRiaHPrAIjB0FmdU7F7KXLhycbNiSbrK0Lf1aLz2vzGzROPWnNLYNQ3e XXrZCW/SIuk13I7Zx6sFKfEHfEfvfuu2NMUQGyCJkSFvVpsVPxHCDqNQdaFyFkTzWVlA /UzIHVkfbqyHkt3OA0Q6tKa9x/YuITBCMCqLTVrNQnKBYY71E2WpPb8olaPGqmp0KIl3 0kUA== X-Gm-Message-State: AOUpUlEoH3Fs9HYPfPhWfXRPZrvo7FirZQiPdnFEkkt4K506MyCI951F 0/R6ec7nmz3Pr+69JJ5RQeXUgjbV62I= X-Google-Smtp-Source: AA+uWPxIpO0y2vQGPGhQF7Wdoy4vVPTskcrl3gkq2JWRAPrgod4EOmEa+As85QB8ArY4Kcahy0zIeA== X-Received: by 2002:a2e:2f19:: with SMTP id v25-v6mr18227788ljv.113.1534451656230; Thu, 16 Aug 2018 13:34:16 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id 66-v6sm39668ljz.8.2018.08.16.13.34.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Aug 2018 13:34:15 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 16 Aug 2018 23:34:13 +0300 Message-Id: <20180816203413.1598-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180816203413.1598-1-semen.protsenko@linaro.org> References: <20180816203413.1598-1-semen.protsenko@linaro.org> Cc: Tom Rini , Sandeep Patil , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v4 2/2] cmd: Add dtimg command 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" dtimg command allows user to work with Android DTB/DTBO image format. Such as, getting the address of desired DTB/DTBO file, printing the dump of the image in U-Boot shell, etc. This command is needed to provide Android boot with new Android DT image format further. Signed-off-by: Sam Protsenko Reviewed-by: Tom Rini --- Changes in v4: - rebased - fixed SPDX tags - use obj-$(CONFIG_CMD_DTIMG) instead #ifdef cmd/Kconfig | 8 +++ cmd/Makefile | 1 + cmd/dtimg.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++ common/Makefile | 2 + 4 files changed, 152 insertions(+) create mode 100644 cmd/dtimg.c diff --git a/cmd/Kconfig b/cmd/Kconfig index bd90946667..b9215abae3 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -254,6 +254,14 @@ config CMD_BOOTMENU help Add an ANSI terminal boot menu command. +config CMD_DTIMG + bool "dtimg" + help + Android DTB/DTBO image manipulation commands. Read dtb/dtbo files from + image into RAM, dump image structure information, etc. Those dtb/dtbo + files should be merged in one dtb further, which needs to be passed to + the kernel, as part of a boot process. + config CMD_ELF bool "bootelf, bootvx" default y diff --git a/cmd/Makefile b/cmd/Makefile index 12d2118f1d..b1206fca85 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -43,6 +43,7 @@ ifdef CONFIG_POST obj-$(CONFIG_CMD_DIAG) += diag.o endif obj-$(CONFIG_CMD_DISPLAY) += display.o +obj-$(CONFIG_CMD_DTIMG) += dtimg.o obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o obj-$(CONFIG_CMD_EEPROM) += eeprom.o diff --git a/cmd/dtimg.c b/cmd/dtimg.c new file mode 100644 index 0000000000..65c8d101b9 --- /dev/null +++ b/cmd/dtimg.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 Linaro Ltd. + * Sam Protsenko + */ + +#include +#include + +enum cmd_dtimg_info { + CMD_DTIMG_START = 0, + CMD_DTIMG_SIZE, +}; + +static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + char *endp; + ulong hdr_addr; + + if (argc != 2) + return CMD_RET_USAGE; + + hdr_addr = simple_strtoul(argv[1], &endp, 16); + if (*endp != '\0') { + printf("Error: Wrong image address\n"); + return CMD_RET_FAILURE; + } + + if (!android_dt_check_header(hdr_addr)) { + printf("Error: DT image header is incorrect\n"); + return CMD_RET_FAILURE; + } + + android_dt_print_contents(hdr_addr); + + return CMD_RET_SUCCESS; +} + +static int dtimg_get_fdt(int argc, char * const argv[], enum cmd_dtimg_info cmd) +{ + ulong hdr_addr; + u32 index; + char *endp; + ulong fdt_addr; + u32 fdt_size; + char buf[65]; + + if (argc != 4) + return CMD_RET_USAGE; + + hdr_addr = simple_strtoul(argv[1], &endp, 16); + if (*endp != '\0') { + printf("Error: Wrong image address\n"); + return CMD_RET_FAILURE; + } + + if (!android_dt_check_header(hdr_addr)) { + printf("Error: DT image header is incorrect\n"); + return CMD_RET_FAILURE; + } + + index = simple_strtoul(argv[2], &endp, 0); + if (*endp != '\0') { + printf("Error: Wrong index\n"); + return CMD_RET_FAILURE; + } + + if (!android_dt_get_fdt_by_index(hdr_addr, index, &fdt_addr, &fdt_size)) + return CMD_RET_FAILURE; + + switch (cmd) { + case CMD_DTIMG_START: + snprintf(buf, sizeof(buf), "%lx", fdt_addr); + break; + case CMD_DTIMG_SIZE: + snprintf(buf, sizeof(buf), "%x", fdt_size); + break; + default: + printf("Error: Unknown cmd_dtimg_info value: %d\n", cmd); + return CMD_RET_FAILURE; + } + + env_set(argv[3], buf); + + return CMD_RET_SUCCESS; +} + +static int do_dtimg_start(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return dtimg_get_fdt(argc, argv, CMD_DTIMG_START); +} + +static int do_dtimg_size(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return dtimg_get_fdt(argc, argv, CMD_DTIMG_SIZE); +} + +static cmd_tbl_t cmd_dtimg_sub[] = { + U_BOOT_CMD_MKENT(dump, 2, 0, do_dtimg_dump, "", ""), + U_BOOT_CMD_MKENT(start, 4, 0, do_dtimg_start, "", ""), + U_BOOT_CMD_MKENT(size, 4, 0, do_dtimg_size, "", ""), +}; + +static int do_dtimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + cmd_tbl_t *cp; + + cp = find_cmd_tbl(argv[1], cmd_dtimg_sub, ARRAY_SIZE(cmd_dtimg_sub)); + + /* Strip off leading 'dtimg' command argument */ + argc--; + argv++; + + if (!cp || argc > cp->maxargs) + return CMD_RET_USAGE; + if (flag == CMD_FLAG_REPEAT && !cp->repeatable) + return CMD_RET_SUCCESS; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + dtimg, CONFIG_SYS_MAXARGS, 0, do_dtimg, + "manipulate dtb/dtbo Android image", + "dump \n" + " - parse specified image and print its structure info\n" + " : image address in RAM, in hex\n" + "dtimg start \n" + " - get address (hex) of FDT in the image, by index\n" + " : image address in RAM, in hex\n" + " : index of desired FDT in the image\n" + " : name of variable where to store address of FDT\n" + "dtimg size \n" + " - get size (hex, bytes) of FDT in the image, by index\n" + " : image address in RAM, in hex\n" + " : index of desired FDT in the image\n" + " : name of variable where to store size of FDT" +); diff --git a/common/Makefile b/common/Makefile index 7100541ece..7473b85011 100644 --- a/common/Makefile +++ b/common/Makefile @@ -108,6 +108,8 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o obj-y += stdio.o +obj-$(CONFIG_CMD_DTIMG) += image-android-dt.o + ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o endif