From patchwork Thu Jul 19 19:30:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 142382 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2108816ljj; Thu, 19 Jul 2018 12:30:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd3T808TRiFhyUzVvqkAHTQ/HqeJs1/3GgRqmdCh7FVr4tuT6EE2vnXdqrWfgsaVIQvsl3E X-Received: by 2002:a50:8ee4:: with SMTP id x33-v6mr12145121edx.175.1532028641624; Thu, 19 Jul 2018 12:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532028641; cv=none; d=google.com; s=arc-20160816; b=Vy54BTC3Wxk6ux5eYlJPC/yItmye49hOZbLjLH+EVVtYzEjC1rmerhxJHK4r7ynFnx YVrMVopD9JCfMYXs4kO8EOyCcGJZdw/W37E499eO0TssX84QWGh+/c+aCItdZpzR7bsO g6qOc2nGnKfbLr8OLf0bN3oO/7RG10fGKSRa2PGwjwQRwImBPjugVC1ZgfQYKmpXsKZB h1dfETygtAZ2sMdVmz6nyk7lI//yW6YnnBmblSzX8fPhH9H+jcqvdiTaJzX+9fKOo343 LJXC5V9C4AljPIVC4vUnSvEq55nf7J2WsIRBhzTOLdWLKHYlx6YsfK0WbQoklUgB1ftc GNHQ== 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=yjlbgXODSnWQ8A2/asVZsuvDKnjj/3oVZD1ASCBUqb8=; b=EoLaCsJjh0lYrqczuGHRUDVUeXdwS3HaWZyDOfxInXXyo6HRHo4y6krv0m5cMcGndx B5Mvo+C1KPkqj8Sq5EM3tAK6HnVvBp9+j5QZSNjDuuXnZjrwzjrP407cinmop7uleRGs NiJ7GZLXgaBXUno8Y8MufWACT0DuNxGOLH5ljDHkoqyN4s+d565r6fMaRp+5HLrNnE+2 rWzCsE9t6eSAKHq5WyknYIoHJHgJwgo4bp24oOMMIybENSVgugFWcp2PAnnfFGo+Jek+ lmlMeaByiIiHgw0mhAvBPMi8kOp434WhvPwx83eeNjQ1Z6SEeXfxLjtNFg8TWq4ROMbK LLwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Mz4JxV2H; 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 h50-v6si221139ede.283.2018.07.19.12.30.40; Thu, 19 Jul 2018 12:30:41 -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=Mz4JxV2H; 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 A1399C21E38; Thu, 19 Jul 2018 19:30:37 +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=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 8025CC21C27; Thu, 19 Jul 2018 19:30:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E928DC21C27; Thu, 19 Jul 2018 19:30:33 +0000 (UTC) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by lists.denx.de (Postfix) with ESMTPS id 21966C21BE5 for ; Thu, 19 Jul 2018 19:30:31 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id m12-v6so209897lfc.10 for ; Thu, 19 Jul 2018 12:30:31 -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=UoAwF2wngCxFt+OW61cL+5QNY1tqXhrY1aVJoTPmYU0=; b=Mz4JxV2HQ9LzmzdB8IVvFSCbpNTh62paeQHnHYzQEG9LkjkSelxOyjJd1+5u7As5uY HZDgTnMTfljBxn0KliWOePHnD7luvoHp0O1UoV2a0sj4l0Q+ybYPu44LvPqjQvx2mfcE rEnV6MjSjmrIGxt66ZEGxamA40of/JfsE42Sg= 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=UoAwF2wngCxFt+OW61cL+5QNY1tqXhrY1aVJoTPmYU0=; b=ZfktAxVtJvgCc5QKl2/KyQoL9XYJjaMXGRMSoTuhf2UD55SeWx3I0kGxnzqaVdiV3u 0gkNQZnIt1aPcKQO12FNdUBNXLyi+9cJcFtrFhAwsJ+e+9/E4hbMVCfe4DPWbHWeFl+6 9R6+yCHY4zev2IM+y7iMfYgLbxzozcTuSAY6agZMBdSTyb0VtdMiq4YOSd/iuP0IkvUZ h9bMMsOeKfdSJ0jCVdU1PZRBV5Z7sIFUDZg0jTcNm02jh1XRni4YviMk2/8PAKgAajii Iqb7K91YvzoZMlKSL7clpXSlp2fLTvB3Uz6BAZ/7f/AdfLmaHRtfeWSGLD9zr61be7z6 Y2hg== X-Gm-Message-State: AOUpUlHek35NlvFlydjjwo7d8ijQoFCZGYMWljxJTezJ1DkDSCfwhi9Y 89WsrARJSk4wlPTcckDPAfi0W+g9TJF+iA== X-Received: by 2002:a19:a705:: with SMTP id q5-v6mr7936712lfe.148.1532028630157; Thu, 19 Jul 2018 12:30:30 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id b141-v6sm1066253lfb.6.2018.07.19.12.30.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Jul 2018 12:30:29 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Thu, 19 Jul 2018 22:30:28 +0300 Message-Id: <20180719193028.814-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: Maxime Ripard , Tom Rini Subject: [U-Boot] [RFC v2] 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 Two things were done in this patch: - print messages from drivers in nested style (with "->" prefix); to do so, add GD_FLG_PR_PREFIX flag and check it in puts() - make "OK" to be printed on the same line as main message; to do so, issue ASCII escape codes [1] to move cursor back to main message line [1] https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences Signed-off-by: Sam Protsenko --- common/console.c | 6 ++++++ env/env.c | 17 +++++++++++++---- include/asm-generic/global_data.h | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/common/console.c b/common/console.c index 2ba33dc574..a0db0ffea6 100644 --- a/common/console.c +++ b/common/console.c @@ -533,6 +533,12 @@ void putc(const char c) void puts(const char *s) { + if (gd->flags & GD_FLG_PR_PREFIX) { + gd->flags &= ~GD_FLG_PR_PREFIX; + puts(" -> "); + gd->flags |= GD_FLG_PR_PREFIX; + } + #ifdef CONFIG_DEBUG_UART if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) { while (*s) { diff --git a/env/env.c b/env/env.c index 5c0842ac07..ff044ccee1 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,20 @@ 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); + gd->flags |= GD_FLG_PR_PREFIX; ret = drv->load(); - if (ret) + if (ret) { printf("Failed (%d)\n", ret); - else - printf("OK\n"); + gd->flags &= ~GD_FLG_PR_PREFIX; + } else { + size_t len = strlen(msg); + + gd->flags &= ~GD_FLG_PR_PREFIX; + printf("\033[1A\033[%zuC OK\n", len - 1); + } if (!ret) return 0; diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 0fd4900392..7e83617664 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -150,5 +150,6 @@ typedef struct global_data { #define GD_FLG_ENV_DEFAULT 0x02000 /* Default variable flag */ #define GD_FLG_SPL_EARLY_INIT 0x04000 /* Early SPL init is done */ #define GD_FLG_LOG_READY 0x08000 /* Log system is ready for use */ +#define GD_FLG_PR_PREFIX 0x10000 /* Print prefix before message */ #endif /* __ASM_GENERIC_GBL_DATA_H */