Enable log in U-Boot


To enable pr_debug

- Define CONFIG_LOGLEVEL > 7 in defconfig
- Define DEBUG in the .c file on the first line above #includes

== Source ==
----------------
#define pr_debug(fmt, ...)
    CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0;

CONFIG_LOGLEVEL - Defined in the source file

-----------------

#if CONFIG_IS_ENABLED(LOG)
    #define log_debug(_fmt...)      log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
#else
    #define log_debug(_fmt, ...)    debug(_fmt, ##__VA_ARGS__)
#endif
------------------
 
#define debug(fmt, args...) debug_cond(_DEBUG, fmt, ##args)

--------
#if !_DEBUG && CONFIG_IS_ENABLED(LOG)
    #define debug_cond(cond, fmt, args...)
    {
        log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args);
    }
#else
    #define debug_cond(cond, fmt, args...)
    {
        if (cond)
            printf(pr_fmt(fmt), ##args);
    }
#endif
-------------------

log.h
--------------------
#ifdef DEBUG
#define _DEBUG 1
#else
#define _DEBUG 0
-------------------



Comments

Popular posts from this blog

High Assurance boot in i.MX6 (Secure boot)

How to find a machine is little or big endian?