From patchwork Wed Jul 18 21:37:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 142301 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1014918ljj; Wed, 18 Jul 2018 14:37:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd5cvMHvnJehU1cnf4BVu2cjpnJmohaKf8W5w0PMNBF4bWkSNW01TJ6QcLfBDrqy4+xpYYf X-Received: by 2002:a50:c313:: with SMTP id a19-v6mr8463303edb.177.1531949865665; Wed, 18 Jul 2018 14:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531949865; cv=none; d=google.com; s=arc-20160816; b=vZmJq+2lu/KyYZu4hr7hmo2kfxOW/4e+lDSEzEMjhMxmNWY3zt4kVntQvjKwLx0k2s 9586WyvmHNkTvXl3ynQiAb+J+a3JZERv0VAT8eKk2/InVE6S+8vMFuiWX/mK05orIA7D N+WAr1eYJwaR8pdR4aPX9XJvOJ30D0foh+sSdi0u0k8N9HT+QPXz5ERW4E+h08BJaecw FhJdj8s4MGcbbllewsclSYqrTiT2EyD5QclbNUhudbPvk6cRsCrvy0UqgkGFn09M1SH3 8xivkTwL24+oI2kK19aIxz7ct4h8BIsZf4clhOuzBMLLKoHHuqvNmmSvasjRjk2ahfaw WhvQ== 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=/2ZjCPUxIR+anwF1kXsrprgA/o4AvD0mtevLrfnbx4c=; b=CKFJZWpr5SEDBQ3S2SD7wqi0TpgGFiCOIECMP7z68zFvVpzScGeXqs35pFYk+spVaa hc6F4ge3XnY4Iyndld68K58erw4xzMCpiueILaN10N+0yBwokrqH+QXudRiNFXJACt73 RXgwpc5a0HVxe3v2crwm6/oXUBMh+Uh9eg9opQNvPTv3DLGS0vKPHUw0qiz6fuvF5OAC u1peABnuIJOsBwulWXKt2vH5wXLZLYqPMtG8bNAa9DbmBxe6/ng+U5zy3zMWyTrEpl2q G4GIxdo2vi/ellULrFhu1ZdXc9eEZH4lO4nNT3ADamukMX1sQ8H/EEsEUudEhlig10hW ncwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h90kqUcD; 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 p62-v6si2496023edb.161.2018.07.18.14.37.45; Wed, 18 Jul 2018 14:37:45 -0700 (PDT) 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=h90kqUcD; 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 18795C21C27; Wed, 18 Jul 2018 21:37:43 +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_H3, RCVD_IN_MSPIKE_WL, 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 B6FD5C21C27; Wed, 18 Jul 2018 21:37:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BE3FFC21C27; Wed, 18 Jul 2018 21:37:39 +0000 (UTC) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by lists.denx.de (Postfix) with ESMTPS id 5B285C21BE5 for ; Wed, 18 Jul 2018 21:37:39 +0000 (UTC) Received: by mail-lf0-f68.google.com with SMTP id a134-v6so4507435lfe.6 for ; Wed, 18 Jul 2018 14:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=JRYwHLIRgDj0wkUQU8K1NoBGHOLFrw3jzAw6Duudncc=; b=h90kqUcDwsdwS5zEg7Xh7qkDQecEvAh8nIa1jKbfaI71zkdt8Dhwt90/1WxeGvmh2u 7JQ6UMWRu+6b+uqEe15d2HEFOtnafLBQbV5t9efcm5X4DWz5BB5Ao73gIWt2B6ltuvXP 0mEWrTVRVzpozkgKkHHdE4CeZC5Kv71Dn5tc4= 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=JRYwHLIRgDj0wkUQU8K1NoBGHOLFrw3jzAw6Duudncc=; b=SuUeAPWyecum6bRweNqYW7Brmdi3XgHfpB7fQ58BDVZOxh1Ui5GJyOXYfFZvasJAm9 MLeQyQI0ns2S1CLbrZAnBCmNf/tE0zDA8zAmWU8Iiaq66nt20IEKmI8LN34xlt+SCJxY BMMMaQ1Mdbsi6lpzeh6FqfYciEwFoju5ERtWGPqrhnTTGhXkRlPgX9e5ZjWPs+WpBD+l dqqIiqiXxzUhJCEw2ACdqsM6jnzVUSBCX+WLJMmVbGprOplY0GotslOjDcMDox6LJr91 /FOiOodtSsnmtztMDvmCH9+4dnHhWayBfHIpOuJu/WdRZZcUW7H65lsG/kNiyMFnV8/n ITJw== X-Gm-Message-State: AOUpUlH7CG5PH1pbwHp7R2a+hvzDaO1k9ubx1f3SPfHddyOadY/Ude9S I46SakoXLMSuFgJgR5AL8jR3rLXoVaI= X-Received: by 2002:a19:4ecd:: with SMTP id u74-v6mr4783576lfk.57.1531949858450; Wed, 18 Jul 2018 14:37:38 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id f18-v6sm783021lja.85.2018.07.18.14.37.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Jul 2018 14:37:37 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Jul 2018 00:37:36 +0300 Message-Id: <20180718213736.22650-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: Maxime Ripard , Tom Rini Subject: [U-Boot] [RFC] env: Fix errors printing on env loading 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" This is just a draft to discuss ideas related to "Make U-Boot log great again" thread. With this patch we will have something like this: Attempting to load environment from FAT: MMC: no card present ** Bad device mmc 0 ** Failed (-5) Attempting to load environment from MMC: OK instead of this: Loading Environment from FAT... MMC: no card present ** Bad device mmc 0 ** Failed (-5) Loading Environment from MMC... OK The only way I see to do so is to use ASCII escape codes for moving the cursor (in non-error case). I'd also like to add prefixes to error messages, like it's done in [2], but it requires adding one pointer to global data struct. [1] https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences [2] https://lists.denx.de/pipermail/u-boot/2018-July/335072.html Signed-off-by: Sam Protsenko --- env/env.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/env/env.c b/env/env.c index 5c0842ac07..a674ac2eab 100644 --- a/env/env.c +++ b/env/env.c @@ -187,6 +187,7 @@ int env_load(void) for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) { int ret; + char msg[75]; if (!drv->load) continue; @@ -194,12 +195,17 @@ int env_load(void) if (!env_has_inited(drv->location)) continue; - printf("Loading Environment from %s... ", drv->name); + snprintf(msg, 75, "Attempting to load environment from %s:\n", + drv->name); + puts(msg); ret = drv->load(); - if (ret) + if (ret) { printf("Failed (%d)\n", ret); - else - printf("OK\n"); + } else { + size_t len = strlen(msg); + + printf("\033[1A\033[%zuC OK\n", len - 1); + } if (!ret) return 0;