[PATCH v3 1/4] debug_uart: Replace debug functions with dummies if CONFIG_DEBUG_UART is not set

Łukasz Czechowski lukasz.czechowski at thaumatec.com
Wed Nov 27 23:21:17 CET 2024


Hi Kever,

On 2024/11/27 03:42 Kever Yang <kever.yang at rock-chips.com> wrote:
>
> Hi Lukasz,
>
>      I got a new error base on patch [1], see full log here [2].

Looking at the file efi_stub.c that is used in the failing
configuration it looks to me
that some functions from debug_uart.h are used here for convenience
(i.e. printhex),
even though the DEBUG_UART is not used. This is contrary to my assumption that
DEBUG_UART_FUNCS macro should not be used if DEBUG UART is not available.
In order to apply the patch then, either the efi_stub code must be
updated to not
use debug functions or the assumption must be relaxed - I'm not yet
sure what shall be
the correct approach.

>
> +/binman/rom/intel-mrc (mrc.bin):
> +In file included from lib/efi/efi_stub.c:12:
> +include/debug_uart.h:205:9: error: stray '#' in program
> +  205 |         #warning "DEBUG_UART not defined!"
> +      |         ^
> +lib/efi/efi_stub.c:91:1: note: in expansion of macro 'DEBUG_UART_FUNCS'
> +   91 | DEBUG_UART_FUNCS
> +      | ^~~~~~~~~~~~~~~~
> +include/debug_uart.h:205:18: error: expected '=', ',', ';', 'asm' or
> '__attribute__' before string constant
> +      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
> +lib/efi/efi_stub.c:86:13: error: '_debug_uart_putc' defined but not
> used [-Werror=unused-function]
> +   86 | static void _debug_uart_putc(int ch)
> +      |             ^~~~~~~~~~~~~~~~
> +cc1: all warnings being treated as errors
> +make[3]: *** [scripts/Makefile.build:257: lib/efi/efi_stub.o] Error 1
>
>
> [1]https://patchwork.ozlabs.org/project/uboot/patch/20241108163612.1.Ib408a6723ba954c932968419678bd45b0767a470@changeid/
> [2] https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/jobs/958639
>
>
> Thanks,
> - Kever
> On 2024/9/18 21:01, Lukasz Czechowski wrote:
> > In case DEBUG UART is not used, define dummy macros replacing
> > the actual function implementations that will not be available.
> > This allows to compile code and avoid linker errors.
> > Because the DEBUG_UART_FUNCS macro should not be used if
> > DEBUG UART is not available, redefine it to generate compilation
> > warning.
> >
> > Signed-off-by: Lukasz Czechowski <lukasz.czechowski at thaumatec.com>
> >
> > Reviewed-by: Simon Glass <sjg at chromium.org>
> > Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
> > ---
> >   include/debug_uart.h | 16 ++++++++++++++++
> >   1 file changed, 16 insertions(+)
> >
> > diff --git a/include/debug_uart.h b/include/debug_uart.h
> > index 714b369e6fe..dc0f1aa4c98 100644
> > --- a/include/debug_uart.h
> > +++ b/include/debug_uart.h
> > @@ -128,6 +128,8 @@ void printdec(unsigned int value);
> >                       (1 << CONFIG_DEBUG_UART_SHIFT), \
> >               CONFIG_DEBUG_UART_SHIFT)
> >
> > +#ifdef CONFIG_DEBUG_UART
> > +
> >   /*
> >    * Now define some functions - this should be inserted into the serial driver
> >    */
> > @@ -197,4 +199,18 @@ void printdec(unsigned int value);
> >               _DEBUG_UART_ANNOUNCE \
> >       } \
> >
> > +#else
> > +
> > +#define DEBUG_UART_FUNCS \
> > +     #warning "DEBUG_UART not defined!"
> > +
> > +#define printch(ch) do{}while(0);
> > +#define printascii(str) do{}while(0);
> > +#define printhex2(value) do{}while(0);
> > +#define printhex4(value) do{}while(0);
> > +#define printhex8(value) do{}while(0);
> > +#define printdec(value) do{}while(0);
> > +
> > +#endif
> > +
> >   #endif

Best regards,
Lukasz


More information about the U-Boot mailing list