> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 clk-debug-tools 测量时钟频率

[clk-debug-tools-for-qualcomm-linux](https://github.com/qualcomm-linux/clk-debug-tools-for-qualcomm-linux) 仓库托管了针对 `linux-next` 的树外(out-of-tree)Linux 内核 `clk` 调试补丁,以及在 Qualcomm SoC 上驱动基于时钟测量的调试的脚本。这些工具通过 `debugfs` 公开硬件时钟测量支持,以便可以将时钟的实际测量频率与配置的频率进行核对。

## **前提条件**

在使用这些工具之前,请确保您具备以下条件:

* 目标设备的 `linux-next` 内核检出,已应用来自 `patches/` 目录的 DebugCC `clk` 调试补丁,并已构建和烧录到目标设备。
* 目标设备上已在 `/sys/kernel/debug` 挂载 `debugfs`。
* 目标设备上的 root shell 访问权限。
* 目标设备上可用的符合 POSIX 标准的 shell(`sh`),用于运行位于 `scripts/` 中的辅助脚本。

## **应用内核补丁**

1. 在 `linux-next` 检出中,使用 `git am` 按顺序先应用通用补丁集,再应用目标特定的补丁系列:
   * 应用 `common/` 目录中的补丁。
     ```text theme={null}
     git am common/*.patch
     ```
   * 应用相应 `soc/<target>/` 目录中的补丁。例如,对于 SA8775P:
     ```text theme={null}
     git am soc/sa8775p/*.patch
     ```
2. 在应用补丁后构建内核,并使用您的标准构建和烧录流程将其烧录到目标设备。
3. 将 `scripts/` 目录中的脚本复制到目标设备上。

## **测量时钟频率**

运行适用于您的目标平台的辅助脚本,并传入要测量的时钟名称。例如,在 SA8775P 上:

```text theme={null}
sh scripts/clk_measure_sa8775p.sh <clock_name>
```

* `<clock_name>` 必须与脚本内部支持的时钟列表中的条目匹配。
* 该脚本以 Hz 为单位打印测量的时钟频率。

有关完整源代码、分支和目标特定的补丁集,请参阅 [clk-debug-tools-for-qualcomm-linux 仓库](https://github.com/qualcomm-linux/clk-debug-tools-for-qualcomm-linux)。
