From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA92CC433EF for ; Sun, 19 Sep 2021 19:01:00 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12F6461050 for ; Sun, 19 Sep 2021 19:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 12F6461050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 094CD82039; Sun, 19 Sep 2021 21:00:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="OWyDrBh3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A629982039; Sun, 19 Sep 2021 21:00:20 +0200 (CEST) Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5E61F82039 for ; Sun, 19 Sep 2021 20:59:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x229.google.com with SMTP id n78so8455644oig.6 for ; Sun, 19 Sep 2021 11:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aUzI53r3l4XA3VTosIUqh5RZMlrySm9dsjhQ/TJqXZo=; b=OWyDrBh3tFFj6fhifyElwY8ByCJC7/gbB9CKvAqYlUecSYZDfelfwz1zk0qw2SKxPH 811nV+qjtGORNoBbuvoSkqVKhxVKPxIaHRm69Nb6w0PD/l/I8PVfKHk3nssjv8P1/BjT ZQiBEM20FVik/nG5gtafNpBgOXZcSgeeBAfy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aUzI53r3l4XA3VTosIUqh5RZMlrySm9dsjhQ/TJqXZo=; b=cqcnmSi+nVo5g8BbYqUQ51sUk+ttD/dhhu43rRith+r+ljURNiBZV7OblNL/GPrpct 1a7GVD+NBBuGwN3r0xkS6TcAYUhEiQ16Eg6zNHdDkknHc2cZ3j7/2ylZ+i96mygavLiA sgB5ehqgSWKHsqNDtkUO8IFloau1wMBusFPxiY5kODDkDNzDRqSpZ8g6dJZBPZrILLhW Tr8sRK2G+YLxMIMVpdDLjEucmgkC6VqeT/HZNYa6F63HmoNp5TSJgxveA+rWkSrtXPFS GRePJgXXlPu5sr45NOT3Br4FPa3PYcg9cl/eONIdzVnZ3UNMCZdSEX85vpH/FKFHtB+P o6CA== X-Gm-Message-State: AOAM532IsjCuuvVDcZcCrtfB8VV59JQygSZ4g/4E7DOUkhpkrJiI3ynb QrASPXBYO8ZZo/nK3CFy78m2C1xWhgIOAQ== X-Google-Smtp-Source: ABdhPJxqpBzOSuwYGAqvTvAxvySxUJLcSRgOtez06ImPrn96kzPo6oUOOqqvWRHsDCgN32TdB3pGwA== X-Received: by 2002:a05:6808:168e:: with SMTP id bb14mr10760712oib.121.1632077995574; Sun, 19 Sep 2021 11:59:55 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id bj27sm2634540oib.58.2021.09.19.11.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 11:59:55 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Claudiu Manoil , Heinrich Schuchardt , Joe Hershberger , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Naoki Hayama , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Patrick Delaunay , Priyanka Jain , Rasmus Villemoes , Stefan Roese , Vladimir Oltean , Wolfgang Denk Subject: [PATCH v4 0/5] env: Allow environment in text files Date: Sun, 19 Sep 2021 12:59:45 -0600 Message-Id: <20210919185950.3813952-1-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean One barrier to completing the 7-year-long Kconfig migration is that the default environment is implemented using ad-hoc CONFIG options. At present U-Boot environment variables, and thus scripts, are defined by CONFIG_EXTRA_ENV_SETTINGS. It is not really feasible to move the environment to Kconfig as it is hundreds of lines of text in some cases. Even considering the current situation, it is painful to add large amounts of text to the config-header file and dealing with quoting and newlines is harder than it should be. It would be better if we could just type the script into a text file and have it included by U-Boot. Add a feature that brings in a .env file associated with the board config, if present. To use it, create a file in a board//env directory called .env (or common.env if you want the same environment for all boards). The environment variables should be of the form "var=value". Values can extend to multiple lines. This series converts the existing environment documentation to rST and updates it to explain how to use this. Note: this series was originally sent eight years ago: https://patchwork.ozlabs.org/project/uboot/patch/1382763695-2849-4-git-send-email-sjg@chromium.org/ It has been updated to work with Kconfig, etc. Some review comments in that patch were infeasible so I have not addressed them. I would like this series to be considered independently, on its merits. Rather than deal with the complexity of rewriting the distro-boot script, this is disabled for sandbox. The forthcoming bootmethod approach should provide the same functionality without needing the complex scripting in the environment. Migration needs more thought, although it can be done later. It may be possible to do migrate automatically, using buildman to extract the built-in environmnent from the ELF file. This would produce a pretty ugly conversion though, since it would drop all the intermediate variables used to create the environment. Better would be to parse the config.h file, figure out the components of CONFIG_EXTRA_ENV_SETTINGS then output these as separate pieces in the file. It is not clear how easy that would be, nor whether the result would be very pretty. Also the __stringify() macro needs to be handled somehow. This series is available at u-boot-dm/env-working Comments welcome. Changes in v4: - Add new patch to move environment documentation to rST - Move this from being part of configuring U-Boot to part of building it - Don't put the environment in autoconf.mk as it is not needed - Add documentation in rST format instead of README - Drop mention of import/export - Update awk script to ignore blank lines, as generated by clang - Add documentation in rST format instead of README Changes in v3: - Adjust Makefile to generate the .inc and .h files in separate fules - Add more detail in the README about the format of .env files - Improve the comment about " in the awk script - Correctly terminate environment files with \n - Define __UBOOT_CONFIG__ when collecting environment files - Add new patch to use a text-based environment for sandbox Changes in v2: - Move .env file from include/configs to board/ - Use awk script to process environment since it is much easier on the brain - Add information and updated example script to README - Add dependency rule so that the environment is rebuilt when it changes - Add separate patch to enable C preprocessor for environment files - Enable var+=value form to simplify composing variables in multiple steps Simon Glass (5): sandbox: Drop distro_boot doc: Move environment documentation to rST env: Allow U-Boot scripts to be placed in a .env file env: Allow environment files to use the C preprocessor sandbox: Use a text-based environment Makefile | 39 ++- README | 328 -------------------------- board/sandbox/env/sandbox.env | 25 ++ config.mk | 2 + doc/usage/environment.rst | 431 ++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + env/embedded.c | 1 + include/configs/sandbox.h | 40 ---- include/env_default.h | 8 + scripts/env2string.awk | 55 +++++ 10 files changed, 561 insertions(+), 369 deletions(-) create mode 100644 board/sandbox/env/sandbox.env create mode 100644 doc/usage/environment.rst create mode 100644 scripts/env2string.awk -- 2.33.0.464.g1972c5931b-goog