From patchwork Tue May 22 09:23:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 918149 X-Patchwork-Delegate: lukma@denx.de 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="I78qMEhC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40qsb81XqNz9s4q for ; Tue, 22 May 2018 20:39:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EC647C21DA2; Tue, 22 May 2018 10:39:24 +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=FREEMAIL_FROM, KHOP_BIG_TO_CC, 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 8A0E8C21DCA; Tue, 22 May 2018 10:37:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D0474C21E4E; Tue, 22 May 2018 09:25:22 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id ECBAFC21E07 for ; Tue, 22 May 2018 09:25:12 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id w194-v6so29810982wmf.2 for ; Tue, 22 May 2018 02:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a8+/c1qzYTJdo4jSonskkgm/i0a+KgeUah0woVVYiwI=; b=I78qMEhCIZqyjjmi/PKoIrpzOUSWVCcUIEjkt2SKi+Ou1W8L1rCDsUXhkZRFb+tqIK +I8BAhIdr3E9vhswh8IFwWyGrDtUieTqEIlM2SRNPLt9opksodiDNMjVaptQwcPj9+kp HRSrczdroj4IAzpjXCSQW6bE28phtMsKHuJZ2OEbHUIvu6qBNkW3B5u/0BwZDCTDtHWz qBM0mPgwzpxBrI/THFVzoNKmX/vFnkxhySxtT1cnc0cdMJL6YccJdG9EmHUfU8tjKHLu 6wbHgcjtSmXjjIk5qRu6P1FwuePd7IouOel0di9H6RD4VUm4NF4cbN+slimo7oKr5f3Y +FkQ== 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=a8+/c1qzYTJdo4jSonskkgm/i0a+KgeUah0woVVYiwI=; b=BonjFMElz0FHFv11lODQMMagKNLMMFnszkTUJEzKV89QysgoV0MDhpg1q0R80KzLLh ufK7xOdMZm2SeN4QCV3nrrSzqg7A4wNK7v2WlyYhrNX4qc8I2KWdqx67nZOqi+EMkOXU eaU/l1giO9eHfZi3CrwlVK3oq2k71V9aqz0bwZCrX3uhX64xxhkYHtIclHJCHF2MlyYA yxqoWwd2WAPIMYrJxZFXAt/YqUy0GonB8PXoBLBsp1w4ioGGxTe7C6XU1FC0DuR/aYTF dmj5yJMYiHcxYf9Yk5/8ZKAxTG7d8ZWd4ytdMf8zdax0liRXNmU+ED6ukl5IFrH59iQd lX7A== X-Gm-Message-State: ALKqPwci8GrcIvcS+lCW+55RzW+HAC9GyitGZ8+8d9NLQf/IJxYWrCdq inIujdlv1Y4yprUZsNcRSUud497wxKA= X-Google-Smtp-Source: AB8JxZpMmvmrSEZgvD+JD2wVqAYPAa5cdOA14hSYEkLLwIsBdI0LQMd1eKnPiVLzlk2XNTpnadnSUQ== X-Received: by 2002:a1c:7e8d:: with SMTP id z135-v6mr553452wmc.6.1526981111369; Tue, 22 May 2018 02:25:11 -0700 (PDT) Received: from localhost.localdomain (193.164.125.18.ip.redstone-isp.net. [193.164.125.18]) by smtp.gmail.com with ESMTPSA id s7-v6sm1404418wrp.4.2018.05.22.02.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 02:25:10 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger Date: Tue, 22 May 2018 09:23:48 +0000 Message-Id: <20180522092352.19794-15-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180522092352.19794-1-alex.kiernan@gmail.com> References: <20180522092352.19794-1-alex.kiernan@gmail.com> X-Mailman-Approved-At: Tue, 22 May 2018 10:37:51 +0000 Cc: Jocelyn Bohr , Chris Packham , Angelo Dureghello , Heinrich Schuchardt , Alexander Graf , Benjamin Young , Andre Przywara , Jassi Brar , Jagan Teki , Andy Yan , Maxime Ripard Subject: [U-Boot] [PATCH v6 14/18] mmc: Separate "mmc swrite" from fastboot 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" Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc swrite" command is separated from the fastboot code. Move image-sparse from common to lib so it's clear it's library code. Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig. Signed-off-by: Alex Kiernan Acked-by: Jassi Brar --- Changes in v6: None Changes in v5: - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig. Changes in v4: - new Changes in v3: None Changes in v2: None cmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 11 +++++++++++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 6 +----- scripts/config_whitelist.txt | 1 - 8 files changed, 28 insertions(+), 13 deletions(-) rename {common => lib}/image-sparse.c (97%) diff --git a/cmd/Kconfig b/cmd/Kconfig index 91f6dfef92..98763c9108 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support. +config CMD_MMC_SWRITE + bool "mmc swrite" + depends on CMD_MMC && MMC_WRITE + select IMAGE_SPARSE + help + Enable support for the "mmc swrite" command to write Android sparse + images to eMMC. + config CMD_NAND bool "nand" default y if NAND_SUNXI diff --git a/cmd/mmc.c b/cmd/mmc.c index cc445258c0..66c3ee008d 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag, return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } -#if CONFIG_IS_ENABLED(MMC_WRITE) -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, lbaint_t blkcnt, const void *buffer) { @@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag, } #endif +#if CONFIG_IS_ENABLED(MMC_WRITE) static int do_mmc_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -868,10 +868,10 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), #if CONFIG_IS_ENABLED(MMC_WRITE) U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), -#if defined(CONFIG_FASTBOOT_FLASH) - U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), -#endif U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), +#endif +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) + U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), #endif U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), @@ -927,7 +927,7 @@ U_BOOT_CMD( "info - display info of the current MMC device\n" "mmc read addr blk# cnt\n" "mmc write addr blk# cnt\n" -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) "mmc swrite addr blk#\n" #endif "mmc erase blk# cnt\n" diff --git a/common/Makefile b/common/Makefile index 9ec40b9d27..b3da72ebb2 100644 --- a/common/Makefile +++ b/common/Makefile @@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o obj-$(CONFIG_CMD_BEDBUG) += bedbug.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o -obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 1d7caaff99..0c9ced53de 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -57,6 +57,7 @@ config FASTBOOT_FLASH bool "Enable FASTBOOT FLASH command" default y if ARCH_SUNXI depends on MMC || (NAND && CMD_MTDPARTS) + select IMAGE_SPARSE help The fastboot protocol includes a "flash" command for writing the downloaded image to a non-volatile storage device. Define diff --git a/lib/Kconfig b/lib/Kconfig index 1590f7afa4..15c6a52d4a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -61,6 +61,17 @@ config SPL_STRTO config TPL_STRTO bool +config IMAGE_SPARSE + bool + +config IMAGE_SPARSE_FILLBUF_SIZE + hex "Android sparse image CHUNK_TYPE_FILL buffer size" + default 0x80000 + depends on IMAGE_SPARSE + help + Set the size of the fill buffer used when processing CHUNK_TYPE_FILL + chunks. + config USE_PRIVATE_LIBGCC bool "Use private libgcc" depends on HAVE_PRIVATE_LIBGCC diff --git a/lib/Makefile b/lib/Makefile index d531ea54b3..a4bbe2fb48 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o +obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o obj-y += initcall.o obj-$(CONFIG_LMB) += lmb.o obj-y += ldiv.o diff --git a/common/image-sparse.c b/lib/image-sparse.c similarity index 97% rename from common/image-sparse.c rename to lib/image-sparse.c index 1ae7a4d0e8..036062139b 100644 --- a/common/image-sparse.c +++ b/lib/image-sparse.c @@ -44,10 +44,6 @@ #include -#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE -#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512) -#endif - static void default_log(const char *ignored, char *response) {} int write_sparse_image(struct sparse_storage *info, @@ -69,7 +65,7 @@ int write_sparse_image(struct sparse_storage *info, int i; int j; - fill_buf_num_blks = CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE / info->blksz; + fill_buf_num_blks = CONFIG_IMAGE_SPARSE_FILLBUF_SIZE / info->blksz; /* Read and skip over sparse image header */ sparse_header = (sparse_header_t *)data; diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 9f95e8fa0e..42de673ac1 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -590,7 +590,6 @@ CONFIG_EXYNOS_RELOCATE_CODE_BASE CONFIG_EXYNOS_SPL CONFIG_EXYNOS_TMU CONFIG_FACTORYSET -CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE CONFIG_FAST_FLASH_BIT CONFIG_FB_ADDR CONFIG_FB_BACKLIGHT