From patchwork Mon Nov 6 13:16:37 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: 118034 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2755457qgn; Mon, 6 Nov 2017 05:16:53 -0800 (PST) X-Google-Smtp-Source: ABhQp+QI3goAC0SHgDTKvNUk7bXJXelspx6Kecg5zy7Weag7wUmHm49oXxHUlpaX1GFoiybwp7Ir X-Received: by 10.80.177.179 with SMTP id m48mr20729113edd.114.1509974213751; Mon, 06 Nov 2017 05:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509974213; cv=none; d=google.com; s=arc-20160816; b=w8W5xAdGaS9Z5saupMExGRQVwkA74KbycCcybyXw+jfm0AO57YdGq1PGwWQDUnZucC DC3GmcS2YlTWLEixcPm5dhWp8UyRq8zMWWhQq+feV0XUxmxo/pSDiXk0avx+KK8Qqujo xr73HVL+RPUsvRBgm+HxWwbqSIPg6dtLVdZfU4aViU6QY1lvqtkdqSdVXM1WxPI4ESPl /Un3sUvrDMnL0GdOSEVqOaibSNoOU8tu4owoIz73Oygrxn9ARsTP8NY8+x+odK9dPNVF 6vY+pqxqclTfAI0Xt4FxX/BByPUAUS48TDuU+RcmAnpPm2q/jE0bBf5C1yGiEfazIEzo F0tA== 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:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=CDMXqQAJreEr8BxK1cvbKbewzRSM56vj/y0Z75uGmMo=; b=nBBAKjX4INF1NIK/BBDHB5EDc+jaCVwKd5oc9XAqhwNuVEwmItx6jFPbUIbkrKFtkl vEygOFOxgQYGoi3S3Mbtc9liVh2AmMU2g7Ti/HKFTEdTsxhhs/8hi89z4DXaKojOEN9L yypArj5KVBifMBCIeaXFmhqPGKadGaYb+KGDTiDq2+yHf72mCVxECBiomYBjoZc5oq7T aepMcNKb5kCHJyYpLayzcZyJQv29Xg/O7T3zM8eZ0nxbKRfi8mUhd/PTyB/KG79E2haa 5OxFENBK1oenW62ogAgBJ78euTsLU+fIM0mTCRE8ouE1DjRcNMbMOVf/EEDrhiGhDFgK hOGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VQj/X6VA; 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 b40si1939340edd.163.2017.11.06.05.16.53; Mon, 06 Nov 2017 05:16:53 -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=VQj/X6VA; 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 D45C7C21DE9; Mon, 6 Nov 2017 13:16:49 +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 BD895C21D8C; Mon, 6 Nov 2017 13:16:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5961CC21D8C; Mon, 6 Nov 2017 13:16:46 +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 4D233C21D84 for ; Mon, 6 Nov 2017 13:16:45 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id g10so1017832wrg.11 for ; Mon, 06 Nov 2017 05:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RbZC019LYQ5m+qq6jwG37ZpfdEMvTxjUDsk/glXFbOY=; b=VQj/X6VAfEWtGvPL5vy/BsQ740jWJmGvZmxZ1lFkExsE3p2yrjIy55KvP9a7yKUSiV IykkrOnB1CUiA0nHFIBj+83PGLntfjbKSthUFHTHbpRy5KFOQgaGf0RMrwoFFDmmJYdK PsjmPJ0pqbJdeCTVCEMzpUfyWAJyQKkre/a88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RbZC019LYQ5m+qq6jwG37ZpfdEMvTxjUDsk/glXFbOY=; b=UJQSgZrHA0MgqS6cVYjwFiYF0Rajij+ySlwdDfGVHM+k371cCf9zzb9aduO+5cL+TN IO/x49soNAAmp4xKD4pp6vlwIEkng4JCffiHBPWRTOd/aAnIVdtgp96rbagtRH/u6OUa Fdj+V+owC5mktwWnomUGBrYESYMlXtiCX3y1qO+efWVUxXaLfD2h3AXZuZ720YBlfLWH KN0krxoJZGCuOLyEBlDd/yc+ZG8K+AL6vJ6KXpnARctjkqb6NgR30xN+G090zYqQ4i3D oGKfgI3SHBFAXPGA/ZygcmMyFD+Zct+AqYuI6rrV6wuy/UAnBdb1/W+uWg0Wd/rMb3R+ /G/g== X-Gm-Message-State: AMCzsaWODTCu6An9OTclMW1ajdIN/bYNE7SCFpyziN4R6DkiIYWZmxGY bAkXdPKFZ5Q9ee737Qy9NgOMOg== X-Received: by 10.223.130.56 with SMTP id 53mr13804806wrb.131.1509974204845; Mon, 06 Nov 2017 05:16:44 -0800 (PST) Received: from localhost.localdomain ([90.68.73.7]) by smtp.gmail.com with ESMTPSA id 141sm11210302wmr.45.2017.11.06.05.16.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 05:16:44 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, u-boot@lists.denx.de Date: Mon, 6 Nov 2017 14:16:37 +0100 Message-Id: <1509974198-14831-1-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: nicolas.dechesne@linaro.org, daniel.lezcano@linaro.org Subject: [U-Boot] [PATCH 1/2] env: Save environment at the end of an MMC 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" Allow the platform to define a partition by name at the end of which the environment data will be located. Signed-off-by: Jorge Ramirez-Ortiz --- doc/device-tree-bindings/config.txt | 9 ++++++ env/mmc.c | 62 ++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index fe0e04a..15e4349 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -21,6 +21,15 @@ u-boot,efi-partition-entries-offset This setting will override any values configured via Kconfig. +u-boot,mmc-env-partition + if present, the environment shall be placed at the last + CONFIG_ENV_SIZE blocks of the partition on the + CONFIG_SYS_MMC_ENV_DEV. + + if u-boot,mmc-env-offset* is present, this setting will take + precedence. In that case, only if the partition is not found, + mmc-env-offset* will be tried. + u-boot,mmc-env-offset u-boot,mmc-env-offset-redundant If present, the values of the 'u-boot,mmc-env-offset' and/or diff --git a/env/mmc.c b/env/mmc.c index 3f3092d..3343f9e 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -15,9 +15,13 @@ #include #include #include +#include #include #include +#define __STR(X) #X +#define STR(X) __STR(X) + #if defined(CONFIG_ENV_SIZE_REDUND) && \ (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE) #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE @@ -30,18 +34,68 @@ DECLARE_GLOBAL_DATA_PTR; #endif #if CONFIG_IS_ENABLED(OF_CONTROL) +static inline int mmc_offset_try_partition(const char *str, s64 *val) +{ + disk_partition_t info; + struct blk_desc *desc; + int len, i, ret; + + ret = blk_get_device_by_str("mmc", STR(CONFIG_SYS_MMC_ENV_DEV), &desc); + if (ret < 0) + return (ret); + + for (i = 1;;i++) { + ret = part_get_info(desc, i, &info); + if (ret < 0) + return ret; + + if (!strncmp((const char *)info.name, str, sizeof(str))) + break; + } + + /* round up to info.blksz */ + len = (CONFIG_ENV_SIZE + info.blksz - 1) & ~(info.blksz - 1); + + /* use the top of the partion for the environment */ + *val = (info.start + info.size - 1) - len / info.blksz; + + return 0; +} + static inline s64 mmc_offset(int copy) { - const char *propname = "u-boot,mmc-env-offset"; - s64 defvalue = CONFIG_ENV_OFFSET; + const struct { + const char *offset_redund; + const char *partition; + const char *offset; + } dt_prop = { + .offset_redund = "u-boot,mmc-env-offset-redundant", + .partition = "u-boot,mmc-env-partition", + .offset = "u-boot,mmc-env-offset", + }; + s64 val, defvalue; + const char *propname; + const char *str; + int err; + + /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ + str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition); + if (str) { + /* try to place the environment at end of the partition */ + err = mmc_offset_try_partition(str, &val); + if (!err) + return val; + } + + defvalue = CONFIG_ENV_OFFSET; + propname = dt_prop.offset; #if defined(CONFIG_ENV_OFFSET_REDUND) if (copy) { - propname = "u-boot,mmc-env-offset-redundant"; defvalue = CONFIG_ENV_OFFSET_REDUND; + propname = dt_prop.offset_redund; } #endif - return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue); } #else From patchwork Mon Nov 6 13:16:38 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: 118035 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2756263qgn; Mon, 6 Nov 2017 05:17:41 -0800 (PST) X-Google-Smtp-Source: ABhQp+TqPbHPOocEyAzFbkW15wewN4y7nPC0njzFcJlshGQY+RHb56RVjcAOPJOMsBjj1MzDF4gk X-Received: by 10.80.149.221 with SMTP id x29mr19641954eda.4.1509974261244; Mon, 06 Nov 2017 05:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509974261; cv=none; d=google.com; s=arc-20160816; b=iaf/sOD3zniZuyPXXrNh0w/TGRuM78SC13PFiz4yBqBljsbJ2Y/WzySfH7hvsUo1M+ 0WYv5rmLPtRdQ3V9c6aU7epCsN4iFfxuYroAd8y/amJbmQpiGih/snrguqJZEjaX7NaL jQCZkLe3mwUIsxlBtPMNbuoBHPbPmY5On1YE1Cdy9/nosMv6hS8ER5hnu5PFVRtpafi2 zZMcYWDhKjeYSnLzduaO05jpqH9XLnliXAF/0W233nWP+tMvgJbFm3BKvPcBVQEzgnDH mQP+4c78/dm+1UQ4coOyGIMD3ORz0qXjYuFEpobrsJtbUTc85kKNatySE2xah+PSimHO tmbA== 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:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=HI70FMNIQ5iriRTaCVC91mnY5wDzZc4dMIF7wfckF1c=; b=qrquY+LBDatTIUmG5wlRmAJ/XEu1G0dg99Kqka9/YOZMFlz/2eykWR7mjCRSmS2lew wKuVWSJEPMdGtxR7BSgv2jmPm87nxE8/pCoEqwPeDN92iEA6FPVgLoFr6sFwE82u/x94 TT0OYrNnALWNYOiFwEJvUZe3uDIcTn6Y9mEY4KxXL07zHt5I92slFrjtmjzT3KBK6gAm OMXmzWNnFWcBdv7tloChHMbK7hNbacEq2vQXgRVEG5FKoz9YaaW/BoR9fzidV4OjwGAP D5Kpqmkq2lHptiWlobWbNoIAbsRgUxoh8fPnaZ+8pBfUNjdvwFYZwGzrYVpQwLS42fLs 1K0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VwXeIsaq; 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 q31si472343eda.85.2017.11.06.05.17.40; Mon, 06 Nov 2017 05:17:41 -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=VwXeIsaq; 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 D99DEC21D84; Mon, 6 Nov 2017 13:17:09 +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 9E8B3C21F18; Mon, 6 Nov 2017 13:16:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4A2F6C21D8C; Mon, 6 Nov 2017 13:16:47 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by lists.denx.de (Postfix) with ESMTPS id E71B1C21D84 for ; Mon, 6 Nov 2017 13:16:46 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id k61so2725729wrc.4 for ; Mon, 06 Nov 2017 05:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rsd1iCiGVFUfe9xvS7twafz+hPyxaiA9G/ri4m6yqwU=; b=VwXeIsaqPB+m6ChbbGTRDvwdycRsnWM4jWG7RurMQ34ezPbbp2dQ7CpynhLU2Y2S5l 3SMe+Nlt3oeSb2qodabKU/SzxHwe5teMaSM6BHjlcx189rrOOcPP9m6j7nxPgHeWuuML zLw4ipx0VlJShuh2jfluTdMjh/qJiwBMrdRuw= 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=Rsd1iCiGVFUfe9xvS7twafz+hPyxaiA9G/ri4m6yqwU=; b=UKfi509XzUCJOc8XOWVTevDr4wL7FPYa1PEV3eIidrt4ITUrH12OatNGYjCMFJcZt3 wD9GhJ2qE2wKR9OFS2AThWTs9Z4LbLmMD3+C2hISNe5LASxWsT2enjKe0gABLrW07M4P uC21Fcl8ntI7cTvWXGbjGeijgKQn10s+s/bB2a3TJIP3GOuMj2TtsnJlU2mOEvwsFCng i8L1ZhXhPGAOJy7bBLjoQdeqiiQFVC1N8nu8axw+il3RUkvi/upYFz63Fk37Uh9qV9y+ 1Ex/fYx6oG6rY68ehIlgGmOjvhiMlnsTS6stkN91oitjk2gYfXiN8VUUvfzobmMqqSZF 64FA== X-Gm-Message-State: AMCzsaXBqZJOke5z0EcqcGJA72zIMuYMHZ4FwfO8K9RPeWUsvU4No1T4 fxcP6GQTP05u0VSrxK8xjgasvw== X-Received: by 10.223.147.39 with SMTP id 36mr11783724wro.175.1509974206526; Mon, 06 Nov 2017 05:16:46 -0800 (PST) Received: from localhost.localdomain ([90.68.73.7]) by smtp.gmail.com with ESMTPSA id 141sm11210302wmr.45.2017.11.06.05.16.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 05:16:45 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, u-boot@lists.denx.de Date: Mon, 6 Nov 2017 14:16:38 +0100 Message-Id: <1509974198-14831-2-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509974198-14831-1-git-send-email-jorge.ramirez-ortiz@linaro.org> References: <1509974198-14831-1-git-send-email-jorge.ramirez-ortiz@linaro.org> Cc: nicolas.dechesne@linaro.org, daniel.lezcano@linaro.org Subject: [U-Boot] [PATCH 2/2] configs: dragonboard410c: Save environment data on eMMC 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" Save the environment data at the end of the boot partition on emmc Signed-off-by: Jorge Ramirez-Ortiz --- arch/arm/dts/dragonboard410c-uboot.dtsi | 7 +++++++ configs/dragonboard410c_defconfig | 2 ++ include/configs/dragonboard410c.h | 1 + 3 files changed, 10 insertions(+) diff --git a/arch/arm/dts/dragonboard410c-uboot.dtsi b/arch/arm/dts/dragonboard410c-uboot.dtsi index cc2c175..c3475c4 100644 --- a/arch/arm/dts/dragonboard410c-uboot.dtsi +++ b/arch/arm/dts/dragonboard410c-uboot.dtsi @@ -6,6 +6,13 @@ * SPDX-License-Identifier: GPL-2.0+ */ +/ { + config { + u-boot,mmc-env-partition = "boot"; + }; +}; + + &pm8916_gpios { usb_hub_reset_pm { gpios = <&pm8916_gpios 2 0>; diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig index a85aa74..4c04544 100644 --- a/configs/dragonboard410c_defconfig +++ b/configs/dragonboard410c_defconfig @@ -43,3 +43,5 @@ CONFIG_USB_ETHER_ASIX88179=y CONFIG_USB_ETHER_MCS7830=y CONFIG_USB_ETHER_SMSC95XX=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_OF_CONTROL=y +CONFIG_ENV_IS_IN_MMC=y diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h index 6b5d59d..d2447b2 100644 --- a/include/configs/dragonboard410c.h +++ b/include/configs/dragonboard410c.h @@ -100,6 +100,7 @@ REFLASH(dragonboard/u-boot.img, 8)\ BOOTENV #define CONFIG_ENV_SIZE 0x2000 +#define CONFIG_SYS_MMC_ENV_DEV 0 /* mmc0 = emmc, mmc1 = sd */ #define CONFIG_ENV_VARS_UBOOT_CONFIG /* Size of malloc() pool */