Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCBE5C433F5 for ; Sat, 2 Oct 2021 00:39:23 +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 E40D161A7A for ; Sat, 2 Oct 2021 00:39:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E40D161A7A 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 D51B282021; Sat, 2 Oct 2021 02:39:18 +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="ibe1d+hS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D6D581FEC; Sat, 2 Oct 2021 02:38:59 +0200 (CEST) Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) (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 D2BCA815B7 for ; Sat, 2 Oct 2021 02:38: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=sjg@chromium.org Received: by mail-ot1-x334.google.com with SMTP id r43-20020a05683044ab00b0054716b40005so13549956otv.4 for ; Fri, 01 Oct 2021 17:38:52 -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=CQI4gd+iaXwH16+RR2UgtrZou1ezOfycfpkK0Tjz2OQ=; b=ibe1d+hSlv1AR3vSpsceTVOizskZRFJUFGsA1WH4g8JK1pTwkxfX/VAHUUGB0KLLmV WojXyWSbmPOnCUMk2kWebtZdk6PwjQBjffLH1PtJL84Zt5uZaRqbJP9qLekYWoYO/HGy 6cjr6w7MjSvfZT+FO+56xDw5ltBVm7103NLBk= 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=CQI4gd+iaXwH16+RR2UgtrZou1ezOfycfpkK0Tjz2OQ=; b=unVtDR4Kbl54gkgY7JNKPqqpas6dM+0VUmy0BTVxseZEkPHdV57zaojkgCfYiGbT5a fJcypsAcB9t51gQM53gdbEAcosW6iisB+Muu/Y8LjGWU+XIRCzPw2idZD9c07fljNIxM t/Mbfgc6yMfJRnslGAvAErYV8v4U7Q8XFp8rdf19BzMyRsIWbvFRgPZ8g4Ze7x0Xj0w4 kcIDdfmmfSBiw8V+DvO015AfpNBEFsH8P/7ifm5X+mr6NoNfmHBpXv6hryheTOvBbcsJ Id2vG5bMH3q7pFQKdgbFFgO0Ygy4renDQvBbA7JnXLlodat5RwyQ7svOWibj9UTsUii1 /1CQ== X-Gm-Message-State: AOAM533d1HUtmiDTTdx0iscj8lqmFVM8yVkNDL59+qopwLVouFqAzDiF YNl9MFRQSXaO2ECJhpGqFsurNwtfvha2ig== X-Google-Smtp-Source: ABdhPJy0y69K2BrEBOCJvYDI8xZ54KARcvYNgNFfEW/M7VJo6nn1HwtifhigPoeeUWhBPgmaLJRIUg== X-Received: by 2002:a9d:7588:: with SMTP id s8mr643728otk.323.1633135131024; Fri, 01 Oct 2021 17:38:51 -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 i12sm1412354oik.50.2021.10.01.17.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 17:38:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Denk , Tom Rini , Simon Glass , Joe Hershberger Subject: [PATCH v5 0/5] env: Allow environment in text files Date: Fri, 1 Oct 2021 18:38:42 -0600 Message-Id: <20211002003848.1803446-1-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-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 v5: - Minor updates as suggested by Wolfgang - Explain how to include the common.env file - Explain why variables starting with _ , and / are not supported - Expand the definition of how to declare an environment variable - Explain what happens to empty variables - Update maintainer 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 - Move use of += to this patch - Explain that environment variables may not end in + 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 MAINTAINERS | 7 + Makefile | 39 ++- README | 328 ------------------------- board/sandbox/env/sandbox.env | 25 ++ config.mk | 2 + doc/usage/environment.rst | 444 ++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + env/embedded.c | 1 + include/configs/sandbox.h | 40 --- include/env_default.h | 8 + scripts/env2string.awk | 56 +++++ 11 files changed, 582 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.800.g4c38ced690-goog