From patchwork Thu Dec 14 13:26:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 121932 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6804599qgn; Thu, 14 Dec 2017 05:28:01 -0800 (PST) X-Google-Smtp-Source: ACJfBot9FXUje31cu22I3ILmJe1i/bk80bfgTR7yFj+d82p7IVyord/y5eETpU1/Ml4E9OQvf45y X-Received: by 10.80.209.193 with SMTP id i1mr12239858edg.107.1513258081234; Thu, 14 Dec 2017 05:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513258081; cv=none; d=google.com; s=arc-20160816; b=VJOs7AbYNaxJdntS9it67Qrhi0HwedAm/kp6b9FgKsOda4zKcFAqVXEw2LmLWO+aw6 yWhSnyr2LncTYE9bUooXdyXHs5jHrNYexTOXieMqeeiSbIOsKQVD2yyYlVw5XWUCtR7B sgVWTw01ysQopKAyUmza6zMVs2xwtTgBS0J5qwyUMmbPHVv8J1+NazCZg7H7oVs1EKl4 R78IT7rnKlxzk14v8UWWW9UEQVXGbWi3NnQ/y50X07L1E3zHeoDNFDrn76y3Zkx1l5jy tZuYHWrNDRLSvMZQn0CSThaRC4uqjKk5WIg+fvWExJHfHM3dndC3qK9EJNf78G7RHZLT xuaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:arc-authentication-results; bh=aS49BlLBkMLVcJoVcuRzvSz4xEX2Lf7O8iaitJJSs0A=; b=NLjuvRqoAtNBfIOiq1W55wCDGcmKaBF8hAHS5u+ku1fsS9sXUP4zjNIXFbZab0owzM 271ib8qUkg5+H2bokaPhHvXjDO0Tgkw9H5J14K0d4HBUeQ8qhpvWuDR+19inOY0lYiCl GL5toE/PzCN+5BL45yGzjNB9o+/gqQ7etj156fpTaBz8mFqEYgvSgKsa4IRs8XkuwLGd hJNJhMhuBvxPWbvmLGWjpUC0+NY0D24oqNMNpgJffj7YkZ4kXq1a1SrLmnEMGUo484/i VpIdvjiuO7QLQmznpmc1PflvSKSX9qHy/ObHrD2Z8q/sqFY+Na9f6yBUxE2umI4TFoL1 G6IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HEHqE4VL; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id i6si3082307edf.419.2017.12.14.05.28.00; Thu, 14 Dec 2017 05:28:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HEHqE4VL; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id C6BB6C21EF1; Thu, 14 Dec 2017 13:27: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.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 BCFB7C21E51; Thu, 14 Dec 2017 13:27:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 53D2AC21DBB; Thu, 14 Dec 2017 13:27:06 +0000 (UTC) Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by lists.denx.de (Postfix) with ESMTPS id 04BCDC21DBB for ; Thu, 14 Dec 2017 13:27:06 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id q9so5152140wre.7 for ; Thu, 14 Dec 2017 05:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=x3Lh60uoS4haCy780x/MJ9/5h1co7duWn8Yj3sdiPFU=; b=HEHqE4VLktYEVfdnHvJZC2Dzmq0nIuACMWxR7XibM0TREhlWzbFT5D8XU7/EH+ENol XuA9g27c31MwHwr6I0ZWnJChk/MVVNBwgQhdjrJFZg7Z3CNpF2Sj6Fz0+mY1Y5eJwt4r kJTsLs/jnt1XL5Bcy2t1nTx7r13zSqyFLpj4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=x3Lh60uoS4haCy780x/MJ9/5h1co7duWn8Yj3sdiPFU=; b=V6sBygdL2H9LjsRXgPnz9c1LguUlwFwubZgdGgVQ696DLx1w4LG9E4dWlten6IeP52 w28VTl3Pmk/7SNAVGuSXZGUfWhJkfzpFX7P23atPWxsOoYWxEGqELoAvuqfxpMEmV+is hpBV6repANZW3T+1bGTd4suSFKc+SYxcEeCtxsl1we4gnG6+tYY4gXPy3Ff7pv9Z0HwY Q6K0dv9023Lp+/KPyncQ4A7TgGazTEAdWJTDQJMDcGfFjCPXI3mbr7A7y80JxOQf7oiD X6nrw/9OYmyYW3LFLyv+7fAP0/2wSn5APt1462DdR5oYyCVEWKBHhZ5QOuCqcMH4e20k pYgA== X-Gm-Message-State: AKGB3mIRGCDmOoWlTTTarV9jdLPq6rKWnObt93ZC2u1hlxBOQoz5dJbV kwAgEP6XOOsxGEIb4dpHYOreM2Hp15w= X-Received: by 10.223.138.138 with SMTP id y10mr6184465wry.167.1513258025566; Thu, 14 Dec 2017 05:27:05 -0800 (PST) Received: from igloo.80.58.61.254 (141.pool85-51-114.dynamic.orange.es. [85.51.114.141]) by smtp.gmail.com with ESMTPSA id l3sm3235378wrg.2.2017.12.14.05.27.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 05:27:04 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, u-boot@lists.denx.de Date: Thu, 14 Dec 2017 14:26:53 +0100 Message-Id: <1513258020-23589-2-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513258020-23589-1-git-send-email-jorge.ramirez-ortiz@linaro.org> References: <1513258020-23589-1-git-send-email-jorge.ramirez-ortiz@linaro.org> Subject: [U-Boot] [PATCH v2 1/8] env: enable accessing the environment in an EXT4 partition 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" For example to store the environment in a file named "/uboot.env" in MMC "0", where partition "1" contains the EXT4 filesystem, the following configs should be added to the board's default config: CONFIG_ENV_IS_IN_EXT4=y CONFIG_ENV_EXT4_DEVICE_AND_PART="0:1" CONFIG_ENV_EXT4_FILE="/uboot.env" CONFIG_ENV_EXT4_INTERFACE="mmc" Signed-off-by: Jorge Ramirez-Ortiz --- env/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++ env/env.c | 2 ++ env/ext4.c | 20 ++++++++++---------- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index 2477bf8..71529b2 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -81,6 +81,13 @@ config ENV_IS_IN_FAT - CONFIG_FAT_WRITE: This must be enabled. Otherwise it cannot save the environment file. +config ENV_IS_IN_EXT4 + bool "Environment is in a EXT4 filesystem" + depends on !CHAIN_OF_TRUST + select EXT4_WRITE + help + Define this if you want to use the EXT4 file system for the environment. + config ENV_IS_IN_FLASH bool "Environment in flash memory" depends on !CHAIN_OF_TRUST @@ -396,6 +403,38 @@ config ENV_FAT_FILE It's a string of the FAT file name. This file use to store the environment. +config ENV_EXT4_INTERFACE + string "Name of the block device for the environment" + depends on ENV_IS_IN_EXT4 + help + Define this to a string that is the name of the block device. + +config ENV_EXT4_DEVICE_AND_PART + string "Device and partition for where to store the environemt in EXT4" + depends on ENV_IS_IN_EXT4 + help + Define this to a string to specify the partition of the device. It can + be as following: + + "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1) + - "D:P": device D partition P. Error occurs if device D has no + partition table. + - "D:0": device D. + - "D" or "D:": device D partition 1 if device D has partition + table, or the whole device D if has no partition + table. + - "D:auto": first partition in device D with bootable flag set. + If none, first valid partition in device D. If no + partition table then means device D. + +config ENV_EXT4_FILE + string "Name of the EXT4 file to use for the environemnt" + depends on ENV_IS_IN_EXT4 + default "uboot.env" + help + It's a string of the EXT4 file name. This file use to store the + environment (explicit path to the file) + if ARCH_SUNXI config ENV_OFFSET diff --git a/env/env.c b/env/env.c index 76a5608..7455632 100644 --- a/env/env.c +++ b/env/env.c @@ -32,6 +32,8 @@ static enum env_location env_get_default_location(void) return ENVL_EEPROM; else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) return ENVL_FAT; + else if IS_ENABLED(CONFIG_ENV_IS_IN_EXT4) + return ENVL_EXT4; else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH) return ENVL_FLASH; else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC) diff --git a/env/ext4.c b/env/ext4.c index 6520221..07fd061 100644 --- a/env/ext4.c +++ b/env/ext4.c @@ -46,8 +46,8 @@ static int env_ext4_save(void) if (err) return err; - part = blk_get_device_part_str(EXT4_ENV_INTERFACE, - EXT4_ENV_DEVICE_AND_PART, + part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE, + CONFIG_ENV_EXT4_DEVICE_AND_PART, &dev_desc, &info, 1); if (part < 0) return 1; @@ -57,16 +57,16 @@ static int env_ext4_save(void) if (!ext4fs_mount(info.size)) { printf("\n** Unable to use %s %s for saveenv **\n", - EXT4_ENV_INTERFACE, EXT4_ENV_DEVICE_AND_PART); + CONFIG_ENV_EXT4_INTERFACE, CONFIG_ENV_EXT4_DEVICE_AND_PART); return 1; } - err = ext4fs_write(EXT4_ENV_FILE, (void *)&env_new, sizeof(env_t)); + err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)&env_new, sizeof(env_t)); ext4fs_close(); if (err == -1) { printf("\n** Unable to write \"%s\" from %s%d:%d **\n", - EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part); + CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev, part); return 1; } @@ -84,8 +84,8 @@ static int env_ext4_load(void) int err; loff_t off; - part = blk_get_device_part_str(EXT4_ENV_INTERFACE, - EXT4_ENV_DEVICE_AND_PART, + part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE, + CONFIG_ENV_EXT4_DEVICE_AND_PART, &dev_desc, &info, 1); if (part < 0) goto err_env_relocate; @@ -95,16 +95,16 @@ static int env_ext4_load(void) if (!ext4fs_mount(info.size)) { printf("\n** Unable to use %s %s for loading the env **\n", - EXT4_ENV_INTERFACE, EXT4_ENV_DEVICE_AND_PART); + CONFIG_ENV_EXT4_INTERFACE, CONFIG_ENV_EXT4_DEVICE_AND_PART); goto err_env_relocate; } - err = ext4_read_file(EXT4_ENV_FILE, buf, 0, CONFIG_ENV_SIZE, &off); + err = ext4_read_file(CONFIG_ENV_EXT4_FILE, buf, 0, CONFIG_ENV_SIZE, &off); ext4fs_close(); if (err == -1) { printf("\n** Unable to read \"%s\" from %s%d:%d **\n", - EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part); + CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev, part); goto err_env_relocate; }