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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FDA4C433EF for ; Thu, 14 Oct 2021 18:23:49 +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 9DFB261037 for ; Thu, 14 Oct 2021 18:23:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9DFB261037 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 8B3A4837DE; Thu, 14 Oct 2021 20:23:40 +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="Bh/usisT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ADA55836AA; Thu, 14 Oct 2021 20:23:25 +0200 (CEST) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 3BF9F836A1 for ; Thu, 14 Oct 2021 20:23:06 +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-io1-xd2f.google.com with SMTP id s17so4825154ioa.13 for ; Thu, 14 Oct 2021 11:23:05 -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=gu4xvYovmP/phehXZYbBNb6ZHxDjPowZ8ifIYzlMybU=; b=Bh/usisTOEy9jCgyvOaklnt8EFDYOostNNMEVLocjZ7N7C1gd45m9KQihInPdL+SSi 8QVp9c9i5BMJpLTtz62Wdg7SKphaMjGuJ1yx0jPpoAsn7knv5RjY1IHM1usTFBLnm0zl Rcl1nIaNGXwowNTlcq8JErRy68cQoOyMPHfRg= 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=gu4xvYovmP/phehXZYbBNb6ZHxDjPowZ8ifIYzlMybU=; b=XQnc5vlefjKfkomxw3Snwm7yg7B/cOe09poOfrizniYytY/6RgcUPMny18TyHRd9/U PV0S7Hdxagj1Z/IjY0BfuHydO+Q0t60wHfcWf5Fy3WZfO35SYmuyz2ezcZMrFuOOl74w thulAaoSxf7jysH+EeTXmR3KFPDOSBGiVZs/hqTgFPkfZ7vilhPhKu2UeyYZGGDW+ZhY UZGM4ij/GVfT0FXNiB6c3SYhMnN2z8p4s9YIiqUuYExwor5RxhQgP3fiU7mKXnKgzc7N wdt0CBsTvSdQzeLnWJoThi6zWLZBeO5khp0LdLNonRLNrEl9WeF37IjxR1B5LnI5LvqA a8ug== X-Gm-Message-State: AOAM532ZeY4RlZOhnAm+SPxyp7Sd3pxeK57EM1CbdqWSRZGhYFsZnU51 HIyz9f0Kkohdnc2Qufl4Usg6yOPjvGE= X-Google-Smtp-Source: ABdhPJyq913vSsy7dCDTMM7HYe4HOZKMcUMMmcpMFFLotFXVuJG3ia+qSPQ9hKumfCyQkY+PTUTMkg== X-Received: by 2002:a05:6638:3809:: with SMTP id i9mr5034290jav.115.1634235783824; Thu, 14 Oct 2021 11:23:03 -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 h26sm1717536ila.4.2021.10.14.11.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:23:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Wolfgang Denk , Simon Glass , Joe Hershberger Subject: [PATCH v6 0/7] env: Allow environment in text files Date: Thu, 14 Oct 2021 12:22:50 -0600 Message-Id: <20211014182257.468649-1-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-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 v6: - Move all updates to a separate patch - Combine the two env2string.awk patches into one - Move all updates to a separate patch - More updates and improvements - Add new patch to tidy up use of autostart env var 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 - Move use of += to this patch - Explain that environment variables may not end in + - Minor updates as suggested by Wolfgang 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 - Add new patch to move environment documentation to rST 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 (7): binman: Allow timeout to occur in the image or its section sandbox: Drop distro_boot doc: Move environment documentation to rST env: Allow U-Boot scripts to be placed in a .env file sandbox: Use a text-based environment doc: Improve environment documentation bootm: Tidy up use of autostart env var MAINTAINERS | 7 + Makefile | 39 ++- README | 328 ------------------------ board/sandbox/env/sandbox.env | 25 ++ cmd/bootm.c | 4 +- cmd/elf.c | 3 +- common/bootm_os.c | 5 +- config.mk | 2 + doc/usage/environment.rst | 453 ++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + env/common.c | 7 + env/embedded.c | 1 + include/configs/sandbox.h | 40 --- include/env.h | 7 + include/env_default.h | 8 + scripts/env2string.awk | 56 +++++ tools/binman/ftest.py | 3 +- 17 files changed, 609 insertions(+), 380 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.1079.g6e70778dc9-goog