123 lines
4.2 KiB
Bash
Executable File
123 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# 在真机上验证 Ubuntu HWE 6.17 仓库补丁 0001(源码 dry-run)+ 0002/0003(运行时 + 可选 HDMI 播放)。
|
||
# 成功:退出 0,并打印 VERIFY_OK。
|
||
#
|
||
# 用法:
|
||
# ./scripts/verify-ubuntu-hwe617-patches-runtime.sh
|
||
# RUN_HDMI_TEST=0 ./scripts/verify-ubuntu-hwe617-patches-runtime.sh # 不跑 speaker-test
|
||
# HDMI_PLUGHW=plughw:0,3 ./scripts/verify-ubuntu-hwe617-patches-runtime.sh
|
||
#
|
||
# 依赖:bash、grep、timeout;RUN_HDMI_TEST=1 时需 speaker-test、sudo、dmesg、debugfs。
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
SRC="${SRC:-$REPO_ROOT/kernel-src/linux-hwe-6.17-6.17.0}"
|
||
RUN_HDMI_TEST="${RUN_HDMI_TEST:-1}"
|
||
HDMI_PLUGHW="${HDMI_PLUGHW:-plughw:0,2}"
|
||
|
||
RED='\033[0;31m'
|
||
GRN='\033[0;32m'
|
||
RST='\033[0m'
|
||
|
||
pass() { echo -e "${GRN}OK${RST}: $*"; }
|
||
fail() { echo -e "${RED}FAIL${RST}: $*" >&2; exit 1; }
|
||
info() { echo "==> $*"; }
|
||
|
||
info "Repository root: $REPO_ROOT"
|
||
info "SRC (0001 dry-run): $SRC"
|
||
|
||
# --- 0001: patch dry-run ---
|
||
info "Step 0001: ipc3-pcm FREE/trigger patch (dry-run)"
|
||
if [[ ! -f "$SRC/sound/soc/sof/ipc3-pcm.c" ]]; then
|
||
fail "Missing $SRC/sound/soc/sof/ipc3-pcm.c — set SRC= to your linux-hwe-6.17 tree or see kernel-src/README.md"
|
||
fi
|
||
if ! OUT="$("$REPO_ROOT/scripts/verify-ubuntu-hwe617-0001-patch.sh" 2>&1)"; then
|
||
echo "$OUT"
|
||
fail "0001 patch dry-run failed"
|
||
fi
|
||
echo "$OUT"
|
||
pass "0001 patch applies or is already present in ipc3-pcm.c"
|
||
|
||
# --- Module snd_sof ---
|
||
if [[ ! -d /sys/module/snd_sof ]]; then
|
||
fail "snd_sof not loaded (is this a SOF machine? lsmod | grep snd_sof)"
|
||
fi
|
||
pass "module snd_sof is loaded"
|
||
|
||
# --- 0002 prerequisite: sof_debug bit 11 ---
|
||
SD="/sys/module/snd_sof/parameters/sof_debug"
|
||
if [[ ! -r "$SD" ]]; then
|
||
fail "cannot read $SD"
|
||
fi
|
||
V="$(cat "$SD" | tr -d '\n')"
|
||
if [[ "$V" =~ ^0[xX] ]]; then
|
||
VN=$((16#${V#0x}))
|
||
else
|
||
VN=$((10#$V))
|
||
fi
|
||
if (( (VN & 2048) != 2048 )); then
|
||
fail "sof_debug must include bit 11 (2048 / 0x800) for 0002; got $V. See patches/ubuntu-hwe-6.17/VERIFY_PATCHES.md"
|
||
fi
|
||
pass "sof_debug includes SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD (bit 11): $V"
|
||
|
||
# --- debugfs ---
|
||
if [[ ! -f /sys/kernel/debug/dynamic_debug/control ]]; then
|
||
sudo mount -t debugfs none /sys/kernel/debug 2>/dev/null || true
|
||
fi
|
||
if [[ ! -f /sys/kernel/debug/dynamic_debug/control ]]; then
|
||
fail "dynamic_debug not available (mount debugfs; run script with sudo if permission denied below)"
|
||
fi
|
||
|
||
DD_CTRL="/sys/kernel/debug/dynamic_debug/control"
|
||
enable_dd() {
|
||
local f="$1"
|
||
sudo sh -c "echo 'file ${f} +p' >> '$DD_CTRL'" || fail "dynamic_debug +p for $f"
|
||
}
|
||
|
||
info "Step 0002: enable ipc3-pcm.c dynamic_debug"
|
||
enable_dd "sound/soc/sof/ipc3-pcm.c"
|
||
pass "dynamic_debug: sound/soc/sof/ipc3-pcm.c +p"
|
||
|
||
info "Step 0003: enable hda-dai.c dynamic_debug"
|
||
enable_dd "sound/soc/sof/intel/hda-dai.c"
|
||
pass "dynamic_debug: sound/soc/sof/intel/hda-dai.c +p"
|
||
|
||
if [[ "$RUN_HDMI_TEST" != "1" ]]; then
|
||
echo ""
|
||
pass "RUN_HDMI_TEST=0 — skipped speaker-test / dmesg content checks"
|
||
echo ""
|
||
echo -e "${GRN}VERIFY_OK: all checks passed${RST} (0001 source + prerequisites for 0002/0003)"
|
||
exit 0
|
||
fi
|
||
|
||
if ! command -v speaker-test >/dev/null 2>&1; then
|
||
fail "speaker-test not found; install alsa-utils or set RUN_HDMI_TEST=0"
|
||
fi
|
||
|
||
info "Step 0002/0003 playback: speaker-test on $HDMI_PLUGHW (sudo dmesg -C first)"
|
||
sudo dmesg -C 2>/dev/null || true
|
||
if ! timeout 8 speaker-test -D "$HDMI_PLUGHW" -c2 -t sine -f 440 2>/dev/null; then
|
||
fail "speaker-test failed for $HDMI_PLUGHW — check aplay -l and HDMI_PLUGHW="
|
||
fi
|
||
|
||
sleep 0.3
|
||
DM="$(sudo dmesg -T 2>/dev/null || sudo dmesg)"
|
||
|
||
if ! echo "$DM" | grep -qF "STREAM_PCM_PARAMS: comp_id"; then
|
||
fail "0002: no 'STREAM_PCM_PARAMS: comp_id' in dmesg after playback (sof_debug + ipc3-pcm +p?)"
|
||
fi
|
||
if ! echo "$DM" | grep -qF "STREAM_PCM_PARAMS: buf pages"; then
|
||
fail "0002: no second STREAM_PCM_PARAMS line (buf pages) in dmesg"
|
||
fi
|
||
pass "0002: STREAM_PCM_PARAMS field lines present in dmesg"
|
||
|
||
if ! echo "$DM" | grep -qF "hda_link_dma_hw_params"; then
|
||
fail "0003: no 'hda_link_dma_hw_params' in dmesg after playback (hda-dai +p?)"
|
||
fi
|
||
pass "0003: hda_link_dma_hw_params line present in dmesg"
|
||
|
||
echo ""
|
||
echo -e "${GRN}VERIFY_OK: all checks passed${RST} (0001 source + 0002/0003 runtime + HDMI playback)"
|
||
exit 0
|