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 40212C433F5 for ; Fri, 22 Oct 2021 03:10:25 +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 857C6614C8 for ; Fri, 22 Oct 2021 03:10:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 857C6614C8 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 219BE83557; Fri, 22 Oct 2021 05:10:23 +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="CZPSjarr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2624983534; Fri, 22 Oct 2021 05:10:05 +0200 (CEST) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 3DA8183589 for ; Fri, 22 Oct 2021 05:09:29 +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-x233.google.com with SMTP id bk18so3366134oib.8 for ; Thu, 21 Oct 2021 20:09:29 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=SHzxKPfGzVG7Wz9DKQyaZTYHt0nkN69OLL6+/1nJFV0=; b=CZPSjarrhCv6zF3/IWtQ/s1haUbnBUqBM3+SRy0Z81pwD1V+NamQC71Pwr6mSKCA9e svuvcWArtRSuQTb0KF0gAiFChth0+xRhEEV6i0eAu3QFQDHVIxtGMkl1gwPvg7SrfZY8 V0Lww0ICk6F33V6Qh6sW+z1SesrUglsm/c9pY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=SHzxKPfGzVG7Wz9DKQyaZTYHt0nkN69OLL6+/1nJFV0=; b=eHp780mr/vmsCiEcuBqDFG6L6944m0+onnhuuom6H/1KNnuEfIFjEQRcQ7JSTT9bq5 Xnn3aFEmFxnV/2m7l1MDJs+V+1ZZs1SegjWUx86f3kzPiZylO/jPTzXqfMW/mJvZUmTG /9x35StziiTfRCtc39chUCGXdsRlFF1glgRQmAFm8bhSw6RTo/mkgU0Lv5e3WTk3gyQo 6uKJSQe07tfbA0wjCxPB8v0BWLOv0C1o8sdWDbMS5HibaaWVgb7dhkgKWWA03VEZyaOv 7+pdNUyRB+bLqRxjqVtYNDrwf6K1tgDLiE3vTg3dDN5EL+WbjzmtvMx8w8tb7wmo0QvI L/Ng== X-Gm-Message-State: AOAM532r8bbne5AuJpZgbr9r5HjvVLesWa1yj4r8c1HH0juS/BrXsmEs op8SPeDXlpR1AqbeUMPMKee0RBf1DAfwJw== X-Google-Smtp-Source: ABdhPJw6QoRg70EPW2ZGvWNHuOUv/7a0zEMK2+a9U/Cn69BPUFbJsBGFJA8Z3NwfFX6Vh6HGKZWwnw== X-Received: by 2002:aca:bd0b:: with SMTP id n11mr7529334oif.100.1634872167712; Thu, 21 Oct 2021 20:09:27 -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 az14sm1483350oib.51.2021.10.21.20.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 20:09:27 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Denk , u-boot-board-maintainers@lists.denx.de, Rasmus Villemoes , u-boot-custodians@lists.denx.de, Tom Rini , Heinrich Schuchardt , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Simon Glass Subject: [PATCH v10 9/9] bootm: Tidy up use of autostart env var Date: Thu, 21 Oct 2021 21:08:52 -0600 Message-Id: <20211022030852.1986718-8-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211022030852.1986718-1-sjg@chromium.org> References: <20211022030852.1986718-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 This has different semantics in different places. Go with the bootm method and put it in a common function so that the behaviour is consistent in U-Boot. Update the docs. To be clear, this changes the way that 'bootelf' and standalone boot work. Before, if autostart was set to "fred" or "YES", for example, they would consider that a "yes". This may change behaviour for some boards, but the only in-tree boards which mention autostart use "no" to disable it, which will still work. Signed-off-by: Simon Glass Suggested-by: Wolfgang Denk --- (no changes since v9) Changes in v9: - More bikeshedding on env_get_autostart() - Fix '' in cover letter - Use env_get_yesno() in env_get_autostart() and update docs Changes in v8: - Go into more detail about the change of behaviour with autostart Changes in v7: - Update the cover letter Changes in v6: - Add new patch to tidy up use of autostart env var cmd/bootm.c | 4 +--- cmd/elf.c | 3 +-- common/bootm_os.c | 5 +---- doc/usage/environment.rst | 5 +++-- env/common.c | 5 +++++ include/env.h | 7 +++++++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index 92468d09a1f..b82a872a86c 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -140,9 +140,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd) { - const char *ep = env_get("autostart"); - - if (ep && !strcmp(ep, "yes")) { + if (env_get_autostart()) { char *local_args[2]; local_args[0] = (char *)cmd; local_args[1] = NULL; diff --git a/cmd/elf.c b/cmd/elf.c index d75b21461c2..2b33c50bd02 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -41,7 +41,6 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) unsigned long addr; /* Address of the ELF image */ unsigned long rc; /* Return value from user code */ char *sload = NULL; - const char *ep = env_get("autostart"); int rcode = 0; /* Consume 'bootelf' */ @@ -69,7 +68,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) else addr = load_elf_image_shdr(addr); - if (ep && !strcmp(ep, "no")) + if (!env_get_autostart()) return rcode; printf("## Starting application at 0x%08lx ...\n", addr); diff --git a/common/bootm_os.c b/common/bootm_os.c index 39623f9126b..f30dcebbf7d 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -26,12 +26,9 @@ DECLARE_GLOBAL_DATA_PTR; static int do_bootm_standalone(int flag, int argc, char *const argv[], bootm_headers_t *images) { - char *s; int (*appl)(int, char *const[]); - /* Don't start if "autostart" is set to "no" */ - s = env_get("autostart"); - if ((s != NULL) && !strcmp(s, "no")) { + if (!env_get_autostart()) { env_set_hex("filesize", images->os.image_len); return 0; } diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index 8ddc672d467..d295cc89878 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -179,8 +179,9 @@ autostart be automatically started (by internally calling "bootm") - If set to "no", a standalone image passed to the - "bootm" command will be copied to the load address + If unset, or set to "1"/"yes"/"true" (case insensitive, just the first + character is enough), a standalone image + passed to the "bootm" command will be copied to the load address (and eventually uncompressed), but NOT be started. This can be used to load and uncompress arbitrary data. diff --git a/env/common.c b/env/common.c index 81e9e0b2aaf..e46a9ee644e 100644 --- a/env/common.c +++ b/env/common.c @@ -47,6 +47,11 @@ int env_get_yesno(const char *var) 1 : 0; } +bool env_get_autostart(void) +{ + return env_get_yesno("autostart") == 1; +} + /* * Look up the variable from the default environment */ diff --git a/include/env.h b/include/env.h index d5e2bcb530f..fdad495691f 100644 --- a/include/env.h +++ b/include/env.h @@ -143,6 +143,13 @@ int env_get_f(const char *name, char *buf, unsigned int len); */ int env_get_yesno(const char *var); +/** + * env_get_autostart() - Check if autostart is enabled + * + * @return true if the "autostart" env var exists and is set to "yes" + */ +bool env_get_autostart(void); + /** * env_set() - set an environment variable * -- 2.33.0.1079.g6e70778dc9-goog