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

# Measure clock rates using clk-debug-tools

The [clk-debug-tools-for-qualcomm-linux](https://github.com/qualcomm-linux/clk-debug-tools-for-qualcomm-linux) repository hosts out-of-tree Linux kernel `clk` debug patches for `linux-next`, plus scripts that drive clock-measurement based debugging on Qualcomm SoCs. These tools expose hardware clock-measure support through `debugfs` so that the actual measured rate of a clock can be checked against the rate that's configured.

## **Prerequisites**

Before you use these tools, make sure you have the following:

* A `linux-next` kernel checkout for the target device, with the DebugCC `clk` debug patches from the `patches/` directory applied, built, and flashed to the target.
* `debugfs` mounted on the target device at `/sys/kernel/debug`.
* Root shell access on the target device.
* A POSIX-compliant shell (`sh`) available on-target to run the helper scripts located in `scripts/`.

## **Apply the kernel patches**

1. From a `linux-next` checkout, apply the common patch set followed by the target-specific patch series, in order, using `git am`:
   * Apply the patches from the `common/` directory.
     ```text theme={null}
     git am common/*.patch
     ```
   * Apply the patches from the corresponding `soc/<target>/` directory. For example, for SA8775P:
     ```text theme={null}
     git am soc/sa8775p/*.patch
     ```
2. Build the kernel with the patches applied, and flash it to the target device using your standard build and flash procedure.
3. Copy the scripts from the `scripts/` directory onto the target device.

## **Measure a clock rate**

Run the helper script for your target platform, passing the name of the clock to measure. For example, on SA8775P:

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

* `<clock_name>` must match an entry in the script's internal list of supported clocks.
* The script prints the measured clock rate in Hz.

For the full source, branches, and target-specific patch sets, see the [clk-debug-tools-for-qualcomm-linux repository](https://github.com/qualcomm-linux/clk-debug-tools-for-qualcomm-linux).
