前面有描述如何使能dev_dbg相关打印。
这里系统整理了下uboot的log系统。
主要参考uboot/doc/README.log
摘录一些重要的片段。
22 Logging levels
23 --------------
24
25 There are a number logging levels available, in increasing order of verbosity:
26
27 LOGL_EMERG› - Printed before U-Boot halts
28 LOGL_ALERT› - Indicates action must be taken immediate or U-Boot will crash
29 LOGL_CRIT› - Indicates a critical error that will cause boot failure
30 LOGL_ERR›- Indicates an error that may cause boot failure
31 LOGL_WARNING›- Warning about an unexpected condition
32 LOGL_NOTE› - Important information about progress
33 LOGL_INFO› - Information about normal boot progress
34 LOGL_DEBUG› - Debug information (useful for debugging a driver or subsystem)
35 LOGL_DEBUG_CONTENT› - Debug message showing full message content
36 LOGL_DEBUG_IO› - Debug message showing hardware I/O access
39 Logging category
40 ----------------
41
42 Logging can come from a wide variety of places within U-Boot. Each log message
43 has a category which is intended to allow messages to be filtered according to
44 their source.
45
46 The following main categories are defined:
47
48 LOGC_NONE› - Unknown category (e.g. a debug() statement)
49 UCLASS_...› - Related to a particular uclass (e.g. UCLASS_USB)
50 LOGC_ARCH› - Related to architecture-specific code
51 LOGC_BOARD› - Related to board-specific code
52 LOGC_CORE› - Related to core driver-model support
53 LOGC_DT› - Related to device tree control
56 Enabling logging
57 ----------------
58
59 The following options are used to enable logging at compile time:
60
61 CONFIG_LOG› › - Enables the logging system
62 CONFIG_MAX_LOG_LEVEL - Max log level to build (anything higher is compiled
63 › › › › out)
64 CONFIG_LOG_CONSOLE› - Enable writing log records to the console
65
66 If CONFIG_LOG is not set, then no logging will be available.
67
68 The above have SPL versions also, e.g. CONFIG_SPL_MAX_LOG_LEVEL.
ok, 记录步骤。
1. menuconfig, 开CONFIG_LOG, 设置CONFIG_MAX_LOG_LEVEL, CONFIG_LOG_CONSOLE等
2. 代码中 设置 category, 如 77 #define LOG_CATEGORY UCLASS_USB
编译尝试下, 发现无log输出...
把log_cmd打开 试验下, menuconfig 开宏,
CONFIG_LOG_TEST
CONFIG_CMD_LOG
如此uboot shell中就有log命令产生。
ZynqMP> log
log - log system
Usage:
log level - get/set log level
log test - run log tests
ZynqMP> log level
Default log level: 0
ZynqMP> log level 7
ZynqMP> fastboot 0
g_dnl_register: g_dnl_driver.name = usb_dnl_fastboot
registering UDC driver [<NULL>]
0
g_dnl_bind: gadget: 0x000000007dea8410 cdev: 0x000000007dec0510
usb_add_config: adding config #1 'usb_dnload'/000000007dec16c0
g_dnl_do_config: configuration: 0x000000007dec16c0 composite dev: 0x000000007dec0510
fastboot_add: cdev: 0x000000007dec0510
adding 'f_fastboot'/000000007dec0240 to config 'usb_dnload'/000000007dec16c0
cfg 1/000000007dec16c0 speeds: high full
usb_add_config: interface 0 = f_fastboot/000000007dec0240
g_dnl_bind: calling usb_gadget_connect for controller 'dwc3-gadget'
0
gadget no-function data soft-connect
......
查看源码, log系统中用的是gd->default_log_level变量, 默认值是LOGL_INFO。
215 int log_init(void)
{
......
242 › gd->default_log_level = LOGL_INFO;
......
}
ok, 能用就行。