From patchwork Wed Jan 10 10:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jorge Ramirez-Ortiz, Gmail" X-Patchwork-Id: 124037 Delivered-To: patch@linaro.org Received: by 10.80.140.226 with SMTP id r31csp1488290edr; Wed, 10 Jan 2018 02:36:47 -0800 (PST) X-Google-Smtp-Source: ACJfBouCK1ech0fECFK3lnkNB55CMCKM7eQE4HegV4ZaoXlf2ekE48jkbbth9X2afc+FR0nWy/gH X-Received: by 10.80.136.129 with SMTP id d1mr25584484edd.256.1515580607554; Wed, 10 Jan 2018 02:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515580607; cv=none; d=google.com; s=arc-20160816; b=Dv670cvAYFtGBXWZHJE264i9kQmIGsNXwPLKU+VGVGuAolQxFptrgandTiPNPq7egp nmTjU7pKLreN5Oes3NIrJTno2aSZax5PmnBgaekB2tEQycpalnqG5ZVwWJiHe+BL5rT2 3i2jWwe0tWyVW7v36tS6mW46KvkZ4QUcUDVvKx6UFXcZ+iEWtg3/2oRPGbZURAELg8T5 H9bdlLuECS0HKSDxcz8bkG556EILnda3hqkUXUKkuH8MIma/2g+cZrtaEiGes8GPAN6f OAbKRnRvdr5DCralFQlxg4qUI9iFi/qvXbv8zDD3tyJHR7nTrFd/InrHJiCGLZ2Zsqei uZLA== 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:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=Wtm1LdGDNhQtwrzRyDm6Xk1N3AckSDJhkXKkjOHyDpk=; b=NmAelmxnRmyEt3nj0NWrsfHaKj5+G86bGtYRalW+zM7OWpPrLSAbUGcGVjxtcQqInp nfbO1+IW511R1PQrxA+irHUI6ars4Iz1Y+ckrHSw2R+poRpN6l6BXBX4E9Oad9783IPJ LF7OKajQ+37+ykdCJgfBP98tvqKU0UqEgZYlnS/7nCrSN/N/lL2f1/rtqSwL+/jHjX2P egeb8XlbQ50Jrd7elGr0M36JyCsPJs3koxavXJXkd6avfqLAzbaYuWa9gxTsxT50D6wb trxmsgPYpxG+7nwbIUbLpouFpvL3ueBVE/T/FZmSyL00+Y/fz2jdsNw6XhFBoaPE/1Sc cOZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=UE4+bl1x; 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=gmail.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id o32si3954098edd.465.2018.01.10.02.36.47; Wed, 10 Jan 2018 02:36:47 -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=@gmail.com header.s=20161025 header.b=UE4+bl1x; 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=gmail.com Received: by lists.denx.de (Postfix, from userid 105) id 339A3C2217C; Wed, 10 Jan 2018 10:34:33 +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, 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 C4566C2210C; Wed, 10 Jan 2018 10:34:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 37A09C2209F; Wed, 10 Jan 2018 10:34:02 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id 3EE30C21E2C for ; Wed, 10 Jan 2018 10:33:58 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id o7so14093768wro.8 for ; Wed, 10 Jan 2018 02:33:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=fhhTPbDrJg2mgH33UcIF+IcXMyQLbrv5DZx/5bKFcqs=; b=UE4+bl1xeE1hebQLclwQHF0P8j8AOsHP52uuIy9jGcYn/I1yexUKHZA23vGh4Ed1rI CYnCTzEn+FqC5p530YDRFFs7B/cdRrRzkxNiieZCX2xf1PiJeS++1sSeqLhz7MPAZmNX lj9+0sgimZP5v3tUMjmrqdhddW9TgcLuXrpJeEHg6gDqjYQiSoRSb14kpOmsDEf+mGO4 S0TJrhzm495lHtKYvQeaggnMoPJNPcqQIgZBkdAw5u+xijwZZOHv3vkHkEnrIX5n951S R8DxRo3Cx+/JFca2lbh8xUIuoVUiFveTjY3gwVLrAJjUueJIB8gR1n2zyJIRt/vIEiYp dt3w== 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; bh=fhhTPbDrJg2mgH33UcIF+IcXMyQLbrv5DZx/5bKFcqs=; b=Kino8juzmgeX3ji198WH5M6GxAoCvw+yUCO7wwzn4ynmsq82C2HGl4eGQ/rHFEXtZx +pzrwUPXNQ+EsiveD26cGVS/TCmvnzrv80yCruFw8FsUfCqqkgQUl3xmEfpeXr98AAcd m3+aGR+JZpUDlNfUwB8svsnwxL0GbunHGZyW8bads5iuq/lVlHuhfTakMnx86DW9Gs1a s8eL61RfKEfCZz17M1h3rBhZKGuu3mtdu8Is12lkcac/biGc2eCgIV8qUHvhV+SM31SD dvEpjdUGDFnwh4x8XK+9Q2V8z7S/3EbiBv55USqarhS6B8defyv1apVw9Dc4RG/CCqy9 Vu8A== X-Gm-Message-State: AKGB3mIZLP/t5VFdHxLyNPmY/jRlJFEW/b/jAonfbD4SbmnQTmDQ0Oeb bLJSQGZbvy6CyirC7hW6oPsbHA== X-Received: by 10.223.134.161 with SMTP id 30mr16438642wrx.93.1515580437633; Wed, 10 Jan 2018 02:33:57 -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 z71sm5091969wrc.11.2018.01.10.02.33.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 02:33:57 -0800 (PST) From: Jorge Ramirez-Ortiz To: u-boot@lists.denx.de Date: Wed, 10 Jan 2018 11:33:48 +0100 Message-Id: <1515580432-25985-1-git-send-email-jorge.ramirez.ortiz@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [U-Boot] [PATCH v1 01/05] 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" From: Jorge Ramirez-Ortiz 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 bef6e89..692f863 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; }