From patchwork Thu Sep 19 17:28:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164768 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eEM39cOQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3ks4nCkz9sNw for ; Fri, 20 Sep 2019 03:29:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3720FC21D83; Thu, 19 Sep 2019 17:29:10 +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_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 A75C3C21DD3; Thu, 19 Sep 2019 17:29:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5DDEDC21DF8; Thu, 19 Sep 2019 17:28:41 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by lists.denx.de (Postfix) with ESMTPS id 6EBBFC21C3F for ; Thu, 19 Sep 2019 17:28:40 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id y5so2760621pfo.4 for ; Thu, 19 Sep 2019 10:28:40 -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 :mime-version:content-transfer-encoding; bh=hmaF9yQWs1ftjCGt2ho+ufNx3HU5VU9tMugrbyxomKA=; b=eEM39cOQBvRGBwY5MW/XVjJ/V1SVEVd+wWJIhfBJHVDvx0UnUN2kcpbhVJfxzGzzSm YuD1YuzTFUR7l38K3hFfJb4Jx5flV+VSfPN7KOSZENCcqAaefiK4072q787sivT4zVIx 69NEec2NyVXaID2UbWX7GWTh8kaJBQ1hRFKTayIe253LrIhIws9bZLv6wtp9ebCPkZlG NfqaicLVKULYna+9sachDISmxUtYYHE1R3SZx9v9AAOFraX4/U0t6OC1SaH8FscU0N1O 4DZYhg72Zzfa4hqU0Vx+H581TS9fgunhmHIjc3LRuo9Ln4+oDlUI0I+RUt2L1xxkLd0e pWQQ== 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:mime-version:content-transfer-encoding; bh=hmaF9yQWs1ftjCGt2ho+ufNx3HU5VU9tMugrbyxomKA=; b=pNwFHwOnB4b/zIlh6RLm6HJJcrlNXMmx8WL+Ds1NfaWgsd6pnCOxUuTcDRUNdWPNVx ZyXGy9zdr7CNGnWeYnknu3VnwnoficYENqjC5wlU5LnFEKO0MCC1VVGT3Z/rxPDY7Q9q 3RA2cKFng6iafEtefMl/W8fv7qbgeJXfkS46NWbQtEDrT2re6xPBtsZ2Ae1Z2FLBPEsO SiBQaJhSZVEqqxlswut0Kieh1Gf3Zf4s8e5Z1PB7PTIjqfgbBM0tFEWijUhFCcilvMHK 7lTq9UfpYtQ1/isAX7eJ5R0qRvy4yUZYm1KqNCpZpXvX9C6c763PLv5FZVr6rnxHZ+kR eb0Q== X-Gm-Message-State: APjAAAUEQ6oTMREwijhT/ywyECdAF9yxHXmVkMxXhInUpw3mkp+zLZUj AhuftUcRO5gtlc18ldS/ua0hYCiiZTg= X-Google-Smtp-Source: APXvYqxtwK4wcNxbbKdEpgV+KexkntvagH7IOGUOOw8FcJ64/ymHcZeQsW7UXl6vM78WeMkwSldJqg== X-Received: by 2002:a62:1d12:: with SMTP id d18mr11719862pfd.53.1568914118567; Thu, 19 Sep 2019 10:28:38 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id x6sm292019pfd.53.2019.09.19.10.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:28:37 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:16 +0300 Message-Id: <20190919172822.8255-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 1/7] image: android: Add functions for handling dtb field 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Android Boot Image v2 adds "DTB" payload (and corresponding field in the image header). Provide functions for its handling: - android_image_get_dtb_by_index(): Obtain DTB file from "DTB" part of boot image, by file index - android_image_print_dtb_contents(): Iterate over all DTB files in "DTB" part of boot image and print those files info "DTB" payload might be in one of the following formats: 1. concatenated DTB files 2. Android DTBO format The latter requires "android-image-dt.c" functionality, so this commit selects that file for building for CONFIG_ANDROID_BOOT_IMAGE option. Right now this new functionality isn't used, but it can be used further. As it's required to apply some specific dtbo file(s) from "dtbo" partition, we can't automate this process inside of "bootm" command. But we can do next: - come up with some new command like "bootimg" to extract dtb file from boot image (using functions from this patch) - extract desired dtbo files from "dtbo" partition using "dtimg" command - merge dtbo files into dtb file using "fdt apply" command - pass resulting dtb file into bootm command in order to boot the Android kernel with Android ramdisk from boot image Signed-off-by: Sam Protsenko --- common/Makefile | 2 +- common/image-android.c | 191 +++++++++++++++++++++++++++++++++++++++++ include/image.h | 5 ++ 3 files changed, 197 insertions(+), 1 deletion(-) diff --git a/common/Makefile b/common/Makefile index 302d8beaf3..7e5f5058b3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -108,7 +108,7 @@ endif obj-y += image.o obj-$(CONFIG_ANDROID_AB) += android_ab.o -obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o +obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o obj-$(CONFIG_$(SPL_)MULTI_DTB_FIT) += boot_fit.o common_fit.o diff --git a/common/image-android.c b/common/image-android.c index 3564a64221..63e41ea5f1 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,108 @@ int android_image_get_second(const struct andr_img_hdr *hdr, return 0; } +/** + * android_image_get_dtb_img_addr() - Get the address of DTB area in boot image. + * @hdr: Boot image header address + * @addr: Will contain the address of DTB area in boot image + * + * Return: true on success or false on fail. + */ +static bool android_image_get_dtb_img_addr(const struct andr_img_hdr *hdr, + ulong *addr) +{ + ulong dtb_img_addr; + + if (android_image_check_header(hdr)) { + printf("Error: Boot Image header is incorrect\n"); + return false; + } + + if (hdr->header_version < 2) { + printf("Error: header_version must be >= 2 to get dtb\n"); + return false; + } + + if (hdr->dtb_size == 0) { + printf("Error: dtb_size is 0\n"); + return false; + } + + /* Calculate the address of DTB area in boot image */ + dtb_img_addr = (ulong)hdr; + dtb_img_addr += hdr->page_size; + dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size); + dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size); + dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size); + dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size); + + if (addr) + *addr = dtb_img_addr; + + return true; +} + +/** + * android_image_get_dtb_by_index() - Get address and size of file in DTB area. + * @hdr: Boot image header address + * @index: Index of desired DTB in DTB area (starting from 0) + * @addr: If not NULL, will contain address to specified DTB + * @size: If not NULL, will contain size of specified DTB + * + * Get the address and size of DTB file by its index in DTB area of Android + * Boot Image in RAM. + * + * Return: true on success or false on error. + */ +bool android_image_get_dtb_by_index(const struct andr_img_hdr *hdr, u32 index, + ulong *addr, u32 *size) +{ + bool res; + ulong dtb_img_addr; /* address of DTB part in boot image */ + ulong dtb_addr; /* address of DTB file with specified index */ + u32 i; /* index iterator */ + + res = android_image_get_dtb_img_addr(hdr, &dtb_img_addr); + if (!res) + return false; + + /* Check if DTB area of boot image is in DTBO format */ + if (android_dt_check_header((ulong)dtb_img_addr)) { + return android_dt_get_fdt_by_index(dtb_img_addr, index, addr, + size); + } + + /* Find out the address of DTB with specified index in concat blobs */ + i = 0; + dtb_addr = dtb_img_addr; + while (dtb_addr < dtb_img_addr + hdr->dtb_size) { + const struct fdt_header *fdt; + u32 dtb_size; + + fdt = (const struct fdt_header *)dtb_addr; + if (fdt_check_header(fdt) != 0) { + printf("Error: Invalid FDT header for index %u\n", i); + return false; + } + + dtb_size = fdt_totalsize(fdt); + + if (i == index) { + if (size) + *size = dtb_size; + if (addr) + *addr = dtb_addr; + return true; + } + + dtb_addr += dtb_size; + ++i; + } + + printf("Error: Index is out of bounds (%u/%u)\n", index, i); + return false; +} + #if !defined(CONFIG_SPL_BUILD) /** * android_print_contents - prints out the contents of the Android format image @@ -246,4 +349,92 @@ void android_print_contents(const struct andr_img_hdr *hdr) printf("%sdtb addr: %llx\n", p, hdr->dtb_addr); } } + +static bool android_image_print_dtb_info(const struct fdt_header *fdt, + u32 index) +{ + int root_node_off; + u32 fdt_size; + const char *model; + const char *compatible; + + root_node_off = fdt_path_offset(fdt, "/"); + if (root_node_off < 0) { + printf("Error: Root node not found\n"); + return false; + } + + fdt_size = fdt_totalsize(fdt); + compatible = fdt_getprop(fdt, root_node_off, "compatible", + NULL); + model = fdt_getprop(fdt, root_node_off, "model", NULL); + + printf(" - DTB #%u:\n", index); + printf(" (DTB)size = %d\n", fdt_size); + printf(" (DTB)model = %s\n", model ? model : "(unknown)"); + printf(" (DTB)compatible = %s\n", + compatible ? compatible : "(unknown)"); + + return true; +} + +/** + * android_image_print_dtb_contents() - Print info for DTB files in DTB area. + * @hdr: Boot image header address + * + * DTB payload in Android Boot Image v2+ can be in one of following formats: + * 1. Concatenated DTB files + * 2. Android DTBO format (see CONFIG_CMD_DTIMG for details) + * + * This function does next: + * 1. Prints out the format used in DTB area + * 2. Iterates over all DTB files in DTB area and prints out the info for + * each file. + * + * Return: true on success or false on error. + */ +bool android_image_print_dtb_contents(const struct andr_img_hdr *hdr) +{ + bool res; + ulong dtb_img_addr; /* address of DTB part in boot image */ + ulong dtb_addr; /* address of DTB file with specified index */ + u32 i; /* index iterator */ + + res = android_image_get_dtb_img_addr(hdr, &dtb_img_addr); + if (!res) + return false; + + /* Check if DTB area of boot image is in DTBO format */ + if (android_dt_check_header((ulong)dtb_img_addr)) { + printf("## DTB area contents (DTBO format):\n"); + android_dt_print_contents(dtb_img_addr); + return true; + } + + printf("## DTB area contents (concat format):\n"); + + /* Iterate over concatenated DTB files */ + i = 0; + dtb_addr = dtb_img_addr; + while (dtb_addr < dtb_img_addr + hdr->dtb_size) { + const struct fdt_header *fdt; + u32 dtb_size; + + fdt = (const struct fdt_header *)dtb_addr; + if (fdt_check_header(fdt) != 0) { + printf("Error: Invalid FDT header for index %u\n", i); + return false; + } + + res = android_image_print_dtb_info(fdt, i); + if (!res) + return false; + + dtb_size = fdt_totalsize(fdt); + dtb_addr += dtb_size; + ++i; + } + + return true; +} #endif diff --git a/include/image.h b/include/image.h index c1065c06f9..08eda41961 100644 --- a/include/image.h +++ b/include/image.h @@ -1333,10 +1333,15 @@ 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); +bool android_image_get_dtb_by_index(const struct andr_img_hdr *hdr, u32 index, + ulong *addr, u32 *size); ulong android_image_get_end(const struct andr_img_hdr *hdr); ulong android_image_get_kload(const struct andr_img_hdr *hdr); ulong android_image_get_kcomp(const struct andr_img_hdr *hdr); void android_print_contents(const struct andr_img_hdr *hdr); +#if !defined(CONFIG_SPL_BUILD) +bool android_image_print_dtb_contents(const struct andr_img_hdr *hdr); +#endif #endif /* CONFIG_ANDROID_BOOT_IMAGE */ From patchwork Thu Sep 19 17:28:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164767 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ZqZyQnDc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3jz67FRz9s4Y for ; Fri, 20 Sep 2019 03:29:11 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 80381C21C3F; Thu, 19 Sep 2019 17:28:55 +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_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 021C9C21C50; Thu, 19 Sep 2019 17:28:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 697D6C21DF9; Thu, 19 Sep 2019 17:28:47 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by lists.denx.de (Postfix) with ESMTPS id 0429AC21DFD for ; Thu, 19 Sep 2019 17:28:47 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id h195so2755408pfe.5 for ; Thu, 19 Sep 2019 10:28:46 -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 :mime-version:content-transfer-encoding; bh=H6FiZ1sso3JM0rzlk89//J9q7laRiclcIxMDxCdeGAM=; b=ZqZyQnDc/fKIkMkvRZmzaa/IK7Id40DYsFVeNPjUei3hPToCb0hUyn9TAbYhMuw930 XXEGWjp56Ws6mfGLGt2VbvHyNPj2F9jALBAOC6AbnpyO+j4MEjuxUkq1kV+rNbBk18UC fZ8CHedVFBVcnmxNNgB1/cbsZB1Fto6qb5rcGDzMFvZERA/XqeFTdySeGEW3ifs8UVOZ Bj+KTg9g1RaIHAShqm+PrwBBoawg0qLUN2IqvunurnKh6Ri8qLOXZamS/c0QKFl/oGCx Lj4VGMhfkiHR43eCFGxesmW3IZSc/hwxm5rWnK4MtqmJcS/O1sr0x8k9ujgACdnyUpXU s3Yw== 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:mime-version:content-transfer-encoding; bh=H6FiZ1sso3JM0rzlk89//J9q7laRiclcIxMDxCdeGAM=; b=VVsg3QxHUnbZzSpOCi29QkTX8uNLDixWAHVR+RV1bVCh5M5tw4DOE+p5xi5xzuUriT Ge2F7ZlMKBHWNOsYQ3WzQn/h0ro2XPEK/8iKHdbpC7ewAgqKClNesGgqeUfKycHhOLiD noBvQG+tSlqdXRhO2YCpeZhjTuZkqQycy9lsOE5dzqfevRWID0a5tbXwsvL6eWbsRWNG jOy8+QUtLXP6UX2yoxHKi4aMvBzdb5q75Vd2jJ2wlSANnZP/cUsJwQrn+NClpoqqLzes L0+L014ePV730jAHUla64SUBStXlUvioCe3NSikqdtk3R5mYA2difPuxk1WlvL4WRX9w OFpA== X-Gm-Message-State: APjAAAWBBv4zRCaTznmX32rQS8cXhE6eSvgtw0ykjoeylbefz2hyMmyH gtrpSoKgqj2FwA8BbPLtwktr99+x3No= X-Google-Smtp-Source: APXvYqz/HsvCy/cNyN4uHivLjuzLr2iKjXCHZIr7YmhBbpeS/bz5QDBZuapYRsIhkAuCPL7OlwkzLg== X-Received: by 2002:a17:90a:9d87:: with SMTP id k7mr4966721pjp.103.1568914125277; Thu, 19 Sep 2019 10:28:45 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id 197sm28254623pge.39.2019.09.19.10.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:28:44 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:17 +0300 Message-Id: <20190919172822.8255-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 2/7] image: android: Add routine to get dtbo params 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Android Boot Image v1 adds "Recovery DTB" field in image header and associate payload in boot image itself [1]. Payload should be in Android DTB/DTBO format [2]. That "Recovery DTB" area should be only populated for non-A/B devices, and only in recovery image. Add function to get an address and size of that payload. That function can be further used e.g. in 'bootimg' command to provide the user a way to get the address of recovery dtbo from U-Boot shell, which can be further parsed using 'dtimg' command. [1] https://source.android.com/devices/bootloader/boot-image-header [2] https://source.android.com/devices/architecture/dto/partitions Signed-off-by: Sam Protsenko --- common/image-android.c | 54 ++++++++++++++++++++++++++++++++++++++++++ include/image.h | 2 ++ 2 files changed, 56 insertions(+) diff --git a/common/image-android.c b/common/image-android.c index 63e41ea5f1..5ecd75dcfc 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -196,6 +196,60 @@ int android_image_get_second(const struct andr_img_hdr *hdr, return 0; } +/** + * android_image_get_dtbo() - Get address and size of recovery DTBO image. + * @hdr: Boot image header address + * @addr: If not NULL, will contain address of recovery DTBO image + * @size: If not NULL, will contain size of recovery DTBO image + * + * Get the address and size of DTBO image in "Recovery DTBO" area of Android + * Boot Image in RAM. The format of this image is Android DTBO (see + * corresponding "DTB/DTBO Partitions" AOSP documentation for details). Once + * the address is obtained from this function, one can use 'dtimg' U-Boot + * command or android_dt_*() functions to extract desired DTBO file. + * + * This DTBO (included in boot image) is only needed for non-A/B devices, and it + * only can be found in recovery image. On A/B devices we can always rely on + * "dtbo" partition. See "Including DTBO in Recovery for Non-A/B Devices" in + * AOSP documentation for details. + * + * Return: true on success or false on error. + */ +bool android_image_get_dtbo(const struct andr_img_hdr *hdr, ulong *addr, + u32 *size) +{ + ulong dtbo_img_addr; + + if (android_image_check_header(hdr)) { + printf("Error: Boot Image header is incorrect\n"); + return false; + } + + if (hdr->header_version < 1) { + printf("Error: header_version must be >= 1 to get dtbo\n"); + return false; + } + + if (hdr->recovery_dtbo_size == 0) { + printf("Error: recovery_dtbo_size is 0\n"); + return false; + } + + /* Calculate the address of DTB area in boot image */ + dtbo_img_addr = (ulong)hdr; + dtbo_img_addr += hdr->page_size; + dtbo_img_addr += ALIGN(hdr->kernel_size, hdr->page_size); + dtbo_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size); + dtbo_img_addr += ALIGN(hdr->second_size, hdr->page_size); + + if (addr) + *addr = dtbo_img_addr; + if (size) + *size = hdr->recovery_dtbo_size; + + return true; +} + /** * android_image_get_dtb_img_addr() - Get the address of DTB area in boot image. * @hdr: Boot image header address diff --git a/include/image.h b/include/image.h index 08eda41961..c8a3088acb 100644 --- a/include/image.h +++ b/include/image.h @@ -1333,6 +1333,8 @@ 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); +bool android_image_get_dtbo(const struct andr_img_hdr *hdr, ulong *addr, + u32 *size); bool android_image_get_dtb_by_index(const struct andr_img_hdr *hdr, u32 index, ulong *addr, u32 *size); ulong android_image_get_end(const struct andr_img_hdr *hdr); From patchwork Thu Sep 19 17:28:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164770 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EMnkGFwR"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3mk4zWhz9s4Y for ; Fri, 20 Sep 2019 03:31:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 46DE5C21D83; Thu, 19 Sep 2019 17:29:29 +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_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 727A4C21DD3; Thu, 19 Sep 2019 17:29:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3F9F2C21DF3; Thu, 19 Sep 2019 17:28:57 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by lists.denx.de (Postfix) with ESMTPS id C6492C21BE5 for ; Thu, 19 Sep 2019 17:28:53 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id q10so2779304pfl.0 for ; Thu, 19 Sep 2019 10:28:53 -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 :mime-version:content-transfer-encoding; bh=iFizIJeCVRWit8wdKQ/Vf4ghDtBmKZGMmWDzl7C3LCI=; b=EMnkGFwRfcJo1Xklejf06YAjoOEO02zRiFzw+D6jN9Fwfs0ar1epkdKeQle8XdtFBs 92/yvK4jXhE4bsq/STpgcWmn9ELgB1Z3ovhdXe5Z46g8E/EsdVZALylzLbUPXEVDVIKA tBNcEX2P9RF9rmX9WeS9UmPPPC3bN5n0dCrm1v/IyaZYnjwbAuHefArTtUwdjJhx+ZTn q7PcP2kvwFW+P6tiUHR1VBsAYzwSaoM0TO5eQ1c71zojz7cHgHry4hdbhVcP17MIb/1k dWSRxcDa0w9jXAx2pmPltYoA2moL+/VqqrYQXIJhO2UuzLns2ZT5uAgwCbXPYxDcst4y DZAg== 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:mime-version:content-transfer-encoding; bh=iFizIJeCVRWit8wdKQ/Vf4ghDtBmKZGMmWDzl7C3LCI=; b=aE3qEUPQW9r1lx2iSmpkd+3z0QnKqOTrDa0MOrSjeBTASeANyghMIivVXs8lapSWfJ GbKH2HjJ+vMgo285NwEc+lbtKMnniuZVZ0RTWmvKyja6bs7Kh6Lm/m/7qDzIcKRKv2bR BXu8CYPUFM6Yv21kf3CSns5N8A2qXCDVrPn/2ypXX0malFbpUdEpIdhiDGrS5bnhRQRj 962iN7Rvn4en80aVnm9+9dHl5msbOaiRMI39V3SNlC1dqKe8EbIfl+N9vEDZmjfoXyCT +gOfISN2oif9q6HpgFRzCnibXyPXaI6Y4mPuHN4x974aGlEz5UqFIEgb9lEuV7v94ukP Hasw== X-Gm-Message-State: APjAAAUperYWWnZh/b2svBD9t82L5Z43j5LIW8eBnzPW4pqKAIJE2aE7 BMzhetFbUnkhnHID5tUv/VnLuEJzLMQ= X-Google-Smtp-Source: APXvYqy6zUa/ytkxj77vEd9zDQKkmiJkD8c4BOCLfO8L4YF4mGD4J1OU3A8vDKN6ExaxGGGKUXxGEg== X-Received: by 2002:a63:4857:: with SMTP id x23mr10377916pgk.142.1568914132039; Thu, 19 Sep 2019 10:28:52 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id r18sm14435018pfc.3.2019.09.19.10.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:28:51 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:18 +0300 Message-Id: <20190919172822.8255-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 3/7] cmd: bootimg: Add bootimg 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This command can be used to extract fields and image payloads from Android Boot Image. It can be used for example to implement boot flow where dtb is taken from boot.img (as v2 incorporated dtb inside of boot.img). Using this command, one can obtain needed dtb file from boot.img in scripting manner, and then apply needed dtbo's (from "dtbo" partition) on top of that, providing then the resulting image to bootm command in order to boot the Android. Also right now this command has the sub-command to get an address and size of recovery dtbo from recovery image. It can be further parsed using 'dtimg' command and merged into dtb file (for non-A/B devices only, see [1,2] for details). [1] https://source.android.com/devices/bootloader/boot-image-header [2] https://source.android.com/devices/architecture/dto/partitions Signed-off-by: Sam Protsenko --- cmd/Kconfig | 8 +++ cmd/Makefile | 1 + cmd/bootimg.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 cmd/bootimg.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 98647f58b7..37f3003c2b 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -305,6 +305,14 @@ config CMD_DTIMG files should be merged in one dtb further, which needs to be passed to the kernel, as part of a boot process. +config CMD_BOOTIMG + bool "bootimg" + depends on ANDROID_BOOT_IMAGE + help + Android Boot Image manipulation commands. Allows one to extract + images contained in boot.img, like kernel, ramdisk, dtb, etc, and + obtain corresponding meta-information from boot.img. + config CMD_ELF bool "bootelf, bootvx" default y diff --git a/cmd/Makefile b/cmd/Makefile index ac843b4b16..bf15e38f41 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -48,6 +48,7 @@ ifdef CONFIG_POST obj-$(CONFIG_CMD_DIAG) += diag.o endif obj-$(CONFIG_CMD_DTIMG) += dtimg.o +obj-$(CONFIG_CMD_BOOTIMG) += bootimg.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/bootimg.c b/cmd/bootimg.c new file mode 100644 index 0000000000..4ef405f99a --- /dev/null +++ b/cmd/bootimg.c @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 Linaro Ltd. + * Sam Protsenko + */ + +#include +#include + +static int do_bootimg_ver(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + const struct andr_img_hdr *hdr; + char buf[65]; + + if (argc != 2) + return CMD_RET_USAGE; + + hdr = (const struct andr_img_hdr *)load_addr; + if (android_image_check_header(hdr)) { + printf("Error: Boot Image header is incorrect\n"); + return CMD_RET_FAILURE; + } + + snprintf(buf, sizeof(buf), "%u", hdr->header_version); + env_set(argv[1], buf); + + return CMD_RET_SUCCESS; +} + +static int do_bootimg_get_dtbo(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + const struct andr_img_hdr *hdr; + char buf[65]; + ulong addr; + u32 size; + + if (argc < 2 || argc > 3) + return CMD_RET_USAGE; + + hdr = (const struct andr_img_hdr *)load_addr; + if (!android_image_get_dtbo(hdr, &addr, &size)) + return CMD_RET_FAILURE; + + snprintf(buf, sizeof(buf), "%lx", addr); + env_set(argv[1], buf); + + if (argc == 3) { + snprintf(buf, sizeof(buf), "%x", size); + env_set(argv[2], buf); + } + + return CMD_RET_SUCCESS; +} + +static int do_bootimg_dtb_dump(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + const struct andr_img_hdr *hdr; + + if (argc != 1) + return CMD_RET_USAGE; + + hdr = (const struct andr_img_hdr *)load_addr; + if (android_image_print_dtb_contents(hdr)) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; +} + +static int do_bootimg_dtb_load_addr(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + const struct andr_img_hdr *hdr; + char buf[65]; + + if (argc != 2) + return CMD_RET_USAGE; + + hdr = (const struct andr_img_hdr *)load_addr; + if (android_image_check_header(hdr)) { + printf("Error: Boot Image header is incorrect\n"); + return CMD_RET_FAILURE; + } + + if (hdr->header_version < 2) { + printf("Error: header_version must be >= 2 for this\n"); + return CMD_RET_FAILURE; + } + + snprintf(buf, sizeof(buf), "%lx", (ulong)hdr->dtb_addr); + env_set(argv[1], buf); + + return CMD_RET_SUCCESS; +} + +static int do_bootimg_get_dtb_file(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + const struct andr_img_hdr *hdr; + char *endp; + char buf[65]; + u32 index; + ulong addr; + u32 size; + + if (argc < 3 || argc > 4) + return CMD_RET_USAGE; + + index = simple_strtoul(argv[1], &endp, 0); + if (*endp != '\0') { + printf("Error: Wrong index\n"); + return CMD_RET_FAILURE; + } + + hdr = (const struct andr_img_hdr *)load_addr; + if (!android_image_get_dtb_by_index(hdr, index, &addr, &size)) + return CMD_RET_FAILURE; + + snprintf(buf, sizeof(buf), "%lx", addr); + env_set(argv[2], buf); + + if (argc == 4) { + snprintf(buf, sizeof(buf), "%x", size); + env_set(argv[3], buf); + } + + return CMD_RET_SUCCESS; +} + +static cmd_tbl_t cmd_bootimg_sub[] = { + U_BOOT_CMD_MKENT(ver, 2, 1, do_bootimg_ver, "", ""), + U_BOOT_CMD_MKENT(get_dtbo, 3, 1, do_bootimg_get_dtbo, "", ""), + U_BOOT_CMD_MKENT(dtb_dump, 1, 1, do_bootimg_dtb_dump, "", ""), + U_BOOT_CMD_MKENT(dtb_load_addr, 2, 1, do_bootimg_dtb_load_addr, "", ""), + U_BOOT_CMD_MKENT(get_dtb_file, 4, 1, do_bootimg_get_dtb_file, "", ""), +}; + +static int do_bootimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + cmd_tbl_t *cp; + + cp = find_cmd_tbl(argv[1], cmd_bootimg_sub, + ARRAY_SIZE(cmd_bootimg_sub)); + + /* Strip off leading 'bootimg' command argument */ + argc--; + argv++; + + if (!cp || argc > cp->maxargs) + return CMD_RET_USAGE; + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) + return CMD_RET_SUCCESS; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + bootimg, CONFIG_SYS_MAXARGS, 0, do_bootimg, + "manipulate Android Boot Image (must reside in $loadaddr)", + "ver \n" + " - get header version\n" + "bootimg get_dtbo [size_var]\n" + " - get address and size (hex) of recovery DTBO area in the image\n" + " : variable name to contain DTBO area address\n" + " [size_var]: variable name to contain DTBO area size\n" + "bootimg dtb_dump\n" + " - print info for all files in DTB area\n" + "bootimg dtb_load_addr \n" + " - get load address (hex) of DTB\n" + "bootimg get_dtb_file [size_var]\n" + " - get address and size (hex) of DTB file in the image\n" + " : index of desired DTB file in DTB area\n" + " : variable name to contain DTB file address\n" + " [size_var]: variable name to contain DTB file size\n" +); From patchwork Thu Sep 19 17:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164773 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dwGfq9lP"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3np3hXYz9s7T for ; Fri, 20 Sep 2019 03:32:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 31C19C21E2F; Thu, 19 Sep 2019 17:30:25 +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.8 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID, UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E73A5C21DD9; Thu, 19 Sep 2019 17:29:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0D68CC21DD9; Thu, 19 Sep 2019 17:29:04 +0000 (UTC) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by lists.denx.de (Postfix) with ESMTPS id 60C9AC21DD9 for ; Thu, 19 Sep 2019 17:29:00 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id a2so2734513pfo.10 for ; Thu, 19 Sep 2019 10:29:00 -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 :mime-version:content-transfer-encoding; bh=hJKPceOJ3U+nHVuX+n2sNZL0s9wbWWxBOt0ovS6HTLI=; b=dwGfq9lPe3BVbVK93JLgEWckTdvgOvlZnR7TpWFNWhgY/bpOCYMSiXihLIjbh9Xvql /axFG3xG5GQ25sRH9RYtDpKwTD1a+edHAQTFa6xp6WLXLLV1LMMwI5DaAWuHNMMVtfk7 yevEprWCOYCyAmmBbF6DbgAMY1skzgjg0G2qXrKPIqiWEHhIlG3VRvE5hfBCr984Gy8x TDL/A/sghIGDNGusvy2FVnMnrkVMCqgCBrNJbrrOlz3q6Bn4e8iTc3y5ExbS/A2Y0Feh AzvzHVQ/TQ0eC2TQyqpKbzO9IyhUPPnCWIREJgopBsx6zGFkhFBsUJvrLLUNS36BIMA3 HQRw== 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:mime-version:content-transfer-encoding; bh=hJKPceOJ3U+nHVuX+n2sNZL0s9wbWWxBOt0ovS6HTLI=; b=amPFxvKJajmtp54IqSkYHGl0N3628eGmDaYxhKHAzfxaUARu928Aqv6CD04Qm5RurP ZODIpQGU71W8xXjIjHzyMCjaPBW0t1c+wTPF0BN+IJE5DBieii18q41JcEDxprSQ+FaU sYtbV4sDKNsLk2wAbA+hrivF+V+whIa5Vrkk9g8tHGXzd5NzMUaEOMgmlRBWOWKy4LAf mjC6dlrHJZCOvoF2ZVuj8zEBWLJMjS+JOVqFaD24aKpMkaLZjZleqniyb8jboRubnqSM 3Zup5eVbdwiLjHzlcT5zhXSqaShCy/EXXXSprNqmIwZsbvr49Rm0EpQ2D5Zqb7vpjmUy dJ/g== X-Gm-Message-State: APjAAAXhXn0Uknj8lqn8ZTYQh5N88V1BHqHDxVuVepUXlyMrsap0JRAF 9FNHHFiSzRDzuD1Y/jLRG5TTplQJFw8= X-Google-Smtp-Source: APXvYqzfZRdHdZDNpZoqc9o8ou37PwTr8jHCU5eWJMqEOpDYScA4h513RjmTnDk2T9hgBpbnGDtuEw== X-Received: by 2002:a63:ed08:: with SMTP id d8mr10548426pgi.239.1568914138573; Thu, 19 Sep 2019 10:28:58 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id p189sm13433267pfp.163.2019.09.19.10.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:28:57 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:19 +0300 Message-Id: <20190919172822.8255-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 4/7] configs: am57xx_evm: Enable Android commands 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Enable Android commands that will be needed for Android 10 boot flow implementation, for all AM57x variants. Commands enabled: 1. 'bootimg': - CONFIG_CMD_BOOTIMG=y 2. 'ab_select': - CONFIG_ANDROID_AB=y - CONFIG_CMD_AB_SELECT=y 3. 'avb': - CONFIG_LIBAVB=y - CONFIG_AVB_VERIFY=y - CONFIG_CMD_AVB=y While at it, resync defconfig files with "make savedefconfig". Signed-off-by: Sam Protsenko --- configs/am57xx_evm_defconfig | 8 +++++++- configs/am57xx_hs_evm_defconfig | 6 ++++++ configs/am57xx_hs_evm_usb_defconfig | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 248c302057..ee7852fd30 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -10,6 +10,7 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_ARMV7_LPAE=y CONFIG_AHCI=y +CONFIG_SPL_TEXT_BASE=0x40300000 CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y CONFIG_OF_BOARD_SETUP=y @@ -20,7 +21,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y -CONFIG_SPL_TEXT_BASE=0x40300000 +CONFIG_AVB_VERIFY=y +CONFIG_ANDROID_AB=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y @@ -30,11 +32,14 @@ CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_DTIMG=y +CONFIG_CMD_BOOTIMG=y CONFIG_CMD_SPL=y CONFIG_CMD_BCB=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_AB_SELECT=y # CONFIG_CMD_PMIC is not set +CONFIG_CMD_AVB=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="am572x-idk" @@ -98,3 +103,4 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" CONFIG_USB_GADGET_VENDOR_NUM=0x0451 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022 +CONFIG_LIBAVB=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 7b56df8db7..89e5094a74 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -26,6 +26,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_AVB_VERIFY=y +CONFIG_ANDROID_AB=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y @@ -33,10 +35,13 @@ CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_CMD_DTIMG=y +CONFIG_CMD_BOOTIMG=y CONFIG_CMD_BCB=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_AB_SELECT=y # CONFIG_CMD_PMIC is not set +CONFIG_CMD_AVB=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15" @@ -96,3 +101,4 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" CONFIG_USB_GADGET_VENDOR_NUM=0x0451 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022 +CONFIG_LIBAVB=y diff --git a/configs/am57xx_hs_evm_usb_defconfig b/configs/am57xx_hs_evm_usb_defconfig index c8078e9f4e..04dc402a23 100644 --- a/configs/am57xx_hs_evm_usb_defconfig +++ b/configs/am57xx_hs_evm_usb_defconfig @@ -14,6 +14,7 @@ CONFIG_SPL=y CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_ARMV7_LPAE=y +CONFIG_SPL_TEXT_BASE=0x40306D50 CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT_IMAGE_POST_PROCESS=y CONFIG_SPL_LOAD_FIT=y @@ -26,7 +27,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y -CONFIG_SPL_TEXT_BASE=0x40306D50 +CONFIG_AVB_VERIFY=y +CONFIG_ANDROID_AB=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y @@ -38,10 +40,13 @@ CONFIG_SPL_USB_GADGET=y CONFIG_SPL_DFU=y CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_DTIMG=y +CONFIG_CMD_BOOTIMG=y CONFIG_CMD_BCB=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_AB_SELECT=y # CONFIG_CMD_PMIC is not set +CONFIG_CMD_AVB=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15" @@ -103,3 +108,4 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" CONFIG_USB_GADGET_VENDOR_NUM=0x0451 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022 +CONFIG_LIBAVB=y From patchwork Thu Sep 19 17:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164769 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="z6W4K5gW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3mG4ycFz9s4Y for ; Fri, 20 Sep 2019 03:31:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 46C79C21E1D; Thu, 19 Sep 2019 17:30:02 +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_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 A7643C21E1A; Thu, 19 Sep 2019 17:29:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 60BCDC21E1A; Thu, 19 Sep 2019 17:29:12 +0000 (UTC) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by lists.denx.de (Postfix) with ESMTPS id 4D018C21D8E for ; Thu, 19 Sep 2019 17:29:07 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id a3so2246794pgm.13 for ; Thu, 19 Sep 2019 10:29:07 -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 :mime-version:content-transfer-encoding; bh=B69e85YxAyB60AfxOIGF2IMxTSoV/H8dclHtp0L+BlM=; b=z6W4K5gWZUwtuF2LZ4VPzhGTHl5s+C5UKpUIiK97UdlA3tVnJKzOjIU44YxcDWJndg R/xrI/YHWLcyq+XRAX3WDkWIblApIzJFyZHrwkCbFnfsAP7rYEkUpCbcBU+MxwsFRnMe SGPBYflGgmqzp/sDm1SGKNtmb687bFwxf+9CuXYPK5QFVUxID7pY6PPcARcNo7+B1I28 wanYeWU/McidWqNTHnkdof6hWEHOSNeTw1Qg5xKVPULtafTD6Fw0TRnBmfsGRMx0Au7R w1qDHO5L50iz/jZcYJh8feee8AIXtqq03PbPHZWvidsytgv5M54AEwehLPzcg6Ce45EP Hd4Q== 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:mime-version:content-transfer-encoding; bh=B69e85YxAyB60AfxOIGF2IMxTSoV/H8dclHtp0L+BlM=; b=dnkpQVlTDDiB68gGunQXP9GQ/JkNbmocCT3oH/xjcJ2AW1el1SN/3df9FWurMpsD/+ A0nPuHZCZqCluXIx742YO53tMIVJC6WjqaomtZrNy2WaFKIJHAsLtAEYc040ahomzKbF 2hrP2mdhGOH0K5ujt3FYQg08N+ThgZdkZKqdYJ3szvesPY1bOfDDRHwJcUauyxqadKbV V1Ez/t3x3W4rrey8O8usirL5RHkkMV6kJkRxjuyB8h7fJ1xeU3+Npv19jc6gB+1nMafO gAQ2PVjZIg59AE7bOB7Tln7g8RIbeGbrF/RQnfZoaVmjpa5zB3OzrQ/GdhEo8umtDvT9 8WrA== X-Gm-Message-State: APjAAAWoP6I6LCwxom6caaxxJoYQAVMusRLRkNcb9vfKFJBDyvysi9zj +d/GQOaTjCrkBqJ97Al+ev+0RCFTJ18= X-Google-Smtp-Source: APXvYqxp3o55zNnIUDPjjlbhQaUCtFvn2rrkDmqz5wtIKx1uZiYzAgpPUqmogzm5N2fyMcV5v/YkjQ== X-Received: by 2002:aa7:9f43:: with SMTP id h3mr11796670pfr.215.1568914145312; Thu, 19 Sep 2019 10:29:05 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id q88sm6868264pjq.9.2019.09.19.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:29:04 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:20 +0300 Message-Id: <20190919172822.8255-6-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 5/7] env: ti: boot: Respect slot_suffix in AVB commands 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Sam Protsenko --- include/environment/ti/boot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 684a744f31..da99215fbd 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -63,7 +63,7 @@ "else " \ "echo AVB verification failed.;" \ "exit; fi;" -#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify;\0" +#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0" #else #define AVB_VERIFY_CHECK "" #define AVB_VERIFY_CMD "" From patchwork Thu Sep 19 17:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164771 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SbDi7CVi"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3nH0zj0z9s7T for ; Fri, 20 Sep 2019 03:32:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C1FD7C21E13; Thu, 19 Sep 2019 17:29:47 +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_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 2526FC21DFD; Thu, 19 Sep 2019 17:29:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ADF72C21DDC; Thu, 19 Sep 2019 17:29:18 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lists.denx.de (Postfix) with ESMTPS id 78020C21D9A for ; Thu, 19 Sep 2019 17:29:13 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id y72so2726124pfb.12 for ; Thu, 19 Sep 2019 10:29:13 -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 :mime-version:content-transfer-encoding; bh=xHjTR5UUAxXZ6gsWJce0dEMf7lmFgry1vH2LqtAcdBM=; b=SbDi7CVi0qqGjqEO24JaNfpOG4UwfGR9y0MvMvtB0aupwQodMJY4jHdm2IPLJsA643 ArhervPvCQqrUqXDctFXLpCIEsby9RUabOftdOtLBSDwEJwBy1cTPmqcGWoaY28P4ILU +dliEAN7ow7GAf0dnS8Vv2c9HKpKeq2OKoB35usoi6Wlq55q3TgEoyiV84ZYwLVvW4rP snAoAoKjL1MkvLw/YXYGiFgKb78alF1TOXQ8BgC7dLWVfRpce0wttvBqbRqWaRNrGCwq fAopNDdfDq5m64B6SGaUbrFHHH2dvhLFESRUsrAwfpicOD0CJ6fWK4otik5rhALNjzjf 8ZSg== 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:mime-version:content-transfer-encoding; bh=xHjTR5UUAxXZ6gsWJce0dEMf7lmFgry1vH2LqtAcdBM=; b=XNCTG9BMvDT+cOl5F5fzka0yCpiqf0dlhxBCKWgA0HepMYdMxOLX+8jDl2vHukyxDP kfNnu2dkwNTApB2ASoJVoxxD7SzP9scbZ2buDtfWnYgjemoXHhwtg1pv1Z4NkLGC9Od2 aNLi+emdvRajz327U8bsSlBl4oK7EEk/83G9dLXK64i1AS9LI/YK6ynyfZi6gv/oryf+ buex/j+w/W+IsOEHGZ3Foa9A/nac4h82vwjFiiBdKTjYge6q91kcOzjZfHMtAzpwC4Ve 3TOyOdmAhOdLde6xLV0F4ISEbm3I75bWmpYJmkb+K3byjGHhBMtAaI1oxfrjLw2mlSY5 nd3w== X-Gm-Message-State: APjAAAVc9wSwXpMqk8wdZ+EayhwZAJLSahIGUjHFswn+hFqe7RcAEVhZ tm8W1mUye5libekTHIdcFWUxJTEyEsQ= X-Google-Smtp-Source: APXvYqydWCMab3tD7zr2wvBCiA9JGEGkOp2Ij/YzStsS0+o+QCq+eSt51QDBeu766JRqsM/I+qH8fQ== X-Received: by 2002:aa7:80ca:: with SMTP id a10mr11676935pfn.96.1568914151770; Thu, 19 Sep 2019 10:29:11 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id z2sm19521244pfq.58.2019.09.19.10.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:29:11 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:21 +0300 Message-Id: <20190919172822.8255-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 6/7] env: ti: boot: Boot Android with dynamic partitions 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Changes: - use boot.img instead of boot_fit.img - use .dtb from boot.img v2 - implement recovery boot - always boot ramdisk from boot.img, we can't mount system as root now, as system is a logical partition inside of super partition - don't add "skip_initramfs" to cmdline anymore - to boot into recovery, use boot image from recovery partition - prepare partition table: - A/B scheme - use 'super' partition instead of 'system' and 'vendor' - add dtbo partitions - introduce metadata partition Not implemented: reading and applying dtbo files from dtbo partition. Signed-off-by: Sam Protsenko --- include/environment/ti/boot.h | 105 +++++++++++++--------------------- 1 file changed, 41 insertions(+), 64 deletions(-) diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index da99215fbd..a7644a5874 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -13,28 +13,6 @@ #define CONSOLEDEV "ttyS2" #endif -#define VBMETA_PART_SIZE (64 * 1024) - -#if defined(CONFIG_LIBAVB) -#define VBMETA_PART \ - "name=vbmeta,size=" __stringify(VBMETA_PART_SIZE) \ - ",uuid=${uuid_gpt_vbmeta};" -#else -#define VBMETA_PART "" -#endif - -#if defined(CONFIG_CMD_AB_SELECT) -#define COMMON_PARTS \ - "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ - "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ - "name=system_a,size=1024M,uuid=${uuid_gpt_system_a};" \ - "name=system_b,size=1024M,uuid=${uuid_gpt_system_b};" -#else -#define COMMON_PARTS \ - "name=boot,size=20M,uuid=${uuid_gpt_boot};" \ - "name=system,size=1024M,uuid=${uuid_gpt_system};" -#endif - #ifndef PARTS_DEFAULT /* Define the default GPT table for eMMC */ #define PARTS_DEFAULT \ @@ -49,10 +27,15 @@ "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ - "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \ - COMMON_PARTS \ - "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \ - VBMETA_PART \ + "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ + "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ + "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ + "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ + "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ + "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ + "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ + "name=super,size=2560M,uuid=${uuid_gpt_super};" \ + "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ "name=userdata,size=-,uuid=${uuid_gpt_userdata}" #endif /* PARTS_DEFAULT */ @@ -72,7 +55,7 @@ #define CONTROL_PARTITION "misc" #if defined(CONFIG_CMD_AB_SELECT) -#define AB_SELECT \ +#define AB_SELECT_SLOT \ "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ "then " \ "echo " CONTROL_PARTITION \ @@ -82,18 +65,12 @@ "echo " CONTROL_PARTITION " partition not found;" \ "exit;" \ "fi;" \ - "setenv slot_suffix _${slot_name};" \ - "if part number mmc ${mmcdev} system${slot_suffix} " \ - "system_part_number; then " \ - "setenv bootargs_ab " \ - "ro root=/dev/mmcblk${mmcdev}p${system_part_number} " \ - "rootwait init=/init skip_initramfs " \ - "androidboot.slot_suffix=${slot_suffix};" \ - "echo A/B cmdline addition: ${bootargs_ab};" \ - "setenv bootargs ${bootargs} ${bootargs_ab};" \ - "else " \ - "echo system${slot_suffix} partition not found;" \ - "fi;" + "setenv slot_suffix _${slot_name};" + +#define AB_SELECT_ARGS \ + "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ + "echo A/B cmdline addition: ${bootargs_ab};" \ + "setenv bootargs ${bootargs} ${bootargs_ab};" #else #define AB_SELECT "" #endif @@ -121,46 +98,46 @@ "setenv mmcroot /dev/mmcblk0p2 rw; " \ "run mmcboot;\0" \ "emmc_android_boot=" \ + "setenv mmcdev 1; " \ + "mmc dev $mmcdev; " \ + "mmc rescan; " \ + AB_SELECT_SLOT \ "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ CONTROL_PARTITION "; then " \ + "setenv ardaddr -; " \ "if bcb test command = bootonce-bootloader; then " \ - "echo BCB: Bootloader boot...; " \ + "echo Android: Bootloader boot...; " \ "bcb clear command; bcb store; " \ FASTBOOT_CMD \ + "exit; " \ "elif bcb test command = boot-recovery; then " \ - "echo BCB: Recovery boot...; " \ - "echo Warning: recovery is not implemented; " \ - "echo Performing normal boot for now...; " \ - "bcb clear command; bcb store; " \ - "run emmc_android_normal_boot; " \ + "echo Android: Recovery boot...; " \ + "setenv ardaddr $loadaddr;" \ + "setenv apart recovery; " \ "else " \ - "echo BCB: Normal boot requested...; " \ - "run emmc_android_normal_boot; " \ + "echo Android: Normal boot...; " \ + "setenv ardaddr $loadaddr; " \ + "setenv apart boot${slot_suffix}; " \ "fi; " \ "else " \ "echo Warning: BCB is corrupted or does not exist; " \ - "echo Performing normal boot...; " \ - "run emmc_android_normal_boot; " \ - "fi;\0" \ - "emmc_android_normal_boot=" \ - "echo Trying to boot Android from eMMC ...; " \ - "run update_to_fit; " \ + "echo Android: Normal boot...; " \ + "fi; " \ "setenv eval_bootargs setenv bootargs $bootargs; " \ "run eval_bootargs; " \ - "setenv mmcdev 1; " \ "setenv machid fe6; " \ - "mmc dev $mmcdev; " \ - "mmc rescan; " \ AVB_VERIFY_CHECK \ - AB_SELECT \ - "if part start mmc ${mmcdev} boot${slot_suffix} boot_start; " \ - "then " \ - "part size mmc ${mmcdev} boot${slot_suffix} " \ - "boot_size; " \ - "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \ - "bootm ${loadaddr}#${fdtfile}; " \ + AB_SELECT_ARGS \ + "if part start mmc $mmcdev $apart boot_start; then " \ + "part size mmc $mmcdev $apart boot_size; " \ + "mmc read $loadaddr $boot_start $boot_size; " \ + "bootimg get_dtb_file 0 dtb_start dtb_size; " \ + "cp.b $dtb_start $fdtaddr $dtb_size; " \ + "fdt addr $fdtaddr; " \ + "bootm $loadaddr $ardaddr $fdtaddr; " \ "else " \ - "echo boot${slot_suffix} partition not found; " \ + "echo $apart partition not found; " \ + "exit; " \ "fi;\0" #ifdef CONFIG_OMAP54XX From patchwork Thu Sep 19 17:28:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 1164774 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rDZd+au8"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Z3nw5Q8Pz9s7T for ; Fri, 20 Sep 2019 03:32:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 330E4C21DB3; Thu, 19 Sep 2019 17:30:13 +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_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 43006C21E13; Thu, 19 Sep 2019 17:29:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 073F0C21DDC; Thu, 19 Sep 2019 17:29:25 +0000 (UTC) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by lists.denx.de (Postfix) with ESMTPS id 7ED66C21D65 for ; Thu, 19 Sep 2019 17:29:20 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id b10so1931743plr.4 for ; Thu, 19 Sep 2019 10:29: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ckkmDkusuLFuQnce96NiBTY5lAMksNWK7exrMQu4Wj0=; b=rDZd+au8kGEktxkxy0hm8I+OUTwKMhjYjxI9U0G0bc6nqVTLVGZVofSeDKIm5GfsEj jszHqWg56CuW/TWSrKmwrnNgJu5fkvCQviqDsMUl0v4XsMGD4ncKpwDG2J/FnGtBjqJA 4oPKJnJiBtTlzc1awv1dXvDJi8E2B5yPgmyG3oV1O+f61Udqz7tG2YUp20eXsC0VRNjh 5Gn+xbP2COjQUjYYyrskmv32A1d/xkA1k13wa5L1s0BfmF7VZGXOkV4Ph4ua8eHH+z3i Amx1f2oWJvx38A3h00TocsGJSjUhUxuLr/1DVnitGH+jkhmhbaiYew6pr2c0pYW4a/fl OByQ== 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:mime-version:content-transfer-encoding; bh=ckkmDkusuLFuQnce96NiBTY5lAMksNWK7exrMQu4Wj0=; b=QNDi0jA3UEKtfwafRrZ8JEiQ+JwZzn4U21sadjnXleqFbsLq2s3E1+hMactlgkZS8F G3Kb1PeCduHkSK46WQpQoFsStAta1ULQnIy9kfv9zb3BrjLxJhauP1Xiru87ivCV/c42 t1bWtKpTMk7q/fA1VAxFTW8A3r2nLZpIeulhZyy50QzD68yHPmuGkhSdbkTmScclqiBp 8rfzg1OV7FwGh/9FXbMvy7fah8tV/r3pIbJjGn7Xtzerg29XCuVfkAICPGdnfv2acAvD yzyQz4eDKtXq2aQdoWKohEpwCHP8O4I0ibwvPTmL/mqgAsbuW6VIOFLpleYjg5eZJ48j Iv8w== X-Gm-Message-State: APjAAAXT/Vnxx1ThqFK/w5GGSKIFhmKeWZ0pFZT/bJmtohfanDfsOFSz npytFAGUEGgvO2+C0kyZS0tnyrnY3s8= X-Google-Smtp-Source: APXvYqwnftCxafspjHPGd2rjl2/WpfLUXqV9f2LNpazAWknxkOBLnHk6EjWv+hHfkLXJpDMgJKKgcg== X-Received: by 2002:a17:902:a50a:: with SMTP id s10mr11001230plq.336.1568914158352; Thu, 19 Sep 2019 10:29:18 -0700 (PDT) Received: from localhost ([2001:67c:2e5c:2011:2e0:4cff:fe68:2882]) by smtp.gmail.com with ESMTPSA id 127sm13224966pfy.56.2019.09.19.10.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 10:29:17 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Sep 2019 20:28:22 +0300 Message-Id: <20190919172822.8255-8-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919172822.8255-1-semen.protsenko@linaro.org> References: <20190919172822.8255-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Cc: Alex Deymo , Eugeniu Rosca , Praneeth Bajjuri , Mykhailo Sopiha Subject: [U-Boot] [PATCH 7/7] arm: ti: boot: Use correct dtb and dtbo on Android boot 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Read correct dtb file from boot.img/recovery.img and apply correct dtbo files from dtbo partition. Signed-off-by: Sam Protsenko --- include/configs/ti_armv7_common.h | 7 +++++ include/environment/ti/boot.h | 44 ++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h index 2de6bc2390..188171e4c4 100644 --- a/include/configs/ti_armv7_common.h +++ b/include/configs/ti_armv7_common.h @@ -37,11 +37,18 @@ * seen large trees). We say all of this must be within the first 256MB * as that will normally be within the kernel lowmem and thus visible via * bootm_size and we only run on platforms with 256MB or more of memory. + * + * As a temporary storage for DTBO files (which should be applied into DTB + * file), we use the location 15.5 MB above the ramdisk. If someone wants to + * use ramdisk bigger than 15.5 MB, then DTBO can be loaded and applied to DTB + * file before loading the ramdisk, as DTBO location is only used as a temporary + * storage, and can be re-used after 'fdt apply' command is done. */ #define DEFAULT_LINUX_BOOT_ENV \ "loadaddr=0x82000000\0" \ "kernel_addr_r=0x82000000\0" \ "fdtaddr=0x88000000\0" \ + "dtboaddr=0x89000000\0" \ "fdt_addr_r=0x88000000\0" \ "rdaddr=0x88080000\0" \ "ramdisk_addr_r=0x88080000\0" \ diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index a7644a5874..1b2b923842 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -75,6 +75,46 @@ #define AB_SELECT "" #endif +/* + * Prepares complete device tree file for current board (for Android boot). + * + * Boot image or recovery image should be loaded into $loadaddr prior to running + * these commands. The logic of these commnads is next: + * + * 1. Read correct DTB file for current SoC/board from boot image in $loadaddr + * to $fdtaddr + * 2. Merge all needed DTBO files for current board from 'dtbo' partition + * into read DTB file + * 3. User should provide $fdtaddr as 3rd argument to 'bootm' + * + * XXX: Why passing 0x100000 to 'fdt addr'? Maybe omit it (it's optional)? + */ +#define PREPARE_FDT \ + "echo ---> Preparing FDT...; " \ + "if test $board_name = am57xx_evm_reva3; then " \ + "echo \" -> Reading DTBO partition...\"; " \ + "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ + "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ + "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ + "echo \" -> Reading DTB file for AM57x EVM RevA3...\"; " \ + "bootimg get_dtb_file 0 dtb_start dtb_size; " \ + "cp.b $dtb_start $fdtaddr $dtb_size; " \ + "fdt addr $fdtaddr 0x100000; " \ + "echo \" -> Applying DTBOs for AM57x EVM RevA3...\"; " \ + "dtimg start ${dtboaddr} 0 dtbo_addr; " \ + "fdt apply $dtbo_addr; " \ + "dtimg start ${dtboaddr} 1 dtbo_addr; " \ + "fdt apply $dtbo_addr; " \ + "elif test $board_name = beagle_x15_revc; then " \ + "echo \" -> Reading DTB file for Beagle X15 RevC...\"; " \ + "bootimg get_dtb_file 0 dtb_start dtb_size; " \ + "cp.b $dtb_start $fdtaddr $dtb_size; " \ + "fdt addr $fdtaddr 0x100000; " \ + "else " \ + "echo Error: Android boot is not supported for $board_name; " \ + "exit; " \ + "fi; " \ + #define FASTBOOT_CMD \ "echo Booting into fastboot ...; " \ "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " @@ -131,9 +171,7 @@ "if part start mmc $mmcdev $apart boot_start; then " \ "part size mmc $mmcdev $apart boot_size; " \ "mmc read $loadaddr $boot_start $boot_size; " \ - "bootimg get_dtb_file 0 dtb_start dtb_size; " \ - "cp.b $dtb_start $fdtaddr $dtb_size; " \ - "fdt addr $fdtaddr; " \ + PREPARE_FDT \ "bootm $loadaddr $ardaddr $fdtaddr; " \ "else " \ "echo $apart partition not found; " \