@[toc]
在这里插入图片描述

https://github.com/wdfk-prog/linux/tree/ART-PI_DEBUG

DEBUG_LL的功能

  • 开启早期的调试功能
1
2
3
4
5
6
7
8
9
10
11
12
13
# These options are only for real kernel hackers who want to get their hands dirty.
config DEBUG_LL
bool "Kernel low-level debugging functions (read help!)"
depends on DEBUG_KERNEL
help
Say Y here to include definitions of printascii, printch, printhex
in the kernel. This is helpful if you are debugging code that
executes before the console is initialized.

Note that selecting this option will limit the kernel to a single
UART definition, as specified below. Attempting to boot the kernel
image on a different platform *will not work*, so this option should
not be enabled for kernels that are intended to be portable.
1
2
3
4
5
6
7
8
9
10
11
12
13
# 这些选项仅适用于想要亲自动手的真正内核黑客。
config DEBUG_LL
bool "Kernel low-level debugging functions (read help!)"
depends on DEBUG_KERNEL
help
在此处说 Y 以包括 printascii、 printch、 printhex 的定义
在内核中。 如果您正在调试
在控制台初始化之前执行。

请注意,选择此选项会将内核限制为单个
UART 定义,如下所述。尝试引导内核
图像在不同平台上*将不起作用*,因此此选项应该
不会为旨在可移植的内核启用。

Kconfig配置

  1. CONFIG_DEBUG_UART_PHYSCONFIG_DEBUG_UART_VIRT需要根据实际板子进行调整
  2. CONFIG_STM32H7_DEBUG_UART选择对应的芯片系列
1
2
3
4
CONFIG_DEBUG_LL=y
CONFIG_STM32H7_DEBUG_UART=y
CONFIG_DEBUG_UART_PHYS=0x40004c00
CONFIG_DEBUG_UART_VIRT=0x40004c00

STM32XX_DEBUG_UART

  • 在H7或者其他任何系列的配置中都可以看到help中写到默认选择的是串口1的输出功能.如果板子上的串口需要更改,就需要手动更新CONFIG_DEBUG_UART_PHYSCONFIG_DEBUG_UART_VIRT
1
2
3
4
5
6
7
8
9
10
11
config STM32H7_DEBUG_UART
bool "Use STM32H7 UART for low-level debug"
depends on MACH_STM32H743
select DEBUG_STM32_UART
help
Say Y here if you want kernel low-level debugging support
on STM32H7 based platforms, which default UART is wired on
USART1, but another UART instance can be selected by modifying
CONFIG_DEBUG_UART_PHYS.

If unsure, say N.

CONFIG_DEBUG_UART_PHYSCONFIG_DEBUG_UART_VIRT

  1. 这两个在stm32中是一样的东西.实际上填写串口的寄存器地址既可.
  2. 具体的debug.s和stm32.s就不进行分析了.感兴趣自行观看源码既可.
  3. 这里说一下找到所需要的串口寄存器的方法
  4. 看芯片手册找到对应串口的寄存器地址既可.
  5. 或者可以反汇编dtb文件,找到所需要的串口的地址既可

最终效果

1
2
3
4
5
# Start of compressed kernel 
# End of compressed kernel
# Start of kernel copy
# End of kernel copy
C:0xC0080060-0xC02151C0->0xC02E3000-0xC0478160

结论

  1. 观察开始和结束的压缩地址
  2. 我们即将将内核复制到新的内存区域。
  3. 新内存区域的边界可以在 R10 和 R9,而 R5 和 R6 包含边界
  4. 的 MEMORY 中。致电 dbgkc 将有助于打印此内容信息。
  5. 说明这个内核代码会覆盖当前的代码区域,需要进行搬运后再次重定向进行执行