diff mbox series

[2/3] log: use debug uart to output trace before LOG init

Message ID 20201106175339.30683-2-patrick.delaunay@st.com
State Superseded
Delegated to: Tom Rini
Headers show
Series [1/3] log: don't build the trace buffer when log is not ready | expand

Commit Message

Patrick DELAUNAY Nov. 6, 2020, 5:53 p.m. UTC
Use the debug uart functions to output the traces before
the log initialization (when CONFIG_LOG is not activated)
as it is done in puts/putc function in console.c.

This patch allows to display the first U-Boot traces
(with macro debug) when CONFIG_DEBUG_UART is activated
and not only drop them.

For example for traces in board_f.c requested by the macro debug,
when LOG_DEBUG is defined and CONFIG_LOG is activated.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 common/log.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Simon Glass Nov. 11, 2020, 2:32 p.m. UTC | #1
+Heinrich Schuchardt

On Fri, 6 Nov 2020 at 10:55, Patrick Delaunay <patrick.delaunay@st.com> wrote:
>
> Use the debug uart functions to output the traces before
> the log initialization (when CONFIG_LOG is not activated)
> as it is done in puts/putc function in console.c.
>
> This patch allows to display the first U-Boot traces
> (with macro debug) when CONFIG_DEBUG_UART is activated
> and not only drop them.
>
> For example for traces in board_f.c requested by the macro debug,
> when LOG_DEBUG is defined and CONFIG_LOG is activated.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  common/log.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Again this needs a sandbox test

>
> diff --git a/common/log.c b/common/log.c
> index aadf533fb2..aa5505943f 100644
> --- a/common/log.c
> +++ b/common/log.c
> @@ -7,6 +7,7 @@
>   */
>
>  #include <common.h>
> +#include <debug_uart.h>
>  #include <log.h>
>  #include <malloc.h>
>  #include <dm/uclass.h>
> @@ -245,6 +246,16 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
>
>         if (!(gd->flags & GD_FLG_LOG_READY)) {
>                 gd->log_drop_count++;
> +
> +               /* manage droppped trace at default level with debug uart */

dropped


> +               if (IS_ENABLED(CONFIG_DEBUG_UART) &&
> +                   (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug)) {
> +                       va_start(args, fmt);
> +                       vsnprintf(buf, sizeof(buf), fmt, args);
> +                       printascii(buf);
> +                       va_end(args);
> +               }
> +
>                 return -ENOSYS;
>         }
>         va_start(args, fmt);
> --
> 2.17.1
>
Patrick DELAUNAY Nov. 19, 2020, 1:42 p.m. UTC | #2
Hi Simon,

> From: Simon Glass <sjg@chromium.org>
> Sent: mercredi 11 novembre 2020 15:32
> To: Patrick DELAUNAY <patrick.delaunay@st.com>; Heinrich Schuchardt
> 
> +Heinrich Schuchardt

OK

> On Fri, 6 Nov 2020 at 10:55, Patrick Delaunay <patrick.delaunay@st.com> wrote:
> >
> > Use the debug uart functions to output the traces before the log
> > initialization (when CONFIG_LOG is not activated) as it is done in
> > puts/putc function in console.c.
> >
> > This patch allows to display the first U-Boot traces (with macro
> > debug) when CONFIG_DEBUG_UART is activated and not only drop them.
> >
> > For example for traces in board_f.c requested by the macro debug, when
> > LOG_DEBUG is defined and CONFIG_LOG is activated.
> >
> > Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> > ---
> >
> >  common/log.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Again this needs a sandbox test

I am preparing a sandbox test for v2.
But I think I will replace printascii() by console function, puts()

To use all supported feature of console.c

=> DEBUG_UART / PRE_CONSOLE_BUFFER / CONSOLE_RECORD

CONSOLE_RECORD is needed by unitary test...
 
> >
> > diff --git a/common/log.c b/common/log.c index aadf533fb2..aa5505943f
> > 100644
> > --- a/common/log.c
> > +++ b/common/log.c
> > @@ -7,6 +7,7 @@
> >   */
> >
> >  #include <common.h>
> > +#include <debug_uart.h>
> >  #include <log.h>
> >  #include <malloc.h>
> >  #include <dm/uclass.h>
> > @@ -245,6 +246,16 @@ int _log(enum log_category_t cat, enum
> > log_level_t level, const char *file,
> >
> >         if (!(gd->flags & GD_FLG_LOG_READY)) {
> >                 gd->log_drop_count++;
> > +
> > +               /* manage droppped trace at default level with debug
> > + uart */
> 
> dropped
> 

OK

 
> > +               if (IS_ENABLED(CONFIG_DEBUG_UART) &&
> > +                   (rec.level <= CONFIG_LOG_DEFAULT_LEVEL ||
> rec.force_debug)) {
> > +                       va_start(args, fmt);
> > +                       vsnprintf(buf, sizeof(buf), fmt, args);
> > +                       printascii(buf);
> > +                       va_end(args);
> > +               }
> > +
> >                 return -ENOSYS;
> >         }
> >         va_start(args, fmt);
> > --
> > 2.17.1
> >

Thanks for the review

Patrick
diff mbox series

Patch

diff --git a/common/log.c b/common/log.c
index aadf533fb2..aa5505943f 100644
--- a/common/log.c
+++ b/common/log.c
@@ -7,6 +7,7 @@ 
  */
 
 #include <common.h>
+#include <debug_uart.h>
 #include <log.h>
 #include <malloc.h>
 #include <dm/uclass.h>
@@ -245,6 +246,16 @@  int _log(enum log_category_t cat, enum log_level_t level, const char *file,
 
 	if (!(gd->flags & GD_FLG_LOG_READY)) {
 		gd->log_drop_count++;
+
+		/* manage droppped trace at default level with debug uart */
+		if (IS_ENABLED(CONFIG_DEBUG_UART) &&
+		    (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug)) {
+			va_start(args, fmt);
+			vsnprintf(buf, sizeof(buf), fmt, args);
+			printascii(buf);
+			va_end(args);
+		}
+
 		return -ENOSYS;
 	}
 	va_start(args, fmt);