Registered User |
Registered User |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
== Debug with console == | == Debug with console == | ||
See {{DocSource | domain=U-Boot |path=develop/logging.html | text=U-Boot Documentation}} or {{CodeSource | U-Boot |doc/ | See {{DocSource | domain=U-Boot |path=develop/logging.html | text=U-Boot Documentation}} or {{CodeSource | U-Boot |doc/develop/logging.rst}} for U-Boot logging details. | ||
CONFIG_LOG is enable in OpenSTLinux. | '''CONFIG_LOG''' is enable in OpenSTLinux. | ||
By default, traces are available on the U-Boot console which use <code>stdout-path</code> defined in the <code>chosen</code> node of the Linux kernel device tree as described in the Linux kernel binding<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/chosen.txt | Documentation/devicetree/bindings/chosen.txt}} the Linux kernel binding for chosen node</ref>. | By default, traces are available on the U-Boot console which use <code>stdout-path</code> defined in the <code>chosen</code> node of the Linux kernel device tree as described in the Linux kernel binding<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/chosen.txt | Documentation/devicetree/bindings/chosen.txt}} the Linux kernel binding for chosen node</ref>. | ||
Line 14: | Line 14: | ||
The ST boards use the default logging configuration: | The ST boards use the default logging configuration: | ||
* CONFIG_LOG_DEFAULT_LEVEL = CONFIG_LOG_MAX_LEVEL = 6 | * {{highlight|CONFIG_LOG_DEFAULT_LEVEL}} = {{highlight|CONFIG_LOG_MAX_LEVEL}} = {{highlightParam|LOGL_INFO}} = {{highlightParam|6}}<br/>the 'debug' macros used by U-Boot (log_debug(), debug(), pr_debug()...) are removed in the U-Boot binary. | ||
* CONFIG_LOGF_FILE, CONFIG_LOGF_LINE, CONFIG_LOGF_FUNC are not activated<br/>no debug information in log messages by default. | * CONFIG_LOGF_FILE, CONFIG_LOGF_LINE, CONFIG_LOGF_FUNC are not activated<br/>no debug information in log messages by default. | ||
To | To enable all the debug traces in U-Boot you need to increase the max logging level with a major impact on U-Boot size; e.g. set {{highlight|CONFIG_LOG_MAX_LEVEL}} to {{highlightParam|LOGL_DEBUG}} by adding in your defconfig file the line: | ||
When the traces are present in U-Boot, you can change the default trace level with CONFIG_LOG_DEFAULT_LEVEL or you can use the <code>log</code> command (CONFIG_CMD_LOG) to dynamically configure and filter the output: | {{highlight|CONFIG_LOG_MAX_LEVEL}}={{HighlightParam|7}} | ||
When the traces are present in U-Boot, you can change the default trace level with {{highlight|CONFIG_LOG_DEFAULT_LEVEL}} or you can use the <code>log</code> command (CONFIG_CMD_LOG) to dynamically configure and filter the output: | |||
{{U-Boot$}} log level 7 | {{U-Boot$}} log level 7 | ||
Line 63: | Line 65: | ||
=== Load U-Boot symbol === | === Load U-Boot symbol === | ||
With [[U-Boot_overview#U- | With [[U-Boot_overview#U-Boot_execution_sequence|U-Boot relocation]], symbols are more difficult to load, see {{CodeSource | U-Boot | doc/README.arm-relocation}} for details. | ||
If you connect GDB on running target, you can load the debug symbols: | If you connect GDB on running target, you can load the debug symbols: | ||
Line 105: | Line 105: | ||
<references/> | <references/> | ||
<noinclude> | |||
[[Category:U-Boot|U-Boot - 8]] | [[Category:U-Boot|U-Boot - 8]] | ||
[[Category:Tracing tools]] | [[Category:Tracing tools]] |
Latest revision as of 15:01, 2 November 2022
1. Debug with console
See U-Boot Documentation or doc/develop/logging.rst for U-Boot logging details.
CONFIG_LOG is enable in OpenSTLinux.
By default, traces are available on the U-Boot console which use stdout-path
defined in the chosen
node of the Linux kernel device tree as described in the Linux kernel binding[1].
See page How to configure U-Boot for your board for configuration details.
The ST boards use the default logging configuration:
- CONFIG_LOG_DEFAULT_LEVEL = CONFIG_LOG_MAX_LEVEL = LOGL_INFO = 6
the 'debug' macros used by U-Boot (log_debug(), debug(), pr_debug()...) are removed in the U-Boot binary. - CONFIG_LOGF_FILE, CONFIG_LOGF_LINE, CONFIG_LOGF_FUNC are not activated
no debug information in log messages by default.
To enable all the debug traces in U-Boot you need to increase the max logging level with a major impact on U-Boot size; e.g. set CONFIG_LOG_MAX_LEVEL to LOGL_DEBUG by adding in your defconfig file the line:
CONFIG_LOG_MAX_LEVEL=7
When the traces are present in U-Boot, you can change the default trace level with CONFIG_LOG_DEFAULT_LEVEL or you can use the log
command (CONFIG_CMD_LOG) to dynamically configure and filter the output:
STM32MP> log level 7
STM32MP> log format all
1.1. Activate debug trace on one file
To turn on this debug logging just in one file, you can define LOG_DEBUG and DEBUG for this file
- add define before any include in the <file>.c file
#define LOG_DEBUG
#define DEBUG
- with a Makefile
CFLAGS_<file>.o+= -DLOG_DEBUG -DDEBUG
1.2. Debug before console
If U-Boot fails before the console configuration (in the first stage of U-Boot execution), trace is not available.
In this case, you need to:
- debug with GDB (see the next chapter)
or,
- activate the debug UART feature:
- add in defconfig of U-Boot configuration
- CONFIG_DEBUG_UART
- CONFIG_DEBUG_UART_STM32
- adapt the function board_debug_uart_init(): that configures the required resources (pad, clock) before initialization by the U-Boot driver.
This function needs to be adapted for your board.
- add in defconfig of U-Boot configuration
2. Debug with GDB
With OpenSTLinux, you can directly use GDB script Setup.gdb:
Or for manual GDB connection, you need to:
- get the elf files for U-Boot =
u-boot
available in the build directory - connect GDB to the target
- reset with attach the target with the gdb "monitor reset halt" command:
execution is stopped in ROM code or at the beginning of FSBL execution. - load the symbols of the binary to be debugged with commands available in next chapter:
#Load U-Boot symbol - start execution with the "continue" command
2.1. Load U-Boot symbol
With U-Boot relocation, symbols are more difficult to load, see doc/README.arm-relocation for details.
If you connect GDB on running target, you can load the debug symbols:
- Before relocation with "symbol-file" command:
symbol-file u-boot
- After relocation with "add-symbol-file" command to relocate the symbol with the code offset = gd->relocaddr:
--> only for "gd_t" definition set $offset = ((gd_t *)$r9)->relocaddr --> get relocation offset symbol-file --> clear previous symbol add-symbol-file u-boot $offsetsymbol-file u-boot
The following GDB example script automatically loads the U-Boot symbol before and after relocation for a programmed board, after "monitor reset halt" command:
0xC0100000 commands > symbol-file u-boot > thbreak relocate_code > commands > print "RELOCATE U-Boot..." > set $offset = ((gd_t *)$r9)->relocaddr > print $offset > symbol-file > add-symbol-file u-boot $offset > thbreak boot_jump_linux > continue > end > continue > endthbreak *
This script uses a temporary hardware breakpoint "thbreak" to load the symbol when U-Boot code is loaded in DDR by FSBL = TF-A at the U-Boot entry point, CONFIG_SYS_TEXT_BASE =
It allows the symbol to be loaded only when code is executed to avoid DDR access before DDR initialization.
3. References
- ↑ Documentation/devicetree/bindings/chosen.txt the Linux kernel binding for chosen node