# 使用 sysfs 或 debugfs 节点进行调试

有多种 sysfs 和 debugfs 节点可用于识别状态或更新状态。

应使用以下命令挂载 debugfs。此命令可以使能 debugfs 文件系统。

mount -t debugfs none /sys/kernel/debug
    Copy to clipboard

**获取 UFS 状态信息**

| 所需的 UFS 状态信息 | 命令 |
| --- | --- |
| 检查 PA/DL 错误计数 | `cat /sys/kernel/debug/ufshcd/1d84000.ufs/stats` |
| 读取 UFS 截断延迟，单位为 ms | `cat /sys/devices/platform/soc@0/1d84000.ufs/clkgate_delay_ms` |
| 读取给定点上 UFS 时钟的当前频率 | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/cur_freq` |
| 读取 UFS I/O 调度程序详细信息 | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/governor` |
| 时钟缩减期间读取 UFS 最小频率 | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/min_freq` |
| 时钟增加期间读取 UFS 最大频率 | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/max_freq` |
| 读取 UFS 设备状态 ACTIVE 或 SLEEP<br>`cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/dev_pm` | 读取 UFS 设备状态 ACTIVE 或 SLEEP<br>`cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/dev_pm` |
| 读取 UFS 档位信息，如 HS\_G3、HS\_G4 | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/gear` |
| 读取 UFS 通道数 | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/lane` |
| 读取 UFS 链路状态，ACTIVE 或 HIBERN8 | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/link_state` |
| 读取 UFS 速率信息，例如速率 A 或 B | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/rate` |
| 读取 UFS 设备描述符信息 | `ls /sys/devices/platform/soc@0/1d84000.ufs/device_descriptor` |
| 读取 UFS 健康描述符信息 | `ls /sys/devices/platform/soc@0/1d84000.ufs/health_descriptor` |
| 读取 UFS runtime 状态信息，active 或 suspend | `cat /sys/devices/platform/soc@0/1d84000.ufs/power/runtime_status` |
| 查找和/或修改 SPM/RPM 级别 | `cat /sys/devices/platform/soc@0/1d84000.ufs/rpm_lvl`<br><br><br>`cat /sys/devices/platform/soc@0/1d84000.ufs/spm_lvl` |

**获取 SD 卡状态信息**

| 所需的 SD 卡状态信息 | 命令 |
| --- | --- |
| 读取 SD 卡错误统计信息 | `cat /sys/kernel/debug/mmc1/err_stats` |
| 读取 SD 卡最新错误状态详情 | `cat /sys/kernel/debug/mmc1/err_state` |
| 检查当前运行时钟的详细信息 | `cat /sys/kernel/debug/mmc1/clock` |
| 读取 SD 卡 runtime 状态信息（active 或 suspend） | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_status` |
| 读取 SD 卡自动 suspend 延迟时间 | `cat /sys/devices/platform/soc@0/8804000.mmc/power/autosuspend_delay_ms` |
| 读取 SD 卡 runtime active 时间 | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_active_time` |
| 读取 SD 卡 runtime suspend 时间 | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_suspended_time` |
| 读取 SD 卡 uevent 详细信息 | `cat /sys/devices/platform/soc@0/8804000.mmc/uevent` |

Last Published: Dec 10, 2024

[Previous Topic
调试 UFS 问题](https://docs.qualcomm.com/bundle/publicresource/80-70015-6SC/topics/ufs-debugging.md)

Source: [https://docs.qualcomm.com/doc/80-70015-6SC/topic/ufs-sysfs-debugfs.html](https://docs.qualcomm.com/doc/80-70015-6SC/topic/ufs-sysfs-debugfs.html)